[gnome-builder] app: focus previous preferences window if available



commit b3cf55487e2ac0ea993a51631ac545483116cc34
Author: Christian Hergert <christian hergert me>
Date:   Tue Jan 13 13:28:23 2015 -0800

    app: focus previous preferences window if available
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742864

 src/app/gb-application.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 9541610..2a3b38e 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -28,6 +28,7 @@
 #include "gb-application.h"
 #include "gb-editor-file-marks.h"
 #include "gb-editor-workspace.h"
+#include "gb-glib.h"
 #include "gb-log.h"
 #include "gb-keybindings.h"
 #include "gb-preferences-window.h"
@@ -42,8 +43,9 @@
 
 struct _GbApplicationPrivate
 {
-  GbKeybindings *keybindings;
-  GSettings     *editor_settings;
+  GbKeybindings       *keybindings;
+  GSettings           *editor_settings;
+  GbPreferencesWindow *preferences_window;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (GbApplication, gb_application, GTK_TYPE_APPLICATION)
@@ -479,6 +481,12 @@ gb_application_activate_preferences_action (GSimpleAction *action,
 
   g_return_if_fail (GB_IS_APPLICATION (application));
 
+  if (application->priv->preferences_window)
+    {
+      gtk_window_present (GTK_WINDOW (application->priv->preferences_window));
+      return;
+    }
+
   list = gtk_application_get_windows (GTK_APPLICATION (application));
 
   for (; list; list = list->next)
@@ -488,6 +496,7 @@ gb_application_activate_preferences_action (GSimpleAction *action,
   window = g_object_new (GB_TYPE_PREFERENCES_WINDOW,
                          "transient-for", workbench,
                          NULL);
+  gb_set_weak_pointer (window, &application->priv->preferences_window);
 
   gtk_window_present (GTK_WINDOW (window));
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]