From a1896c559a087d24ccbff6f53a90196e072a47b4 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 30 Aug 2002 14:29:27 +0000 Subject: [PATCH] r1859: New 'Class' parameter to Filer_OpenDir SOAP method allows setting the WM_CLASS of a new window so that the window manager can treat it specially, such as opening it in a certain place, or make it sticky (requested by Matthew Weier O'Phinney). --- ROX-Filer/Help/Changes | 7 +++++++ ROX-Filer/src/Docs/Manual.xml | 5 ++++- ROX-Filer/src/abox.c | 2 +- ROX-Filer/src/action.c | 2 +- ROX-Filer/src/dnd.c | 2 +- ROX-Filer/src/filer.c | 12 +++++++----- ROX-Filer/src/filer.h | 2 +- ROX-Filer/src/menu.c | 8 ++++---- ROX-Filer/src/remote.c | 10 ++++++---- ROX-Filer/src/run.c | 10 +++++----- ROX-Filer/src/toolbar.c | 8 ++++---- ROX-Filer/src/type.c | 6 +++--- ROX-Filer/src/usericons.c | 2 +- 13 files changed, 45 insertions(+), 31 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 06aac75f..44c64ab7 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -2,6 +2,13 @@ A RISC OS-like filer for X by Thomas Leonard +30-Aug-2002 +~~~~~~~~~~~ +New 'Class' parameter to Filer_OpenDir SOAP method allows setting the +WM_CLASS of a new window so that the window manager can treat it +specially, such as opening it in a certain place, or make it sticky +(requested by Matthew Weier O'Phinney). + 27-Aug-2002 ~~~~~~~~~~~ New option to set the pinboard font (Krzysztof Luks). diff --git a/ROX-Filer/src/Docs/Manual.xml b/ROX-Filer/src/Docs/Manual.xml index dff574e8..2a107320 100644 --- a/ROX-Filer/src/Docs/Manual.xml +++ b/ROX-Filer/src/Docs/Manual.xml @@ -3429,13 +3429,16 @@ EOF OpenDir(Filename, - [Style, Details, Sort]) + [Style, Details, Sort, + Class]) Open a window showing directory Filename. Style is one of Large, Small or Huge. Details is one of None, Summary, Size, Type, Times or Permissions. Sort is one of Name, Type, Date or Size. If any of these three option parameters are missing, the default is used. + 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. Panel(Side, diff --git a/ROX-Filer/src/abox.c b/ROX-Filer/src/abox.c index 278293e0..e2fda950 100644 --- a/ROX-Filer/src/abox.c +++ b/ROX-Filer/src/abox.c @@ -346,7 +346,7 @@ static void select_row_callback(GtkTreeView *treeview, goto out; } - abox->preview = filer_opendir(dir, NULL); + abox->preview = filer_opendir(dir, NULL, NULL); if (abox->preview) { display_set_autoselect(abox->preview, leaf); diff --git a/ROX-Filer/src/action.c b/ROX-Filer/src/action.c index 5084e4bd..250aa966 100644 --- a/ROX-Filer/src/action.c +++ b/ROX-Filer/src/action.c @@ -348,7 +348,7 @@ static void process_message(GUIside *gui_side, const gchar *buffer) else if (*buffer == '/') abox_set_current_object(abox, buffer + 1); else if (*buffer == 'o') - filer_opendir(buffer + 1, NULL); + filer_opendir(buffer + 1, NULL, NULL); else if (*buffer == '!') { gui_side->errors++; diff --git a/ROX-Filer/src/dnd.c b/ROX-Filer/src/dnd.c index 4dd95bf1..d0402ca0 100644 --- a/ROX-Filer/src/dnd.c +++ b/ROX-Filer/src/dnd.c @@ -1076,7 +1076,7 @@ static gboolean spring_now(gpointer data) } else { - spring_window = filer_opendir(dest_path, spring_src_window); + spring_window = filer_opendir(dest_path, spring_src_window, NULL); if (spring_window) { gtk_timeout_add(500, spring_check_idle, NULL); diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index bef7bbdc..54bb2577 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -86,7 +86,7 @@ static void set_scanning_display(FilerWindow *filer_window, gboolean scanning); static gboolean may_rescan(FilerWindow *filer_window, gboolean warning); static gboolean minibuffer_show_cb(FilerWindow *filer_window); static FilerWindow *find_filer_window(const char *sym_path, FilerWindow *diff); -static void filer_add_widgets(FilerWindow *filer_window); +static void filer_add_widgets(FilerWindow *filer_window, const gchar *wm_class); static void filer_add_signals(FilerWindow *filer_window); static void set_selection_state(FilerWindow *filer_window, gboolean normal); @@ -877,7 +877,7 @@ void filer_open_parent(FilerWindow *filer_window) return; /* Already in the root */ dir = g_dirname(current); - filer_opendir(dir, filer_window); + filer_opendir(dir, filer_window, NULL); g_free(dir); } @@ -1024,7 +1024,7 @@ DirItem *filer_selected_item(FilerWindow *filer_window) * Returns the new filer window, or NULL on error. * Note: if unique windows is in use, may return an existing window. */ -FilerWindow *filer_opendir(const char *path, FilerWindow *src_win) +FilerWindow *filer_opendir(const char *path, FilerWindow *src_win, const gchar *wm_class) { FilerWindow *filer_window; char *real_path; @@ -1113,7 +1113,7 @@ FilerWindow *filer_opendir(const char *path, FilerWindow *src_win) } /* Add all the user-interface elements & realise */ - filer_add_widgets(filer_window); + filer_add_widgets(filer_window, wm_class); if (src_win) gtk_window_set_position(GTK_WINDOW(filer_window->window), GTK_WIN_POS_MOUSE); @@ -1155,13 +1155,15 @@ FilerWindow *filer_opendir(const char *path, FilerWindow *src_win) /* This adds all the widgets to a new filer window. It is in a separate * function because filer_opendir() was getting too long... */ -static void filer_add_widgets(FilerWindow *filer_window) +static void filer_add_widgets(FilerWindow *filer_window, const gchar *wm_class) { GtkWidget *hbox, *vbox; /* Create the top-level window widget */ filer_window->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); filer_set_title(filer_window); + if (wm_class) + gtk_window_set_wmclass(GTK_WINDOW(filer_window->window), wm_class, PROJECT); /* This property is cleared when the window is destroyed. * You can thus ref filer_window->window and use this to see diff --git a/ROX-Filer/src/filer.h b/ROX-Filer/src/filer.h index c9cbe0dc..b5240a70 100644 --- a/ROX-Filer/src/filer.h +++ b/ROX-Filer/src/filer.h @@ -95,7 +95,7 @@ extern Option o_filer_size_limit; /* Prototypes */ void filer_init(void); -FilerWindow *filer_opendir(const char *path, FilerWindow *src_win); +FilerWindow *filer_opendir(const char *path, FilerWindow *src_win, const gchar *wm_class); void filer_update_dir(FilerWindow *filer_window, gboolean warning); void filer_update_all(void); DirItem *filer_selected_item(FilerWindow *filer_window); diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index 09041315..d4a4741e 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -1180,7 +1180,7 @@ static void run_action(DirItem *item) void open_home(gpointer data, guint action, GtkWidget *widget) { - filer_opendir(home_dir, NULL); + filer_opendir(home_dir, NULL, NULL); } static void open_vfs_avfs(FilerWindow *filer_window, DirItem *item) @@ -1415,7 +1415,7 @@ static void customise_send_to(gpointer data) g_string_free(dirs, TRUE); if (save) - filer_opendir(save, NULL); + filer_opendir(save, NULL, NULL); } /* Add everything in the directory /SendTo/[.type[_subtype]] @@ -1582,7 +1582,7 @@ static void new_window(gpointer data, guint action, GtkWidget *widget) "is turned on in the Options window.")); } else - filer_opendir(window_with_focus->sym_path, window_with_focus); + filer_opendir(window_with_focus->sym_path, window_with_focus, NULL); } #if 0 @@ -1693,7 +1693,7 @@ void menu_rox_help(gpointer data, guint action, GtkWidget *widget) if (action == HELP_ABOUT) infobox_new(app_dir); else if (action == HELP_DIR) - filer_opendir(make_path(app_dir, "Help")->str, NULL); + filer_opendir(make_path(app_dir, "Help")->str, NULL, NULL); else if (action == HELP_MANUAL) { gchar *manual = NULL; diff --git a/ROX-Filer/src/remote.c b/ROX-Filer/src/remote.c index 0ee5700a..ea0d4a7c 100644 --- a/ROX-Filer/src/remote.c +++ b/ROX-Filer/src/remote.c @@ -121,7 +121,7 @@ gboolean remote_init(xmlDocPtr rpc, gboolean new_copy) soap_register("Version", rpc_Version, NULL, NULL); soap_register("Run", rpc_Run, "Filename", NULL); - soap_register("OpenDir", rpc_OpenDir, "Filename", "Style,Details,Sort"); + soap_register("OpenDir", rpc_OpenDir, "Filename", "Style,Details,Sort,Class"); soap_register("CloseDir", rpc_CloseDir, "Filename", NULL); soap_register("Examine", rpc_Examine, "Filename", NULL); soap_register("Show", rpc_Show, "Directory,Leafname", NULL); @@ -554,20 +554,22 @@ static xmlNodePtr rpc_Version(GList *args) return reply; } -/* Args: Path, [Style, Details, Sort] */ +/* Args: Path, [Style, Details, Sort, Class] */ static xmlNodePtr rpc_OpenDir(GList *args) { char *path; - char *style, *details, *sort; + char *style, *details, *sort, *class; FilerWindow *fwin; path = string_value(ARG(0)); style = string_value(ARG(1)); details = string_value(ARG(2)); sort = string_value(ARG(3)); + class = string_value(ARG(4)); - fwin = filer_opendir(path, NULL); + fwin = filer_opendir(path, NULL, class); g_free(path); + g_free(class); if (style) { diff --git a/ROX-Filer/src/run.c b/ROX-Filer/src/run.c index 3360a52c..4e0752a0 100644 --- a/ROX-Filer/src/run.c +++ b/ROX-Filer/src/run.c @@ -228,7 +228,7 @@ gboolean run_diritem(const guchar *full_path, if (filer_window) filer_change_to(filer_window, full_path, NULL); else - filer_opendir(full_path, src_window); + filer_opendir(full_path, src_window, NULL); return TRUE; case TYPE_FILE: if ((item->mime_type == application_executable) && !edit) @@ -348,14 +348,14 @@ void open_to_show(const guchar *path) if (slash == dir || !slash) { /* Item in the root (or root itself!) */ - new = filer_opendir("/", NULL); + new = filer_opendir("/", NULL, NULL); if (new && dir[1]) display_set_autoselect(new, dir + 1); } else { *slash = '\0'; - new = filer_opendir(dir, NULL); + new = filer_opendir(dir, NULL, NULL); if (new) { if (slash[1] == '.') @@ -488,7 +488,7 @@ static gboolean follow_symlink(const char *full_path, { FilerWindow *new; - new = filer_opendir(new_dir, src_window); + new = filer_opendir(new_dir, src_window, NULL); if (new) display_set_autoselect(new, slash + 1); } @@ -528,7 +528,7 @@ static void dir_show_help(DirItem *item, const char *path) help_dir = g_strconcat(path, "/Help", NULL); if (mc_stat(help_dir, &info) == 0) - filer_opendir(help_dir, NULL); + filer_opendir(help_dir, NULL, NULL); else if (item->flags & ITEM_FLAG_APPDIR) info_message( _("Application:\n" diff --git a/ROX-Filer/src/toolbar.c b/ROX-Filer/src/toolbar.c index 6976c592..9ee1bee6 100644 --- a/ROX-Filer/src/toolbar.c +++ b/ROX-Filer/src/toolbar.c @@ -306,7 +306,7 @@ static void toolbar_help_clicked(GtkWidget *widget, FilerWindow *filer_window) filer_change_to(filer_window, make_path(app_dir, "Help")->str, NULL); else - filer_opendir(make_path(app_dir, "Help")->str, NULL); + filer_opendir(make_path(app_dir, "Help")->str, NULL, NULL); } static void toolbar_refresh_clicked(GtkWidget *widget, @@ -318,7 +318,7 @@ static void toolbar_refresh_clicked(GtkWidget *widget, if (event->type == GDK_BUTTON_RELEASE && ((GdkEventButton *) event)->button != 1) { - filer_opendir(filer_window->sym_path, filer_window); + filer_opendir(filer_window->sym_path, filer_window, NULL); } else { @@ -334,7 +334,7 @@ static void toolbar_home_clicked(GtkWidget *widget, FilerWindow *filer_window) event = gtk_get_current_event(); if (event->type == GDK_BUTTON_RELEASE && NEW_WIN_BUTTON(event)) { - filer_opendir(home_dir, filer_window); + filer_opendir(home_dir, filer_window, NULL); } else filer_change_to(filer_window, home_dir, NULL); @@ -350,7 +350,7 @@ static void toolbar_close_clicked(GtkWidget *widget, FilerWindow *filer_window) if (event->type == GDK_BUTTON_RELEASE && ((GdkEventButton *) event)->button != 1) { - filer_opendir(filer_window->sym_path, filer_window); + filer_opendir(filer_window->sym_path, filer_window, NULL); } else gtk_widget_destroy(filer_window->window); diff --git a/ROX-Filer/src/type.c b/ROX-Filer/src/type.c index 03ce4597..447b59cc 100644 --- a/ROX-Filer/src/type.c +++ b/ROX-Filer/src/type.c @@ -995,15 +995,15 @@ static void edit_mime_types(guchar *unused) mkdir(make_path(home_dir, ".mime")->str, 0700); path = make_path(home_dir, ".mime/packages")->str; mkdir(path, 0700); - filer_opendir(path, NULL); + filer_opendir(path, NULL, NULL); path = "/usr/local/share/mime/packages"; if (mc_stat(path, &info) == 0) - filer_opendir(path, NULL); + filer_opendir(path, NULL, NULL); path = "/usr/share/mime/packages"; if (mc_stat(path, &info) == 0) - filer_opendir(path, NULL); + filer_opendir(path, NULL, NULL); } static GList *build_type_edit(Option *none, xmlNode *node, guchar *label) diff --git a/ROX-Filer/src/usericons.c b/ROX-Filer/src/usericons.c index 1d3bc203..c66b3ac2 100644 --- a/ROX-Filer/src/usericons.c +++ b/ROX-Filer/src/usericons.c @@ -661,7 +661,7 @@ static void open_icon_dir(GtkMenuItem *item, gpointer data) const char *dir; dir = gtk_label_get_text(GTK_LABEL(GTK_BIN(item)->child)); - filer = filer_opendir(dir, NULL); + filer = filer_opendir(dir, NULL, NULL); if (filer) display_set_thumbs(filer, TRUE); } -- 2.11.4.GIT