diff options
author | Lauris Kaplinski <lauris@src.gnome.org> | 2000-09-08 02:30:30 +0800 |
---|---|---|
committer | Lauris Kaplinski <lauris@src.gnome.org> | 2000-09-08 02:30:30 +0800 |
commit | 0db696fa4205edb578c56cade278061b4bbe54f2 (patch) | |
tree | b481424b3de3f269586f7658dd463864974bda6c | |
parent | 722a05828e68522a639a04ae0b13855e6b70820b (diff) | |
download | gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar.gz gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.tar.zst gsoc2013-evolution-0db696fa4205edb578c56cade278061b4bbe54f2.zip |
Bunch of unicode related changes
svn path=/trunk/; revision=5235
-rw-r--r-- | calendar/ChangeLog | 7 | ||||
-rw-r--r-- | calendar/cal-client/Makefile.am | 15 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-editor.c | 3 | ||||
-rw-r--r-- | e-util/ChangeLog | 10 | ||||
-rw-r--r-- | e-util/e-dialog-widgets.c | 5 | ||||
-rw-r--r-- | e-util/e-font.c | 33 | ||||
-rw-r--r-- | e-util/e-unicode.c | 42 | ||||
-rw-r--r-- | e-util/e-unicode.h | 5 | ||||
-rw-r--r-- | filter/ChangeLog | 6 | ||||
-rw-r--r-- | filter/filter-editor.c | 16 | ||||
-rw-r--r-- | filter/filter-filter.c | 6 | ||||
-rw-r--r-- | filter/filter-folder.c | 12 | ||||
-rw-r--r-- | filter/filter-option.c | 6 | ||||
-rw-r--r-- | filter/filter-rule.c | 5 | ||||
-rw-r--r-- | filter/score-editor.c | 18 | ||||
-rw-r--r-- | filter/vfolder-editor.c | 17 | ||||
-rw-r--r-- | filter/vfolder-rule.c | 11 | ||||
-rw-r--r-- | mail/folder-browser.c | 2 | ||||
-rw-r--r-- | mail/mail-config-gui.c | 4 | ||||
-rw-r--r-- | widgets/misc/e-unicode.c | 42 | ||||
-rw-r--r-- | widgets/misc/e-unicode.h | 5 |
21 files changed, 221 insertions, 49 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 526cefb453..b944adc3f2 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2000-09-07 Lauris Kaplinski <lauris@helixcode.com> + + * cal-client/Makefile.am: Added -lunicode + + * gui/dialogs/task-editor.c: More UTF-8 wrappers + (priority_index_to_value): Kill warning, add assertion + 2000-09-06 JP Rosevear <jpr@helixcode.com> * gui/e-day-view-main-item.c (e_day_view_main_item_draw_day_event): diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am index 8a88215257..ce968767f5 100644 --- a/calendar/cal-client/Makefile.am +++ b/calendar/cal-client/Makefile.am @@ -65,7 +65,22 @@ client_test_INCLUDES = \ client_test_LDADD = \ $(BONOBO_VFS_GNOME_LIBS) \ + -lunicode \ $(top_builddir)/calendar/cal-util/libcal-util.la \ $(top_builddir)/libversit/libversit.la \ $(top_builddir)/libical/src/libical/libical.a \ libcal-client.la + + + + + + + + + + + + + + diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index a91278b84a..6b79896e2e 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -1252,6 +1252,9 @@ priority_index_to_value (TaskEditorPriority priority) case PRIORITY_LOW: retval = 7; break; + default: + g_assert_not_reached (); + break; } return retval; diff --git a/e-util/ChangeLog b/e-util/ChangeLog index e17f53ff4b..ddec5e90a4 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,13 @@ +2000-09-07 Lauris Kaplinski <lauris@helixcode.com> + + * e-dialog-widgets.c (e_dialog_editable_get): Use UTF-8 + (e_dialog_editable_set): Use UTF-8 + + * e-font.c (translate_encoding): More encodings + (e_gdk_font_encoding): Use experimental stuff + + * e-unicode.* (e_utf8_gtk_editable_insert_text): New wrapper + 2000-09-07 Federico Mena Quintero <federico@helixcode.com> * e-canvas.c (emit_event): Remove incorrect optimization. Events diff --git a/e-util/e-dialog-widgets.c b/e-util/e-dialog-widgets.c index fd1b929c9f..4a4664cd41 100644 --- a/e-util/e-dialog-widgets.c +++ b/e-util/e-dialog-widgets.c @@ -30,6 +30,7 @@ #include <gtk/gtkspinbutton.h> #include <libgnomeui/gnome-dateedit.h> #include "e-dialog-widgets.h" +#include "e-unicode.h" @@ -351,7 +352,7 @@ e_dialog_editable_set (GtkWidget *widget, const char *value) gint pos; pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (widget), value, strlen (value), &pos); + e_utf8_gtk_editable_insert_text (GTK_EDITABLE (widget), value, strlen (value), &pos); } } @@ -369,7 +370,7 @@ e_dialog_editable_get (GtkWidget *widget) g_return_val_if_fail (widget != NULL, NULL); g_return_val_if_fail (GTK_IS_EDITABLE (widget), NULL); - return gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); + return e_utf8_gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); } /** diff --git a/e-util/e-font.c b/e-util/e-font.c index 6f46b07f03..cfee9f0923 100644 --- a/e-util/e-font.c +++ b/e-util/e-font.c @@ -143,6 +143,14 @@ translate_encoding (const gchar *encoding) g_hash_table_insert (eh, "iso8859-3", "iso-8859-3"); g_hash_table_insert (eh, "iso8859-4", "iso-8859-4"); g_hash_table_insert (eh, "iso8859-5", "iso-8859-5"); + g_hash_table_insert (eh, "iso8859-6", "iso-8859-6"); + g_hash_table_insert (eh, "iso8859-7", "iso-8859-7"); + g_hash_table_insert (eh, "iso8859-8", "iso-8859-8"); + g_hash_table_insert (eh, "iso8859-9", "iso-8859-9"); + g_hash_table_insert (eh, "iso8859-10", "iso-8859-10"); + g_hash_table_insert (eh, "iso8859-13", "iso-8859-13"); + g_hash_table_insert (eh, "iso8859-14", "iso-8859-14"); + g_hash_table_insert (eh, "iso8859-15", "iso-8859-15"); g_hash_table_insert (eh, "iso10646-1", "UCS2"); } @@ -159,6 +167,7 @@ e_gdk_font_encoding (GdkFont *font) Bool status; char *name, *p; const gchar *encoding; + gint i; if (!font) return NULL; @@ -183,7 +192,15 @@ e_gdk_font_encoding (GdkFont *font) if (!status) return NULL; - name = gdk_atom_name (atom); + name = p = gdk_atom_name (atom); + + for (i = 0; i < 13; i++) { + /* Skip hyphen */ + while (*p && (*p != '-')) p++; + if (*p) p++; + } + +#if 0 p = strchr (name, '-'); /* Foundry */ p = strchr (p + 1, '-'); /* Family */ p = strchr (p + 1, '-'); /* Weight */ @@ -199,6 +216,11 @@ e_gdk_font_encoding (GdkFont *font) p = strchr (p + 1, '-'); /* Charset */ encoding = translate_encoding (p + 1); +#else + if (!*p) return NULL; + + encoding = translate_encoding (p); +#endif g_free (name); @@ -218,9 +240,7 @@ e_uiconv_from_gdk_font (GdkFont *font) if (!enc) return (unicode_iconv_t) -1; - if (!uh) { - uh = g_hash_table_new (g_str_hash, g_str_equal); - } + if (!uh) uh = g_hash_table_new (g_str_hash, g_str_equal); uiconv = g_hash_table_lookup (uh, enc); @@ -246,9 +266,7 @@ e_uiconv_to_gdk_font (GdkFont *font) if (!enc) return (unicode_iconv_t) -1; - if (!uh) { - uh = g_hash_table_new (g_str_hash, g_str_equal); - } + if (!uh) uh = g_hash_table_new (g_str_hash, g_str_equal); uiconv = g_hash_table_lookup (uh, enc); @@ -267,3 +285,4 @@ e_uiconv_to_gdk_font (GdkFont *font) + diff --git a/e-util/e-unicode.c b/e-util/e-unicode.c index 0946647fd8..8357977f8e 100644 --- a/e-util/e-unicode.c +++ b/e-util/e-unicode.c @@ -13,7 +13,7 @@ #include "e-unicode.h" #include "e-font.h" -#undef FONT_TESTING +#define FONT_TESTING void e_unicode_init (void) @@ -89,7 +89,7 @@ e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string) } gchar * -e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) +e_utf8_from_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes) { #ifndef FONT_TESTING /* test it out with iso-8859-1 */ @@ -97,7 +97,6 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) static gboolean uinit = FALSE; static gboolean uerror = FALSE; static unicode_iconv_t uiconv = (unicode_iconv_t) -1; - const gchar *encoding; #else unicode_iconv_t uiconv; #endif @@ -113,6 +112,8 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) if (!string) return NULL; + g_return_val_if_fail (widget, NULL); + #ifndef FONT_TESTING if (!uinit) { e_unicode_init (); @@ -129,7 +130,7 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) if (uiconv == (unicode_iconv_t) -1) return NULL; #endif - ibl = strlen (string); + ibl = bytes; new = ob = g_new (gchar, ibl * 6 + 1); obl = ibl * 6 + 1; @@ -141,7 +142,13 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) } gchar * -e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) +e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) +{ + return e_utf8_from_gtk_string_sized (widget, string, strlen (string)); +} + +gchar * +e_utf8_to_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes) { #ifndef FONT_TESTING /* test it out with iso-8859-1 */ @@ -161,6 +168,8 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) if (!string) return NULL; + g_return_val_if_fail (widget, NULL); + #ifndef FONT_TESTING if (!uinit) { e_unicode_init (); @@ -177,7 +186,7 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) if (uiconv == (unicode_iconv_t) -1) return NULL; #endif - ibl = strlen (string); + ibl = bytes; new = ob = g_new (gchar, ibl * 4 + 1); obl = ibl * 4 + 1; @@ -189,6 +198,11 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) } gchar * +e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) +{ + return e_utf8_to_gtk_string_sized (widget, string, strlen (string)); +} +gchar * e_utf8_gtk_entry_get_text (GtkEntry *entry) { gchar *s, *u; @@ -212,6 +226,18 @@ e_utf8_gtk_editable_get_chars (GtkEditable *editable, gint start, gint end) } void +e_utf8_gtk_editable_insert_text (GtkEditable *editable, const gchar *text, gint length, gint *position) +{ + gchar *s; + + s = e_utf8_to_gtk_string_sized ((GtkWidget *) editable, text, length); + + gtk_editable_insert_text (editable, s, length, position); + + g_free (s); +} + +void e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text) { gchar *s; @@ -225,14 +251,14 @@ e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text) } GtkWidget * -e_utf8_gtk_menu_item_new_with_label (const gchar *label) +e_utf8_gtk_menu_item_new_with_label (GtkMenu *menu, const gchar *label) { GtkWidget *w; gchar *s; if (!label) return NULL; - s = e_utf8_to_gtk_string (NULL, label); + s = e_utf8_to_gtk_string ((GtkWidget *) menu, label); w = gtk_menu_item_new_with_label (s); if (s) g_free (s); diff --git a/e-util/e-unicode.h b/e-util/e-unicode.h index 00cc3ab292..654d8d94ee 100644 --- a/e-util/e-unicode.h +++ b/e-util/e-unicode.h @@ -23,8 +23,10 @@ const gchar *e_utf8_strstrcase (const gchar *haystack, const gchar *needle); gchar *e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string); gchar *e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string); +gchar *e_utf8_from_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes); gchar * e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string); +gchar * e_utf8_to_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes); /* * These are simple wrappers that save us some typing @@ -36,8 +38,9 @@ gchar *e_utf8_gtk_entry_get_text (GtkEntry *entry); void e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text); gchar *e_utf8_gtk_editable_get_chars (GtkEditable *editable, gint start, gint end); +void e_utf8_gtk_editable_insert_text (GtkEditable *editable, const gchar *text, gint length, gint *position); -GtkWidget *e_utf8_gtk_menu_item_new_with_label (const gchar *label); +GtkWidget *e_utf8_gtk_menu_item_new_with_label (GtkMenu *menu, const gchar *label); void e_utf8_gtk_clist_set_text (GtkCList *clist, gint row, gint col, const gchar *text); gint e_utf8_gtk_clist_append (GtkCList *clist, gchar *text[]); diff --git a/filter/ChangeLog b/filter/ChangeLog index 0796572667..03e1ecd565 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,9 @@ +2000-09-07 Lauris Kaplinski <lauris@helixcode.com> + + * filter-editor.c, filter-filter.c, filter-folder.c, filter-option.c: + * filter-rule.c, score-editor.c, vfolder-editor.c, vfolder-rule.c: + More UTF-8 wrapping + 2000-09-06 Jeffrey Stedfast <fejj@helixcode.com> * filter-driver.c (filter_driver_run): Totally rewritten to filter diff --git a/filter/filter-editor.c b/filter/filter-editor.c index 9f4a0e1872..99fb869e6d 100644 --- a/filter/filter-editor.c +++ b/filter/filter-editor.c @@ -22,6 +22,7 @@ #include <gnome.h> #include <glade/glade.h> +#include <e-util/e-unicode.h> #include "filter-editor.h" #include "filter-context.h" #include "filter-filter.h" @@ -158,9 +159,11 @@ static void rule_add(GtkWidget *widget, struct _editor_data *data) gtk_widget_show((GtkWidget *)gd); result = gnome_dialog_run_and_close(gd); if (result == 0) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(((FilterRule *)rule)->name); + GtkListItem *item; GList *l = NULL; - + gchar *s = e_utf8_to_gtk_string ((GtkWidget *) data->list, ((FilterRule *)rule)->name); + item = (GtkListItem *)gtk_list_item_new_with_label (s); + g_free (s); gtk_object_set_data((GtkObject *)item, "rule", rule); gtk_widget_show((GtkWidget *)item); l = g_list_append(l, item); @@ -196,7 +199,9 @@ static void rule_edit(GtkWidget *widget, struct _editor_data *data) pos = rule_context_get_rank_rule_with_source (data->f, data->current, data->current_source); if (pos != -1) { GtkListItem *item = g_list_nth_data(data->list->children, pos); - gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), data->current->name); + gchar *s = e_utf8_to_gtk_string ((GtkWidget *) item, data->current->name); + gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), s); + g_free (s); } } } @@ -319,6 +324,7 @@ select_source (GtkMenuItem *mi, struct _editor_data *data) d(printf("Checking for rules that are of type %d\n", source)); while ((rule = rule_context_next_rule (data->f, rule)) != NULL) { GtkWidget *item; + gchar *s; if (rule->source != source) { d(printf(" skipping %s: %d != %d\n", rule->name, rule->source, source)); @@ -326,7 +332,9 @@ select_source (GtkMenuItem *mi, struct _editor_data *data) } d(printf(" hit %s (%d)\n", rule->name, source)); - item = gtk_list_item_new_with_label (rule->name); + s = e_utf8_to_gtk_string ((GtkWidget *) data->list, rule->name); + item = gtk_list_item_new_with_label (s); + g_free (s); gtk_object_set_data (GTK_OBJECT (item), "rule", rule); gtk_widget_show (GTK_WIDGET (item)); newitems = g_list_append (newitems, item); diff --git a/filter/filter-filter.c b/filter/filter-filter.c index b0699ce827..86cc3baff2 100644 --- a/filter/filter-filter.c +++ b/filter/filter-filter.c @@ -22,6 +22,7 @@ #include <gnome.h> #include <gnome-xml/xmlmemory.h> +#include <e-util/e-unicode.h> #include "filter-filter.h" #include "filter-context.h" @@ -272,6 +273,7 @@ get_rule_part_widget(FilterContext *f, FilterPart *newpart, FilterRule *fr) GtkWidget *p; int index=0, current=0; struct _part_data *data; + gchar *s; data = g_malloc0(sizeof(*data)); data->fr = fr; @@ -286,7 +288,9 @@ get_rule_part_widget(FilterContext *f, FilterPart *newpart, FilterRule *fr) menu = (GtkMenu *)gtk_menu_new(); while ((part=filter_context_next_action(f, part))) { - item = (GtkMenuItem *)gtk_menu_item_new_with_label(part->title); + s = e_utf8_to_gtk_string ((GtkWidget *) menu, part->title); + item = (GtkMenuItem *)gtk_menu_item_new_with_label(s); + g_free (s); gtk_object_set_data((GtkObject *)item, "part", part); gtk_signal_connect((GtkObject *)item, "activate", option_activate, data); gtk_menu_append(menu, (GtkWidget *)item); diff --git a/filter/filter-folder.c b/filter/filter-folder.c index cb2d87c29f..4e9523b57a 100644 --- a/filter/filter-folder.c +++ b/filter/filter-folder.c @@ -178,6 +178,7 @@ static void button_clicked(GtkButton *button, FilterFolder *ff) #ifdef SHELL const char *allowed_types[] = { "mail", NULL }; char *def, *physical_uri, *evolution_uri; + gchar *s; def = ff->uri ? ff->uri : ""; @@ -192,9 +193,10 @@ static void button_clicked(GtkButton *button, FilterFolder *ff) ff->uri = physical_uri; g_free(ff->name); - ff->name = g_strdup(g_basename (evolution_uri)); - - gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, ff->name); + ff->name = g_strdup (g_basename (evolution_uri)); + s = e_utf8_to_gtk_string((GtkWidget *) button, ff->name); + gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, s); + g_free (s); } else { g_free (physical_uri); } @@ -227,7 +229,9 @@ static void button_clicked(GtkButton *button, FilterFolder *ff) else str = uri; ff->name = g_strdup(str); - gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, ff->name); + s = e_utf8_to_gtk_string ((GtkWidget *) button, ff->name); + gtk_label_set_text((GtkLabel *)GTK_BIN(button)->child, s); + g_free (s); case 1: gnome_dialog_close(gd); case -1: diff --git a/filter/filter-option.c b/filter/filter-option.c index bbf1a8ef90..28a57ccf0e 100644 --- a/filter/filter-option.c +++ b/filter/filter-option.c @@ -25,6 +25,7 @@ #include "filter-option.h" #include "filter-part.h" #include "e-util/e-sexp.h" +#include "e-util/e-unicode.h" #define d(x) @@ -238,11 +239,14 @@ static GtkWidget *get_widget(FilterElement *fe) GList *l = fo->options; struct _filter_option *op; int index = 0, current=0; + gchar *s; menu = (GtkMenu *)gtk_menu_new(); while (l) { op = l->data; - item = (GtkMenuItem *)gtk_menu_item_new_with_label(op->title); + s = e_utf8_to_gtk_string ((GtkWidget *) menu, op->title); + item = (GtkMenuItem *)gtk_menu_item_new_with_label(s); + g_free (s); gtk_object_set_data((GtkObject *)item, "option", op); gtk_signal_connect((GtkObject *)item, "activate", option_activate, fo); gtk_menu_append(menu, (GtkWidget *)item); diff --git a/filter/filter-rule.c b/filter/filter-rule.c index 21aa5ed396..bf26845d38 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -364,6 +364,7 @@ get_rule_part_widget(RuleContext *f, FilterPart *newpart, FilterRule *fr) GtkWidget *p; int index=0, current=0; struct _part_data *data; + gchar *s; data = g_malloc0(sizeof(*data)); data->fr = fr; @@ -382,7 +383,9 @@ get_rule_part_widget(RuleContext *f, FilterPart *newpart, FilterRule *fr) menu = (GtkMenu *)gtk_menu_new(); /* sigh, this is a little ugly */ while ((part=rule_context_next_part(f, part))) { - item = (GtkMenuItem *)gtk_menu_item_new_with_label(part->title); + s = e_utf8_to_gtk_string ((GtkWidget *) menu, part->title); + item = (GtkMenuItem *)gtk_menu_item_new_with_label (s); + g_free (s); gtk_object_set_data((GtkObject *)item, "part", part); gtk_signal_connect((GtkObject *)item, "activate", option_activate, data); gtk_menu_append(menu, (GtkWidget *)item); diff --git a/filter/score-editor.c b/filter/score-editor.c index 6598cd9e33..1f45036e61 100644 --- a/filter/score-editor.c +++ b/filter/score-editor.c @@ -22,6 +22,7 @@ #include <gnome.h> #include <glade/glade.h> +#include <e-util/e-unicode.h> #include "score-editor.h" #include "score-context.h" #include "score-rule.h" @@ -130,9 +131,13 @@ static void rule_add(GtkWidget *widget, struct _editor_data *data) gtk_widget_show((GtkWidget *)gd); result = gnome_dialog_run_and_close(gd); if (result == 0) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(((FilterRule *)rule)->name); + GtkListItem *item; GList *l = NULL; + gchar *s; + s = e_utf8_to_gtk_string ((GtkWidget *) data->list, ((FilterRule *) rule)->name); + item = (GtkListItem *)gtk_list_item_new_with_label (s); + g_free (s); gtk_object_set_data((GtkObject *)item, "rule", rule); gtk_widget_show((GtkWidget *)item); l = g_list_append(l, item); @@ -166,7 +171,9 @@ static void rule_edit(GtkWidget *widget, struct _editor_data *data) pos = rule_context_get_rank_rule(data->f, data->current); if (pos != -1) { GtkListItem *item = g_list_nth_data(data->list->children, pos); - gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), data->current->name); + gchar *s = e_utf8_to_gtk_string ((GtkWidget *) data->list, data->current->name); + gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), s); + g_free (s); } } } @@ -298,7 +305,12 @@ GtkWidget *score_editor_construct (struct _ScoreContext *f) data->list = (GtkList *)w; l = NULL; while ((rule = rule_context_next_rule((RuleContext *)f, rule))) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(rule->name); + GtkListItem *item; + gchar *s; + + s = e_utf8_to_gtk_string ((GtkWidget *) data->list, rule->name); + item = (GtkListItem *)gtk_list_item_new_with_label (s); + g_free (s); gtk_object_set_data((GtkObject *)item, "rule", rule); gtk_widget_show((GtkWidget *)item); l = g_list_append(l, item); diff --git a/filter/vfolder-editor.c b/filter/vfolder-editor.c index c5bf378625..45c4648368 100644 --- a/filter/vfolder-editor.c +++ b/filter/vfolder-editor.c @@ -22,6 +22,7 @@ #include <gnome.h> #include <glade/glade.h> +#include <e-util/e-unicode.h> #include "vfolder-editor.h" #include "vfolder-context.h" #include "vfolder-rule.h" @@ -156,8 +157,13 @@ static void rule_add(GtkWidget *widget, struct _editor_data *data) gtk_widget_show((GtkWidget *)gd); result = gnome_dialog_run_and_close(gd); if (result == 0) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(rule->name); + GtkListItem *item; GList *l = NULL; + gchar *s; + + s = e_utf8_to_gtk_string ((GtkWidget *) data->list, rule->name); + item = (GtkListItem *)gtk_list_item_new_with_label(rule->name); + g_free (s); gtk_object_set_data((GtkObject *)item, "rule", rule); gtk_widget_show((GtkWidget *)item); @@ -192,7 +198,9 @@ static void rule_edit(GtkWidget *widget, struct _editor_data *data) pos = rule_context_get_rank_rule(data->f, data->current); if (pos != -1) { GtkListItem *item = g_list_nth_data(data->list->children, pos); - gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), data->current->name); + gchar *s = e_utf8_to_gtk_string ((GtkWidget *) item, data->current->name); + gtk_label_set_text((GtkLabel *)(((GtkBin *)item)->child), s); + g_free (s); } } } @@ -324,7 +332,10 @@ GtkWidget *vfolder_editor_construct (struct _VfolderContext *f) data->list = (GtkList *)w; l = NULL; while ((rule = rule_context_next_rule((RuleContext *)f, rule))) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(rule->name); + GtkListItem *item; + gchar *s = e_utf8_to_gtk_string ((GtkWidget *) data->list, rule->name); + item = (GtkListItem *)gtk_list_item_new_with_label(s); + g_free (s); gtk_object_set_data((GtkObject *)item, "rule", rule); gtk_widget_show((GtkWidget *)item); l = g_list_append(l, item); diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c index d6da471b07..1ee769057f 100644 --- a/filter/vfolder-rule.c +++ b/filter/vfolder-rule.c @@ -22,6 +22,7 @@ #include <gnome.h> #include <glade/glade.h> +#include <e-util/e-unicode.h> #include "vfolder-context.h" #include "vfolder-rule.h" #include "shell/evolution-shell-client.h" @@ -263,6 +264,7 @@ static void source_add(GtkWidget *widget, struct _source_data *data) char *def, *uri; GtkListItem *item; GList *l; + gchar *s; def = ""; evolution_shell_client_user_select_folder (global_shell_client, @@ -273,7 +275,9 @@ static void source_add(GtkWidget *widget, struct _source_data *data) data->vr->sources = g_list_append(data->vr->sources, uri); l = NULL; - item = (GtkListItem *)gtk_list_item_new_with_label(uri); + s = e_utf8_to_gtk_string ((GtkWidget *) data->list, uri); + item = (GtkListItem *)gtk_list_item_new_with_label (s); + g_free (s); gtk_object_set_data((GtkObject *)item, "source", uri); gtk_widget_show((GtkWidget *)item); l = g_list_append(NULL, item); @@ -340,7 +344,10 @@ static GtkWidget *get_widget(FilterRule *fr, struct _RuleContext *f) l = NULL; source = NULL; while ((source = vfolder_rule_next_source(vr, source))) { - GtkListItem *item = (GtkListItem *)gtk_list_item_new_with_label(source); + GtkListItem *item; + gchar *s = e_utf8_to_gtk_string ((GtkWidget *) data->list, source); + item = (GtkListItem *)gtk_list_item_new_with_label (s); + g_free (s); gtk_object_set_data((GtkObject *)item, "source", (void *)source); gtk_widget_show((GtkWidget *)item); l = g_list_append(l, item); diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 72d75af0d3..75cf0f06ac 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -205,7 +205,7 @@ create_option_menu (char **menu_list, int item, void *data) while (*menu_list){ GtkWidget *entry; - entry = e_utf8_gtk_menu_item_new_with_label (*menu_list); + entry = e_utf8_gtk_menu_item_new_with_label ((GtkWidget *) menu, *menu_list); gtk_widget_show (entry); gtk_object_set_data((GtkObject *)entry, "search_option", (void *)i); gtk_menu_append (GTK_MENU (menu), entry); diff --git a/mail/mail-config-gui.c b/mail/mail-config-gui.c index 49466b64a4..1cb972dc6b 100644 --- a/mail/mail-config-gui.c +++ b/mail/mail-config-gui.c @@ -741,7 +741,7 @@ service_page_item_auth_fill (MailDialogServicePage *page, for (; authtypes; authtypes = authtypes->next) { authtype = authtypes->data; - item = e_utf8_gtk_menu_item_new_with_label (_(authtype->name)); + item = gtk_menu_item_new_with_label (_(authtype->name)); if (!firstitem) firstitem = item; spitem->auth_items = g_list_append (spitem->auth_items, item); @@ -1119,7 +1119,7 @@ service_page_new (const char *label_text, GSList *services) gtk_notebook_append_page (GTK_NOTEBOOK (page->notebook), spitem->vbox, NULL); - spitem->item = e_utf8_gtk_menu_item_new_with_label (_(mcs->provider->name)); + spitem->item = gtk_menu_item_new_with_label (_(mcs->provider->name)); if (!first_item) first_item = spitem->item; diff --git a/widgets/misc/e-unicode.c b/widgets/misc/e-unicode.c index 0946647fd8..8357977f8e 100644 --- a/widgets/misc/e-unicode.c +++ b/widgets/misc/e-unicode.c @@ -13,7 +13,7 @@ #include "e-unicode.h" #include "e-font.h" -#undef FONT_TESTING +#define FONT_TESTING void e_unicode_init (void) @@ -89,7 +89,7 @@ e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string) } gchar * -e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) +e_utf8_from_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes) { #ifndef FONT_TESTING /* test it out with iso-8859-1 */ @@ -97,7 +97,6 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) static gboolean uinit = FALSE; static gboolean uerror = FALSE; static unicode_iconv_t uiconv = (unicode_iconv_t) -1; - const gchar *encoding; #else unicode_iconv_t uiconv; #endif @@ -113,6 +112,8 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) if (!string) return NULL; + g_return_val_if_fail (widget, NULL); + #ifndef FONT_TESTING if (!uinit) { e_unicode_init (); @@ -129,7 +130,7 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) if (uiconv == (unicode_iconv_t) -1) return NULL; #endif - ibl = strlen (string); + ibl = bytes; new = ob = g_new (gchar, ibl * 6 + 1); obl = ibl * 6 + 1; @@ -141,7 +142,13 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) } gchar * -e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) +e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string) +{ + return e_utf8_from_gtk_string_sized (widget, string, strlen (string)); +} + +gchar * +e_utf8_to_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes) { #ifndef FONT_TESTING /* test it out with iso-8859-1 */ @@ -161,6 +168,8 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) if (!string) return NULL; + g_return_val_if_fail (widget, NULL); + #ifndef FONT_TESTING if (!uinit) { e_unicode_init (); @@ -177,7 +186,7 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) if (uiconv == (unicode_iconv_t) -1) return NULL; #endif - ibl = strlen (string); + ibl = bytes; new = ob = g_new (gchar, ibl * 4 + 1); obl = ibl * 4 + 1; @@ -189,6 +198,11 @@ e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) } gchar * +e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string) +{ + return e_utf8_to_gtk_string_sized (widget, string, strlen (string)); +} +gchar * e_utf8_gtk_entry_get_text (GtkEntry *entry) { gchar *s, *u; @@ -212,6 +226,18 @@ e_utf8_gtk_editable_get_chars (GtkEditable *editable, gint start, gint end) } void +e_utf8_gtk_editable_insert_text (GtkEditable *editable, const gchar *text, gint length, gint *position) +{ + gchar *s; + + s = e_utf8_to_gtk_string_sized ((GtkWidget *) editable, text, length); + + gtk_editable_insert_text (editable, s, length, position); + + g_free (s); +} + +void e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text) { gchar *s; @@ -225,14 +251,14 @@ e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text) } GtkWidget * -e_utf8_gtk_menu_item_new_with_label (const gchar *label) +e_utf8_gtk_menu_item_new_with_label (GtkMenu *menu, const gchar *label) { GtkWidget *w; gchar *s; if (!label) return NULL; - s = e_utf8_to_gtk_string (NULL, label); + s = e_utf8_to_gtk_string ((GtkWidget *) menu, label); w = gtk_menu_item_new_with_label (s); if (s) g_free (s); diff --git a/widgets/misc/e-unicode.h b/widgets/misc/e-unicode.h index 00cc3ab292..654d8d94ee 100644 --- a/widgets/misc/e-unicode.h +++ b/widgets/misc/e-unicode.h @@ -23,8 +23,10 @@ const gchar *e_utf8_strstrcase (const gchar *haystack, const gchar *needle); gchar *e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string); gchar *e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string); +gchar *e_utf8_from_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes); gchar * e_utf8_to_gtk_string (GtkWidget *widget, const gchar *string); +gchar * e_utf8_to_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes); /* * These are simple wrappers that save us some typing @@ -36,8 +38,9 @@ gchar *e_utf8_gtk_entry_get_text (GtkEntry *entry); void e_utf8_gtk_entry_set_text (GtkEntry *entry, const gchar *text); gchar *e_utf8_gtk_editable_get_chars (GtkEditable *editable, gint start, gint end); +void e_utf8_gtk_editable_insert_text (GtkEditable *editable, const gchar *text, gint length, gint *position); -GtkWidget *e_utf8_gtk_menu_item_new_with_label (const gchar *label); +GtkWidget *e_utf8_gtk_menu_item_new_with_label (GtkMenu *menu, const gchar *label); void e_utf8_gtk_clist_set_text (GtkCList *clist, gint row, gint col, const gchar *text); gint e_utf8_gtk_clist_append (GtkCList *clist, gchar *text[]); |