4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2002, the ROX-Filer team.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
22 /* filer.c - code for handling filer windows */
32 #include <sys/param.h>
36 #include <gdk/gdkkeysyms.h>
44 #include "gui_support.h"
55 #include "minibuffer.h"
62 #include "view_iface.h"
63 #include "view_collection.h"
65 static XMLwrapper
*groups
= NULL
;
67 /* This is rather badly named. It's actually the filer window which received
68 * the last key press or Menu click event.
70 FilerWindow
*window_with_focus
= NULL
;
72 GList
*all_filer_windows
= NULL
;
74 static FilerWindow
*window_with_primary
= NULL
;
76 /* Static prototypes */
77 static void attach(FilerWindow
*filer_window
);
78 static void detach(FilerWindow
*filer_window
);
79 static void filer_window_destroyed(GtkWidget
*widget
,
80 FilerWindow
*filer_window
);
81 static void update_display(Directory
*dir
,
84 FilerWindow
*filer_window
);
85 static void set_scanning_display(FilerWindow
*filer_window
, gboolean scanning
);
86 static gboolean
may_rescan(FilerWindow
*filer_window
, gboolean warning
);
87 static gboolean
minibuffer_show_cb(FilerWindow
*filer_window
);
88 static FilerWindow
*find_filer_window(const char *sym_path
, FilerWindow
*diff
);
89 static void filer_add_widgets(FilerWindow
*filer_window
, const gchar
*wm_class
);
90 static void filer_add_signals(FilerWindow
*filer_window
);
92 static void set_selection_state(FilerWindow
*filer_window
, gboolean normal
);
93 static void filer_next_thumb(GObject
*window
, const gchar
*path
);
94 static void start_thumb_scanning(FilerWindow
*filer_window
);
95 static void filer_options_changed(void);
96 static void set_style_by_number_of_items(FilerWindow
*filer_window
);
98 static GdkCursor
*busy_cursor
= NULL
;
99 static GdkCursor
*crosshair
= NULL
;
101 /* Indicates whether the filer's display is different to the machine it
102 * is actually running on.
104 static gboolean not_local
= FALSE
;
106 static Option o_filer_change_size
, o_filer_change_size_num
;
107 static Option o_short_flag_names
;
108 Option o_filer_auto_resize
, o_unique_filer_windows
;
109 Option o_filer_size_limit
;
111 void filer_init(void)
115 gchar
*dpyhost
, *tmp
;
117 option_add_int(&o_filer_size_limit
, "filer_size_limit", 75);
118 option_add_int(&o_filer_auto_resize
, "filer_auto_resize",
120 option_add_int(&o_unique_filer_windows
, "filer_unique_windows", 0);
122 option_add_int(&o_short_flag_names
, "filer_short_flag_names", FALSE
);
124 option_add_int(&o_filer_change_size
, "filer_change_size", TRUE
);
125 option_add_int(&o_filer_change_size_num
, "filer_change_size_num", 30);
127 option_add_notify(filer_options_changed
);
129 busy_cursor
= gdk_cursor_new(GDK_WATCH
);
130 crosshair
= gdk_cursor_new(GDK_CROSSHAIR
);
132 /* Is the display on the local machine, or are we being
133 * run remotely? See filer_set_title().
135 ohost
= our_host_name();
136 dpy
= gdk_get_display();
137 dpyhost
= g_strdup(dpy
);
138 tmp
= strchr(dpyhost
, ':');
142 if (dpyhost
[0] && strcmp(ohost
, dpyhost
) != 0)
144 /* Try the cannonical name for dpyhost (see our_host_name()
149 ent
= gethostbyname(dpyhost
);
150 if (!ent
|| strcmp(ohost
, ent
->h_name
) != 0)
157 static gboolean
if_deleted(gpointer item
, gpointer removed
)
159 int i
= ((GPtrArray
*) removed
)->len
;
160 DirItem
**r
= (DirItem
**) ((GPtrArray
*) removed
)->pdata
;
161 char *leafname
= ((DirItem
*) item
)->leafname
;
165 if (strcmp(leafname
, r
[i
]->leafname
) == 0)
172 /* Resize the filer window to w x h pixels, plus border (not clamped).
173 * If triggered by a key event, warp the pointer (for SloppyFocus users).
175 void filer_window_set_size(FilerWindow
*filer_window
, int w
, int h
)
180 g_return_if_fail(filer_window
!= NULL
);
182 if (filer_window
->scrollbar
)
183 w
+= filer_window
->scrollbar
->allocation
.width
;
185 if (o_toolbar
.int_value
!= TOOLBAR_NONE
)
186 h
+= filer_window
->toolbar
->allocation
.height
;
187 if (filer_window
->message
)
188 h
+= filer_window
->message
->allocation
.height
;
190 window
= filer_window
->window
;
192 if (GTK_WIDGET_VISIBLE(window
))
195 GtkRequisition
*req
= &window
->requisition
;
196 GdkWindow
*gdk_window
= window
->window
;
198 w
= MAX(req
->width
, w
);
199 h
= MAX(req
->height
, h
);
200 gdk_window_get_position(gdk_window
, &x
, &y
);
202 if (x
+ w
> screen_width
|| y
+ h
> screen_height
)
204 if (x
+ w
> screen_width
)
205 x
= screen_width
- w
- 4;
206 if (y
+ h
> screen_height
)
207 y
= screen_height
- h
- 4;
208 gdk_window_move_resize(gdk_window
, x
, y
, w
, h
);
211 gdk_window_resize(gdk_window
, w
, h
);
214 gtk_window_set_default_size(GTK_WINDOW(window
), w
, h
);
216 event
= gtk_get_current_event();
217 if (event
&& event
->type
== GDK_KEY_PRESS
)
219 GdkWindow
*win
= filer_window
->window
->window
;
221 XWarpPointer(gdk_x11_drawable_get_xdisplay(win
),
223 gdk_x11_drawable_get_xid(win
),
229 /* Resize the window to fit the items currently in the Directory.
230 * When opening a directory for the first time, the names will be known but not
231 * the types and images. We can still make a good estimate of the size.
233 void filer_window_autosize(FilerWindow
*filer_window
)
235 view_autosize(filer_window
->view
);
238 /* Called on a timeout while scanning or when scanning ends
239 * (whichever happens first).
241 static gint
open_filer_window(FilerWindow
*filer_window
)
243 view_style_changed(filer_window
->view
, 0);
245 if (filer_window
->open_timeout
)
247 gtk_timeout_remove(filer_window
->open_timeout
);
248 filer_window
->open_timeout
= 0;
251 if (!GTK_WIDGET_VISIBLE(filer_window
->window
))
253 set_style_by_number_of_items(filer_window
);
254 filer_window_autosize(filer_window
);
255 gtk_widget_show(filer_window
->window
);
261 static void update_display(Directory
*dir
,
264 FilerWindow
*filer_window
)
266 ViewIface
*view
= (ViewIface
*) filer_window
->view
;
271 view_add_items(view
, items
);
272 /* Open and resize if currently hidden */
273 open_filer_window(filer_window
);
276 view_delete_if(view
, if_deleted
, items
);
279 set_scanning_display(filer_window
, TRUE
);
280 toolbar_update_info(filer_window
);
283 if (filer_window
->window
->window
)
284 gdk_window_set_cursor(
285 filer_window
->window
->window
,
287 set_scanning_display(filer_window
, FALSE
);
288 toolbar_update_info(filer_window
);
289 open_filer_window(filer_window
);
291 if (filer_window
->had_cursor
&&
292 !view_cursor_visible(view
))
294 view_show_cursor(view
);
295 filer_window
->had_cursor
= FALSE
;
297 if (filer_window
->auto_select
)
298 display_set_autoselect(filer_window
,
299 filer_window
->auto_select
);
300 g_free(filer_window
->auto_select
);
301 filer_window
->auto_select
= NULL
;
303 filer_create_thumbs(filer_window
);
305 if (filer_window
->thumb_queue
)
306 start_thumb_scanning(filer_window
);
309 view_update_items(view
, items
);
314 static void attach(FilerWindow
*filer_window
)
316 gdk_window_set_cursor(filer_window
->window
->window
, busy_cursor
);
317 view_clear(filer_window
->view
);
318 filer_window
->scanning
= TRUE
;
319 dir_attach(filer_window
->directory
, (DirCallback
) update_display
,
321 filer_set_title(filer_window
);
324 static void detach(FilerWindow
*filer_window
)
326 g_return_if_fail(filer_window
->directory
!= NULL
);
328 dir_detach(filer_window
->directory
,
329 (DirCallback
) update_display
, filer_window
);
330 g_object_unref(filer_window
->directory
);
331 filer_window
->directory
= NULL
;
334 static void filer_window_destroyed(GtkWidget
*widget
,
335 FilerWindow
*filer_window
)
337 all_filer_windows
= g_list_remove(all_filer_windows
, filer_window
);
339 g_object_set_data(G_OBJECT(widget
), "filer_window", NULL
);
341 if (window_with_primary
== filer_window
)
342 window_with_primary
= NULL
;
344 if (window_with_focus
== filer_window
)
347 window_with_focus
= NULL
;
350 if (filer_window
->directory
)
351 detach(filer_window
);
353 if (filer_window
->open_timeout
)
355 gtk_timeout_remove(filer_window
->open_timeout
);
356 filer_window
->open_timeout
= 0;
359 if (filer_window
->thumb_queue
)
361 g_list_foreach(filer_window
->thumb_queue
, (GFunc
) g_free
, NULL
);
362 g_list_free(filer_window
->thumb_queue
);
367 g_free(filer_window
->auto_select
);
368 g_free(filer_window
->real_path
);
369 g_free(filer_window
->sym_path
);
370 g_free(filer_window
);
375 /* Returns TRUE iff the directory still exists. */
376 static gboolean
may_rescan(FilerWindow
*filer_window
, gboolean warning
)
380 g_return_val_if_fail(filer_window
!= NULL
, FALSE
);
382 /* We do a fresh lookup (rather than update) because the inode may
385 dir
= g_fscache_lookup(dir_cache
, filer_window
->real_path
);
389 info_message(_("Directory missing/deleted"));
390 gtk_widget_destroy(filer_window
->window
);
393 if (dir
== filer_window
->directory
)
397 detach(filer_window
);
398 filer_window
->directory
= dir
;
399 attach(filer_window
);
405 /* No items are now selected. This might be because another app claimed
406 * the selection or because the user unselected all the items.
408 void filer_lost_selection(FilerWindow
*filer_window
, guint time
)
410 if (window_with_primary
== filer_window
)
412 window_with_primary
= NULL
;
413 gtk_selection_owner_set(NULL
, GDK_SELECTION_PRIMARY
, time
);
417 /* Another app has claimed the primary selection */
418 static void filer_lost_primary(GtkWidget
*window
,
419 GdkEventSelection
*event
,
422 FilerWindow
*filer_window
= (FilerWindow
*) user_data
;
424 if (window_with_primary
&& window_with_primary
== filer_window
)
426 window_with_primary
= NULL
;
427 set_selection_state(filer_window
, FALSE
);
431 /* Someone wants us to send them the selection */
432 static void selection_get(GtkWidget
*widget
,
433 GtkSelectionData
*selection_data
,
438 GString
*reply
, *header
;
439 FilerWindow
*filer_window
= (FilerWindow
*) data
;
443 reply
= g_string_new(NULL
);
444 header
= g_string_new(NULL
);
449 g_string_sprintf(header
, " %s",
450 make_path(filer_window
->sym_path
, "")->str
);
452 case TARGET_URI_LIST
:
453 g_string_sprintf(header
, " file://%s%s",
454 our_host_name_for_dnd(),
455 make_path(filer_window
->sym_path
, "")->str
);
459 view_get_iter(filer_window
->view
, &iter
, VIEW_ITER_SELECTED
);
461 while ((item
= iter
.next(&iter
)))
463 g_string_append(reply
, header
->str
);
464 g_string_append(reply
, item
->leafname
);
468 gtk_selection_data_set(selection_data
, xa_string
,
469 8, reply
->str
+ 1, reply
->len
- 1);
472 g_warning("Attempt to paste empty selection!");
473 gtk_selection_data_set(selection_data
, xa_string
, 8, "", 0);
476 g_string_free(reply
, TRUE
);
477 g_string_free(header
, TRUE
);
480 /* Selection has been changed -- try to grab the primary selection
481 * if we don't have it. Also called when clicking on an insensitive selection
483 * Also updates toolbar info.
485 void filer_selection_changed(FilerWindow
*filer_window
, gint time
)
487 toolbar_update_info(filer_window
);
489 if (window_with_primary
== filer_window
)
490 return; /* Already got primary */
492 if (!view_count_selected(filer_window
->view
))
493 return; /* Nothing selected */
495 if (filer_window
->temp_item_selected
== FALSE
&&
496 gtk_selection_owner_set(GTK_WIDGET(filer_window
->window
),
497 GDK_SELECTION_PRIMARY
,
500 window_with_primary
= filer_window
;
501 set_selection_state(filer_window
, TRUE
);
504 set_selection_state(filer_window
, FALSE
);
507 /* Open the item (or add it to the shell command minibuffer) */
508 void filer_openitem(FilerWindow
*filer_window
, ViewIter
*iter
, OpenFlags flags
)
510 gboolean shift
= (flags
& OPEN_SHIFT
) != 0;
511 gboolean close_mini
= flags
& OPEN_FROM_MINI
;
512 gboolean close_window
= (flags
& OPEN_CLOSE_WINDOW
) != 0;
515 gboolean wink
= TRUE
;
518 g_return_if_fail(filer_window
!= NULL
&& iter
!= NULL
);
520 item
= iter
->peek(iter
);
522 g_return_if_fail(item
!= NULL
);
524 if (filer_window
->mini_type
== MINI_SHELL
)
526 minibuffer_add(filer_window
, item
->leafname
);
531 dir_update_item(filer_window
->directory
, item
->leafname
);
533 if (item
->base_type
== TYPE_DIRECTORY
)
535 /* Never close a filer window when opening a directory
536 * (click on a dir or click on an app with shift).
538 if (shift
|| !(item
->flags
& ITEM_FLAG_APPDIR
))
539 close_window
= FALSE
;
542 full_path
= make_path(filer_window
->sym_path
, item
->leafname
)->str
;
543 if (shift
&& (item
->flags
& ITEM_FLAG_SYMLINK
))
546 old_dir
= filer_window
->directory
;
547 if (run_diritem(full_path
, item
,
548 flags
& OPEN_SAME_WINDOW
? filer_window
: NULL
,
552 if (old_dir
!= filer_window
->directory
)
556 gtk_widget_destroy(filer_window
->window
);
560 view_wink_item(filer_window
->view
, iter
);
562 minibuffer_hide(filer_window
);
567 static gint
pointer_in(GtkWidget
*widget
,
568 GdkEventCrossing
*event
,
569 FilerWindow
*filer_window
)
571 may_rescan(filer_window
, TRUE
);
575 static gint
pointer_out(GtkWidget
*widget
,
576 GdkEventCrossing
*event
,
577 FilerWindow
*filer_window
)
583 /* Move the cursor to the next selected item in direction 'dir'
586 static void next_selected(FilerWindow
*filer_window
, int dir
)
588 ViewIter iter
, cursor
;
589 gboolean have_cursor
;
590 ViewIface
*view
= filer_window
->view
;
592 g_return_if_fail(dir
== 1 || dir
== -1);
594 view_get_cursor(view
, &cursor
);
595 have_cursor
= cursor
.peek(&cursor
) != NULL
;
597 view_get_iter(view
, &iter
,
599 (have_cursor
? VIEW_ITER_FROM_CURSOR
: 0) |
600 (dir
< 0 ? VIEW_ITER_BACKWARDS
: 0));
602 if (have_cursor
&& view_get_selected(view
, &cursor
))
603 iter
.next(&iter
); /* Skip the cursor itself */
605 if (iter
.next(&iter
))
606 view_cursor_to_iter(view
, &iter
);
613 static void return_pressed(FilerWindow
*filer_window
, GdkEventKey
*event
)
615 TargetFunc cb
= filer_window
->target_cb
;
616 gpointer data
= filer_window
->target_data
;
620 filer_target_mode(filer_window
, NULL
, NULL
, NULL
);
622 view_get_cursor(filer_window
->view
, &iter
);
623 if (!iter
.peek(&iter
))
628 cb(filer_window
, &iter
, data
);
632 if (event
->state
& GDK_SHIFT_MASK
)
634 if (event
->state
& GDK_MOD1_MASK
)
635 flags
|= OPEN_CLOSE_WINDOW
;
637 flags
|= OPEN_SAME_WINDOW
;
639 filer_openitem(filer_window
, &iter
, flags
);
642 /* Makes sure that 'groups' is up-to-date, reloading from file if it has
643 * changed. If no groups were loaded and there is no file then initialised
644 * groups to an empty document.
645 * Return the node for the 'name' group.
647 static xmlNode
*group_find(char *name
)
652 /* Update the groups, if possible */
653 path
= choices_find_path_load("Groups.xml", PROJECT
);
657 wrapper
= xml_cache_load(path
);
661 g_object_unref(groups
);
670 groups
= xml_new(NULL
);
671 groups
->doc
= xmlNewDoc("1.0");
673 xmlDocSetRootElement(groups
->doc
,
674 xmlNewDocNode(groups
->doc
, NULL
, "groups", NULL
));
678 node
= xmlDocGetRootElement(groups
->doc
);
680 for (node
= node
->xmlChildrenNode
; node
; node
= node
->next
)
684 gid
= xmlGetProp(node
, "name");
689 if (strcmp(name
, gid
) != 0)
700 static void group_save(FilerWindow
*filer_window
, char *name
)
707 group
= group_find(name
);
710 xmlUnlinkNode(group
);
713 group
= xmlNewChild(xmlDocGetRootElement(groups
->doc
),
714 NULL
, "group", NULL
);
715 xmlSetProp(group
, "name", name
);
717 xmlNewChild(group
, NULL
, "directory", filer_window
->sym_path
);
719 view_get_iter(filer_window
->view
, &iter
, VIEW_ITER_SELECTED
);
721 while ((item
= iter
.next(&iter
)))
722 xmlNewChild(group
, NULL
, "item", item
->leafname
);
724 save_path
= choices_find_path_save("Groups.xml", PROJECT
, TRUE
);
727 save_xml_file(groups
->doc
, save_path
);
732 static gboolean
group_restore_cb(ViewIter
*iter
, gpointer data
)
734 GHashTable
*in_group
= (GHashTable
*) data
;
736 return g_hash_table_lookup(in_group
,
737 iter
->peek(iter
)->leafname
) != NULL
;
740 static void group_restore(FilerWindow
*filer_window
, char *name
)
742 GHashTable
*in_group
;
744 xmlNode
*group
, *node
;
746 group
= group_find(name
);
750 report_error(_("Group %s is not set. Select some files "
751 "and press Ctrl+%s to set the group. Press %s "
752 "on its own to reselect the files later.\n"
753 "Make sure NumLock is on if you use the keypad."),
758 node
= get_subnode(group
, NULL
, "directory");
759 g_return_if_fail(node
!= NULL
);
760 path
= xmlNodeListGetString(groups
->doc
, node
->xmlChildrenNode
, 1);
761 g_return_if_fail(path
!= NULL
);
763 if (strcmp(path
, filer_window
->sym_path
) != 0)
764 filer_change_to(filer_window
, path
, NULL
);
767 in_group
= g_hash_table_new(g_str_hash
, g_str_equal
);
768 for (node
= group
->xmlChildrenNode
; node
; node
= node
->next
)
771 if (node
->type
!= XML_ELEMENT_NODE
)
773 if (strcmp(node
->name
, "item") != 0)
776 leaf
= xmlNodeListGetString(groups
->doc
,
777 node
->xmlChildrenNode
, 1);
779 g_warning("Missing leafname!\n");
781 g_hash_table_insert(in_group
, leaf
, filer_window
);
784 view_select_if(filer_window
->view
, &group_restore_cb
, in_group
);
786 g_hash_table_foreach(in_group
, (GHFunc
) g_free
, NULL
);
787 g_hash_table_destroy(in_group
);
790 static gboolean
popup_menu(GtkWidget
*widget
, FilerWindow
*filer_window
)
794 view_get_cursor(filer_window
->view
, &iter
);
796 show_filer_menu(filer_window
, NULL
, &iter
);
801 /* Handle keys that can't be bound with the menu */
802 static gint
key_press_event(GtkWidget
*widget
,
804 FilerWindow
*filer_window
)
806 GtkWidget
*focus
= GTK_WINDOW(widget
)->focus_widget
;
807 guint key
= event
->keyval
;
810 window_with_focus
= filer_window
;
812 /* Delay setting up the keys until now to speed loading... */
814 ensure_filer_menu(); /* Gets the keys working... */
816 if (!g_slist_find(filer_keys
->acceleratables
, widget
))
817 gtk_window_add_accel_group(GTK_WINDOW(filer_window
->window
),
820 if (focus
&& focus
!= widget
&&
821 gtk_widget_get_toplevel(focus
) == widget
)
822 if (gtk_widget_event(focus
, (GdkEvent
*) event
))
823 return TRUE
; /* Handled */
828 filer_target_mode(filer_window
, NULL
, NULL
, NULL
);
831 return_pressed(filer_window
, event
);
833 case GDK_ISO_Left_Tab
:
834 next_selected(filer_window
, -1);
837 next_selected(filer_window
, 1);
840 change_to_parent(filer_window
);
848 view_get_cursor(filer_window
->view
, &iter
);
849 show_filer_menu(filer_window
,
850 (GdkEvent
*) event
, &iter
);
854 if (key
>= GDK_0
&& key
<= GDK_9
)
855 group
[0] = key
- GDK_0
+ '0';
856 else if (key
>= GDK_KP_0
&& key
<= GDK_KP_9
)
857 group
[0] = key
- GDK_KP_0
+ '0';
862 if (event
->state
& GDK_CONTROL_MASK
)
863 group_save(filer_window
, group
);
865 group_restore(filer_window
, group
);
871 void filer_open_parent(FilerWindow
*filer_window
)
874 const char *current
= filer_window
->sym_path
;
876 if (current
[0] == '/' && current
[1] == '\0')
877 return; /* Already in the root */
879 dir
= g_dirname(current
);
880 filer_opendir(dir
, filer_window
, NULL
);
884 void change_to_parent(FilerWindow
*filer_window
)
887 const char *current
= filer_window
->sym_path
;
889 if (current
[0] == '/' && current
[1] == '\0')
890 return; /* Already in the root */
892 dir
= g_dirname(current
);
893 filer_change_to(filer_window
, dir
, g_basename(current
));
897 /* Removes trailing /s from path (modified in place) */
898 static void tidy_sympath(gchar
*path
)
902 g_return_if_fail(path
!= NULL
);
905 while (l
> 1 && path
[l
- 1] == '/')
912 /* Make filer_window display path. When finished, highlight item 'from', or
913 * the first item if from is NULL. If there is currently no cursor then
914 * simply wink 'from' (if not NULL).
915 * If the cause was a key event and we resize, warp the pointer.
917 void filer_change_to(FilerWindow
*filer_window
,
918 const char *path
, const char *from
)
921 char *sym_path
, *real_path
;
924 g_return_if_fail(filer_window
!= NULL
);
926 filer_cancel_thumbnails(filer_window
);
930 sym_path
= g_strdup(path
);
931 real_path
= pathdup(path
);
932 new_dir
= g_fscache_lookup(dir_cache
, real_path
);
936 delayed_error(_("Directory '%s' is not accessible"),
943 if (o_unique_filer_windows
.int_value
)
947 fw
= find_filer_window(sym_path
, filer_window
);
949 gtk_widget_destroy(fw
->window
);
952 from_dup
= from
&& *from
? g_strdup(from
) : NULL
;
954 detach(filer_window
);
955 g_free(filer_window
->real_path
);
956 g_free(filer_window
->sym_path
);
957 filer_window
->real_path
= real_path
;
958 filer_window
->sym_path
= sym_path
;
959 tidy_sympath(filer_window
->sym_path
);
961 filer_window
->directory
= new_dir
;
963 g_free(filer_window
->auto_select
);
964 filer_window
->auto_select
= from_dup
;
966 filer_window
->had_cursor
= filer_window
->had_cursor
||
967 view_cursor_visible(filer_window
->view
);
969 filer_set_title(filer_window
);
970 if (filer_window
->window
->window
)
971 gdk_window_set_role(filer_window
->window
->window
,
972 filer_window
->sym_path
);
973 view_cursor_to_iter(filer_window
->view
, NULL
);
975 attach(filer_window
);
977 set_style_by_number_of_items(filer_window
);
979 if (o_filer_auto_resize
.int_value
== RESIZE_ALWAYS
)
980 filer_window_autosize(filer_window
);
982 if (filer_window
->mini_type
== MINI_PATH
)
983 gtk_idle_add((GtkFunction
) minibuffer_show_cb
,
987 /* Returns a list containing the full (sym) pathname of every selected item.
988 * You must g_free() each item in the list.
990 GList
*filer_selected_items(FilerWindow
*filer_window
)
992 GList
*retval
= NULL
;
993 guchar
*dir
= filer_window
->sym_path
;
997 view_get_iter(filer_window
->view
, &iter
, VIEW_ITER_SELECTED
);
998 while ((item
= iter
.next(&iter
)))
1000 retval
= g_list_prepend(retval
,
1001 g_strdup(make_path(dir
, item
->leafname
)->str
));
1004 return g_list_reverse(retval
);
1007 /* Return the single selected item. Error if nothing is selected. */
1008 DirItem
*filer_selected_item(FilerWindow
*filer_window
)
1013 view_get_iter(filer_window
->view
, &iter
, VIEW_ITER_SELECTED
);
1015 item
= iter
.next(&iter
);
1016 g_return_val_if_fail(item
!= NULL
, NULL
);
1017 g_return_val_if_fail(iter
.next(&iter
) == NULL
, NULL
);
1022 /* Creates and shows a new filer window.
1023 * If src_win != NULL then display options can be taken from that source window.
1024 * Returns the new filer window, or NULL on error.
1025 * Note: if unique windows is in use, may return an existing window.
1027 FilerWindow
*filer_opendir(const char *path
, FilerWindow
*src_win
, const gchar
*wm_class
)
1029 FilerWindow
*filer_window
;
1031 DisplayStyle dstyle
;
1034 /* Get the real pathname of the directory and copy it */
1035 real_path
= pathdup(path
);
1037 if (o_unique_filer_windows
.int_value
)
1039 FilerWindow
*same_dir_window
;
1041 same_dir_window
= find_filer_window(path
, NULL
);
1043 if (same_dir_window
)
1045 gtk_window_present(GTK_WINDOW(same_dir_window
->window
));
1046 return same_dir_window
;
1050 filer_window
= g_new(FilerWindow
, 1);
1051 filer_window
->message
= NULL
;
1052 filer_window
->minibuffer
= NULL
;
1053 filer_window
->minibuffer_label
= NULL
;
1054 filer_window
->minibuffer_area
= NULL
;
1055 filer_window
->temp_show_hidden
= FALSE
;
1056 filer_window
->sym_path
= g_strdup(path
);
1057 filer_window
->real_path
= real_path
;
1058 filer_window
->scanning
= FALSE
;
1059 filer_window
->had_cursor
= FALSE
;
1060 filer_window
->auto_select
= NULL
;
1061 filer_window
->toolbar_text
= NULL
;
1062 filer_window
->target_cb
= NULL
;
1063 filer_window
->mini_type
= MINI_NONE
;
1064 filer_window
->selection_state
= GTK_STATE_INSENSITIVE
;
1065 filer_window
->toolbar
= NULL
;
1066 filer_window
->toplevel_vbox
= NULL
;
1068 tidy_sympath(filer_window
->sym_path
);
1070 /* Finds the entry for this directory in the dir cache, creating
1071 * a new one if needed. This does not cause a scan to start,
1072 * so if a new entry is created then it will be empty.
1074 filer_window
->directory
= g_fscache_lookup(dir_cache
, real_path
);
1075 if (!filer_window
->directory
)
1077 delayed_error(_("Directory '%s' not found."), path
);
1078 g_free(filer_window
->real_path
);
1079 g_free(filer_window
->sym_path
);
1080 g_free(filer_window
);
1084 filer_window
->temp_item_selected
= FALSE
;
1085 filer_window
->flags
= (FilerFlags
) 0;
1086 filer_window
->details_type
= DETAILS_SUMMARY
;
1087 filer_window
->display_style
= UNKNOWN_STYLE
;
1088 filer_window
->thumb_queue
= NULL
;
1089 filer_window
->max_thumbs
= 0;
1091 if (src_win
&& o_display_inherit_options
.int_value
)
1093 filer_window
->sort_fn
= src_win
->sort_fn
;
1094 dstyle
= src_win
->display_style
;
1095 dtype
= src_win
->details_type
;
1096 filer_window
->show_hidden
= src_win
->show_hidden
;
1097 filer_window
->show_thumbs
= src_win
->show_thumbs
;
1101 int i
= o_display_sort_by
.int_value
;
1102 filer_window
->sort_fn
= i
== 0 ? sort_by_name
:
1103 i
== 1 ? sort_by_type
:
1104 i
== 2 ? sort_by_date
:
1107 dstyle
= o_display_size
.int_value
;
1108 dtype
= o_display_details
.int_value
;
1109 filer_window
->show_hidden
=
1110 o_display_show_hidden
.int_value
;
1111 filer_window
->show_thumbs
=
1112 o_display_show_thumbs
.int_value
;
1115 /* Add all the user-interface elements & realise */
1116 filer_add_widgets(filer_window
, wm_class
);
1118 gtk_window_set_position(GTK_WINDOW(filer_window
->window
),
1121 /* Connect to all the signal handlers */
1122 filer_add_signals(filer_window
);
1124 display_set_layout(filer_window
, dstyle
, dtype
);
1126 /* Open the window after a timeout, or when scanning stops.
1127 * Do this before attaching, because attach() might tell us to
1128 * stop scanning (if a scan isn't needed).
1130 filer_window
->open_timeout
= gtk_timeout_add(500,
1131 (GtkFunction
) open_filer_window
,
1134 /* The view is created empty and then attach() is called, which
1135 * links the filer window to the entry in the directory cache we
1136 * looked up / created above.
1138 * The attach() function will immediately callback to the filer window
1139 * to deliver a list of all known entries in the directory (so,
1140 * the number of items will be known after attach() returns).
1142 * If the directory was not in the cache (because it hadn't been
1143 * opened it before) then the types and icons for the entries are
1144 * not know, but the list of names is.
1147 attach(filer_window
);
1149 number_of_windows
++;
1150 all_filer_windows
= g_list_prepend(all_filer_windows
, filer_window
);
1152 return filer_window
;
1155 /* This adds all the widgets to a new filer window. It is in a separate
1156 * function because filer_opendir() was getting too long...
1158 static void filer_add_widgets(FilerWindow
*filer_window
, const gchar
*wm_class
)
1160 GtkWidget
*hbox
, *vbox
;
1162 /* Create the top-level window widget */
1163 filer_window
->window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
1164 filer_set_title(filer_window
);
1166 gtk_window_set_wmclass(GTK_WINDOW(filer_window
->window
), wm_class
, PROJECT
);
1168 /* This property is cleared when the window is destroyed.
1169 * You can thus ref filer_window->window and use this to see
1170 * if the window no longer exists.
1172 g_object_set_data(G_OBJECT(filer_window
->window
),
1173 "filer_window", filer_window
);
1175 /* Create this now to make the Adjustment before the View */
1176 filer_window
->scrollbar
= gtk_vscrollbar_new(NULL
);
1178 /* The view is the area that actually displays the files */
1179 filer_window
->view
= VIEW(view_collection_new(filer_window
));
1180 gtk_widget_show(GTK_WIDGET(filer_window
->view
));
1182 /* Scrollbar on the right, everything else on the left */
1183 hbox
= gtk_hbox_new(FALSE
, 0);
1184 gtk_container_add(GTK_CONTAINER(filer_window
->window
), hbox
);
1186 vbox
= gtk_vbox_new(FALSE
, 0);
1187 gtk_box_pack_start_defaults(GTK_BOX(hbox
), vbox
);
1188 filer_window
->toplevel_vbox
= GTK_BOX(vbox
);
1190 /* If we want a toolbar, create it now */
1191 toolbar_update_toolbar(filer_window
);
1193 /* If there's a message that should be displayed in each window (eg
1194 * 'Running as root'), add it here.
1196 if (show_user_message
)
1198 filer_window
->message
= gtk_label_new(show_user_message
);
1199 gtk_box_pack_start(GTK_BOX(vbox
), filer_window
->message
,
1201 gtk_widget_show(filer_window
->message
);
1204 /* Now add the area for displaying the files */
1205 gtk_box_pack_start_defaults(GTK_BOX(vbox
),
1206 GTK_WIDGET(filer_window
->view
));
1208 /* And the minibuffer (hidden to start with) */
1209 create_minibuffer(filer_window
);
1210 gtk_box_pack_start(GTK_BOX(vbox
), filer_window
->minibuffer_area
,
1213 /* And the thumbnail progress bar (also hidden) */
1217 filer_window
->thumb_bar
= gtk_hbox_new(FALSE
, 2);
1218 gtk_box_pack_start(GTK_BOX(vbox
), filer_window
->thumb_bar
,
1221 filer_window
->thumb_progress
= gtk_progress_bar_new();
1223 gtk_box_pack_start(GTK_BOX(filer_window
->thumb_bar
),
1224 filer_window
->thumb_progress
, TRUE
, TRUE
, 0);
1226 cancel
= gtk_button_new_with_label(_("Cancel"));
1227 GTK_WIDGET_UNSET_FLAGS(cancel
, GTK_CAN_FOCUS
);
1228 gtk_box_pack_start(GTK_BOX(filer_window
->thumb_bar
),
1229 cancel
, FALSE
, TRUE
, 0);
1230 g_signal_connect_swapped(cancel
, "clicked",
1231 G_CALLBACK(filer_cancel_thumbnails
),
1235 /* Put the scrollbar on the left of everything else... */
1236 gtk_box_pack_start(GTK_BOX(hbox
),
1237 filer_window
->scrollbar
, FALSE
, TRUE
, 0);
1239 gtk_widget_show(hbox
);
1240 gtk_widget_show(vbox
);
1241 gtk_widget_show(filer_window
->scrollbar
);
1243 gtk_widget_realize(filer_window
->window
);
1245 gdk_window_set_role(filer_window
->window
->window
,
1246 filer_window
->sym_path
);
1248 filer_window_set_size(filer_window
, 4, 4);
1251 static void filer_add_signals(FilerWindow
*filer_window
)
1253 GtkTargetEntry target_table
[] =
1255 {"text/uri-list", 0, TARGET_URI_LIST
},
1256 {"STRING", 0, TARGET_STRING
},
1257 {"COMPOUND_TEXT", 0, TARGET_STRING
},/* XXX: Treats as STRING */
1260 /* Events on the top-level window */
1261 gtk_widget_add_events(filer_window
->window
, GDK_ENTER_NOTIFY
);
1262 g_signal_connect(filer_window
->window
, "enter-notify-event",
1263 G_CALLBACK(pointer_in
), filer_window
);
1264 g_signal_connect(filer_window
->window
, "leave-notify-event",
1265 G_CALLBACK(pointer_out
), filer_window
);
1266 g_signal_connect(filer_window
->window
, "destroy",
1267 G_CALLBACK(filer_window_destroyed
), filer_window
);
1269 g_signal_connect(filer_window
->window
, "selection_clear_event",
1270 G_CALLBACK(filer_lost_primary
), filer_window
);
1272 g_signal_connect(filer_window
->window
, "selection_get",
1273 G_CALLBACK(selection_get
), filer_window
);
1274 gtk_selection_add_targets(GTK_WIDGET(filer_window
->window
),
1275 GDK_SELECTION_PRIMARY
,
1277 sizeof(target_table
) / sizeof(*target_table
));
1279 g_signal_connect(filer_window
->window
, "popup-menu",
1280 G_CALLBACK(popup_menu
), filer_window
);
1281 g_signal_connect(filer_window
->window
, "key_press_event",
1282 G_CALLBACK(key_press_event
), filer_window
);
1285 static gint
clear_scanning_display(FilerWindow
*filer_window
)
1287 if (filer_exists(filer_window
))
1288 filer_set_title(filer_window
);
1292 static void set_scanning_display(FilerWindow
*filer_window
, gboolean scanning
)
1294 if (scanning
== filer_window
->scanning
)
1296 filer_window
->scanning
= scanning
;
1299 filer_set_title(filer_window
);
1301 gtk_timeout_add(300, (GtkFunction
) clear_scanning_display
,
1305 /* Note that filer_window may not exist after this call */
1306 void filer_update_dir(FilerWindow
*filer_window
, gboolean warning
)
1308 if (may_rescan(filer_window
, warning
))
1309 dir_update(filer_window
->directory
, filer_window
->sym_path
);
1312 void filer_update_all(void)
1314 GList
*next
= all_filer_windows
;
1318 FilerWindow
*filer_window
= (FilerWindow
*) next
->data
;
1320 /* Updating directory may remove it from list -- stop sending
1321 * patches to move this line!
1325 filer_update_dir(filer_window
, TRUE
);
1329 /* Refresh the various caches even if we don't think we need to */
1330 void full_refresh(void)
1333 reread_mime_files();
1336 /* See whether a filer window with a given path already exists
1337 * and is different from diff.
1339 static FilerWindow
*find_filer_window(const char *sym_path
, FilerWindow
*diff
)
1343 for (next
= all_filer_windows
; next
; next
= next
->next
)
1345 FilerWindow
*filer_window
= (FilerWindow
*) next
->data
;
1347 if (filer_window
!= diff
&&
1348 strcmp(sym_path
, filer_window
->sym_path
) == 0)
1349 return filer_window
;
1355 /* This path has been mounted/umounted/deleted some files - update all dirs */
1356 void filer_check_mounted(const char *real_path
)
1358 GList
*next
= all_filer_windows
;
1362 len
= strlen(real_path
);
1366 FilerWindow
*filer_window
= (FilerWindow
*) next
->data
;
1370 if (strncmp(real_path
, filer_window
->real_path
, len
) == 0)
1372 char s
= filer_window
->real_path
[len
];
1374 if (s
== '/' || s
== '\0')
1375 filer_update_dir(filer_window
, FALSE
);
1379 parent
= g_dirname(real_path
);
1380 refresh_dirs(parent
);
1383 icons_may_update(real_path
);
1386 /* Close all windows displaying 'path' or subdirectories of 'path' */
1387 void filer_close_recursive(const char *path
)
1389 GList
*next
= all_filer_windows
;
1393 real
= pathdup(path
);
1398 FilerWindow
*filer_window
= (FilerWindow
*) next
->data
;
1402 if (strncmp(real
, filer_window
->real_path
, len
) == 0)
1404 char s
= filer_window
->real_path
[len
];
1406 if (len
== 1 || s
== '/' || s
== '\0')
1407 gtk_widget_destroy(filer_window
->window
);
1412 /* Like minibuffer_show(), except that:
1413 * - It returns FALSE (to be used from an idle callback)
1414 * - It checks that the filer window still exists.
1416 static gboolean
minibuffer_show_cb(FilerWindow
*filer_window
)
1418 if (filer_exists(filer_window
))
1419 minibuffer_show(filer_window
, MINI_PATH
);
1423 /* TRUE iff filer_window points to an existing FilerWindow
1426 gboolean
filer_exists(FilerWindow
*filer_window
)
1430 for (next
= all_filer_windows
; next
; next
= next
->next
)
1432 FilerWindow
*fw
= (FilerWindow
*) next
->data
;
1434 if (fw
== filer_window
)
1441 /* Make sure the window title is up-to-date */
1442 void filer_set_title(FilerWindow
*filer_window
)
1444 guchar
*title
= NULL
;
1447 if (filer_window
->scanning
|| filer_window
->show_hidden
||
1448 filer_window
->show_thumbs
)
1450 if (o_short_flag_names
.int_value
)
1452 flags
= g_strconcat(" +",
1453 filer_window
->scanning
? _("S") : "",
1454 filer_window
->show_hidden
? _("A") : "",
1455 filer_window
->show_thumbs
? _("T") : "",
1460 flags
= g_strconcat(" (",
1461 filer_window
->scanning
? _("Scanning, ") : "",
1462 filer_window
->show_hidden
? _("All, ") : "",
1463 filer_window
->show_thumbs
? _("Thumbs, ") : "",
1465 flags
[strlen(flags
) - 2] = ')';
1470 title
= g_strconcat("//", our_host_name(),
1471 filer_window
->sym_path
, flags
, NULL
);
1473 if (!title
&& home_dir_len
> 1 &&
1474 strncmp(filer_window
->sym_path
, home_dir
, home_dir_len
) == 0)
1476 guchar sep
= filer_window
->sym_path
[home_dir_len
];
1478 if (sep
== '\0' || sep
== '/')
1479 title
= g_strconcat("~",
1480 filer_window
->sym_path
+ home_dir_len
,
1486 title
= g_strconcat(filer_window
->sym_path
, flags
, NULL
);
1488 gtk_window_set_title(GTK_WINDOW(filer_window
->window
), title
);
1491 if (flags
[0] != '\0')
1495 /* Reconnect to the same directory (used when the Show Hidden option is
1496 * toggled). This has the side-effect of updating the window title.
1498 void filer_detach_rescan(FilerWindow
*filer_window
)
1500 Directory
*dir
= filer_window
->directory
;
1503 detach(filer_window
);
1504 filer_window
->directory
= dir
;
1505 attach(filer_window
);
1508 /* Puts the filer window into target mode. When an item is chosen,
1509 * fn(filer_window, iter, data) is called. 'reason' will be displayed
1510 * on the toolbar while target mode is active.
1512 * Use fn == NULL to cancel target mode.
1514 void filer_target_mode(FilerWindow
*filer_window
,
1519 TargetFunc old_fn
= filer_window
->target_cb
;
1522 gdk_window_set_cursor(
1523 GTK_WIDGET(filer_window
->view
)->window
,
1524 fn
? crosshair
: NULL
);
1526 filer_window
->target_cb
= fn
;
1527 filer_window
->target_data
= data
;
1529 if (filer_window
->toolbar_text
== NULL
)
1534 GTK_LABEL(filer_window
->toolbar_text
), reason
);
1535 else if (o_toolbar_info
.int_value
)
1538 toolbar_update_info(filer_window
);
1541 gtk_label_set_text(GTK_LABEL(filer_window
->toolbar_text
), "");
1544 static void set_selection_state(FilerWindow
*filer_window
, gboolean normal
)
1546 GtkStateType old_state
= filer_window
->selection_state
;
1548 filer_window
->selection_state
= normal
1549 ? GTK_STATE_SELECTED
: GTK_STATE_INSENSITIVE
;
1551 if (old_state
!= filer_window
->selection_state
1552 && view_count_selected(filer_window
->view
))
1553 gtk_widget_queue_draw(GTK_WIDGET(filer_window
->view
));
1556 void filer_cancel_thumbnails(FilerWindow
*filer_window
)
1558 gtk_widget_hide(filer_window
->thumb_bar
);
1560 g_list_foreach(filer_window
->thumb_queue
, (GFunc
) g_free
, NULL
);
1561 g_list_free(filer_window
->thumb_queue
);
1562 filer_window
->thumb_queue
= NULL
;
1563 filer_window
->max_thumbs
= 0;
1566 /* Generate the next thumb for this window. The window object is
1567 * unref'd when there is nothing more to do.
1568 * If the window no longer has a filer window, nothing is done.
1570 static gboolean
filer_next_thumb_real(GObject
*window
)
1572 FilerWindow
*filer_window
;
1576 filer_window
= g_object_get_data(window
, "filer_window");
1580 g_object_unref(window
);
1584 if (!filer_window
->thumb_queue
)
1586 filer_cancel_thumbnails(filer_window
);
1587 g_object_unref(window
);
1591 total
= filer_window
->max_thumbs
;
1592 done
= total
- g_list_length(filer_window
->thumb_queue
);
1594 path
= (gchar
*) filer_window
->thumb_queue
->data
;
1596 pixmap_background_thumb(path
, (GFunc
) filer_next_thumb
, window
);
1598 filer_window
->thumb_queue
= g_list_remove(filer_window
->thumb_queue
,
1602 gtk_progress_bar_set_fraction(
1603 GTK_PROGRESS_BAR(filer_window
->thumb_progress
),
1604 done
/ (float) total
);
1609 /* path is the thumb just loaded, if any.
1610 * window is unref'd (eventually).
1612 static void filer_next_thumb(GObject
*window
, const gchar
*path
)
1615 dir_force_update_path(path
);
1617 gtk_idle_add((GtkFunction
) filer_next_thumb_real
, window
);
1620 static void start_thumb_scanning(FilerWindow
*filer_window
)
1622 if (GTK_WIDGET_VISIBLE(filer_window
->thumb_bar
))
1623 return; /* Already scanning */
1625 gtk_widget_show_all(filer_window
->thumb_bar
);
1627 g_object_ref(G_OBJECT(filer_window
->window
));
1628 filer_next_thumb(G_OBJECT(filer_window
->window
), NULL
);
1631 /* Set this image to be loaded some time in the future */
1632 void filer_create_thumb(FilerWindow
*filer_window
, const gchar
*path
)
1634 filer_window
->max_thumbs
++;
1636 filer_window
->thumb_queue
= g_list_append(filer_window
->thumb_queue
,
1639 if (filer_window
->scanning
)
1640 return; /* Will start when scan ends */
1642 start_thumb_scanning(filer_window
);
1645 /* If thumbnail display is on, look through all the items in this directory
1646 * and start creating or updating the thumbnails as needed.
1648 void filer_create_thumbs(FilerWindow
*filer_window
)
1653 if (!filer_window
->show_thumbs
)
1656 view_get_iter(filer_window
->view
, &iter
, 0);
1658 while ((item
= iter
.next(&iter
)))
1660 MaskedPixmap
*pixmap
;
1664 if (item
->base_type
!= TYPE_FILE
)
1667 if (strcmp(item
->mime_type
->media_type
, "image") != 0)
1670 path
= make_path(filer_window
->real_path
, item
->leafname
)->str
;
1672 pixmap
= g_fscache_lookup_full(pixmap_cache
, path
,
1673 FSCACHE_LOOKUP_ONLY_NEW
, &found
);
1675 g_object_unref(pixmap
);
1677 /* If we didn't get an image, it could be because:
1679 * - We're loading the image now. found is TRUE,
1680 * and we'll update the item later.
1681 * - We tried to load the image and failed. found
1683 * - We haven't tried loading the image. found is
1684 * FALSE, and we start creating the thumb here.
1687 filer_create_thumb(filer_window
, path
);
1691 static void filer_options_changed(void)
1693 if (o_short_flag_names
.has_changed
)
1697 for (next
= all_filer_windows
; next
; next
= next
->next
)
1699 FilerWindow
*filer_window
= (FilerWindow
*) next
->data
;
1701 filer_set_title(filer_window
);
1706 /* Change to Large or Small icons depending on the number of items
1707 * in the directory, subject to options.
1709 static void set_style_by_number_of_items(FilerWindow
*filer_window
)
1713 g_return_if_fail(filer_window
!= NULL
);
1715 if (!o_filer_change_size
.int_value
)
1716 return; /* Don't auto-set style */
1718 if (filer_window
->display_style
!= LARGE_ICONS
&&
1719 filer_window
->display_style
!= SMALL_ICONS
)
1720 return; /* Only change between these two styles */
1722 n
= view_count_items(filer_window
->view
);
1724 if (n
>= o_filer_change_size_num
.int_value
)
1725 display_set_layout(filer_window
, SMALL_ICONS
,
1726 filer_window
->details_type
);
1728 display_set_layout(filer_window
, LARGE_ICONS
,
1729 filer_window
->details_type
);
1732 /* Append interesting information to this GString */
1733 void filer_add_tip_details(FilerWindow
*filer_window
,
1734 GString
*tip
, DirItem
*item
)
1736 guchar
*fullpath
= NULL
;
1738 fullpath
= make_path(filer_window
->real_path
, item
->leafname
)->str
;
1740 if (item
->flags
& ITEM_FLAG_SYMLINK
)
1744 target
= readlink_dup(fullpath
);
1747 g_string_append(tip
, _("Symbolic link to "));
1748 g_string_append(tip
, target
);
1749 g_string_append_c(tip
, '\n');
1754 if (item
->flags
& ITEM_FLAG_APPDIR
)
1759 info
= appinfo_get(fullpath
, item
);
1760 if (info
&& ((node
= xml_get_section(info
, NULL
, "Summary"))))
1763 str
= xmlNodeListGetString(node
->doc
,
1764 node
->xmlChildrenNode
, 1);
1767 g_string_append(tip
, str
);
1768 g_string_append_c(tip
, '\n');
1773 g_object_unref(info
);
1776 if (!g_utf8_validate(item
->leafname
, -1, NULL
))
1777 g_string_append(tip
,
1778 _("This filename is not valid UTF-8. "
1779 "You should rename it.\n"));