diff options
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r-- | addressbook/gui/widgets/Makefile.am | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 230 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view-widget.c | 5 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view-widget.h | 3 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view.c | 20 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view.h | 3 |
6 files changed, 153 insertions, 110 deletions
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am index f031b284e5..39da68797c 100644 --- a/addressbook/gui/widgets/Makefile.am +++ b/addressbook/gui/widgets/Makefile.am @@ -134,7 +134,7 @@ libeminicard_a_SOURCES = \ # $(GNOME_PRINT_LIBS) gladedir = $(datadir)/evolution/glade -glade_DATA = alphabet.glade +glade_DATA = EXTRA_DIST = \ $(glade_DATA) diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 8b2a002247..bf07164486 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -31,8 +31,10 @@ #include <gal/e-table/e-table-model.h> #include <gal/widgets/e-scroll-frame.h> #include <gal/widgets/e-popup-menu.h> +#include <gal/widgets/e-unicode.h> #include <gal/menus/gal-view-factory-etable.h> #include <gal/menus/gal-view-etable.h> +#include <gal/unicode/gunicode.h> #include <libgnomeui/gnome-dialog-util.h> #include <libgnomeprint/gnome-print.h> @@ -40,6 +42,8 @@ #include <libgnomeprint/gnome-print-master.h> #include <libgnomeprint/gnome-print-master-preview.h> +#include <e-util/e-unicode-i18n.h> + #include "addressbook/printing/e-contact-print.h" #include "addressbook/printing/e-contact-print-envelope.h" @@ -389,80 +393,97 @@ e_addressbook_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) } +/* Translators: put here a list of labels you want to see on buttons in + addressbook. You may use any character to separate labels but it must + also be placed at the begining ot the string */ +const char *button_labels = N_(",123,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"); +/* Translators: put here a list of characters that correspond to buttons + in addressbook. You may use any character to separate labels but it + must also be placed at the begining ot the string. + Use lower case letters if possible. */ +const char *button_letters = N_(",0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"); typedef struct { EAddressbookView *view; - char letter; + gunichar letter; } LetterClosure; +static char ** +e_utf8_split (const char *utf8_str, gunichar delim) +{ + GSList *str_list = NULL, *sl; + int n = 0; + const char *str, *s; + char **str_array; + + g_return_val_if_fail (utf8_str != NULL, NULL); + + str = utf8_str; + while (*str != '\0') { + int len; + char *new_str; + + for (s = str; *s != '\0' && g_utf8_get_char (s) != delim; s = g_utf8_next_char (s)) + ; + len = s - str; + new_str = g_new (char, len + 1); + if (len > 0) { + memcpy (new_str, str, len); + } + new_str[len] = '\0'; + str_list = g_slist_prepend (str_list, new_str); + n++; + if (*s != '\0') { + str = g_utf8_next_char (s); + } else { + str = s; + } + } + + str_array = g_new (char *, n + 1); + str_array[n--] = NULL; + for (sl = str_list; sl != NULL; sl = sl->next) { + str_array[n--] = sl->data; + } + g_slist_free (str_list); + + return str_array; +} + static void jump_to_letter(GtkWidget *button, LetterClosure *closure) { char *query; - switch (closure->letter) { - case '1': - query = g_strdup ("(not (or " - "(beginswith \"file_as\" \"a\") " - "(beginswith \"file_as\" \"b\") " - "(beginswith \"file_as\" \"c\") " - "(beginswith \"file_as\" \"d\") " - "(beginswith \"file_as\" \"e\") " - "(beginswith \"file_as\" \"f\") " - "(beginswith \"file_as\" \"g\") " - "(beginswith \"file_as\" \"h\") " - "(beginswith \"file_as\" \"i\") " - "(beginswith \"file_as\" \"j\") " - "(beginswith \"file_as\" \"k\") " - "(beginswith \"file_as\" \"l\") " - "(beginswith \"file_as\" \"m\") " - "(beginswith \"file_as\" \"n\") " - "(beginswith \"file_as\" \"o\") " - "(beginswith \"file_as\" \"p\") " - "(beginswith \"file_as\" \"q\") " - "(beginswith \"file_as\" \"r\") " - "(beginswith \"file_as\" \"s\") " - "(beginswith \"file_as\" \"t\") " - "(beginswith \"file_as\" \"u\") " - "(beginswith \"file_as\" \"v\") " - "(beginswith \"file_as\" \"w\") " - "(beginswith \"file_as\" \"x\") " - "(beginswith \"file_as\" \"y\") " - "(beginswith \"file_as\" \"z\") " - - "(beginswith \"file_as\" \"A\") " - "(beginswith \"file_as\" \"B\") " - "(beginswith \"file_as\" \"C\") " - "(beginswith \"file_as\" \"D\") " - "(beginswith \"file_as\" \"E\") " - "(beginswith \"file_as\" \"F\") " - "(beginswith \"file_as\" \"G\") " - "(beginswith \"file_as\" \"H\") " - "(beginswith \"file_as\" \"I\") " - "(beginswith \"file_as\" \"J\") " - "(beginswith \"file_as\" \"K\") " - "(beginswith \"file_as\" \"L\") " - "(beginswith \"file_as\" \"M\") " - "(beginswith \"file_as\" \"N\") " - "(beginswith \"file_as\" \"O\") " - "(beginswith \"file_as\" \"P\") " - "(beginswith \"file_as\" \"Q\") " - "(beginswith \"file_as\" \"R\") " - "(beginswith \"file_as\" \"S\") " - "(beginswith \"file_as\" \"T\") " - "(beginswith \"file_as\" \"U\") " - "(beginswith \"file_as\" \"V\") " - "(beginswith \"file_as\" \"W\") " - "(beginswith \"file_as\" \"X\") " - "(beginswith \"file_as\" \"Y\") " - "(beginswith \"file_as\" \"Z\") " - "))"); - break; - default: + + if (g_unichar_isdigit (closure->letter)) { + const char *letters = U_(button_letters); + char **letter_v; + GString *gstr; + char **p; + + letter_v = e_utf8_split (g_utf8_next_char (letters), + g_utf8_get_char (letters)); + g_assert (letter_v != NULL && letter_v[0] != NULL); + gstr = g_string_new ("(not (or "); + for (p = letter_v + 1; *p != NULL; p++) { + char s[7]; + + g_string_sprintfa (gstr, "(beginswith \"file_as\" \"%s\")", *p); + s[g_unichar_to_utf8 (g_unichar_toupper (g_utf8_get_char (*p)), s)] = '\0'; + g_string_sprintfa (gstr, "(beginswith \"file_as\" \"%s\")", s); + } + g_string_append (gstr, "))"); + query = gstr->str; + g_string_free (gstr, FALSE); + } else { + char s1[6 + 1], s2[6 + 1]; + + s1 [g_unichar_to_utf8 (closure->letter, s1)] = '\0'; + s2 [g_unichar_to_utf8 (g_unichar_toupper (closure->letter), s2)] = '\0'; query = g_strdup_printf ("(or " - "(beginswith \"file_as\" \"%c\")" - "(beginswith \"file_as\" \"%c\")" - ")", closure->letter, toupper (closure->letter)); - break; + "(beginswith \"file_as\" \"%s\")" + "(beginswith \"file_as\" \"%s\")" + ")", s1, s2); } gtk_object_set (GTK_OBJECT (closure->view), "query", query, @@ -476,44 +497,59 @@ free_closure(GtkWidget *button, LetterClosure *closure) g_free(closure); } -static void -connect_button (EAddressbookView *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 (EAddressbookView *view) { - GtkWidget *widget; - char letter; - GladeXML *gui = glade_xml_new (EVOLUTION_GLADEDIR "/alphabet.glade", NULL); + GtkWidget *widget, *viewport, *vbox; + const char *labels, *letters; + char **label_v, **letter_v; + char **pl, **pc; + gunichar sep; + + widget = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + + viewport = gtk_viewport_new (NULL, NULL); + gtk_container_add (GTK_CONTAINER (widget), viewport); + gtk_container_set_border_width (GTK_CONTAINER (viewport), 4); + gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE); + + vbox = gtk_vbox_new (FALSE, 4); + gtk_container_add (GTK_CONTAINER (viewport), vbox); + gtk_widget_set_usize (vbox, 27, 0); + + labels = U_(button_labels); + sep = g_utf8_get_char (labels); + label_v = e_utf8_split (g_utf8_next_char (labels), sep); + letters = U_(button_letters); + sep = g_utf8_get_char (letters); + letter_v = e_utf8_split (g_utf8_next_char (letters), sep); + g_assert (label_v != NULL && letter_v != NULL); + for (pl = label_v, pc = letter_v; *pl != NULL && *pc != NULL; pl++, pc++) { + GtkWidget *button; + LetterClosure *closure; + char *label; + + label = e_utf8_to_locale_string (*pl); + button = gtk_button_new_with_label (label); + g_free (label); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + + closure = g_new (LetterClosure, 1); + closure->view = view; + closure->letter = g_utf8_get_char (*pc); + 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); - 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); } - - gtk_object_unref(GTK_OBJECT(gui)); + g_strfreev (label_v); + g_strfreev (letter_v); + + gtk_widget_show_all (widget); + return widget; } diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c index e01ec2cbb0..73d76ade73 100644 --- a/addressbook/gui/widgets/e-minicard-view-widget.c +++ b/addressbook/gui/widgets/e-minicard-view-widget.c @@ -326,8 +326,9 @@ e_minicard_view_widget_remove_selection(EMinicardViewWidget *view, e_minicard_view_remove_selection(E_MINICARD_VIEW(view->emv), cb, closure); } -void e_minicard_view_widget_jump_to_letter (EMinicardViewWidget *view, - char letter) +void +e_minicard_view_widget_jump_to_letter (EMinicardViewWidget *view, + gunichar letter) { if (view->emv) e_minicard_view_jump_to_letter(E_MINICARD_VIEW(view->emv), letter); diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h index 61d5912dd5..2d94f15ec5 100644 --- a/addressbook/gui/widgets/e-minicard-view-widget.h +++ b/addressbook/gui/widgets/e-minicard-view-widget.h @@ -22,6 +22,7 @@ #define __E_MINICARD_VIEW_WIDGET_H__ #include <gal/widgets/e-canvas.h> +#include <gal/unicode/gunicode.h> #include "addressbook/backend/ebook/e-book.h" #include "e-minicard-view.h" @@ -66,7 +67,7 @@ void e_minicard_view_widget_remove_selection (EMinicardViewWidget *view, EBookCallback cb, gpointer closure); void e_minicard_view_widget_jump_to_letter (EMinicardViewWidget *view, - char letter); + gunichar letter); GtkWidget *e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter); ESelectionModel *e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view); diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c index 4a3925d75b..fe3cf42206 100644 --- a/addressbook/gui/widgets/e-minicard-view.c +++ b/addressbook/gui/widgets/e-minicard-view.c @@ -342,13 +342,14 @@ e_minicard_view_remove_selection(EMinicardView *view, #if 0 static int -compare_to_letter(EMinicard *card, char *letter) +compare_to_utf_str (EMinicard *card, const char *utf_str) { g_return_val_if_fail(card != NULL, 0); g_return_val_if_fail(E_IS_MINICARD(card), 0); - if (*letter == '1') + if (g_unichar_isdigit (g_utf8_get_char (utf_str))) { return 1; + } if (card->card) { char *file_as; @@ -356,7 +357,7 @@ compare_to_letter(EMinicard *card, char *letter) "file_as", &file_as, NULL); if (file_as) - return strncasecmp(file_as, letter, 1); + return g_utf8_strcasecmp (file_as, utf_str); else return 0; } else { @@ -368,13 +369,16 @@ compare_to_letter(EMinicard *card, char *letter) void -e_minicard_view_jump_to_letter (EMinicardView *view, - char letter) +e_minicard_view_jump_to_letter (EMinicardView *view, + gunichar letter) { #if 0 - e_reflow_sorted_jump(E_REFLOW_SORTED(view), - (GCompareFunc) compare_to_letter, - &letter); + char uft_str[6 + 1]; + + utf_str [g_unichar_to_utf8 (letter, utf_str)] = '\0'; + e_reflow_sorted_jump (E_REFLOW_SORTED (view), + (GCompareFunc) compare_to_utf_str, + utf_str); #endif } diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h index 5c7065fe1d..b735cc1ea7 100644 --- a/addressbook/gui/widgets/e-minicard-view.h +++ b/addressbook/gui/widgets/e-minicard-view.h @@ -25,6 +25,7 @@ #include <gal/widgets/e-reflow.h> #include <gal/widgets/e-selection-model-simple.h> +#include <gal/unicode/gunicode.h> #include "addressbook/backend/ebook/e-book.h" #include "e-addressbook-reflow-adapter.h" @@ -90,7 +91,7 @@ void e_minicard_view_remove_selection (EMinicardView *view, EBookCallback cb, gpointer closure); void e_minicard_view_jump_to_letter (EMinicardView *view, - char letter); + gunichar letter); #ifdef __cplusplus } |