From e4d0aa038b6cc63c63a9c969253c5e96f5853e17 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 23 Jan 2002 13:05:43 +0000 Subject: [PATCH] r1124: Better i18n for icons. --- ROX-Filer/Help/TODO | 5 +++-- ROX-Filer/src/panel.c | 43 +++++++++++++++++++++++++------------------ ROX-Filer/src/pinboard.c | 43 ++++++++++++++++++++++++------------------- 3 files changed, 52 insertions(+), 39 deletions(-) diff --git a/ROX-Filer/Help/TODO b/ROX-Filer/Help/TODO index 4d71720c..29d25f5e 100644 --- a/ROX-Filer/Help/TODO +++ b/ROX-Filer/Help/TODO @@ -10,11 +10,12 @@ BUGS i18n for icon paths. -Using spring-opening with a missing directory has grab problems. - FEATURES FOR 1.3 +Using spring-opening with a missing directory has grab problems (Gkt+ +problem?). + Gtk+ 2.0: - Panel menu appears, but menu item under cursor doesn't highlight (GTK bug?) diff --git a/ROX-Filer/src/panel.c b/ROX-Filer/src/panel.c index 1cc5cc82..dd5e0e34 100644 --- a/ROX-Filer/src/panel.c +++ b/ROX-Filer/src/panel.c @@ -376,7 +376,19 @@ static void panel_load_side(Panel *panel, xmlNodePtr side, gboolean after) if (!path) path = g_strdup(""); +#ifdef GTK2 panel_add_item(panel, path, label, after); +#else + { + gchar *loc_path, *loc_label; + + loc_path = from_utf8(path); + loc_label = from_utf8(leaf); + panel_add_item(panel, loc_path, loc_label, after); + g_free(loc_label); + g_free(loc_path); + } +#endif g_free(path); g_free(label); @@ -397,7 +409,6 @@ static void panel_load_from_xml(Panel *panel, xmlDocPtr doc) static char *pan_from_file(guchar *line) { guchar *sep, *leaf; - gchar *u8_path, *u8_leaf; g_return_val_if_fail(line != NULL, NULL); g_return_val_if_fail(loading_panel != NULL, NULL); @@ -414,14 +425,9 @@ static char *pan_from_file(guchar *line) else leaf = NULL; - u8_path = to_utf8(sep + 1); - u8_leaf = to_utf8(leaf); - g_free(leaf); - - panel_add_item(loading_panel, u8_path, u8_leaf, sep[0] == '>'); + panel_add_item(loading_panel, sep + 1, leaf, sep[0] == '>'); - g_free(u8_path); - g_free(u8_leaf); + g_free(leaf); return NULL; } @@ -430,6 +436,8 @@ static char *pan_from_file(guchar *line) * icon is added to the right/bottom end of the panel. * * If name is NULL a suitable name is taken from path. + * + * name and path are in UTF-8 for Gtk+-2.0 only. */ static void panel_add_item(Panel *panel, guchar *path, @@ -472,17 +480,7 @@ static void panel_add_item(Panel *panel, icon->selected = FALSE; if (name) - { -#ifndef GTK2 - gchar *loc_name; - - loc_name = from_utf8(name); - icon->item = diritem_new(loc_name); - g_free(loc_name); -#else icon->item = diritem_new(name); -#endif - } else { guchar *slash; @@ -894,7 +892,16 @@ static void make_widgets(xmlNodePtr side, GList *widgets) continue; } +#ifdef GTK2 tree = xmlNewTextChild(side, NULL, "icon", icon->src_path); +#else + { + gchar *u8; + u8 = to_utf8(icon->src_path); + tree = xmlNewTextChild(side, NULL, "icon", u8); + g_free(u8); + } +#endif #ifndef GTK2 { diff --git a/ROX-Filer/src/pinboard.c b/ROX-Filer/src/pinboard.c index 8f1c39b8..2f8203dc 100644 --- a/ROX-Filer/src/pinboard.c +++ b/ROX-Filer/src/pinboard.c @@ -282,7 +282,7 @@ void pinboard_activate(guchar *name) * image should be if it is TRUE. * 'name' is the name to use. If NULL then the leafname of path is used. * - * names are in UTF-8. + * name and path are in UTF-8 for Gtk+-2.0 only. */ void pinboard_pin(guchar *path, guchar *name, int x, int y) { @@ -313,17 +313,7 @@ void pinboard_pin(guchar *path, guchar *name, int x, int y) name = icon->path; } -#ifndef GTK2 - { - gchar *loc_name; - - loc_name = from_utf8(name); - icon->item = diritem_new(loc_name); - g_free(loc_name); - } -#else icon->item = diritem_new(name); -#endif diritem_restat(icon->path, icon->item); icon->win = gtk_window_new(GTK_WINDOW_DIALOG); @@ -1058,7 +1048,19 @@ static void pinboard_load_from_xml(xmlDocPtr doc) if (!path) path = g_strdup(""); +#ifdef GTK2 pinboard_pin(path, label, x, y); +#else + { + gchar *loc_path, *loc_label; + + loc_path = from_utf8(path); + loc_label = from_utf8(leaf); + pinboard_pin(loc_path, loc_label, x, y); + g_free(loc_label); + g_free(loc_path); + } +#endif g_free(path); g_free(label); @@ -1071,7 +1073,6 @@ static void pinboard_load_from_xml(xmlDocPtr doc) static char *pin_from_file(guchar *line) { guchar *leaf = NULL; - gchar *u8_path, *u8_leaf; int x, y, n; if (*line == '<') @@ -1096,14 +1097,9 @@ static char *pin_from_file(guchar *line) if (sscanf(line, " %d , %d , %n", &x, &y, &n) < 2) return NULL; /* Ignore format errors */ - u8_path = to_utf8(line + n); - u8_leaf = to_utf8(leaf); - g_free(leaf); - - pinboard_pin(u8_path, u8_leaf, x, y); + pinboard_pin(line + n, leaf, x, y); - g_free(u8_path); - g_free(u8_leaf); + g_free(leaf); return NULL; } @@ -1224,7 +1220,16 @@ void pinboard_save(void) Icon *icon = (Icon *) next->data; char *tmp; +#ifdef GTK2 tree = xmlNewTextChild(root, NULL, "icon", icon->src_path); +#else + { + gchar *u8; + u8 = to_utf8(icon->src_path); + tree = xmlNewTextChild(root, NULL, "icon", u8); + g_free(u8); + } +#endif tmp = g_strdup_printf("%d", icon->x); xmlSetProp(tree, "x", tmp); -- 2.11.4.GIT