--- rox-2.0.1.orig/ROX-Filer/src/filer.c +++ rox-2.0.1/ROX-Filer/src/filer.c @@ -1628,6 +1628,33 @@ } } +/* Close all parent windows */ +void filer_close_recursive_parent(const char *path) +{ + GList *next = all_filer_windows; + gchar *real; + int len; + + real = pathdup(path); + + while (next) + { + FilerWindow *filer_window = (FilerWindow *) next->data; + + next = next->next; + len = strlen(filer_window->real_path); + + if (strncmp(real, filer_window->real_path, len) == 0) + { + char s = filer_window->real_path[len]; + + if (strncmp(real, filer_window->real_path, strlen (real)) != 0) + if (len == 1 || s == '/' || s == '\0') + gtk_widget_destroy(filer_window->window); + } + } +} + /* Like minibuffer_show(), except that: * - It returns FALSE (to be used from an idle callback) * - It checks that the filer window still exists. --- rox-2.0.1.orig/ROX-Filer/src/filer.h +++ rox-2.0.1/ROX-Filer/src/filer.h @@ -114,6 +114,7 @@ void filer_openitem(FilerWindow *filer_window, ViewIter *iter, OpenFlags flags); void filer_check_mounted(const char *real_path); void filer_close_recursive(const char *path); +void filer_close_recursive_parent(const char *path); void filer_change_to(FilerWindow *filer_window, const char *path, const char *from); gboolean filer_exists(FilerWindow *filer_window); --- rox-2.0.1.orig/ROX-Filer/src/menu.c +++ rox-2.0.1/ROX-Filer/src/menu.c @@ -154,6 +154,8 @@ static void new_window(gpointer data, guint action, GtkWidget *widget); /* static void new_user(gpointer data, guint action, GtkWidget *widget); */ static void close_window(gpointer data, guint action, GtkWidget *widget); +static void close_all_parent_windows(gpointer data, guint action, GtkWidget *widget); +static void close_all_windows(gpointer data, guint action, GtkWidget *widget); static void follow_symlinks(gpointer data, guint action, GtkWidget *widget); /* (action used in this - MiniType) */ @@ -240,6 +242,8 @@ /* {">" N_("New, As User..."), NULL, new_user, 0, NULL}, */ {">" N_("Close Window"), NULL, close_window, 0, "", GTK_STOCK_CLOSE}, +{">" N_("Close Parent Windows"), "W", close_all_parent_windows, 0, "", GTK_STOCK_CLOSE}, +{">" N_("Close All Windows"), "Q", close_all_windows, 0, "", GTK_STOCK_CLOSE}, {">", NULL, NULL, 0, ""}, {">" N_("Enter Path..."), "slash", mini_buffer, MINI_PATH, NULL}, {">" N_("Shell Command..."), NULL, mini_buffer, MINI_SHELL, NULL}, @@ -1661,6 +1665,20 @@ gtk_widget_destroy(window_with_focus->window); } +static void close_all_windows(gpointer data, guint action, GtkWidget *widget) +{ + g_return_if_fail(window_with_focus != NULL); + + filer_close_recursive("/"); +} + +static void close_all_parent_windows(gpointer data, guint action, GtkWidget *widget) +{ + g_return_if_fail(window_with_focus != NULL); + + filer_close_recursive_parent(window_with_focus->real_path); +} + static void mini_buffer(gpointer data, guint action, GtkWidget *widget) { MiniType type = (MiniType) action;