Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] add 'role' for 'confirm_dialog' #774

Open
vp1981 opened this issue Jun 28, 2020 · 1 comment
Open

[FR] add 'role' for 'confirm_dialog' #774

vp1981 opened this issue Jun 28, 2020 · 1 comment

Comments

@vp1981
Copy link
Contributor

vp1981 commented Jun 28, 2020

Hello,
most but seems not all spacefm windows (dialogs) set specific 'role' XPROPERTY. One dialog that doesn't have the 'role' is confirm_dialog. The patch below sets the 'role' for it.

diff --git a/src/ptk/ptk-file-misc.c b/src/ptk/ptk-file-misc.c
index 3a42a0a..be3dde3 100644
--- a/src/ptk/ptk-file-misc.c
+++ b/src/ptk/ptk-file-misc.c
@@ -166,7 +166,8 @@ void ptk_delete_files( GtkWindow* parent_win,
                                       GTK_MESSAGE_WARNING,
                                       GTK_BUTTONS_YES_NO,
                                       msg, NULL );
-        gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_YES); //MOD
+        gtk_window_set_role ( GTK_WINDOW( dlg ), "confirm_dialog");
+        gtk_dialog_set_default_response (GTK_DIALOG( dlg ), GTK_RESPONSE_YES); //MOD
         gtk_window_set_title( GTK_WINDOW( dlg ), _("Confirm Delete") );
         xset_set_window_icon( GTK_WINDOW( dlg ) );
@vp1981
Copy link
Contributor Author

vp1981 commented Jun 28, 2020

Hello,
I also made patch to add 'role' property to other dialogs that haven't it.

From 58bccf7006e5fd75e1d8314a43ecc5d0db698fdd Mon Sep 17 00:00:00 2001
From: Vladimir Lomov <[email protected]>
Date: Sun, 28 Jun 2020 14:20:45 +0800
Subject: [PATCH 3/3] added 'role' property for several windows

Signed-off-by: Vladimir Lomov <[email protected]>
---
 src/find-files.c              | 2 ++
 src/pref-dialog.c             | 2 ++
 src/ptk/ptk-app-chooser.c     | 2 ++
 src/ptk/ptk-console-output.c  | 2 ++
 src/ptk/ptk-file-misc.c       | 3 ++-
 src/ptk/ptk-file-properties.c | 2 ++
 src/ptk/ptk-handler.c         | 2 ++
 src/ptk/ptk-input-dialog.c    | 2 ++
 src/ptk/ptk-utils.c           | 4 +++-
 9 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/find-files.c b/src/find-files.c
index cf14269..e9d3337 100644
--- a/src/find-files.c
+++ b/src/find-files.c
@@ -1028,6 +1028,8 @@ void fm_find_files( const char** search_dirs )
 #endif
     data->win = (GtkWidget*)gtk_builder_get_object( builder, "win" );
     g_object_set_data_full( G_OBJECT( data->win ), "find-files", data, (GDestroyNotify)free_data );
+    /// ???
+    gtk_window_set_role( GTK_WINDOW( data->win ), "find_dialog");
 
     GdkPixbuf* icon = NULL;
     GtkIconTheme* theme = gtk_icon_theme_get_default();
diff --git a/src/pref-dialog.c b/src/pref-dialog.c
index f414b46..1b74b2c 100644
--- a/src/pref-dialog.c
+++ b/src/pref-dialog.c
@@ -949,6 +949,8 @@ gboolean fm_edit_preference( GtkWindow* parent, int page )
         if ( parent )
             gtk_window_set_transient_for( GTK_WINDOW( dlg ), parent );
         xset_set_window_icon( GTK_WINDOW( dlg ) );
+	/// ???
+	gtk_window_set_role( GTK_WINDOW( dlg ), "pref_dialog");
 
         ptk_dialog_fit_small_screen( GTK_DIALOG( dlg ) );
         data->dlg = dlg;
diff --git a/src/ptk/ptk-app-chooser.c b/src/ptk/ptk-app-chooser.c
index 1b0aa3b..1da22a7 100644
--- a/src/ptk/ptk-app-chooser.c
+++ b/src/ptk/ptk-app-chooser.c
@@ -205,6 +205,8 @@ GtkWidget* app_chooser_dialog_new( GtkWindow* parent, VFSMimeType* mime_type,
     g_object_set_data_full( G_OBJECT(dlg), "builder", builder, (GDestroyNotify)g_object_unref );
 
     xset_set_window_icon( GTK_WINDOW( dlg ) );
+    /// ???
+    gtk_window_set_role( GTK_WINDOW( dlg ), "choose_dialog");
 
     gtk_dialog_set_alternative_button_order( GTK_DIALOG(dlg), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1 );
     ptk_dialog_fit_small_screen( GTK_DIALOG(dlg) );
diff --git a/src/ptk/ptk-console-output.c b/src/ptk/ptk-console-output.c
index 8853250..0b6a03d 100644
--- a/src/ptk/ptk-console-output.c
+++ b/src/ptk/ptk-console-output.c
@@ -160,6 +160,8 @@ int ptk_console_output_run( GtkWindow* parent_win,
                                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                             GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL );
     gtk_dialog_set_alternative_button_order( GTK_DIALOG(main_dlg), GTK_RESPONSE_CLOSE, GTK_RESPONSE_CANCEL, -1 );
+    /// ???
+    gtk_window_set_role( GTK_WINDOW( main_dlg ), "output_dialog");
 
     g_object_weak_ref( G_OBJECT(main_dlg), on_destroy, data );
 
diff --git a/src/ptk/ptk-file-misc.c b/src/ptk/ptk-file-misc.c
index 3a42a0a..be3dde3 100644
--- a/src/ptk/ptk-file-misc.c
+++ b/src/ptk/ptk-file-misc.c
@@ -166,7 +166,8 @@ void ptk_delete_files( GtkWindow* parent_win,
                                       GTK_MESSAGE_WARNING,
                                       GTK_BUTTONS_YES_NO,
                                       msg, NULL );
-        gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_YES); //MOD
+        gtk_window_set_role ( GTK_WINDOW( dlg ), "confirm_dialog");
+        gtk_dialog_set_default_response (GTK_DIALOG( dlg ), GTK_RESPONSE_YES); //MOD
         gtk_window_set_title( GTK_WINDOW( dlg ), _("Confirm Delete") );
         xset_set_window_icon( GTK_WINDOW( dlg ) );
 
diff --git a/src/ptk/ptk-file-properties.c b/src/ptk/ptk-file-properties.c
index 8aa8ae8..49ea466 100644
--- a/src/ptk/ptk-file-properties.c
+++ b/src/ptk/ptk-file-properties.c
@@ -331,6 +331,8 @@ GtkWidget* file_properties_dlg_new( GtkWindow* parent,
     GtkWidget * dlg = (GtkWidget*)gtk_builder_get_object( builder, "dlg" );
     GtkNotebook* notebook = (GtkNotebook*)gtk_builder_get_object( builder, "notebook" );
     xset_set_window_icon( GTK_WINDOW( dlg ) );
+    /// ???
+    gtk_window_set_role( GTK_WINDOW( dlg ), "property_dialog");
 
     FilePropertiesDialogData* data;
     gboolean need_calc_size = TRUE;
diff --git a/src/ptk/ptk-handler.c b/src/ptk/ptk-handler.c
index 5d00e66..c40596d 100644
--- a/src/ptk/ptk-handler.c
+++ b/src/ptk/ptk-handler.c
@@ -2972,6 +2972,8 @@ void ptk_handler_show_config( int mode, DesktopWindow* desktop,
 
     // Forcing dialog icon
     xset_set_window_icon( GTK_WINDOW( hnd->dlg ) );
+    /// ???
+    gtk_window_set_role( GTK_WINDOW( hnd->dlg ), "handler_dialog");
 
     // Setting saved dialog size
     int width = xset_get_int( handler_conf_xset[HANDLER_MODE_ARC], "x" );
diff --git a/src/ptk/ptk-input-dialog.c b/src/ptk/ptk-input-dialog.c
index d7c5015..5b6923a 100644
--- a/src/ptk/ptk-input-dialog.c
+++ b/src/ptk/ptk-input-dialog.c
@@ -36,6 +36,8 @@ GtkWidget* ptk_input_dialog_new( const char* title,
                                        GTK_RESPONSE_OK,
                                        NULL );
     gtk_dialog_set_alternative_button_order( GTK_DIALOG(dlg), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1 );
+    /// ???
+    gtk_window_set_role( GTK_WINDOW( dlg ), "input_dialog");
 
     box = gtk_dialog_get_content_area ( GTK_DIALOG(dlg) );
     label = gtk_label_new( prompt );
diff --git a/src/ptk/ptk-utils.c b/src/ptk/ptk-utils.c
index 51c5a30..b6c8a46 100644
--- a/src/ptk/ptk-utils.c
+++ b/src/ptk/ptk-utils.c
@@ -205,7 +205,9 @@ void ptk_show_error(GtkWindow* parent, const char* title, const char* message )
     if( title )
         gtk_window_set_title( (GtkWindow*)dlg, title );
     xset_set_window_icon( GTK_WINDOW( dlg ) );
-    gtk_dialog_run( GTK_DIALOG(dlg) );
+    /// ???
+    gtk_window_set_role( GTK_WINDOW( dlg ), "error_dialog");
+    gtk_dialog_run( GTK_DIALOG( dlg ) );
     gtk_widget_destroy( dlg );
 }
 
-- 
2.27.0

I'm sure that I didn't cover all cases where dialogs are used and not sure if setting 'role' property hasn't any side effects.

P.S. For those who interested why I need them this is the story. I'm using AwesomeWM and 'quake' library to make spacefm quake-alike application (hide and show on keystroke). The library uses 'instance' to know what window to operate on. Unfortunately, all windows and dialogs that spacefm creates share the same 'instance' but some of them has 'role' property. I changed 'quake' library a bit (see this feature request) so now it uses 'role' if it was set. Now if all dialogs would have 'role' they could be distinguished from "main" spacefm window and I could set different properties on them (size and position).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant