From 936611683a969d2a93bde1c41d048881e860edea Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 30 May 2000 17:06:11 +0000 Subject: Added alphabet.glade and alphabet.glade.h. 2000-05-30 Christopher James Lahey * gui/component/Makefile.am: Added alphabet.glade and alphabet.glade.h. * gui/component/addressbook.c, gui/component/alphabet.glade, gui/component/alphabet.glade.h: Added an alphabet bar. * gui/minicard/e-minicard-view.c, gui/minicard/e-minicard-view.h, gui/minicard/e-reflow-sorted.c, gui/minicard/e-reflow-sorted.h: Added the ability to just to a particular spot in the reflow. svn path=/trunk/; revision=3283 --- addressbook/ChangeLog | 12 + addressbook/gui/component/Makefile.am | 5 +- addressbook/gui/component/addressbook.c | 89 ++++++- addressbook/gui/component/alphabet.glade | 382 +++++++++++++++++++++++++++++ addressbook/gui/component/alphabet.glade.h | 34 +++ addressbook/gui/minicard/e-minicard-view.c | 30 ++- addressbook/gui/minicard/e-minicard-view.h | 2 + addressbook/gui/minicard/e-reflow-sorted.c | 33 +++ addressbook/gui/minicard/e-reflow-sorted.h | 1 + addressbook/gui/widgets/alphabet.glade | 382 +++++++++++++++++++++++++++++ addressbook/gui/widgets/alphabet.glade.h | 34 +++ addressbook/gui/widgets/e-minicard-view.c | 30 ++- addressbook/gui/widgets/e-minicard-view.h | 2 + 13 files changed, 1023 insertions(+), 13 deletions(-) create mode 100644 addressbook/gui/component/alphabet.glade create mode 100644 addressbook/gui/component/alphabet.glade.h create mode 100644 addressbook/gui/widgets/alphabet.glade create mode 100644 addressbook/gui/widgets/alphabet.glade.h (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index a793e505c1..4583ad3b0e 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,15 @@ +2000-05-30 Christopher James Lahey + + * gui/component/Makefile.am: Added alphabet.glade and + alphabet.glade.h. + + * gui/component/addressbook.c, gui/component/alphabet.glade, + gui/component/alphabet.glade.h: Added an alphabet bar. + + * gui/minicard/e-minicard-view.c, gui/minicard/e-minicard-view.h, + gui/minicard/e-reflow-sorted.c, gui/minicard/e-reflow-sorted.h: + Added the ability to just to a particular spot in the reflow. + 2000-05-30 Christopher James Lahey * printing/Makefile.am: Added BONOBO_GNOME_CFLAGS to CPPFLAGS. diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 0958528daf..370265e019 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -69,12 +69,13 @@ gnorba_DATA = addressbook.gnorba endif gladedir = $(datadir)/evolution/glade -glade_DATA = ldap-server-dialog.glade ldap-server-dialog.glade.h +glade_DATA = ldap-server-dialog.glade ldap-server-dialog.glade.h alphabet.glade EXTRA_DIST = \ $(glade_DATA) \ addressbook.gnorba \ - addressbook.oafinfo + addressbook.oafinfo \ + alphabet.glade.h if ENABLE_PURIFY PLINK = $(LIBTOOL) --mode=link $(PURIFY) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index dab940d088..a128648d76 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -50,7 +50,7 @@ typedef struct { AddressbookViewType view_type; EBook *book; GtkWidget *vbox; - GtkWidget *minicard_vbox; + GtkWidget *minicard_hbox; GtkWidget *canvas; GnomeCanvasItem *view; GnomeCanvasItem *rect; @@ -639,23 +639,84 @@ teardown_minicard_view (AddressbookView *view) gtk_object_destroy(GTK_OBJECT(view->view)); view->view = NULL; } - if (view->minicard_vbox) { - gtk_widget_destroy(view->minicard_vbox); - view->minicard_vbox = NULL; + if (view->minicard_hbox) { + gtk_widget_destroy(view->minicard_hbox); + view->minicard_hbox = NULL; } view->canvas = NULL; } +typedef struct { + AddressbookView *view; + char letter; +} LetterClosure; + +static void +jump_to_letter(GtkWidget *button, LetterClosure *closure) +{ + if (closure->view->view) + e_minicard_view_jump_to_letter(E_MINICARD_VIEW(closure->view->view), closure->letter); +} + +static void +free_closure(GtkWidget *button, LetterClosure *closure) +{ + g_free(closure); +} + +static void +connect_button (AddressbookView *view, GladeXML *gui, char letter) +{ + char *name; + GtkWidget *button; + LetterClosure *closure; + name = g_strdup_printf("button-%c", letter); + button = glade_xml_get_widget(gui, name); + g_free(name); + if (!button) + return; + closure = g_new(LetterClosure, 1); + closure->view = view; + closure->letter = letter; + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(jump_to_letter), closure); + gtk_signal_connect(GTK_OBJECT(button), "destroy", + GTK_SIGNAL_FUNC(free_closure), closure); +} + +static GtkWidget * +create_alphabet (AddressbookView *view) +{ + GtkWidget *widget; + char letter; + GladeXML *gui = glade_xml_new (EVOLUTION_GLADEDIR "/alphabet.glade", NULL); + + widget = glade_xml_get_widget(gui, "scrolledwindow-top"); + if (!widget) { + return NULL; + } + + connect_button(view, gui, '1'); + for (letter = 'a'; letter <= 'z'; letter ++) { + connect_button(view, gui, letter); + } + return widget; +} + static void create_minicard_view (AddressbookView *view, char *initial_query) { GtkWidget *scrollbar; + GtkWidget *vbox; + GtkWidget *alphabet; gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - view->minicard_vbox = gtk_vbox_new(FALSE, 0); + view->minicard_hbox = gtk_hbox_new(FALSE, 0); + + vbox = gtk_vbox_new(FALSE, 0); view->canvas = e_canvas_new(); view->rect = gnome_canvas_item_new( @@ -683,16 +744,26 @@ create_minicard_view (AddressbookView *view, char *initial_query) 0, 0, 100, 100 ); - gtk_box_pack_start(GTK_BOX(view->minicard_vbox), view->canvas, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), view->canvas, TRUE, TRUE, 0); scrollbar = gtk_hscrollbar_new( gtk_layout_get_hadjustment(GTK_LAYOUT(view->canvas))); - gtk_box_pack_start(GTK_BOX(view->minicard_vbox), scrollbar, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); + + gtk_box_pack_start(GTK_BOX(view->minicard_hbox), vbox, TRUE, TRUE, 0); + + alphabet = create_alphabet(view); + if (alphabet) { + gtk_object_ref(GTK_OBJECT(alphabet)); + gtk_widget_unparent(alphabet); + gtk_box_pack_start(GTK_BOX(view->minicard_hbox), alphabet, FALSE, FALSE, 0); + gtk_object_unref(GTK_OBJECT(alphabet)); + } - gtk_box_pack_start(GTK_BOX(view->vbox), view->minicard_vbox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(view->vbox), view->minicard_hbox, TRUE, TRUE, 0); - gtk_widget_show_all( GTK_WIDGET(view->minicard_vbox) ); + gtk_widget_show_all( GTK_WIDGET(view->minicard_hbox) ); /* Connect the signals */ gtk_signal_connect( GTK_OBJECT( view->canvas ), "size_allocate", diff --git a/addressbook/gui/component/alphabet.glade b/addressbook/gui/component/alphabet.glade new file mode 100644 index 0000000000..a2c61d4a47 --- /dev/null +++ b/addressbook/gui/component/alphabet.glade @@ -0,0 +1,382 @@ + + + + + alphabet + alphabet + + src + pixmaps + C + True + True + True + False + False + False + True + True + alphabet.glade.h + + + + GtkWindow + window2 + False + window2 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkScrolledWindow + scrolledwindow-top + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkViewport + viewport1 + GTK_SHADOW_NONE + + + GtkVBox + vbox2 + 27 + False + 0 + + + GtkButton + button-1 + True + + + 0 + False + False + + + + + GtkButton + button-a + True + + + 0 + False + False + + + + + GtkButton + button-b + True + + + 0 + False + False + + + + + GtkButton + button-c + True + + + 0 + False + False + + + + + GtkButton + button-d + True + + + 0 + False + False + + + + + GtkButton + button-e + True + + + 0 + False + False + + + + + GtkButton + button-f + True + + + 0 + False + False + + + + + GtkButton + button-g + True + + + 0 + False + False + + + + + GtkButton + button-h + True + + + 0 + False + False + + + + + GtkButton + button-i + True + + + 0 + False + False + + + + + GtkButton + button-j + True + + + 0 + False + False + + + + + GtkButton + button-k + True + + + 0 + False + False + + + + + GtkButton + button-l + True + + + 0 + False + False + + + + + GtkButton + button-m + True + + + 0 + False + False + + + + + GtkButton + button-n + True + + + 0 + False + False + + + + + GtkButton + button-o + True + + + 0 + False + False + + + + + GtkButton + button-p + True + + + 0 + False + False + + + + + GtkButton + button-q + True + + + 0 + False + False + + + + + GtkButton + button-r + True + + + 0 + False + False + + + + + GtkButton + button-s + True + + + 0 + False + False + + + + + GtkButton + button-t + True + + + 0 + False + False + + + + + GtkButton + button-u + True + + + 0 + False + False + + + + + GtkButton + button-v + True + + + 0 + False + False + + + + + GtkButton + button-w + True + + + 0 + False + False + + + + + GtkButton + button-x + True + + + 0 + False + False + + + + + GtkButton + button-y + True + + + 0 + False + False + + + + + GtkButton + button-z + True + + + 0 + False + False + + + + + + + + diff --git a/addressbook/gui/component/alphabet.glade.h b/addressbook/gui/component/alphabet.glade.h new file mode 100644 index 0000000000..2448eeb4fc --- /dev/null +++ b/addressbook/gui/component/alphabet.glade.h @@ -0,0 +1,34 @@ +/* + * Translatable strings file generated by Glade. + * Add this file to your project's POTFILES.in. + * DO NOT compile it as part of your application. + */ + +gchar *s = N_("window2"); +gchar *s = N_("123"); +gchar *s = N_("a"); +gchar *s = N_("b"); +gchar *s = N_("c"); +gchar *s = N_("d"); +gchar *s = N_("e"); +gchar *s = N_("f"); +gchar *s = N_("g"); +gchar *s = N_("h"); +gchar *s = N_("i"); +gchar *s = N_("j"); +gchar *s = N_("k"); +gchar *s = N_("l"); +gchar *s = N_("m"); +gchar *s = N_("n"); +gchar *s = N_("o"); +gchar *s = N_("p"); +gchar *s = N_("q"); +gchar *s = N_("r"); +gchar *s = N_("s"); +gchar *s = N_("t"); +gchar *s = N_("u"); +gchar *s = N_("v"); +gchar *s = N_("w"); +gchar *s = N_("x"); +gchar *s = N_("y"); +gchar *s = N_("z"); diff --git a/addressbook/gui/minicard/e-minicard-view.c b/addressbook/gui/minicard/e-minicard-view.c index d3acb1ad54..bc2e22fa32 100644 --- a/addressbook/gui/minicard/e-minicard-view.c +++ b/addressbook/gui/minicard/e-minicard-view.c @@ -107,7 +107,7 @@ e_minicard_view_init (EMinicardView *view) view->canvas_destroy_id = 0; gtk_object_set(GTK_OBJECT(view), - "empty_message", _("There are no items to show in this view\n\n" + "empty_message", _("\n\nThere are no items to show in this view\n\n" "Double-click here to create a new Contact."), NULL); @@ -380,3 +380,31 @@ e_minicard_view_remove_selection(EMinicardView *view, } } } + +static int +compare_to_letter(EMinicard *card, char *letter) +{ + g_return_val_if_fail(card != NULL, 0); + g_return_val_if_fail(E_IS_MINICARD(card), 0); + + if (card->card) { + char *file_as; + gtk_object_get(GTK_OBJECT(card->card), + "file_as", &file_as, + NULL); + if (file_as) + return strncasecmp(file_as, letter, 1); + else + return 0; + } else { + return 0; + } +} + +void e_minicard_view_jump_to_letter (EMinicardView *view, + char letter) +{ + e_reflow_sorted_jump(E_REFLOW_SORTED(view), + (GCompareFunc) compare_to_letter, + &letter); +} diff --git a/addressbook/gui/minicard/e-minicard-view.h b/addressbook/gui/minicard/e-minicard-view.h index 780b0dde33..a166a6ade1 100644 --- a/addressbook/gui/minicard/e-minicard-view.h +++ b/addressbook/gui/minicard/e-minicard-view.h @@ -84,6 +84,8 @@ GtkType e_minicard_view_get_type (void); void e_minicard_view_remove_selection (EMinicardView *view, EBookCallback cb, gpointer closure); +void e_minicard_view_jump_to_letter (EMinicardView *view, + char letter); #ifdef __cplusplus } diff --git a/addressbook/gui/minicard/e-reflow-sorted.c b/addressbook/gui/minicard/e-reflow-sorted.c index 7205785c6c..c899ccb9a7 100644 --- a/addressbook/gui/minicard/e-reflow-sorted.c +++ b/addressbook/gui/minicard/e-reflow-sorted.c @@ -34,6 +34,10 @@ static void e_reflow_sorted_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); static void e_reflow_sorted_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); static void e_reflow_sorted_add_item(EReflow *e_reflow, GnomeCanvasItem *item); +#define E_REFLOW_DIVIDER_WIDTH 2 +#define E_REFLOW_BORDER_WIDTH 7 +#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2) + static EReflowClass *parent_class = NULL; /* The arguments we take */ @@ -234,3 +238,32 @@ e_reflow_sorted_add_item(EReflow *reflow, GnomeCanvasItem *item) } e_reflow_post_add_item(reflow, item); } + +void e_reflow_sorted_jump (EReflowSorted *sorted, + GCompareFunc compare_func, + void *value) +{ + int columns = 0; + EReflow *reflow = E_REFLOW(sorted); + GList *list; + + for (list = reflow->columns; list; list = g_list_next(list)) { + if (compare_func(((GList *)list->data)->data, value) >= 0) { + GList *last = list->prev; + GtkAdjustment *adjustment; + if (last) { + GList *walk; + for (walk = last->data; walk != list->data; walk = g_list_next(walk)) { + if (compare_func(walk->data, value) >= 0) { + columns --; + break; + } + } + } + adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(sorted)->canvas)); + gtk_adjustment_set_value(adjustment, (reflow->column_width + E_REFLOW_FULL_GUTTER) * columns); + return; + } + columns ++; + } +} diff --git a/addressbook/gui/minicard/e-reflow-sorted.h b/addressbook/gui/minicard/e-reflow-sorted.h index d9b4acc747..7adfa2c045 100644 --- a/addressbook/gui/minicard/e-reflow-sorted.h +++ b/addressbook/gui/minicard/e-reflow-sorted.h @@ -81,6 +81,7 @@ void e_reflow_sorted_replace_item (EReflowSorted *sorted, GnomeCanvasI void e_reflow_sorted_reorder_item (EReflowSorted *e_reflow_sorted, const gchar *id); GnomeCanvasItem *e_reflow_sorted_get_item (EReflowSorted *e_reflow_sorted, const gchar *id); GtkType e_reflow_sorted_get_type (void); +void e_reflow_sorted_jump (EReflowSorted *sorted, GCompareFunc compare_func, void *value); #ifdef __cplusplus } diff --git a/addressbook/gui/widgets/alphabet.glade b/addressbook/gui/widgets/alphabet.glade new file mode 100644 index 0000000000..a2c61d4a47 --- /dev/null +++ b/addressbook/gui/widgets/alphabet.glade @@ -0,0 +1,382 @@ + + + + + alphabet + alphabet + + src + pixmaps + C + True + True + True + False + False + False + True + True + alphabet.glade.h + + + + GtkWindow + window2 + False + window2 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkScrolledWindow + scrolledwindow-top + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkViewport + viewport1 + GTK_SHADOW_NONE + + + GtkVBox + vbox2 + 27 + False + 0 + + + GtkButton + button-1 + True + + + 0 + False + False + + + + + GtkButton + button-a + True + + + 0 + False + False + + + + + GtkButton + button-b + True + + + 0 + False + False + + + + + GtkButton + button-c + True + + + 0 + False + False + + + + + GtkButton + button-d + True + + + 0 + False + False + + + + + GtkButton + button-e + True + + + 0 + False + False + + + + + GtkButton + button-f + True + + + 0 + False + False + + + + + GtkButton + button-g + True + + + 0 + False + False + + + + + GtkButton + button-h + True + + + 0 + False + False + + + + + GtkButton + button-i + True + + + 0 + False + False + + + + + GtkButton + button-j + True + + + 0 + False + False + + + + + GtkButton + button-k + True + + + 0 + False + False + + + + + GtkButton + button-l + True + + + 0 + False + False + + + + + GtkButton + button-m + True + + + 0 + False + False + + + + + GtkButton + button-n + True + + + 0 + False + False + + + + + GtkButton + button-o + True + + + 0 + False + False + + + + + GtkButton + button-p + True + + + 0 + False + False + + + + + GtkButton + button-q + True + + + 0 + False + False + + + + + GtkButton + button-r + True + + + 0 + False + False + + + + + GtkButton + button-s + True + + + 0 + False + False + + + + + GtkButton + button-t + True + + + 0 + False + False + + + + + GtkButton + button-u + True + + + 0 + False + False + + + + + GtkButton + button-v + True + + + 0 + False + False + + + + + GtkButton + button-w + True + + + 0 + False + False + + + + + GtkButton + button-x + True + + + 0 + False + False + + + + + GtkButton + button-y + True + + + 0 + False + False + + + + + GtkButton + button-z + True + + + 0 + False + False + + + + + + + + diff --git a/addressbook/gui/widgets/alphabet.glade.h b/addressbook/gui/widgets/alphabet.glade.h new file mode 100644 index 0000000000..2448eeb4fc --- /dev/null +++ b/addressbook/gui/widgets/alphabet.glade.h @@ -0,0 +1,34 @@ +/* + * Translatable strings file generated by Glade. + * Add this file to your project's POTFILES.in. + * DO NOT compile it as part of your application. + */ + +gchar *s = N_("window2"); +gchar *s = N_("123"); +gchar *s = N_("a"); +gchar *s = N_("b"); +gchar *s = N_("c"); +gchar *s = N_("d"); +gchar *s = N_("e"); +gchar *s = N_("f"); +gchar *s = N_("g"); +gchar *s = N_("h"); +gchar *s = N_("i"); +gchar *s = N_("j"); +gchar *s = N_("k"); +gchar *s = N_("l"); +gchar *s = N_("m"); +gchar *s = N_("n"); +gchar *s = N_("o"); +gchar *s = N_("p"); +gchar *s = N_("q"); +gchar *s = N_("r"); +gchar *s = N_("s"); +gchar *s = N_("t"); +gchar *s = N_("u"); +gchar *s = N_("v"); +gchar *s = N_("w"); +gchar *s = N_("x"); +gchar *s = N_("y"); +gchar *s = N_("z"); diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c index d3acb1ad54..bc2e22fa32 100644 --- a/addressbook/gui/widgets/e-minicard-view.c +++ b/addressbook/gui/widgets/e-minicard-view.c @@ -107,7 +107,7 @@ e_minicard_view_init (EMinicardView *view) view->canvas_destroy_id = 0; gtk_object_set(GTK_OBJECT(view), - "empty_message", _("There are no items to show in this view\n\n" + "empty_message", _("\n\nThere are no items to show in this view\n\n" "Double-click here to create a new Contact."), NULL); @@ -380,3 +380,31 @@ e_minicard_view_remove_selection(EMinicardView *view, } } } + +static int +compare_to_letter(EMinicard *card, char *letter) +{ + g_return_val_if_fail(card != NULL, 0); + g_return_val_if_fail(E_IS_MINICARD(card), 0); + + if (card->card) { + char *file_as; + gtk_object_get(GTK_OBJECT(card->card), + "file_as", &file_as, + NULL); + if (file_as) + return strncasecmp(file_as, letter, 1); + else + return 0; + } else { + return 0; + } +} + +void e_minicard_view_jump_to_letter (EMinicardView *view, + char letter) +{ + e_reflow_sorted_jump(E_REFLOW_SORTED(view), + (GCompareFunc) compare_to_letter, + &letter); +} diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h index 780b0dde33..a166a6ade1 100644 --- a/addressbook/gui/widgets/e-minicard-view.h +++ b/addressbook/gui/widgets/e-minicard-view.h @@ -84,6 +84,8 @@ GtkType e_minicard_view_get_type (void); void e_minicard_view_remove_selection (EMinicardView *view, EBookCallback cb, gpointer closure); +void e_minicard_view_jump_to_letter (EMinicardView *view, + char letter); #ifdef __cplusplus } -- cgit v1.2.3