Здравствуйте. Вот помучившись с роксом (2.1.1) решил сам покапаться
в исходниках и поправить ситуацию. Вроде получилось (хотя местами
коряво, но я первый раз смотрел GTK-программу).
Вот патч:
diff -Nu src.old/display.c src/display.c
--- src.old/display.c 2003-08-02 17:01:07.000000000 +0400
+++ src/display.c 2004-02-26 15:27:34.811200504 +0300
@@ -741,20 +741,12 @@
}
else
{
- PangoAttribute *attr;
gchar *utf8;
utf8 = to_utf8(item->leafname);
view->layout = gtk_widget_create_pango_layout(
filer_window->window, utf8);
g_free(utf8);
-
- attr = pango_attr_foreground_new(0xffff, 0, 0);
- attr->start_index = 0;
- attr->end_index = -1;
- if (!list)
- list = pango_attr_list_new();
- pango_attr_list_insert(list, attr);
}
if (item->flags & ITEM_FLAG_RECENT)
diff -Nu src.old/filer.c src/filer.c
--- src.old/filer.c 2003-10-26 19:14:28.000000000 +0300
+++ src/filer.c 2004-02-26 15:27:46.764383344 +0300
@@ -2015,11 +2015,6 @@
if (info)
g_object_unref(info);
}
-
- if (!g_utf8_validate(item->leafname, -1, NULL))
- g_string_append(tip,
- _("This filename is not valid UTF-8. "
- "You should rename it.\n"));
}
/* Return the selection as a text/uri-list.
diff -Nu src.old/infobox.c src/infobox.c
--- src.old/infobox.c 2004-01-24 22:00:22.000000000 +0300
+++ src/infobox.c 2004-02-26 15:21:18.581396128 +0300
@@ -122,21 +122,26 @@
void infobox_new(const gchar *pathname)
{
GtkWidget *window, *details;
- gchar *path;
+ gchar *path,*utf8_path;
GObject *owindow;
g_return_if_fail(pathname != NULL);
+
path = g_strdup(pathname); /* Gets attached to window & freed later */
+ utf8_path=g_strdup(pathname);
+ ensure_utf8(&utf8_path);
+
window = gtk_dialog_new_with_buttons(
- g_utf8_validate(path, -1, NULL) ? path
- : _("(bad utf-8)"),
+ utf8_path,
NULL, GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CANCEL, GTK_RESPONSE_DELETE_EVENT,
GTK_STOCK_REFRESH, GTK_RESPONSE_APPLY,
NULL);
+ g_free(utf8_path);
+
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
owindow = G_OBJECT(window);
@@ -443,27 +448,28 @@
static gboolean read_du_output(GIOChannel *source, GIOCondition cond, DU *du)
{
- GString *line;
GIOStatus stat;
GError *err = NULL;
- line = g_string_new("");
- stat = g_io_channel_read_line_string(source, line, NULL, &err);
+ gsize size=250;
+ gchar *line=g_new(gchar,size+1);
+
+ stat = g_io_channel_read_chars(source, line, size, &size, &err);
switch (stat)
{
case G_IO_STATUS_NORMAL:
- insert_size(du, line->str);
+ insert_size(du, line);
break;
case G_IO_STATUS_EOF:
break;
case G_IO_STATUS_AGAIN:
- g_string_free(line, TRUE);
+ g_free(line);
return TRUE;
case G_IO_STATUS_ERROR:
set_cell(du->store, du->path, err->message);
break;
}
- g_string_free(line, TRUE);
+ g_free(line);
return FALSE;
}
@@ -544,11 +550,13 @@
g_object_set_data(G_OBJECT(store), "rox_window", window);
/* For a symlink to an error, don't show the error */
+/*
if (item->base_type == TYPE_ERROR && item->lstat_errno)
{
add_row(store, _("Error:"), g_strerror(item->lstat_errno));
return view;
}
+*/
tmp = g_path_get_dirname(path);
tmp2 = pathdup(tmp);
@@ -581,6 +589,7 @@
du->path = g_strdup(add_row(store, _("Size:"), _("Scanning")));
args[2] = (gchar *) path;
+
if (g_spawn_async_with_pipes(NULL, args, NULL,
G_SPAWN_SEARCH_PATH,
NULL, NULL, &du->child,
diff -Nu src.old/menu.c src/menu.c
--- src.old/menu.c 2004-01-21 23:03:15.000000000 +0300
+++ src/menu.c 2004-02-26 15:18:23.410026224 +0300
@@ -744,12 +744,16 @@
item->leafname);
shade_file_menu_items(FALSE);
file_item = filer_selected_item(filer_window);
+
+ gchar *file_item_leafname=g_strdup(file_item->leafname);
+ ensure_utf8(&file_item_leafname);
+
g_string_printf(buffer, _("%s '%s'"),
basetype_name(file_item),
- g_utf8_validate(file_item->leafname,
- -1, NULL)
- ? file_item->leafname
- : _("(bad utf-8)"));
+ file_item_leafname );
+
+ g_free( file_item_leafname );
+
if (!can_set_run_action(file_item))
menu_set_items_shaded(filer_file_menu,
TRUE, 9, 1);
@@ -1084,7 +1088,7 @@
static gboolean copy_cb(GObject *savebox,
const gchar *current, const gchar *new)
{
- return action_with_leaf(action_copy, current, new);
+ return action_with_leaf(action_copy, current, g_locale_from_utf8(new, -1, NULL, NULL, NULL));
}
static gboolean action_with_leaf(ActionFn action,
@@ -1137,7 +1141,7 @@
static gboolean rename_cb(GObject *savebox,
const gchar *current, const gchar *new)
{
- return action_with_leaf(action_move, current, new);
+ return action_with_leaf(action_move, current, g_locale_from_utf8(new, -1, NULL, NULL, NULL));
}
static gboolean link_cb(GObject *savebox,
@@ -1155,7 +1159,7 @@
else
link_path = g_strdup(initial);
- if (mc_lstat(path, &info) == 0 && S_ISLNK(info.st_mode))
+ if (mc_lstat(g_locale_from_utf8(path, -1, NULL, NULL, NULL), &info) == 0 && S_ISLNK(info.st_mode))
{
GtkWidget *box, *button;
gint ans;
@@ -1188,7 +1192,7 @@
unlink(path);
}
- err = symlink(link_path, path);
+ err = symlink(link_path, g_locale_from_utf8(path, -1, NULL, NULL, NULL));
g_free(link_path);
if (err)
@@ -1276,7 +1280,7 @@
static gboolean new_directory_cb(GObject *savebox,
const gchar *initial, const gchar *path)
{
- if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO))
+ if (mkdir(g_locale_from_utf8(path, -1, NULL, NULL, NULL), S_IRWXU | S_IRWXG | S_IRWXO))
{
report_error("mkdir: %s", g_strerror(errno));
return FALSE;
@@ -1310,7 +1314,7 @@
{
int fd;
- fd = open(path, O_CREAT | O_EXCL, 0666);
+ fd = open(g_locale_from_utf8(path, -1, NULL, NULL, NULL), O_CREAT | O_EXCL, 0666);
if (fd == -1)
{
diff -Nu src.old/view_details.c src/view_details.c
--- src.old/view_details.c 2003-05-27 16:58:23.000000000 +0400
+++ src/view_details.c 2004-02-26 15:33:23.003267264 +0300
@@ -336,17 +336,8 @@
break;
case COL_COLOUR:
g_value_init(value, GDK_TYPE_COLOR);
- if (view_item->utf8_name)
- {
- GdkColor red;
- red.red = 0xffff;
- red.green = 0;
- red.blue = 0;
- g_value_set_boxed(value, &red);
- }
- else
- g_value_set_boxed(value,
- type_get_colour(item, NULL));
+ g_value_set_boxed(value,
+ type_get_colour(item, NULL));
break;
case COL_OWNER:
g_value_init(value, G_TYPE_STRING);