[gnome-builder] prefs: add IdePreferencesWindow



commit 15efd9e34cc2efe8bad7267a46ebabda1ec10228
Author: Christian Hergert <chergert redhat com>
Date:   Mon Sep 25 19:56:52 2017 -0700

    prefs: add IdePreferencesWindow
    
    This will simplify things going forward so we can use templates
    for the window and upcoming CSD headerbar.

 src/libide/application/ide-application-actions.c |   27 +++++---------
 src/libide/ide.h                                 |    1 +
 src/libide/libide.gresource.xml                  |    1 +
 src/libide/preferences/ide-preferences-window.c  |   42 ++++++++++++++++++++++
 src/libide/preferences/ide-preferences-window.h  |   29 +++++++++++++++
 src/libide/preferences/ide-preferences-window.ui |   10 +++++
 src/libide/preferences/meson.build               |    2 +
 7 files changed, 94 insertions(+), 18 deletions(-)
---
diff --git a/src/libide/application/ide-application-actions.c 
b/src/libide/application/ide-application-actions.c
index bac81ef..bb47577 100644
--- a/src/libide/application/ide-application-actions.c
+++ b/src/libide/application/ide-application-actions.c
@@ -33,7 +33,7 @@
 #include "application/ide-application-private.h"
 #include "greeter/ide-greeter-perspective.h"
 #include "keybindings/ide-shortcuts-window.h"
-#include "preferences/ide-preferences-perspective.h"
+#include "preferences/ide-preferences-window.h"
 #include "workbench/ide-workbench.h"
 #include "util/ide-flatpak.h"
 
@@ -43,10 +43,9 @@ ide_application_actions_preferences (GSimpleAction *action,
                                      gpointer       user_data)
 {
   IdeApplication *self = user_data;
-  IdePreferencesPerspective *perspective;
-  GList *windows;
   GtkWindow *toplevel = NULL;
   GtkWindow *window;
+  GList *windows;
 
   IDE_ENTRY;
 
@@ -59,38 +58,30 @@ ide_application_actions_preferences (GSimpleAction *action,
   windows = gtk_application_get_windows (GTK_APPLICATION (self));
   for (; windows != NULL; windows = windows->next)
     {
-      GtkWindow *ele = windows->data;
+      GtkWindow *win = windows->data;
 
-      if (g_object_get_data (G_OBJECT (ele), "PREFERENCES"))
+      if (IDE_IS_PREFERENCES_WINDOW (win))
         {
-          gtk_window_present (ele);
+          gtk_window_present (win);
           return;
         }
 
-      if (toplevel == NULL && IDE_IS_WORKBENCH (ele))
-        toplevel = ele;
+      if (toplevel == NULL && IDE_IS_WORKBENCH (win))
+        toplevel = win;
     }
 
   /* Create a new window for preferences, with enough space for
    * 2 columns of preferences. The window manager will automatically
    * maximize the window if necessary.
    */
-  window = g_object_new (GTK_TYPE_WINDOW,
+  window = g_object_new (IDE_TYPE_PREFERENCES_WINDOW,
                          "transient-for", toplevel,
-                         "title", _("Preferences"),
                          "default-width", 1300,
                          "default-height", 800,
                          "window-position", GTK_WIN_POS_CENTER_ON_PARENT,
                          NULL);
-  g_object_set_data (G_OBJECT (window), "PREFERENCES", "1");
   gtk_application_add_window (GTK_APPLICATION (self), window);
-
-  perspective = g_object_new (IDE_TYPE_PREFERENCES_PERSPECTIVE,
-                              "visible", TRUE,
-                              NULL);
-  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (perspective));
-
-  gtk_window_present (GTK_WINDOW (window));
+  gtk_window_present (window);
 
   IDE_EXIT;
 }
diff --git a/src/libide/ide.h b/src/libide/ide.h
index d911cfa..065ba9f 100644
--- a/src/libide/ide.h
+++ b/src/libide/ide.h
@@ -120,6 +120,7 @@ G_BEGIN_DECLS
 #include "logging/ide-log.h"
 #include "preferences/ide-preferences-addin.h"
 #include "preferences/ide-preferences-perspective.h"
+#include "preferences/ide-preferences-window.h"
 #include "projects/ide-project-edit.h"
 #include "projects/ide-project-file.h"
 #include "projects/ide-project-files.h"
diff --git a/src/libide/libide.gresource.xml b/src/libide/libide.gresource.xml
index 26f115d..a060e6a 100644
--- a/src/libide/libide.gresource.xml
+++ b/src/libide/libide.gresource.xml
@@ -79,6 +79,7 @@
     <file preprocess="xml-stripblanks" alias="ide-omni-bar.ui">workbench/ide-omni-bar.ui</file>
     <file preprocess="xml-stripblanks" 
alias="ide-omni-pausable-row.ui">workbench/ide-omni-pausable-row.ui</file>
     <file preprocess="xml-stripblanks" 
alias="ide-preferences-language-row.ui">preferences/ide-preferences-language-row.ui</file>
+    <file preprocess="xml-stripblanks" 
alias="ide-preferences-window.ui">preferences/ide-preferences-window.ui</file>
     <file preprocess="xml-stripblanks" alias="ide-run-button.ui">runner/ide-run-button.ui</file>
     <file preprocess="xml-stripblanks" alias="ide-transfer-row.ui">transfers/ide-transfer-row.ui</file>
     <file preprocess="xml-stripblanks" 
alias="ide-transfers-button.ui">transfers/ide-transfers-button.ui</file>
diff --git a/src/libide/preferences/ide-preferences-window.c b/src/libide/preferences/ide-preferences-window.c
new file mode 100644
index 0000000..03df883
--- /dev/null
+++ b/src/libide/preferences/ide-preferences-window.c
@@ -0,0 +1,42 @@
+/* ide-preferences-window.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define G_LOG_DOMAIN "ide-preferences-window"
+
+#include "ide-preferences-window.h"
+
+struct _IdePreferencesWindow
+{
+  GtkWindow parent_instance;
+};
+
+G_DEFINE_TYPE (IdePreferencesWindow, ide_preferences_window, GTK_TYPE_WINDOW)
+
+static void
+ide_preferences_window_class_init (IdePreferencesWindowClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/ui/ide-preferences-window.ui");
+}
+
+static void
+ide_preferences_window_init (IdePreferencesWindow *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/libide/preferences/ide-preferences-window.h b/src/libide/preferences/ide-preferences-window.h
new file mode 100644
index 0000000..25b2dfd
--- /dev/null
+++ b/src/libide/preferences/ide-preferences-window.h
@@ -0,0 +1,29 @@
+/* ide-preferences-window.h
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_PREFERENCES_WINDOW (ide_preferences_window_get_type())
+
+G_DECLARE_FINAL_TYPE (IdePreferencesWindow, ide_preferences_window, IDE, PREFERENCES_WINDOW, GtkWindow)
+
+G_END_DECLS
diff --git a/src/libide/preferences/ide-preferences-window.ui 
b/src/libide/preferences/ide-preferences-window.ui
new file mode 100644
index 0000000..4d926b2
--- /dev/null
+++ b/src/libide/preferences/ide-preferences-window.ui
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="IdePreferencesWindow" parent="GtkWindow">
+    <child>
+      <object class="IdePreferencesPerspective" id="perspective">
+        <property name="visible">true</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/libide/preferences/meson.build b/src/libide/preferences/meson.build
index cd770d4..3cdc92e 100644
--- a/src/libide/preferences/meson.build
+++ b/src/libide/preferences/meson.build
@@ -1,11 +1,13 @@
 preferences_headers = [
   'ide-preferences-addin.h',
   'ide-preferences-perspective.h',
+  'ide-preferences-window.h',
 ]
 
 preferences_sources = [
   'ide-preferences-addin.c',
   'ide-preferences-perspective.c',
+  'ide-preferences-window.c',
 ]
 
 preferences_private_sources = [


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