[gnome-builder] prefs: move style scheme and grid pattern to new Theme section



commit bf17b2e3e6f1e8c9de6241f02d92007728924f10
Author: Christian Hergert <christian hergert me>
Date:   Sat May 16 04:13:48 2015 -0700

    prefs: move style scheme and grid pattern to new Theme section

 data/ui/gb-preferences-page-editor.ui        |   39 --------
 data/ui/gb-preferences-page-theme.ui         |   42 +++++++++
 data/ui/gb-preferences-window.ui             |   10 ++
 src/Makefile.am                              |    2 +
 src/preferences/gb-preferences-page-editor.c |   53 -----------
 src/preferences/gb-preferences-page-theme.c  |  122 ++++++++++++++++++++++++++
 src/preferences/gb-preferences-page-theme.h  |   33 +++++++
 src/preferences/gb-preferences-window.c      |    2 +
 src/resources/gnome-builder.gresource.xml    |    1 +
 9 files changed, 212 insertions(+), 92 deletions(-)
---
diff --git a/data/ui/gb-preferences-page-editor.ui b/data/ui/gb-preferences-page-editor.ui
index 4a8a837..ce51d2a 100644
--- a/data/ui/gb-preferences-page-editor.ui
+++ b/data/ui/gb-preferences-page-editor.ui
@@ -34,45 +34,6 @@
               </object>
             </child>
             <child>
-              <object class="GtkLabel" id="style_scheme_label">
-                <property name="visible">true</property>
-                <property name="label" translatable="yes">Styling</property>
-                <property name="xalign">0.0</property>
-                <property name="margin-top">12</property>
-                <property name="margin-bottom">6</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="style_scheme_container">
-                <property name="margin">6</property>
-                <property name="visible">true</property>
-                <property name="vexpand">true</property>
-                <property name="min-content-height">150</property>
-                <property name="shadow-type">in</property>
-                <child>
-                  <object class="GtkSourceStyleSchemeChooserWidget" id="style_scheme_widget">
-                    <property name="visible">true</property>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child>
-              <object class="GbPreferencesSwitch" id="show_grid_lines_switch">
-                <property name="title" translatable="yes">Display Grid Pattern</property>
-                <property name="description" translatable="yes">Display a grid pattern under the source 
code.</property>
-                <property name="settings">editor_settings</property>
-                <property name="settings-schema-key">show-grid-lines</property>
-                <property name="size-group">control_group</property>
-                <property name="visible">true</property>
-              </object>
-            </child>
-            <child>
               <object class="GtkLabel">
                 <property name="visible">true</property>
                 <property name="label" translatable="yes">Highlighting</property>
diff --git a/data/ui/gb-preferences-page-theme.ui b/data/ui/gb-preferences-page-theme.ui
new file mode 100644
index 0000000..4b59697
--- /dev/null
+++ b/data/ui/gb-preferences-page-theme.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="GbPreferencesPageTheme" parent="GbPreferencesPage">
+    <property name="title" translatable="yes">Theme</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">true</property>
+        <property name="hscrollbar-policy">never</property>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">true</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GbPreferencesSwitch" id="show_grid_lines_switch">
+                <property name="title" translatable="yes">Display Grid Pattern</property>
+                <property name="description" translatable="yes">Display a grid pattern under the source 
code.</property>
+                <property name="settings">editor_settings</property>
+                <property name="settings-schema-key">show-grid-lines</property>
+                <property name="size-group">control_group</property>
+                <property name="visible">true</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkSourceStyleSchemeChooserWidget" id="style_scheme_widget">
+                <property name="margin-top">6</property>
+                <property name="visible">true</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+  <object class="GSettings" id="editor_settings">
+    <property name="schema-id">org.gnome.builder.editor</property>
+  </object>
+  <object class="GtkSizeGroup" id="control_group">
+    <property name="mode">horizontal</property>
+  </object>
+</interface>
diff --git a/data/ui/gb-preferences-window.ui b/data/ui/gb-preferences-window.ui
index 4f6a515..027739b 100644
--- a/data/ui/gb-preferences-window.ui
+++ b/data/ui/gb-preferences-window.ui
@@ -155,6 +155,16 @@
               </packing>
             </child>
             <child>
+              <object class="GbPreferencesPageTheme" id="theme_page">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+              </object>
+              <packing>
+                <property name="name">theme</property>
+                <property name="title" translatable="yes">Theme</property>
+              </packing>
+            </child>
+            <child>
               <object class="GbPreferencesPageGit" id="git_page">
                 <property name="visible">True</property>
                 <property name="border_width">12</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index 5706e28..b9e539e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -94,6 +94,8 @@ libgnome_builder_la_SOURCES = \
        preferences/gb-preferences-page-keybindings.h \
        preferences/gb-preferences-page-language.c \
        preferences/gb-preferences-page-language.h \
+       preferences/gb-preferences-page-theme.c \
+       preferences/gb-preferences-page-theme.h \
        preferences/gb-preferences-page.c \
        preferences/gb-preferences-page.h \
        preferences/gb-preferences-switch.c \
diff --git a/src/preferences/gb-preferences-page-editor.c b/src/preferences/gb-preferences-page-editor.c
index 60ac090..8f23546 100644
--- a/src/preferences/gb-preferences-page-editor.c
+++ b/src/preferences/gb-preferences-page-editor.c
@@ -34,11 +34,8 @@ struct _GbPreferencesPageEditor
   GtkSwitch                         *show_line_numbers_switch;
   GtkSwitch                         *highlight_current_line_switch;
   GtkSwitch                         *highlight_matching_brackets_switch;
-  GtkSwitch                         *show_grid_lines_switch;
   GtkSpinButton                     *scroll_off_spin;
   GtkFontButton                     *font_button;
-  GtkSourceStyleSchemeChooserWidget *style_scheme_widget;
-  GtkScrolledWindow                 *style_scheme_container;
   GtkAdjustment                     *scroll_off_adjustment;
   GtkBox                            *scroll_off_container;
   GtkWidget                         *auto_hide_map_switch;
@@ -48,32 +45,9 @@ struct _GbPreferencesPageEditor
 G_DEFINE_TYPE (GbPreferencesPageEditor, gb_preferences_page_editor, GB_TYPE_PREFERENCES_PAGE)
 
 static void
-gb_preferences_page_editor_style_scheme_changed (GtkSourceStyleSchemeChooser *chooser,
-                                                 GParamSpec                  *pspec,
-                                                 GSettings                   *settings)
-{
-  GtkSourceStyleScheme *scheme;
-  const gchar *scheme_id;
-
-  g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME_CHOOSER (chooser));
-  g_return_if_fail (G_IS_SETTINGS (settings));
-
-  scheme = gtk_source_style_scheme_chooser_get_style_scheme (chooser);
-
-  if (scheme)
-    {
-      scheme_id = gtk_source_style_scheme_get_id (scheme);
-      g_settings_set_string (settings, "style-scheme-name", scheme_id);
-    }
-}
-
-static void
 gb_preferences_page_editor_constructed (GObject *object)
 {
   GbPreferencesPageEditor *self = (GbPreferencesPageEditor *)object;
-  GtkSourceStyleSchemeManager *manager;
-  GtkSourceStyleScheme *scheme;
-  gchar *scheme_id;
 
   g_assert (GB_IS_PREFERENCES_PAGE_EDITOR (self));
 
@@ -85,20 +59,6 @@ gb_preferences_page_editor_constructed (GObject *object)
   g_settings_bind (self->editor_settings, "font-name",
                    self->font_button, "font-name",
                    G_SETTINGS_BIND_DEFAULT);
-
-  scheme_id = g_settings_get_string (self->editor_settings, "style-scheme-name");
-  manager = gtk_source_style_scheme_manager_get_default ();
-  scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
-  g_free (scheme_id);
-
-  gtk_source_style_scheme_chooser_set_style_scheme (
-      GTK_SOURCE_STYLE_SCHEME_CHOOSER (self->style_scheme_widget),
-      scheme);
-  g_signal_connect_object (self->style_scheme_widget,
-                           "notify::style-scheme",
-                           G_CALLBACK (gb_preferences_page_editor_style_scheme_changed),
-                           self->editor_settings,
-                           0);
 }
 
 static void
@@ -122,10 +82,7 @@ gb_preferences_page_editor_class_init (GbPreferencesPageEditorClass *klass)
   GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, scroll_off_container);
   GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, scroll_off_spin);
   GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, show_diff_switch);
-  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, show_grid_lines_switch);
   GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, show_line_numbers_switch);
-  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, style_scheme_container);
-  GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, style_scheme_widget);
 }
 
 static void
@@ -160,11 +117,6 @@ gb_preferences_page_editor_init (GbPreferencesPageEditor *self)
                                                NULL);
   gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
   /* To translators: This is a list of keywords for the preferences page */
-                                               _("show grid lines"),
-                                               self->show_grid_lines_switch,
-                                               NULL);
-  gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
-  /* To translators: This is a list of keywords for the preferences page */
                                                _("lines margin scrolloff scroll off"),
                                                self->scroll_off_container,
                                                self->scroll_off_spin,
@@ -176,11 +128,6 @@ gb_preferences_page_editor_init (GbPreferencesPageEditor *self)
                                                NULL);
   gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
   /* To translators: This is a list of keywords for the preferences page */
-                                               _("source style scheme source tango solarized builder 
syntax"),
-                                               self->style_scheme_container,
-                                               NULL);
-  gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
-  /* To translators: This is a list of keywords for the preferences page */
                                                _("minimap mini map overview over view"),
                                                self->show_map_switch,
                                                self->auto_hide_map_switch,
diff --git a/src/preferences/gb-preferences-page-theme.c b/src/preferences/gb-preferences-page-theme.c
new file mode 100644
index 0000000..b33c7d7
--- /dev/null
+++ b/src/preferences/gb-preferences-page-theme.c
@@ -0,0 +1,122 @@
+/* gb-preferences-page-theme.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-preferences-page-theme.h"
+#include "gb-widget.h"
+
+struct _GbPreferencesPageTheme
+{
+  GbPreferencesPage                  parent_instance;
+
+  GSettings                         *editor_settings;
+
+  GtkSourceStyleSchemeChooserWidget *style_scheme_widget;
+  GtkSwitch                         *show_grid_lines_switch;
+};
+
+G_DEFINE_TYPE (GbPreferencesPageTheme, gb_preferences_page_theme, GB_TYPE_PREFERENCES_PAGE)
+
+static void
+style_scheme_changed (GtkSourceStyleSchemeChooser *chooser,
+                      GParamSpec                  *pspec,
+                      GSettings                   *settings)
+{
+  GtkSourceStyleScheme *scheme;
+  const gchar *scheme_id;
+
+  g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME_CHOOSER (chooser));
+  g_return_if_fail (G_IS_SETTINGS (settings));
+
+  scheme = gtk_source_style_scheme_chooser_get_style_scheme (chooser);
+
+  if (scheme)
+    {
+      scheme_id = gtk_source_style_scheme_get_id (scheme);
+      g_settings_set_string (settings, "style-scheme-name", scheme_id);
+    }
+}
+
+
+static void
+gb_preferences_page_theme_constructed (GObject *object)
+{
+  GbPreferencesPageTheme *self = (GbPreferencesPageTheme *)object;
+  GtkSourceStyleSchemeManager *manager;
+  GtkSourceStyleScheme *scheme;
+  gchar *scheme_id;
+
+  G_OBJECT_CLASS (gb_preferences_page_theme_parent_class)->constructed (object);
+
+  scheme_id = g_settings_get_string (self->editor_settings, "style-scheme-name");
+  manager = gtk_source_style_scheme_manager_get_default ();
+  scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
+  g_free (scheme_id);
+
+  gtk_source_style_scheme_chooser_set_style_scheme (
+      GTK_SOURCE_STYLE_SCHEME_CHOOSER (self->style_scheme_widget),
+      scheme);
+  g_signal_connect_object (self->style_scheme_widget,
+                           "notify::style-scheme",
+                           G_CALLBACK (style_scheme_changed),
+                           self->editor_settings,
+                           0);
+}
+
+static void
+gb_preferences_page_theme_finalize (GObject *object)
+{
+  GbPreferencesPageTheme *self = (GbPreferencesPageTheme *)object;
+
+  g_clear_object (&self->editor_settings);
+
+  G_OBJECT_CLASS (gb_preferences_page_theme_parent_class)->finalize (object);
+}
+
+static void
+gb_preferences_page_theme_class_init (GbPreferencesPageThemeClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->constructed = gb_preferences_page_theme_constructed;
+  object_class->finalize = gb_preferences_page_theme_finalize;
+
+  GB_WIDGET_CLASS_TEMPLATE (klass, "gb-preferences-page-theme.ui");
+  GB_WIDGET_CLASS_BIND (klass, GbPreferencesPageTheme, show_grid_lines_switch);
+  GB_WIDGET_CLASS_BIND (klass, GbPreferencesPageTheme, style_scheme_widget);
+}
+
+static void
+gb_preferences_page_theme_init (GbPreferencesPageTheme *self)
+{
+  self->editor_settings = g_settings_new ("org.gnome.builder.editor");
+
+  gtk_widget_init_template (GTK_WIDGET (self));
+
+  gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
+  /* To translators: This is a list of keywords for the preferences page */
+                                               _("show grid lines"),
+                                               self->show_grid_lines_switch,
+                                               NULL);
+  gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
+  /* To translators: This is a list of keywords for the preferences page */
+                                               _("source style scheme source tango solarized builder 
syntax"),
+                                               self->style_scheme_widget,
+                                               NULL);
+}
diff --git a/src/preferences/gb-preferences-page-theme.h b/src/preferences/gb-preferences-page-theme.h
new file mode 100644
index 0000000..88a3931
--- /dev/null
+++ b/src/preferences/gb-preferences-page-theme.h
@@ -0,0 +1,33 @@
+/* gb-preferences-page-theme.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#ifndef GB_PREFERENCES_PAGE_THEME_H
+#define GB_PREFERENCES_PAGE_THEME_H
+
+#include "gb-preferences-page.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_PREFERENCES_PAGE_THEME (gb_preferences_page_theme_get_type())
+
+G_DECLARE_FINAL_TYPE (GbPreferencesPageTheme, gb_preferences_page_theme,
+                      GB, PREFERENCES_PAGE_THEME, GbPreferencesPage)
+
+G_END_DECLS
+
+#endif /* GB_PREFERENCES_PAGE_THEME_H */
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index f4bb936..7f06aba 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -26,6 +26,7 @@
 #include "gb-preferences-page-insight.h"
 #include "gb-preferences-page-keybindings.h"
 #include "gb-preferences-page-language.h"
+#include "gb-preferences-page-theme.h"
 #include "gb-preferences-page.h"
 #include "gb-preferences-window.h"
 #include "gb-widget.h"
@@ -275,6 +276,7 @@ gb_preferences_window_class_init (GbPreferencesWindowClass *klass)
   g_type_ensure (GB_TYPE_PREFERENCES_PAGE_INSIGHT);
   g_type_ensure (GB_TYPE_PREFERENCES_PAGE_KEYBINDINGS);
   g_type_ensure (GB_TYPE_PREFERENCES_PAGE_LANGUAGE);
+  g_type_ensure (GB_TYPE_PREFERENCES_PAGE_THEME);
 }
 
 static void
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index a1e858b..95e01fe 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -54,6 +54,7 @@
     <file alias="ui/gb-preferences-page-insight.ui">../../data/ui/gb-preferences-page-insight.ui</file>
     <file 
alias="ui/gb-preferences-page-keybindings.ui">../../data/ui/gb-preferences-page-keybindings.ui</file>
     <file alias="ui/gb-preferences-page-language.ui">../../data/ui/gb-preferences-page-language.ui</file>
+    <file alias="ui/gb-preferences-page-theme.ui">../../data/ui/gb-preferences-page-theme.ui</file>
     <file alias="ui/gb-preferences-switch.ui">../../data/ui/gb-preferences-switch.ui</file>
     <file alias="ui/gb-preferences-window.ui">../../data/ui/gb-preferences-window.ui</file>
     <file alias="ui/gb-projects-dialog.ui">../../data/ui/gb-projects-dialog.ui</file>


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