[Xfce4-commits] [xfce/xfce4-settings] 01/01: Make minimal dialog single instance (Bug #11169)

noreply at xfce.org noreply at xfce.org
Wed Jun 14 03:14:01 CEST 2017


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-settings.

commit 786c0dc49dd10b092d1bf6d91223d8e148800146
Author: Andre Miranda <andre42m at gmail.com>
Date:   Tue Feb 7 23:29:08 2017 -0300

    Make minimal dialog single instance (Bug #11169)
    
    Signed-off-by: Sean Davis <smd.seandavis at gmail.com>
---
 dialogs/display-settings/main.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index cf4d86c..3d96df1 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -2882,6 +2882,7 @@ display_settings_show_minimal_dialog (GdkDisplay *display)
     GError     *error = NULL;
     gboolean    found = FALSE;
     RRMode      mode;
+    GtkApplication *app;
 
     builder = gtk_builder_new ();
 
@@ -2968,6 +2969,24 @@ display_settings_show_minimal_dialog (GdkDisplay *display)
             gtk_widget_set_sensitive (GTK_WIDGET (only_display2), FALSE);
         }
 
+        /* Initialize application to ensure single instance */
+        app = gtk_application_new ("org.xfce.display.settings", 0);
+
+        g_application_register (G_APPLICATION (app), NULL, &error);
+        if (error != NULL)
+          {
+            g_warning ("Unable to register GApplication: %s", error->message);
+            g_error_free (error);
+            error = NULL;
+          }
+
+        if (g_application_get_is_remote (G_APPLICATION (app)))
+          {
+            g_application_activate (G_APPLICATION (app));
+            g_object_unref (app);
+            return;
+          }
+
         g_signal_connect (only_display1, "toggled", G_CALLBACK (display_settings_minimal_only_display1_toggled),
                           builder);
         g_signal_connect (mirror_displays, "toggled", G_CALLBACK (display_settings_minimal_mirror_displays_toggled),
@@ -2979,6 +2998,8 @@ display_settings_show_minimal_dialog (GdkDisplay *display)
         g_signal_connect (advanced, "clicked", G_CALLBACK (display_settings_minimal_advanced_clicked),
                           builder);
 
+        g_signal_connect_swapped (app, "activate", G_CALLBACK (gtk_window_present), dialog);
+
         /* Show the minimal dialog and start the main loop */
         gtk_window_present (GTK_WINDOW (dialog));
         gtk_main ();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list