r302: Added a choice of details (Summary and Sizes).
[rox-filer.git] / ROX-Filer / src / menu.c
blob45f625190409219c252c9dd90118b500f514334a
1 /*
2 * $Id$
4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2000, Thomas Leonard, <tal197@ecs.soton.ac.uk>.
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)
10 * any later version.
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
15 * more details.
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 /* menu.c - code for handling the popup menu */
24 #include <config.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <sys/stat.h>
28 #include <sys/types.h>
29 #include <sys/wait.h>
30 #include <sys/param.h>
31 #include <fcntl.h>
32 #include <unistd.h>
33 #include <errno.h>
34 #include <string.h>
36 #include <gdk/gdkx.h>
37 #include <gtk/gtk.h>
39 #include "run.h"
40 #include "action.h"
41 #include "filer.h"
42 #include "type.h"
43 #include "support.h"
44 #include "gui_support.h"
45 #include "options.h"
46 #include "choices.h"
47 #include "gtksavebox.h"
48 #include "mount.h"
49 #include "minibuffer.h"
50 #include "i18n.h"
52 #define C_ "<control>"
54 #define MENU_MARGIN 32
56 GtkAccelGroup *filer_keys;
57 GtkAccelGroup *panel_keys;
59 static GtkWidget *popup_menu = NULL; /* Currently open menu */
61 static gint updating_menu = 0; /* Non-zero => ignore activations */
63 /* Options */
64 static GtkWidget *xterm_here_entry;
65 static char *xterm_here_value;
67 /* Static prototypes */
69 static void position_menu(GtkMenu *menu, gint *x, gint *y, gpointer data);
70 static void menu_closed(GtkWidget *widget);
71 static void items_sensitive(gboolean state);
72 static char *load_xterm_here(char *data);
73 static void savebox_show(guchar *title, guchar *path, MaskedPixmap *image,
74 gboolean (*callback)(guchar *current, guchar *new));
75 static gint save_to_file(GtkSavebox *savebox, guchar *pathname);
77 /* Note that for these callbacks none of the arguments are used. */
78 static void large(gpointer data, guint action, GtkWidget *widget);
79 static void small(gpointer data, guint action, GtkWidget *widget);
80 static void large_full_info(gpointer data, guint action, GtkWidget *widget);
81 static void small_full_info(gpointer data, guint action, GtkWidget *widget);
83 static void details_summary(gpointer data, guint action, GtkWidget *widget);
84 static void details_sizes(gpointer data, guint action, GtkWidget *widget);
86 static void sort_name(gpointer data, guint action, GtkWidget *widget);
87 static void sort_type(gpointer data, guint action, GtkWidget *widget);
88 static void sort_size(gpointer data, guint action, GtkWidget *widget);
89 static void sort_date(gpointer data, guint action, GtkWidget *widget);
91 static void hidden(gpointer data, guint action, GtkWidget *widget);
92 static void refresh(gpointer data, guint action, GtkWidget *widget);
94 static void copy_item(gpointer data, guint action, GtkWidget *widget);
95 static void rename_item(gpointer data, guint action, GtkWidget *widget);
96 static void link_item(gpointer data, guint action, GtkWidget *widget);
97 static void open_file(gpointer data, guint action, GtkWidget *widget);
98 static void help(gpointer data, guint action, GtkWidget *widget);
99 static void show_file_info(gpointer data, guint action, GtkWidget *widget);
100 static void mount(gpointer data, guint action, GtkWidget *widget);
101 static void delete(gpointer data, guint action, GtkWidget *widget);
102 static void remove_link(gpointer data, guint action, GtkWidget *widget);
103 static void usage(gpointer data, guint action, GtkWidget *widget);
104 static void chmod_items(gpointer data, guint action, GtkWidget *widget);
105 static void find(gpointer data, guint action, GtkWidget *widget);
107 static void open_vfs_rpm(gpointer data, guint action, GtkWidget *widget);
108 static void open_vfs_utar(gpointer data, guint action, GtkWidget *widget);
109 static void open_vfs_uzip(gpointer data, guint action, GtkWidget *widget);
111 static void select_all(gpointer data, guint action, GtkWidget *widget);
112 static void clear_selection(gpointer data, guint action, GtkWidget *widget);
113 static void show_options(gpointer data, guint action, GtkWidget *widget);
114 static void new_directory(gpointer data, guint action, GtkWidget *widget);
115 static void xterm_here(gpointer data, guint action, GtkWidget *widget);
117 static void open_parent_same(gpointer data, guint action, GtkWidget *widget);
118 static void open_parent(gpointer data, guint action, GtkWidget *widget);
119 static void new_window(gpointer data, guint action, GtkWidget *widget);
120 static void close_window(gpointer data, guint action, GtkWidget *widget);
121 static void enter_path(gpointer data, guint action, GtkWidget *widget);
122 static void shell_command(gpointer data, guint action, GtkWidget *widget);
123 static void run_action(gpointer data, guint action, GtkWidget *widget);
124 static void select_if(gpointer data, guint action, GtkWidget *widget);
125 static void rox_help(gpointer data, guint action, GtkWidget *widget);
127 static void open_as_dir(gpointer data, guint action, GtkWidget *widget);
128 static void close_panel(gpointer data, guint action, GtkWidget *widget);
130 static GtkWidget *create_options();
131 static void update_options();
132 static void set_options();
133 static void save_options();
135 static OptionsSection options =
137 N_("Menu options"),
138 create_options,
139 update_options,
140 set_options,
141 save_options
145 static GtkWidget *filer_menu; /* The popup filer menu */
146 static GtkWidget *filer_file_item; /* The File '' label */
147 static GtkWidget *filer_file_menu; /* The File '' menu */
148 static GtkWidget *filer_vfs_menu; /* The Open VFS menu */
149 static GtkWidget *filer_hidden_menu; /* The Show Hidden item */
150 static GtkWidget *filer_new_window; /* The New Window item */
151 static GtkWidget *panel_menu; /* The popup panel menu */
152 static GtkWidget *panel_hidden_menu; /* The Show Hidden item */
154 /* Used for Copy, etc */
155 static GtkWidget *savebox = NULL;
156 static guchar *current_path = NULL;
157 static gboolean (*current_savebox_callback)(guchar *current, guchar *new);
159 static gint screen_width, screen_height;
161 #undef N_
162 #define N_(x) x
164 static GtkItemFactoryEntry filer_menu_def[] = {
165 {N_("Display"), NULL, NULL, 0, "<Branch>"},
166 {">" N_("Large Icons"), NULL, large, 0, NULL},
167 {">" N_("Small Icons"), NULL, small, 0, NULL},
168 {">" N_("Large, Full Info"), NULL, large_full_info, 0, NULL},
169 {">" N_("Small, Full Info"), NULL, small_full_info, 0, NULL},
170 {">", NULL, NULL, 0, "<Separator>"},
171 {">" N_("Summary"), NULL, details_summary, 0, NULL},
172 {">" N_("Sizes"), NULL, details_sizes, 0, NULL},
173 {">", NULL, NULL, 0, "<Separator>"},
174 {">" N_("Sort by Name"), NULL, sort_name, 0, NULL},
175 {">" N_("Sort by Type"), NULL, sort_type, 0, NULL},
176 {">" N_("Sort by Date"), NULL, sort_date, 0, NULL},
177 {">" N_("Sort by Size"), NULL, sort_size, 0, NULL},
178 {">", NULL, NULL, 0, "<Separator>"},
179 {">" N_("Show Hidden"), NULL, hidden, 0, "<ToggleItem>"},
180 {">" N_("Refresh"), NULL, refresh, 0, NULL},
181 {N_("File"), NULL, NULL, 0, "<Branch>"},
182 {">" N_("Copy..."), NULL, copy_item, 0, NULL},
183 {">" N_("Rename..."), NULL, rename_item, 0, NULL},
184 {">" N_("Link..."), NULL, link_item, 0, NULL},
185 {">" N_("Shift Open"), NULL, open_file, 0, NULL},
186 {">" N_("Help"), NULL, help, 0, NULL},
187 {">" N_("Info"), NULL, show_file_info, 0, NULL},
188 {">" N_("Open VFS"), NULL, NULL, 0, "<Branch>"},
189 {">>" N_("Unzip"), NULL, open_vfs_uzip, 0, NULL},
190 {">>" N_("Untar"), NULL, open_vfs_utar, 0, NULL},
191 {">>" N_("RPM"), NULL, open_vfs_rpm, 0, NULL},
192 {">", NULL, NULL, 0, "<Separator>"},
193 {">" N_("Mount"), NULL, mount, 0, NULL},
194 {">" N_("Delete"), NULL, delete, 0, NULL},
195 {">" N_("Disk Usage"), NULL, usage, 0, NULL},
196 {">" N_("Permissions"), NULL, chmod_items, 0, NULL},
197 {">" N_("Find"), NULL, find, 0, NULL},
198 {N_("Select All"), NULL, select_all, 0, NULL},
199 {N_("Clear Selection"), NULL, clear_selection, 0, NULL},
200 {N_("Options..."), NULL, show_options, 0, NULL},
201 {N_("New Directory..."), NULL, new_directory, 0, NULL},
202 {N_("Xterm Here"), NULL, xterm_here, 0, NULL},
203 {N_("Window"), NULL, NULL, 0, "<Branch>"},
204 {">" N_("Parent, New Window"), NULL, open_parent, 0, NULL},
205 {">" N_("Parent, Same Window"), NULL, open_parent_same, 0, NULL},
206 {">" N_("New Window"), NULL, new_window, 0, NULL},
207 {">" N_("Close Window"), NULL, close_window, 0, NULL},
208 {">", NULL, NULL, 0, "<Separator>"},
209 {">" N_("Enter Path..."), NULL, enter_path, 0, NULL},
210 {">" N_("Shell Command..."), NULL, shell_command, 0, NULL},
211 {">" N_("Set Run Action..."), NULL, run_action, 0, NULL},
212 {">" N_("Select If..."), NULL, select_if, 0, NULL},
213 {">", NULL, NULL, 0, "<Separator>"},
214 {">" N_("Show ROX-Filer Help"), NULL, rox_help, 0, NULL},
217 static GtkItemFactoryEntry panel_menu_def[] = {
218 {N_("Display"), NULL, NULL, 0, "<Branch>"},
219 {">" N_("Sort by Name"), NULL, sort_name, 0, NULL},
220 {">" N_("Sort by Type"), NULL, sort_type, 0, NULL},
221 {">" N_("Sort by Date"), NULL, sort_date, 0, NULL},
222 {">" N_("Sort by Size"), NULL, sort_size, 0, NULL},
223 {">", NULL, NULL, 0, "<Separator>"},
224 {">" N_("Show Hidden"), NULL, hidden, 0, "<ToggleItem>"},
225 {">" N_("Refresh"), NULL, refresh, 0, NULL},
226 {N_("Open Panel as Directory"), NULL, open_as_dir, 0, NULL},
227 {N_("Close Panel"), NULL, close_panel, 0, NULL},
228 {"", NULL, NULL, 0, "<Separator>"},
229 {N_("ROX-Filer Help"), NULL, rox_help, 0, NULL},
230 {N_("ROX-Filer Options..."), NULL, show_options, 0, NULL},
231 {"", NULL, NULL, 0, "<Separator>"},
232 {N_("Show Help"), NULL, help, 0, NULL},
233 {N_("Remove Item"), NULL, remove_link, 0, NULL},
236 typedef struct _FileStatus FileStatus;
238 /* This is for the 'file(1) says...' thing */
239 struct _FileStatus
241 int fd; /* FD to read from, -1 if closed */
242 int input; /* Input watcher tag if fd valid */
243 GtkLabel *label; /* Widget to output to */
244 gboolean start; /* No output yet */
247 #define GET_MENU_ITEM(var, menu) \
248 var = gtk_item_factory_get_widget(item_factory, "<" menu ">");
250 #define GET_SMENU_ITEM(var, menu, sub) \
251 do { \
252 tmp = g_strdup_printf("<" menu ">/%s", _(sub)); \
253 var = gtk_item_factory_get_widget(item_factory, tmp); \
254 g_free(tmp); \
255 } while (0)
257 #define GET_SSMENU_ITEM(var, menu, sub, subsub) \
258 do { \
259 tmp = g_strdup_printf("<" menu ">/%s/%s", _(sub), _(subsub)); \
260 var = gtk_item_factory_get_widget(item_factory, tmp); \
261 g_free(tmp); \
262 } while (0)
264 void menu_init()
266 GtkItemFactory *item_factory;
267 char *menurc;
268 GList *items;
269 guchar *tmp;
270 GtkWidget *item;
271 int n_entries;
272 GtkItemFactoryEntry *translated;
274 /* This call starts returning strange values after a while, so get
275 * the result here during init.
277 gdk_window_get_size(GDK_ROOT_PARENT(), &screen_width, &screen_height);
279 filer_keys = gtk_accel_group_new();
280 item_factory = gtk_item_factory_new(GTK_TYPE_MENU,
281 "<filer>",
282 filer_keys);
284 n_entries = sizeof(filer_menu_def) / sizeof(*filer_menu_def);
285 translated = translate_entries(filer_menu_def, n_entries);
286 gtk_item_factory_create_items (item_factory, n_entries,
287 translated, NULL);
288 free_translated_entries(translated, n_entries);
290 GET_MENU_ITEM(filer_menu, "filer");
291 GET_SMENU_ITEM(filer_file_menu, "filer", "File");
292 GET_SSMENU_ITEM(filer_vfs_menu, "filer", "File", "Open VFS");
293 GET_SSMENU_ITEM(filer_hidden_menu, "filer", "Display", "Show Hidden");
295 items = gtk_container_children(GTK_CONTAINER(filer_menu));
296 filer_file_item = GTK_BIN(g_list_nth(items, 1)->data)->child;
297 g_list_free(items);
299 GET_SSMENU_ITEM(item, "filer", "Window", "New Window");
300 filer_new_window = GTK_BIN(item)->child;
302 panel_keys = gtk_accel_group_new();
303 item_factory = gtk_item_factory_new(GTK_TYPE_MENU,
304 "<panel>",
305 panel_keys);
307 n_entries = sizeof(panel_menu_def) / sizeof(*panel_menu_def);
308 translated = translate_entries(panel_menu_def, n_entries);
309 gtk_item_factory_create_items (item_factory, n_entries,
310 translated, NULL);
311 free_translated_entries(translated, n_entries);
313 GET_MENU_ITEM(panel_menu, "panel");
314 GET_SSMENU_ITEM(panel_hidden_menu, "panel", "Display", "Show Hidden");
316 menurc = choices_find_path_load("menus", PROJECT);
317 if (menurc)
318 gtk_item_factory_parse_rc(menurc);
320 gtk_accel_group_lock(panel_keys);
322 gtk_signal_connect(GTK_OBJECT(filer_menu), "unmap_event",
323 GTK_SIGNAL_FUNC(menu_closed), NULL);
324 gtk_signal_connect(GTK_OBJECT(panel_menu), "unmap_event",
325 GTK_SIGNAL_FUNC(menu_closed), NULL);
326 gtk_signal_connect(GTK_OBJECT(filer_file_menu), "unmap_event",
327 GTK_SIGNAL_FUNC(menu_closed), NULL);
329 options_sections = g_slist_prepend(options_sections, &options);
330 xterm_here_value = g_strdup("xterm");
331 option_register("xterm_here", load_xterm_here);
333 savebox = gtk_savebox_new();
334 gtk_signal_connect_object(GTK_OBJECT(savebox), "save_to_file",
335 GTK_SIGNAL_FUNC(save_to_file), NULL);
336 gtk_signal_connect_object(GTK_OBJECT(savebox), "save_done",
337 GTK_SIGNAL_FUNC(gtk_widget_hide),
338 GTK_OBJECT(savebox));
341 /* Build up some option widgets to go in the options dialog, but don't
342 * fill them in yet.
344 static GtkWidget *create_options()
346 GtkWidget *table, *label;
348 table = gtk_table_new(2, 2, FALSE);
349 gtk_container_set_border_width(GTK_CONTAINER(table), 4);
351 label = gtk_label_new(
352 _("To set the keyboard short-cuts you simply open "
353 "the menu over a filer window, move the pointer over "
354 "the item you want to use and press a key. The key "
355 "will appear next to the menu item and you can just "
356 "press that key without opening the menu in future. "
357 "To save the current menu short-cuts for next time, "
358 "click the Save button at the bottom of this window."));
359 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
360 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 2, 0, 1);
362 label = gtk_label_new(_("'Xterm here' program:"));
363 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
364 xterm_here_entry = gtk_entry_new();
365 gtk_table_attach_defaults(GTK_TABLE(table), xterm_here_entry,
366 1, 2, 1, 2);
368 return table;
371 static char *load_xterm_here(char *data)
373 g_free(xterm_here_value);
374 xterm_here_value = g_strdup(data);
375 return NULL;
378 static void update_options()
380 gtk_entry_set_text(GTK_ENTRY(xterm_here_entry), xterm_here_value);
383 static void set_options()
385 g_free(xterm_here_value);
386 xterm_here_value = g_strdup(gtk_entry_get_text(
387 GTK_ENTRY(xterm_here_entry)));
390 static void save_options()
392 char *menurc;
394 menurc = choices_find_path_save("menus", PROJECT, TRUE);
395 if (menurc)
396 gtk_item_factory_dump_rc(menurc, NULL, TRUE);
398 option_write("xterm_here", xterm_here_value);
402 static void items_sensitive(gboolean state)
404 int n = 7;
405 GList *items, *item;
407 items = item = gtk_container_children(GTK_CONTAINER(filer_file_menu));
408 while (item && n--)
410 gtk_widget_set_sensitive(GTK_BIN(item->data)->child, state);
411 item = item->next;
413 g_list_free(items);
415 items = item = gtk_container_children(GTK_CONTAINER(filer_vfs_menu));
416 while (item)
418 gtk_widget_set_sensitive(GTK_BIN(item->data)->child, state);
419 item = item->next;
421 g_list_free(items);
424 static void position_menu(GtkMenu *menu, gint *x, gint *y, gpointer data)
426 int *pos = (int *) data;
427 GtkRequisition requisition;
429 gtk_widget_size_request(GTK_WIDGET(menu), &requisition);
431 if (pos[0] == -1)
432 *x = screen_width - MENU_MARGIN - requisition.width;
433 else if (pos[0] == -2)
434 *x = MENU_MARGIN;
435 else
436 *x = pos[0] - (requisition.width >> 2);
438 if (pos[1] == -1)
439 *y = screen_height - MENU_MARGIN - requisition.height;
440 else if (pos[1] == -2)
441 *y = MENU_MARGIN;
442 else
443 *y = pos[1] - (requisition.height >> 2);
445 *x = CLAMP(*x, 0, screen_width - requisition.width);
446 *y = CLAMP(*y, 0, screen_height - requisition.height);
449 void show_filer_menu(FilerWindow *filer_window, GdkEventButton *event,
450 int item)
452 DirItem *file_item;
453 int pos[2];
455 updating_menu++;
457 pos[0] = event->x_root;
458 pos[1] = event->y_root;
460 window_with_focus = filer_window;
462 switch (filer_window->panel_type)
464 case PANEL_TOP:
465 pos[1] = -2;
466 break;
467 case PANEL_BOTTOM:
468 pos[1] = -1;
469 break;
470 default:
471 break;
474 if (filer_window->panel_type)
475 collection_clear_selection(filer_window->collection); /* ??? */
477 if (filer_window->collection->number_selected == 0 && item >= 0)
479 collection_select_item(filer_window->collection, item);
480 filer_window->temp_item_selected = TRUE;
482 else
483 filer_window->temp_item_selected = FALSE;
485 if (filer_window->panel_type)
487 gtk_check_menu_item_set_active(
488 GTK_CHECK_MENU_ITEM(panel_hidden_menu),
489 filer_window->show_hidden);
491 else
493 GtkWidget *file_label, *file_menu;
494 Collection *collection = filer_window->collection;
495 GString *buffer;
497 file_label = filer_file_item;
498 file_menu = filer_file_menu;
499 gtk_check_menu_item_set_active(
500 GTK_CHECK_MENU_ITEM(filer_hidden_menu),
501 filer_window->show_hidden);
502 buffer = g_string_new(NULL);
503 switch (collection->number_selected)
505 case 0:
506 g_string_assign(buffer, _("Next Click"));
507 items_sensitive(TRUE);
508 break;
509 case 1:
510 items_sensitive(TRUE);
511 file_item = selected_item(
512 filer_window->collection);
513 g_string_sprintf(buffer, "%s '%s'",
514 basetype_name(file_item),
515 file_item->leafname);
516 break;
517 default:
518 items_sensitive(FALSE);
519 g_string_sprintf(buffer, _("%d items"),
520 collection->number_selected);
521 break;
523 gtk_label_set_text(GTK_LABEL(file_label), buffer->str);
524 g_string_free(buffer, TRUE);
528 gtk_widget_set_sensitive(filer_new_window, !o_unique_filer_windows);
530 if (filer_window->panel_type)
531 popup_menu = panel_menu;
532 else
533 popup_menu = (event->state & GDK_CONTROL_MASK)
534 ? filer_file_menu
535 : filer_menu;
537 updating_menu--;
539 gtk_menu_popup(GTK_MENU(popup_menu), NULL, NULL, position_menu,
540 (gpointer) pos, event->button, event->time);
543 static void menu_closed(GtkWidget *widget)
545 if (window_with_focus == NULL || widget != popup_menu)
546 return; /* Close panel item chosen? */
548 if (window_with_focus->temp_item_selected)
550 collection_clear_selection(window_with_focus->collection);
551 window_with_focus->temp_item_selected = FALSE;
555 void target_callback(Collection *collection, gint item, gpointer real_fn)
557 g_return_if_fail(window_with_focus != NULL);
558 g_return_if_fail(window_with_focus->collection == collection);
559 g_return_if_fail(real_fn != NULL);
561 collection_wink_item(collection, item);
562 collection_clear_selection(collection);
563 collection_select_item(collection, item);
564 ((CollectionTargetFunc)real_fn)(NULL, 0, collection);
565 if (item < collection->number_of_items)
566 collection_unselect_item(collection, item);
569 /* Actions */
571 static void large(gpointer data, guint action, GtkWidget *widget)
573 g_return_if_fail(window_with_focus != NULL);
575 filer_style_set(window_with_focus, LARGE_ICONS);
578 static void small(gpointer data, guint action, GtkWidget *widget)
580 g_return_if_fail(window_with_focus != NULL);
582 filer_style_set(window_with_focus, SMALL_ICONS);
585 static void large_full_info(gpointer data, guint action, GtkWidget *widget)
587 g_return_if_fail(window_with_focus != NULL);
589 filer_style_set(window_with_focus, LARGE_FULL_INFO);
592 static void small_full_info(gpointer data, guint action, GtkWidget *widget)
594 g_return_if_fail(window_with_focus != NULL);
596 filer_style_set(window_with_focus, SMALL_FULL_INFO);
599 static void details_summary(gpointer data, guint action, GtkWidget *widget)
601 g_return_if_fail(window_with_focus != NULL);
603 filer_details_set(window_with_focus, DETAILS_SUMMARY);
606 static void details_sizes(gpointer data, guint action, GtkWidget *widget)
608 g_return_if_fail(window_with_focus != NULL);
610 filer_details_set(window_with_focus, DETAILS_SIZE);
614 static void sort_name(gpointer data, guint action, GtkWidget *widget)
616 g_return_if_fail(window_with_focus != NULL);
618 filer_set_sort_fn(window_with_focus, sort_by_name);
621 static void sort_type(gpointer data, guint action, GtkWidget *widget)
623 g_return_if_fail(window_with_focus != NULL);
625 filer_set_sort_fn(window_with_focus, sort_by_type);
628 static void sort_date(gpointer data, guint action, GtkWidget *widget)
630 g_return_if_fail(window_with_focus != NULL);
632 filer_set_sort_fn(window_with_focus, sort_by_date);
635 static void sort_size(gpointer data, guint action, GtkWidget *widget)
637 g_return_if_fail(window_with_focus != NULL);
639 filer_set_sort_fn(window_with_focus, sort_by_size);
642 static void hidden(gpointer data, guint action, GtkWidget *widget)
644 if (updating_menu)
645 return;
647 g_return_if_fail(window_with_focus != NULL);
649 filer_set_hidden(window_with_focus, !window_with_focus->show_hidden);
652 static void refresh(gpointer data, guint action, GtkWidget *widget)
654 g_return_if_fail(window_with_focus != NULL);
656 full_refresh();
657 filer_update_dir(window_with_focus, TRUE);
660 static void mount(gpointer data, guint action, GtkWidget *widget)
662 g_return_if_fail(window_with_focus != NULL);
664 if (window_with_focus->collection->number_selected == 0)
665 collection_target(window_with_focus->collection,
666 target_callback, mount);
667 else
668 action_mount(window_with_focus, NULL);
671 static void delete(gpointer data, guint action, GtkWidget *widget)
673 g_return_if_fail(window_with_focus != NULL);
675 if (window_with_focus->collection->number_selected == 0)
676 collection_target(window_with_focus->collection,
677 target_callback, delete);
678 else
679 action_delete(window_with_focus);
682 static void remove_link(gpointer data, guint action, GtkWidget *widget)
684 g_return_if_fail(window_with_focus != NULL);
686 if (window_with_focus->collection->number_selected > 1)
688 report_error(PROJECT,
689 _("You can only remove one link at a time"));
690 return;
692 else if (window_with_focus->collection->number_selected == 0)
693 collection_target(window_with_focus->collection,
694 target_callback, remove_link);
695 else
697 struct stat info;
698 DirItem *item;
699 guchar *path;
701 item = selected_item(window_with_focus->collection);
703 path = make_path(window_with_focus->path, item->leafname)->str;
704 if (lstat(path, &info))
705 report_error(PROJECT, g_strerror(errno));
706 else if (!S_ISLNK(info.st_mode))
707 report_error(PROJECT,
708 _("You can only remove symbolic links this way - "
709 "try the 'Open Panel as Directory' item."));
710 else if (unlink(path))
711 report_error(PROJECT, g_strerror(errno));
712 else
713 filer_update_dir(window_with_focus, TRUE);
717 static void usage(gpointer data, guint action, GtkWidget *widget)
719 g_return_if_fail(window_with_focus != NULL);
721 if (window_with_focus->collection->number_selected == 0)
722 collection_target(window_with_focus->collection,
723 target_callback, usage);
724 else
725 action_usage(window_with_focus);
728 static void chmod_items(gpointer data, guint action, GtkWidget *widget)
730 g_return_if_fail(window_with_focus != NULL);
732 if (window_with_focus->collection->number_selected == 0)
733 collection_target(window_with_focus->collection,
734 target_callback, chmod_items);
735 else
736 action_chmod(window_with_focus);
739 static void find(gpointer data, guint action, GtkWidget *widget)
741 g_return_if_fail(window_with_focus != NULL);
743 if (window_with_focus->collection->number_selected == 0)
744 collection_target(window_with_focus->collection,
745 target_callback, find);
746 else
747 action_find(window_with_focus);
750 /* This pops up our savebox widget, cancelling any currently open one,
751 * and allows the user to pick a new path for it.
752 * Once the new path has been picked, the callback will be called with
753 * both the current and new paths.
755 static void savebox_show(guchar *title, guchar *path, MaskedPixmap *image,
756 gboolean (*callback)(guchar *current, guchar *new))
758 if (GTK_WIDGET_VISIBLE(savebox))
759 gtk_widget_hide(savebox);
761 if (current_path)
762 g_free(current_path);
763 current_path = g_strdup(path);
764 current_savebox_callback = callback;
766 gtk_window_set_title(GTK_WINDOW(savebox), title);
767 gtk_savebox_set_pathname(GTK_SAVEBOX(savebox), current_path);
768 gtk_savebox_set_icon(GTK_SAVEBOX(savebox), image->pixmap, image->mask);
770 gtk_widget_grab_focus(GTK_SAVEBOX(savebox)->entry);
771 gtk_widget_show(savebox);
774 static gint save_to_file(GtkSavebox *savebox, guchar *pathname)
776 g_return_val_if_fail(current_savebox_callback != NULL,
777 GTK_XDS_SAVE_ERROR);
779 return current_savebox_callback(current_path, pathname)
780 ? GTK_XDS_SAVED : GTK_XDS_SAVE_ERROR;
783 static gboolean copy_cb(guchar *current, guchar *new)
785 char *new_dir, *leaf;
786 GSList *local_paths;
788 if (new[0] != '/')
790 report_error(PROJECT, _("New pathname is not absolute"));
791 return FALSE;
794 if (new[strlen(new) - 1] == '/')
796 new_dir = g_strdup(new);
797 leaf = NULL;
799 else
801 guchar *slash;
803 slash = strrchr(new, '/');
804 new_dir = g_strndup(new, slash - new);
805 leaf = slash + 1;
808 local_paths = g_slist_append(NULL, current);
809 action_copy(local_paths, new_dir, leaf);
810 g_slist_free(local_paths);
812 g_free(new_dir);
814 return TRUE;
817 #define SHOW_SAVEBOX(title, callback) \
819 DirItem *item; \
820 guchar *path; \
821 item = selected_item(collection); \
822 path = make_path(window_with_focus->path, item->leafname)->str; \
823 savebox_show(title, path, item->image, callback); \
826 static void copy_item(gpointer data, guint action, GtkWidget *widget)
828 Collection *collection;
830 g_return_if_fail(window_with_focus != NULL);
832 collection = window_with_focus->collection;
833 if (collection->number_selected > 1)
835 report_error(PROJECT, _("You cannot do this to more than "
836 "one item at a time"));
837 return;
839 else if (collection->number_selected != 1)
840 collection_target(collection, target_callback, copy_item);
841 else
842 SHOW_SAVEBOX(_("Copy"), copy_cb);
845 static gboolean rename_cb(guchar *current, guchar *new)
847 if (rename(current, new))
849 report_error("ROX-Filer: rename()", g_strerror(errno));
850 return FALSE;
852 return TRUE;
855 static void rename_item(gpointer data, guint action, GtkWidget *widget)
857 Collection *collection;
859 g_return_if_fail(window_with_focus != NULL);
861 collection = window_with_focus->collection;
862 if (collection->number_selected > 1)
864 report_error(PROJECT, _("You cannot do this to more than "
865 "one item at a time"));
866 return;
868 else if (collection->number_selected != 1)
869 collection_target(collection, target_callback, rename_item);
870 else
871 SHOW_SAVEBOX(_("Rename"), rename_cb);
874 static gboolean link_cb(guchar *initial, guchar *path)
876 if (symlink(initial, path))
878 report_error("ROX-Filer: symlink()", g_strerror(errno));
879 return FALSE;
881 return TRUE;
884 static void link_item(gpointer data, guint action, GtkWidget *widget)
886 Collection *collection;
888 g_return_if_fail(window_with_focus != NULL);
890 collection = window_with_focus->collection;
891 if (collection->number_selected > 1)
893 report_error(PROJECT, _("You cannot do this to more than "
894 "one item at a time"));
895 return;
897 else if (collection->number_selected != 1)
898 collection_target(collection, target_callback, link_item);
899 else
900 SHOW_SAVEBOX(_("Symlink"), link_cb);
903 static void open_file(gpointer data, guint action, GtkWidget *widget)
905 Collection *collection;
907 g_return_if_fail(window_with_focus != NULL);
909 collection = window_with_focus->collection;
910 if (collection->number_selected > 1)
912 report_error(PROJECT, _("You cannot do this to more than "
913 "one item at a time"));
914 return;
916 else if (collection->number_selected != 1)
917 collection_target(collection, target_callback, open_file);
918 else
919 filer_openitem(window_with_focus,
920 selected_item_number(collection),
921 OPEN_SAME_WINDOW | OPEN_SHIFT);
924 /* Got some data from file(1) - stick it in the window. */
925 static void add_file_output(FileStatus *fs,
926 gint source, GdkInputCondition condition)
928 char buffer[20];
929 char *str;
930 int got;
932 got = read(source, buffer, sizeof(buffer) - 1);
933 if (got <= 0)
935 int err = errno;
936 gtk_input_remove(fs->input);
937 close(source);
938 fs->fd = -1;
939 if (got < 0)
940 delayed_error(_("ROX-Filer: file(1) says..."),
941 g_strerror(err));
942 return;
944 buffer[got] = '\0';
946 if (fs->start)
948 str = "";
949 fs->start = FALSE;
951 else
952 gtk_label_get(fs->label, &str);
954 str = g_strconcat(str, buffer, NULL);
955 gtk_label_set_text(fs->label, str);
956 g_free(str);
959 static void file_info_destroyed(GtkWidget *widget, FileStatus *fs)
961 if (fs->fd != -1)
963 gtk_input_remove(fs->input);
964 close(fs->fd);
967 g_free(fs);
970 /* g_free() the result */
971 guchar *pretty_type(DirItem *file, guchar *path)
973 if (file->flags & ITEM_FLAG_SYMLINK)
975 char p[MAXPATHLEN + 1];
976 int got;
977 got = readlink(path, p, MAXPATHLEN);
978 if (got > 0 && got <= MAXPATHLEN)
980 p[got] = '\0';
981 return g_strconcat(_("Symbolic link to "), p, NULL);
984 return g_strdup(_("Symbolic link"));
987 if (file->flags & ITEM_FLAG_EXEC_FILE)
988 return g_strdup(_("Executable file"));
990 if (file->flags & ITEM_FLAG_APPDIR)
991 return g_strdup(_("ROX application"));
993 if (file->flags & ITEM_FLAG_MOUNT_POINT)
995 MountPoint *mp;
996 if ((file->flags & ITEM_FLAG_MOUNTED) &&
997 (mp = g_hash_table_lookup(mtab_mounts, path)))
998 return g_strconcat(_("Mount point for "),
999 mp->name, NULL);
1001 return g_strdup(_("Mount point"));
1004 if (file->mime_type)
1005 return g_strconcat(file->mime_type->media_type, "/",
1006 file->mime_type->subtype, NULL);
1008 return g_strdup("-");
1011 #define LABEL(text, row) \
1012 label = gtk_label_new(text); \
1013 gtk_misc_set_alignment(GTK_MISC(label), 1, .5); \
1014 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT); \
1015 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, row, row + 1);
1017 #define VALUE(label, row) \
1018 gtk_misc_set_alignment(GTK_MISC(label), 0, .5); \
1019 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, row, row + 1);
1021 static void show_file_info(gpointer data, guint action, GtkWidget *widget)
1023 GtkWidget *window, *table, *label, *button, *frame, *value;
1024 GtkWidget *file_label;
1025 GString *gstring;
1026 int file_data[2];
1027 guchar *path, *tmp;
1028 char *argv[] = {"file", "-b", NULL, NULL};
1029 Collection *collection;
1030 DirItem *file;
1031 struct stat info;
1032 FileStatus *fs = NULL;
1033 guint perm;
1035 g_return_if_fail(window_with_focus != NULL);
1037 collection = window_with_focus->collection;
1038 if (collection->number_selected > 1)
1040 report_error(PROJECT, _("You cannot do this to more than "
1041 "one item at a time"));
1042 return;
1044 else if (collection->number_selected != 1)
1046 collection_target(collection, target_callback, show_file_info);
1047 return;
1049 file = selected_item(collection);
1050 path = make_path(window_with_focus->path,
1051 file->leafname)->str;
1052 if (lstat(path, &info))
1054 delayed_error(PROJECT, g_strerror(errno));
1055 return;
1058 gstring = g_string_new(NULL);
1060 window = gtk_window_new(GTK_WINDOW_DIALOG);
1061 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
1062 gtk_container_set_border_width(GTK_CONTAINER(window), 4);
1063 gtk_window_set_title(GTK_WINDOW(window), path);
1065 table = gtk_table_new(10, 2, FALSE);
1066 gtk_container_add(GTK_CONTAINER(window), table);
1067 gtk_table_set_row_spacings(GTK_TABLE(table), 8);
1068 gtk_table_set_col_spacings(GTK_TABLE(table), 4);
1070 value = gtk_label_new(file->leafname);
1071 LABEL(_("Name:"), 0);
1072 VALUE(value, 0);
1074 g_string_sprintf(gstring, "%s, %s", user_name(info.st_uid),
1075 group_name(info.st_gid));
1076 value = gtk_label_new(gstring->str);
1077 LABEL(_("Owner, Group:"), 1);
1078 VALUE(value, 1);
1080 if (info.st_size >= PRETTY_SIZE_LIMIT)
1082 g_string_sprintf(gstring, "%s (%ld %s)",
1083 format_size((unsigned long) info.st_size),
1084 (unsigned long) info.st_size, _("bytes"));
1086 else
1088 g_string_assign(gstring,
1089 format_size((unsigned long) info.st_size));
1091 value = gtk_label_new(gstring->str);
1092 LABEL(_("Size:"), 2);
1093 VALUE(value, 2);
1095 value = gtk_label_new(pretty_time(&info.st_ctime));
1096 LABEL(_("Change time:"), 3);
1097 VALUE(value, 3);
1099 value = gtk_label_new(pretty_time(&info.st_mtime));
1100 LABEL(_("Modify time:"), 4);
1101 VALUE(value, 4);
1103 value = gtk_label_new(pretty_time(&info.st_atime));
1104 LABEL(_("Access time:"), 5);
1105 VALUE(value, 5);
1107 value = gtk_label_new(pretty_permissions(info.st_mode));
1108 perm = applicable(info.st_uid, info.st_gid);
1109 gtk_label_set_pattern(GTK_LABEL(value),
1110 perm == 0 ? "___ " :
1111 perm == 1 ? " ___ " :
1112 " ___");
1113 gtk_widget_set_style(value, fixed_style);
1114 LABEL(_("Permissions:"), 6);
1115 VALUE(value, 6);
1117 tmp = pretty_type(file, path);
1118 value = gtk_label_new(tmp);
1119 g_free(tmp);
1120 LABEL(_("Type:"), 7);
1121 VALUE(value, 7);
1123 frame = gtk_frame_new(_("file(1) says..."));
1124 gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 2, 8, 9);
1125 file_label = gtk_label_new(_("<nothing yet>"));
1126 gtk_misc_set_padding(GTK_MISC(file_label), 4, 4);
1127 gtk_label_set_line_wrap(GTK_LABEL(file_label), TRUE);
1128 gtk_container_add(GTK_CONTAINER(frame), file_label);
1130 button = gtk_button_new_with_label(_("OK"));
1131 gtk_window_set_focus(GTK_WINDOW(window), button);
1132 gtk_table_attach(GTK_TABLE(table), button, 0, 2, 10, 11,
1133 GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 40, 4);
1134 gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
1135 gtk_widget_destroy, GTK_OBJECT(window));
1137 gtk_widget_show_all(window);
1138 gdk_flush();
1140 if (pipe(file_data))
1142 g_string_sprintf(gstring, "pipe(): %s", g_strerror(errno));
1143 g_string_free(gstring, TRUE);
1144 return;
1146 switch (fork())
1148 case -1:
1149 g_string_sprintf(gstring, "fork(): %s",
1150 g_strerror(errno));
1151 gtk_label_set_text(GTK_LABEL(file_label), gstring->str);
1152 g_string_free(gstring, TRUE);
1153 close(file_data[0]);
1154 close(file_data[1]);
1155 break;
1156 case 0:
1157 /* We are the child */
1158 close(file_data[0]);
1159 dup2(file_data[1], STDOUT_FILENO);
1160 dup2(file_data[1], STDERR_FILENO);
1161 #ifdef FILE_B_FLAG
1162 argv[2] = path;
1163 #else
1164 argv[1] = file->leafname;
1165 chdir(window_with_focus->path);
1166 #endif
1167 if (execvp(argv[0], argv))
1168 fprintf(stderr, "execvp() error: %s\n",
1169 g_strerror(errno));
1170 _exit(0);
1171 default:
1172 /* We are the parent */
1173 close(file_data[1]);
1174 fs = g_new(FileStatus, 1);
1175 fs->label = GTK_LABEL(file_label);
1176 fs->fd = file_data[0];
1177 fs->start = TRUE;
1178 fs->input = gdk_input_add(fs->fd, GDK_INPUT_READ,
1179 (GdkInputFunction) add_file_output, fs);
1180 gtk_signal_connect(GTK_OBJECT(window), "destroy",
1181 GTK_SIGNAL_FUNC(file_info_destroyed), fs);
1182 g_string_free(gstring, TRUE);
1183 break;
1187 static void app_show_help(char *path)
1189 char *help_dir;
1190 struct stat info;
1192 help_dir = g_strconcat(path, "/Help", NULL);
1194 if (mc_stat(help_dir, &info))
1195 delayed_error(_("Application"),
1196 _("This is an application directory - you can "
1197 "run it as a program, or open it (hold down "
1198 "Shift while you open it). Most applications provide "
1199 "their own help here, but this one doesn't."));
1200 else
1201 filer_opendir(help_dir, PANEL_NO);
1204 static void help(gpointer data, guint action, GtkWidget *widget)
1206 Collection *collection;
1207 DirItem *item;
1209 g_return_if_fail(window_with_focus != NULL);
1211 collection = window_with_focus->collection;
1212 if (collection->number_selected > 1)
1214 report_error(PROJECT, _("You cannot do this to more than "
1215 "one item at a time"));
1216 return;
1218 else if (collection->number_selected != 1)
1220 collection_target(collection, target_callback, help);
1221 return;
1223 item = selected_item(collection);
1224 switch (item->base_type)
1226 case TYPE_FILE:
1227 if (item->flags & ITEM_FLAG_EXEC_FILE)
1228 delayed_error(_("Executable file"),
1229 _("This is a file with an eXecute bit "
1230 "set - it can be run as a program."));
1231 else
1232 delayed_error(_("File"), _(
1233 "This is a data file. Try using the "
1234 "Info menu item to find out more..."));
1235 break;
1236 case TYPE_DIRECTORY:
1237 if (item->flags & ITEM_FLAG_APPDIR)
1238 app_show_help(
1239 make_path(window_with_focus->path,
1240 item->leafname)->str);
1241 else if (item->flags & ITEM_FLAG_MOUNT_POINT)
1242 delayed_error(_("Mount point"), _(
1243 "A mount point is a directory which another "
1244 "filing system can be mounted on. Everything "
1245 "on the mounted filesystem then appears to be "
1246 "inside the directory."));
1247 else
1248 delayed_error(_("Directory"), _(
1249 "This is a directory. It contains an index to "
1250 "other items - open it to see the list."));
1251 break;
1252 case TYPE_CHAR_DEVICE:
1253 case TYPE_BLOCK_DEVICE:
1254 delayed_error(_("Device file"), _(
1255 "Device files allow you to read from or write "
1256 "to a device driver as though it was an "
1257 "ordinary file."));
1258 break;
1259 case TYPE_PIPE:
1260 delayed_error(_("Named pipe"), _(
1261 "Pipes allow different programs to "
1262 "communicate. One program writes data to the "
1263 "pipe while another one reads it out again."));
1264 break;
1265 case TYPE_SOCKET:
1266 delayed_error(_("Socket"), _(
1267 "Sockets allow processes to communicate."));
1268 break;
1269 default:
1270 delayed_error(_("Unknown type"), _(
1271 "I couldn't find out what kind of file this "
1272 "is. Maybe it doesn't exist anymore or you "
1273 "don't have search permission on the directory "
1274 "it's in?"));
1275 break;
1279 #define OPEN_VFS(fs) \
1280 static void open_vfs_ ## fs (gpointer data, guint action, GtkWidget *widget) \
1282 Collection *collection; \
1284 g_return_if_fail(window_with_focus != NULL); \
1286 collection = window_with_focus->collection; \
1287 if (collection->number_selected < 1) \
1288 collection_target(collection, target_callback, \
1289 open_vfs_ ## fs); \
1290 else \
1291 real_vfs_open(#fs); \
1294 static void real_vfs_open(char *fs)
1296 gchar *path;
1297 DirItem *item;
1299 if (window_with_focus->collection->number_selected != 1)
1301 report_error(PROJECT, _("You must select a single file "
1302 "to open as a Virtual File System"));
1303 return;
1306 item = selected_item(window_with_focus->collection);
1308 path = g_strconcat(window_with_focus->path,
1309 "/",
1310 item->leafname,
1311 "#", fs, NULL);
1313 filer_change_to(window_with_focus, path, NULL);
1314 g_free(path);
1317 OPEN_VFS(rpm)
1318 OPEN_VFS(utar)
1319 OPEN_VFS(uzip)
1321 static void select_all(gpointer data, guint action, GtkWidget *widget)
1323 g_return_if_fail(window_with_focus != NULL);
1325 collection_select_all(window_with_focus->collection);
1326 window_with_focus->temp_item_selected = FALSE;
1329 static void clear_selection(gpointer data, guint action, GtkWidget *widget)
1331 g_return_if_fail(window_with_focus != NULL);
1333 collection_clear_selection(window_with_focus->collection);
1334 window_with_focus->temp_item_selected = FALSE;
1337 static void show_options(gpointer data, guint action, GtkWidget *widget)
1339 g_return_if_fail(window_with_focus != NULL);
1341 options_show(window_with_focus);
1344 static gboolean new_directory_cb(guchar *initial, guchar *path)
1346 if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO))
1348 report_error("mkdir", g_strerror(errno));
1349 return FALSE;
1351 return TRUE;
1354 static void new_directory(gpointer data, guint action, GtkWidget *widget)
1356 g_return_if_fail(window_with_focus != NULL);
1358 savebox_show(_("New Directory"),
1359 make_path(window_with_focus->path, _("NewDir"))->str,
1360 type_to_icon(&special_directory),
1361 new_directory_cb);
1364 static void xterm_here(gpointer data, guint action, GtkWidget *widget)
1366 char *argv[] = {NULL, NULL};
1368 argv[0] = xterm_here_value;
1370 g_return_if_fail(window_with_focus != NULL);
1372 if (!spawn_full(argv, window_with_focus->path))
1373 report_error(PROJECT, "Failed to fork() child "
1374 "process");
1377 static void open_parent(gpointer data, guint action, GtkWidget *widget)
1379 g_return_if_fail(window_with_focus != NULL);
1381 filer_open_parent(window_with_focus);
1384 static void open_parent_same(gpointer data, guint action, GtkWidget *widget)
1386 g_return_if_fail(window_with_focus != NULL);
1388 change_to_parent(window_with_focus);
1391 static void new_window(gpointer data, guint action, GtkWidget *widget)
1393 g_return_if_fail(window_with_focus != NULL);
1395 if (o_unique_filer_windows)
1396 report_error(PROJECT, _("You can't open a second view onto "
1397 "this directory because the `Unique Windows' option "
1398 "is turned on in the Options window."));
1399 else
1400 filer_opendir(window_with_focus->path, PANEL_NO);
1403 static void close_window(gpointer data, guint action, GtkWidget *widget)
1405 g_return_if_fail(window_with_focus != NULL);
1407 gtk_widget_destroy(window_with_focus->window);
1410 static void enter_path(gpointer data, guint action, GtkWidget *widget)
1412 g_return_if_fail(window_with_focus != NULL);
1414 minibuffer_show(window_with_focus, MINI_PATH);
1417 static void shell_command(gpointer data, guint action, GtkWidget *widget)
1419 g_return_if_fail(window_with_focus != NULL);
1421 minibuffer_show(window_with_focus, MINI_SHELL);
1424 static void run_action(gpointer data, guint action, GtkWidget *widget)
1426 g_return_if_fail(window_with_focus != NULL);
1428 minibuffer_show(window_with_focus, MINI_RUN_ACTION);
1431 static void select_if(gpointer data, guint action, GtkWidget *widget)
1433 g_return_if_fail(window_with_focus != NULL);
1435 minibuffer_show(window_with_focus, MINI_SELECT_IF);
1438 static void rox_help(gpointer data, guint action, GtkWidget *widget)
1440 g_return_if_fail(window_with_focus != NULL);
1442 filer_opendir(make_path(getenv("APP_DIR"), "Help")->str, PANEL_NO);
1445 static void open_as_dir(gpointer data, guint action, GtkWidget *widget)
1447 g_return_if_fail(window_with_focus != NULL);
1449 filer_opendir(window_with_focus->path, PANEL_NO);
1452 static void close_panel(gpointer data, guint action, GtkWidget *widget)
1454 g_return_if_fail(window_with_focus != NULL);
1456 gtk_widget_destroy(window_with_focus->window);