From 22e95624e61e2c1be3a41d5fa78a5eb1f539dcd1 Mon Sep 17 00:00:00 2001 From: Stephen Watson Date: Thu, 18 Sep 2003 14:59:39 +0000 Subject: [PATCH] r3043: Changed OpenDir according to Thomas's suggestions. OpenDir does not return a value, but you can use any string in the Window element instead. --- ROX-Filer/Help/Changes | 3 +-- ROX-Filer/src/Docs/Manual.xml | 6 +++--- ROX-Filer/src/filer.c | 23 +++++++++++++++++++++++ ROX-Filer/src/filer.h | 2 ++ ROX-Filer/src/remote.c | 20 ++++++-------------- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 66dfd666..7258d6d2 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -5,8 +5,7 @@ 18-Sep-2003 ~~~~~~~~~~~ Implementation of Free Space (Stephen Watson). OpenDir SOAP message now -returns a magic number in hex. Use this in the Window element of -subsequent OpenDir messages to re-use the window. +takes an optional Window element. Pass the same Window to re-use the window. 17-Sep-2003 ~~~~~~~~~~~ diff --git a/ROX-Filer/src/Docs/Manual.xml b/ROX-Filer/src/Docs/Manual.xml index f1c5293a..c47be02a 100644 --- a/ROX-Filer/src/Docs/Manual.xml +++ b/ROX-Filer/src/Docs/Manual.xml @@ -3054,9 +3054,9 @@ EOF Class can be used to set the WM_CLASS property on the new window. You can use this to get your window manager to treat the window specially. - Window is a magic token returned from a - previous OpenDir call and when given will -re-use an existing window, instead of opening a new one. + Window is a string used to identify the + opened window and when given will attempt to +re-use an existing window of the same name, instead of opening a new one. Panel(Side, diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index 554e126e..5d77e4b9 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -82,6 +82,8 @@ FilerWindow *window_with_focus = NULL; GList *all_filer_windows = NULL; +static GHashTable *windows_with_id = NULL; + static FilerWindow *window_with_primary = NULL; /* Static prototypes */ @@ -151,6 +153,9 @@ void filer_init(void) busy_cursor = gdk_cursor_new(GDK_WATCH); crosshair = gdk_cursor_new(GDK_CROSSHAIR); + windows_with_id = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, NULL); + /* Is the display on the local machine, or are we being * run remotely? See filer_set_title(). */ @@ -400,9 +405,17 @@ gboolean filer_window_delete(GtkWidget *window, return FALSE; } +static gboolean remove_this_window(gpointer key, gpointer value, + gpointer udata) +{ + return (value==udata); +} + static void filer_window_destroyed(GtkWidget *widget, FilerWindow *filer_window) { all_filer_windows = g_list_remove(all_filer_windows, filer_window); + g_hash_table_foreach_remove(windows_with_id, remove_this_window, + filer_window); g_object_set_data(G_OBJECT(widget), "filer_window", NULL); @@ -1663,6 +1676,16 @@ gboolean filer_exists(FilerWindow *filer_window) return FALSE; } +FilerWindow *filer_get_by_id(const char *id) +{ + return g_hash_table_lookup(windows_with_id, id); +} + +void filer_set_id(FilerWindow *fwin, const char *id) +{ + g_hash_table_insert(windows_with_id, id, fwin); +} + /* Make sure the window title is up-to-date */ void filer_set_title(FilerWindow *filer_window) { diff --git a/ROX-Filer/src/filer.h b/ROX-Filer/src/filer.h index 940f286f..365f36eb 100644 --- a/ROX-Filer/src/filer.h +++ b/ROX-Filer/src/filer.h @@ -117,6 +117,8 @@ void filer_close_recursive(const char *path); void filer_change_to(FilerWindow *filer_window, const char *path, const char *from); gboolean filer_exists(FilerWindow *filer_window); +FilerWindow *filer_get_by_id(const char *id); +void filer_set_id(FilerWindow *, const char *id); void filer_open_parent(FilerWindow *filer_window); void filer_detach_rescan(FilerWindow *filer_window); void filer_target_mode(FilerWindow *filer_window, diff --git a/ROX-Filer/src/remote.c b/ROX-Filer/src/remote.c index d985180f..76bdee48 100644 --- a/ROX-Filer/src/remote.c +++ b/ROX-Filer/src/remote.c @@ -574,21 +574,17 @@ static xmlNodePtr rpc_OpenDir(GList *args) char *path; char *style, *details, *sort, *class, *window; FilerWindow *fwin=NULL; - xmlNodePtr reply; - gchar *magic; path = string_value(ARG(0)); class = string_value(ARG(4)); window = string_value(ARG(5)); if(window) { - fwin=(FilerWindow *) strtoull(window, NULL, 16); - if(filer_exists(fwin)) - filer_change_to(fwin, path, NULL); - else - fwin=NULL; + fwin=filer_get_by_id(window); } if(!fwin) fwin = filer_opendir(path, NULL, class); + else + filer_change_to(fwin, path, NULL); g_free(path); g_free(class); if (!fwin) @@ -665,14 +661,10 @@ static xmlNodePtr rpc_OpenDir(GList *args) g_free(sort); } - reply = xmlNewNode(NULL, "rox:OpenDirResponse"); - magic = g_strdup_printf("%08x", fwin); - - xmlNewNs(reply, SOAP_RPC_NS, "soap"); - xmlNewChild(reply, NULL, "soap:result", magic); - g_free(magic); + if(window) + filer_set_id(fwin, window); - return reply; + return NULL; } static xmlNodePtr rpc_Run(GList *args) -- 2.11.4.GIT