From 51a60b03f2b60d1f17d0f878c6fb1351443867cb Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 9 Jan 2000 18:51:38 +0000 Subject: [PATCH] r162: Always rescan directories when they are mounted, even if the dates are the same (new/changed media that doesn't do datestamping?). Right-Ctrl-Click opens the File '' menu directly. --- ROX-Filer/src/dir.c | 7 ++++++- ROX-Filer/src/dir.h | 1 + ROX-Filer/src/dnd.c | 4 ++-- ROX-Filer/src/filer.c | 24 ++++-------------------- ROX-Filer/src/filer.h | 2 +- ROX-Filer/src/menu.c | 25 +++++++++++++++++-------- ROX-Filer/src/savebox.c | 2 +- 7 files changed, 32 insertions(+), 33 deletions(-) diff --git a/ROX-Filer/src/dir.c b/ROX-Filer/src/dir.c index fa416e4a..54ee07f9 100644 --- a/ROX-Filer/src/dir.c +++ b/ROX-Filer/src/dir.c @@ -251,6 +251,7 @@ static void init_for_scan(Directory *dir) int i; dir->needs_update = FALSE; + dir->done_some_scanning = FALSE; for (i = 0; i < dir->items->len; i++) ((DirItem *) dir->items->pdata[i])->may_delete = TRUE; @@ -260,7 +261,9 @@ static void start_scanning(Directory *dir, char *pathname) { if (dir->dir_handle) { - dir->needs_update = TRUE; + /* We are already scanning */ + if (dir->done_some_scanning) + dir->needs_update = TRUE; return; } @@ -486,6 +489,8 @@ update: static gint idle_callback(Directory *dir) { struct dirent *ent; + + dir->done_some_scanning = TRUE; do { diff --git a/ROX-Filer/src/dir.h b/ROX-Filer/src/dir.h index 3cb1b9db..8a8dcb3e 100644 --- a/ROX-Filer/src/dir.h +++ b/ROX-Filer/src/dir.h @@ -74,6 +74,7 @@ struct _Directory gboolean needs_update; /* When scan is finished, rescan */ gboolean notify_active; /* Notify timeout is running */ + gboolean done_some_scanning; /* Read any items this scan? */ gint idle; /* Idle callback ID */ DIR *dir_handle; /* NULL => not scanning */ diff --git a/ROX-Filer/src/dnd.c b/ROX-Filer/src/dnd.c index f1f2bc0f..2fb5016c 100644 --- a/ROX-Filer/src/dnd.c +++ b/ROX-Filer/src/dnd.c @@ -805,7 +805,7 @@ static void got_data_xds_reply(GtkWidget *widget, "filer_window"); g_return_if_fail(filer_window != NULL); - update_dir(filer_window); + update_dir(filer_window, TRUE); } else if (response != 'E') { @@ -862,7 +862,7 @@ static void got_data_raw(GtkWidget *widget, if (close(fd) == -1 && !error) error = g_strerror(errno); - update_dir(filer_window); + update_dir(filer_window, TRUE); } if (error) diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index e630bd34..2da516a1 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -716,22 +716,6 @@ static gboolean may_rescan(FilerWindow *filer_window, gboolean warning) return TRUE; } -/* Callback to collection_delete_if() */ -#if 0 -static gboolean remove_deleted(gpointer item_data, gpointer data) -{ - DirItem *item = (DirItem *) item_data; - - if (item->flags & ITEM_FLAG_MAY_DELETE) - { - free_item(item); - return TRUE; - } - - return FALSE; -} -#endif - /* Another app has grabbed the selection */ static gint collection_lose_selection(GtkWidget *widget, GdkEventSelection *event) @@ -1066,7 +1050,7 @@ static void toolbar_refresh_clicked(GtkWidget *widget, FilerWindow *filer_window) { full_refresh(); - update_dir(filer_window); + update_dir(filer_window, TRUE); } static void toolbar_home_clicked(GtkWidget *widget, FilerWindow *filer_window) @@ -1491,9 +1475,9 @@ static char *filer_toolbar(char *data) } /* Note that filer_window may not exist after this call. */ -void update_dir(FilerWindow *filer_window) +void update_dir(FilerWindow *filer_window, gboolean warning) { - if (may_rescan(filer_window, TRUE)) + if (may_rescan(filer_window, warning)) dir_update(filer_window->directory, filer_window->path); } @@ -1537,7 +1521,7 @@ void filer_check_mounted(char *path) char s = filer_window->path[len]; if (s == '/' || s == '\0') - may_rescan(filer_window, FALSE); + update_dir(filer_window, FALSE); } } } diff --git a/ROX-Filer/src/filer.h b/ROX-Filer/src/filer.h index e3fc9723..99b80a99 100644 --- a/ROX-Filer/src/filer.h +++ b/ROX-Filer/src/filer.h @@ -53,7 +53,7 @@ extern GHashTable *child_to_filer; /* Prototypes */ void filer_init(); void filer_opendir(char *path, gboolean panel, Side panel_side); -void update_dir(FilerWindow *filer_window); +void update_dir(FilerWindow *filer_window, gboolean warning); void scan_dir(FilerWindow *filer_window); DirItem *selected_item(Collection *collection); void change_to_parent(FilerWindow *filer_window); diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index ddebce35..134cc6c5 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -54,6 +54,8 @@ GtkAccelGroup *filer_keys; GtkAccelGroup *panel_keys; +static GtkWidget *popup_menu = NULL; /* Currently open menu */ + /* Options */ static GtkWidget *xterm_here_entry; static char *xterm_here_value; @@ -242,13 +244,15 @@ void menu_init() if (menurc) gtk_item_factory_parse_rc(menurc); + gtk_accel_group_lock(panel_keys); + + gtk_signal_connect(GTK_OBJECT(filer_menu), "unmap_event", + GTK_SIGNAL_FUNC(menu_closed), NULL); gtk_signal_connect(GTK_OBJECT(panel_menu), "unmap_event", GTK_SIGNAL_FUNC(menu_closed), NULL); - gtk_signal_connect(GTK_OBJECT(filer_menu), "unmap_event", + gtk_signal_connect(GTK_OBJECT(filer_file_menu), "unmap_event", GTK_SIGNAL_FUNC(menu_closed), NULL); - gtk_accel_group_lock(panel_keys); - options_sections = g_slist_prepend(options_sections, &options); xterm_here_value = g_strdup("xterm"); option_register("xterm_here", load_xterm_here); @@ -440,15 +444,20 @@ void show_filer_menu(FilerWindow *filer_window, GdkEventButton *event, g_string_free(buffer, TRUE); - gtk_menu_popup(filer_window->panel ? GTK_MENU(panel_menu) - : GTK_MENU(filer_menu), - NULL, NULL, position_menu, + if (filer_window->panel) + popup_menu = panel_menu; + else + popup_menu = (event->state & GDK_CONTROL_MASK) + ? filer_file_menu + : filer_menu; + + gtk_menu_popup(GTK_MENU(popup_menu), NULL, NULL, position_menu, (gpointer) pos, event->button, event->time); } static void menu_closed(GtkWidget *widget) { - if (window_with_focus == NULL) + if (window_with_focus == NULL || widget != popup_menu) return; /* Close panel item chosen? */ if (window_with_focus->temp_item_selected) @@ -533,7 +542,7 @@ static void refresh(gpointer data, guint action, GtkWidget *widget) g_return_if_fail(window_with_focus != NULL); full_refresh(); - update_dir(window_with_focus); + update_dir(window_with_focus, TRUE); } static void mount(gpointer data, guint action, GtkWidget *widget) diff --git a/ROX-Filer/src/savebox.c b/ROX-Filer/src/savebox.c index 98581610..0275ea1f 100644 --- a/ROX-Filer/src/savebox.c +++ b/ROX-Filer/src/savebox.c @@ -126,6 +126,6 @@ static void do_callback(GtkWidget *widget, gpointer data) if (callback(initial, path)) { gtk_widget_hide(window); - update_dir(filer_window); + update_dir(filer_window, TRUE); } } -- 2.11.4.GIT