From 559c3031ed810e433c24150e86668c9c371acf8f Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 28 Jul 2003 15:29:37 +0000 Subject: [PATCH] r2918: Doing a Refresh in a directory under /uri/0install triggers a remote refresh. --- ROX-Filer/AppRun | 2 +- ROX-Filer/Help/Changes | 4 ++++ ROX-Filer/src/filer.c | 26 ++++++++++++++++++++++++++ ROX-Filer/src/filer.h | 1 + ROX-Filer/src/gui_support.c | 11 ++++++----- ROX-Filer/src/gui_support.h | 2 +- ROX-Filer/src/main.c | 10 ++++------ ROX-Filer/src/menu.c | 2 +- ROX-Filer/src/remote.c | 7 ++++++- ROX-Filer/src/run.c | 2 +- ROX-Filer/src/toolbar.c | 2 +- ROX-Filer/src/type.c | 2 +- 12 files changed, 53 insertions(+), 18 deletions(-) diff --git a/ROX-Filer/AppRun b/ROX-Filer/AppRun index 8534897d..17f46f43 100755 --- a/ROX-Filer/AppRun +++ b/ROX-Filer/AppRun @@ -16,7 +16,7 @@ DEBUGGER="" case $1 in --debug) shift ; DEBUGGER=gdb ;; - --valgrind) shift ; DEBUGGER=valgrind ;; + --valgrind) shift ; DEBUGGER="valgrind --num-callers=8";; --compile) shift if [ ! -d "$APP_DIR/src" ] ; then diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index e7784d93..92e0bf01 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -2,6 +2,10 @@ A RISC OS-like filer for X by Thomas Leonard +28-Jul-2003 +~~~~~~~~~~~ +Doing a Refresh in a directory under /uri/0install triggers a remote refresh. + 14-Jul-2003 ~~~~~~~~~~~ Less frame-heavy look for info box (Thomas Leonard). diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index daa86773..6d447b14 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -1205,6 +1205,7 @@ FilerWindow *filer_opendir(const char *path, FilerWindow *src_win, filer_window->flags = (FilerFlags) 0; filer_window->details_type = DETAILS_TIMES; filer_window->display_style = UNKNOWN_STYLE; + filer_window->display_style_wanted = UNKNOWN_STYLE; filer_window->thumb_queue = NULL; filer_window->max_thumbs = 0; filer_window->sort_type = -1; @@ -2481,3 +2482,28 @@ void filer_set_autoscroll(FilerWindow *filer_window, gboolean auto_scroll) filer_window->auto_scroll = -1; } } + +#define ZERO_MNT "/uri/0install" + +static void refresh_done(FilerWindow *filer_window) +{ + if (filer_exists(filer_window)) + filer_update_dir(filer_window, TRUE); +} + +void filer_refresh(FilerWindow *filer_window) +{ + if (!strncmp(ZERO_MNT "/", filer_window->real_path, sizeof(ZERO_MNT))) + { + /* Try to run 0refresh */ + gint pid; + const gchar *argv[] = {"0refresh", + filer_window->real_path, NULL}; + pid = rox_spawn(filer_window->real_path, argv); + if (pid) + on_child_death(pid, (CallbackFn) refresh_done, + filer_window); + } + + full_refresh(); +} diff --git a/ROX-Filer/src/filer.h b/ROX-Filer/src/filer.h index bce5cd24..940f286f 100644 --- a/ROX-Filer/src/filer.h +++ b/ROX-Filer/src/filer.h @@ -144,5 +144,6 @@ gint filer_motion_notify(FilerWindow *filer_window, GdkEventMotion *event); gint filer_key_press_event(GtkWidget *widget, GdkEventKey *event, FilerWindow *filer_window); void filer_set_autoscroll(FilerWindow *filer_window, gboolean auto_scroll); +void filer_refresh(FilerWindow *filer_window); #endif /* _FILER_H */ diff --git a/ROX-Filer/src/gui_support.c b/ROX-Filer/src/gui_support.c index 35d2c038..4f14f4e2 100644 --- a/ROX-Filer/src/gui_support.c +++ b/ROX-Filer/src/gui_support.c @@ -509,27 +509,28 @@ void destroy_on_idle(GtkWidget *widget) } /* Spawn a child process (as spawn_full), and report errors. - * TRUE on success. + * Returns the child's PID on succes, or 0 on failure. */ -gboolean rox_spawn(const gchar *dir, const gchar **argv) +gint rox_spawn(const gchar *dir, const gchar **argv) { GError *error = NULL; + gint pid = 0; if (!g_spawn_async_with_pipes(dir, (gchar **) argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_SEARCH_PATH, NULL, NULL, /* Child setup fn */ - NULL, /* Child PID */ + &pid, /* Child PID */ NULL, NULL, NULL, /* Standard pipes */ &error)) { delayed_error("%s", error ? error->message : "(null)"); g_error_free(error); - return FALSE; + return 0; } - return TRUE; + return pid; } GtkWidget *button_new_image_text(GtkWidget *image, const char *message) diff --git a/ROX-Filer/src/gui_support.h b/ROX-Filer/src/gui_support.h index 0117c1b3..80eded1e 100644 --- a/ROX-Filer/src/gui_support.h +++ b/ROX-Filer/src/gui_support.h @@ -41,7 +41,7 @@ gboolean get_pointer_xy(int *x, int *y); void centre_window(GdkWindow *window, int x, int y); void wink_widget(GtkWidget *widget); void destroy_on_idle(GtkWidget *widget); -gboolean rox_spawn(const gchar *dir, const gchar **argv); +gint rox_spawn(const gchar *dir, const gchar **argv); GtkWidget *button_new_mixed(const char *stock, const char *message); GtkWidget *button_new_image_text(GtkWidget *image, const char *message); void entry_set_error(GtkWidget *entry, gboolean error); diff --git a/ROX-Filer/src/main.c b/ROX-Filer/src/main.c index 7e59be8a..9c949ad6 100644 --- a/ROX-Filer/src/main.c +++ b/ROX-Filer/src/main.c @@ -444,6 +444,7 @@ int main(int argc, char **argv) */ if (!new_copy) { + int fd; pid_t child; child = fork(); @@ -452,13 +453,10 @@ int main(int argc, char **argv) /* Otherwise we're the child (or an error occurred - ignore * it!). */ - } - /* Close stdin. We don't need it, and it can cause problems if - * a child process wants a password, etc... - */ - { - int fd; + /* Close stdin. We don't need it, and it can cause problems if + * a child process wants a password, etc... + */ fd = open("/dev/null", O_RDONLY); if (fd > 0) { diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index 705d9f42..d9a6181b 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -992,7 +992,7 @@ static void refresh(gpointer data, guint action, GtkWidget *widget) { g_return_if_fail(window_with_focus != NULL); - full_refresh(); + filer_refresh(window_with_focus); } static void delete(FilerWindow *filer_window) diff --git a/ROX-Filer/src/remote.c b/ROX-Filer/src/remote.c index 5533dc6b..f58175fd 100644 --- a/ROX-Filer/src/remote.c +++ b/ROX-Filer/src/remote.c @@ -426,7 +426,12 @@ static gboolean client_event(GtkWidget *window, return FALSE; src_window = gdk_window_foreign_new(event->data.l[0]); - g_return_val_if_fail(src_window != NULL, FALSE); + if (!src_window) + { + g_warning("SOAP message sender window was destroyed before I \n" + "could read it."); + return FALSE; + } prop = gdk_x11_xatom_to_atom(event->data.l[1]); data = read_property(src_window, prop, &length); diff --git a/ROX-Filer/src/run.c b/ROX-Filer/src/run.c index 1adc63d1..e168084f 100644 --- a/ROX-Filer/src/run.c +++ b/ROX-Filer/src/run.c @@ -235,7 +235,7 @@ gboolean run_diritem(const guchar *full_path, argv[0] = full_path; - return rox_spawn(dir, argv); + return rox_spawn(dir, argv) != 0; } return open_file(full_path, edit ? text_plain diff --git a/ROX-Filer/src/toolbar.c b/ROX-Filer/src/toolbar.c index 3b3f2bc5..b2b15c09 100644 --- a/ROX-Filer/src/toolbar.c +++ b/ROX-Filer/src/toolbar.c @@ -305,7 +305,7 @@ static void toolbar_refresh_clicked(GtkWidget *widget, filer_opendir(filer_window->sym_path, filer_window, NULL); } else - full_refresh(); + filer_refresh(filer_window); } static void toolbar_home_clicked(GtkWidget *widget, FilerWindow *filer_window) diff --git a/ROX-Filer/src/type.c b/ROX-Filer/src/type.c index 4844e644..590247c4 100644 --- a/ROX-Filer/src/type.c +++ b/ROX-Filer/src/type.c @@ -391,7 +391,7 @@ gboolean type_open(const char *path, MIME_type *type) else argv[0] = open; - retval = rox_spawn(home_dir, (const gchar **) argv); + retval = rox_spawn(home_dir, (const gchar **) argv) != 0; if (argv[0] != open) g_free(argv[0]); -- 2.11.4.GIT