[gnome-builder/wip/language-settings: 2/2] prefs: start on GbEditorSettingsWidget
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/language-settings: 2/2] prefs: start on GbEditorSettingsWidget
- Date: Tue, 14 Oct 2014 20:49:27 +0000 (UTC)
commit e49b2a68f34f157efb5120e9ebbf9abc4e9f8d7d
Author: Christian Hergert <christian hergert me>
Date: Mon Oct 13 23:20:41 2014 -0400
prefs: start on GbEditorSettingsWidget
This widget will be used to manage the values of GbEditorSettings. When
selecting a language, this will be shown to configure that individual
language's settings.
It appears that this is going to be too big to do in a popover, so we
will probably use another dialog to conifgure them, as annoying as that
may be. At least it somewhat matches the design of Network settings
in the Control Center.
src/editor/gb-editor-settings-widget.c | 193 ++++++++++++++++++++++++
src/editor/gb-editor-settings-widget.h | 55 +++++++
src/gnome-builder.mk | 2 +
src/preferences/gb-preferences-page-language.c | 4 +
src/resources/gnome-builder.gresource.xml | 1 +
src/resources/ui/gb-editor-settings-widget.ui | 139 +++++++++++++++++
6 files changed, 394 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-settings-widget.c b/src/editor/gb-editor-settings-widget.c
new file mode 100644
index 0000000..14d2707
--- /dev/null
+++ b/src/editor/gb-editor-settings-widget.c
@@ -0,0 +1,193 @@
+/* gb-editor-settings-widget.c
+ *
+ * Copyright (C) 2014 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-editor-settings.h"
+#include "gb-editor-settings-widget.h"
+
+struct _GbEditorSettingsWidgetPrivate
+{
+ GbEditorSettings *settings;
+
+ GtkCheckButton *auto_indent;
+ GtkCheckButton *highlight_current_line;
+ GtkCheckButton *highlight_matching_brackets;
+ GtkCheckButton *indent_on_tab;
+ GtkCheckButton *insert_spaces_instead_of_tabs;
+ GtkCheckButton *show_line_marks;
+ GtkCheckButton *show_line_numbers;
+ GtkCheckButton *show_right_margin;
+ GtkCheckButton *smart_home_end;
+
+ GtkSpinButton *indent_width;
+ GtkSpinButton *right_margin_position;
+ GtkSpinButton *tab_width;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbEditorSettingsWidget, gb_editor_settings_widget,
+ GTK_TYPE_GRID)
+
+enum {
+ PROP_0,
+ PROP_SETTINGS,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+GbEditorSettings *
+gb_editor_settings_widget_get_settings (GbEditorSettingsWidget *widget)
+{
+ g_return_val_if_fail (GB_IS_EDITOR_SETTINGS_WIDGET (widget), NULL);
+
+ return widget->priv->settings;
+}
+
+static void
+gb_editor_settings_widget_set_settings (GbEditorSettingsWidget *widget,
+ GbEditorSettings *settings)
+{
+ GbEditorSettingsWidgetPrivate *priv;
+
+ g_return_if_fail (GB_IS_EDITOR_SETTINGS_WIDGET (widget));
+ g_return_if_fail (GB_IS_EDITOR_SETTINGS (settings));
+
+ priv = widget->priv;
+
+ g_object_bind_property (settings, "auto-indent",
+ priv->auto_indent, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "highlight-current-line",
+ priv->highlight_current_line, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "highlight-matching-brackets",
+ priv->highlight_matching_brackets, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "indent-on-tab",
+ priv->indent_on_tab, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "insert-spaces-instead-of-tabs",
+ priv->insert_spaces_instead_of_tabs, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "show-line-marks",
+ priv->show_line_marks, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "show-line-numbers",
+ priv->show_line_numbers, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "show-right-margin",
+ priv->show_right_margin, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "smart-home-end",
+ priv->smart_home_end, "active",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "indent-width",
+ priv->indent_width, "value",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "right-margin-position",
+ priv->right_margin_position, "value",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (settings, "tab-width",
+ priv->tab_width, "value",
+ G_BINDING_SYNC_CREATE);
+}
+
+static void
+gb_editor_settings_widget_finalize (GObject *object)
+{
+ GbEditorSettingsWidgetPrivate *priv = GB_EDITOR_SETTINGS_WIDGET (object)->priv;
+
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (gb_editor_settings_widget_parent_class)->finalize (object);
+}
+
+static void
+gb_editor_settings_widget_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbEditorSettingsWidget *self = GB_EDITOR_SETTINGS_WIDGET (object);
+
+ switch (prop_id)
+ {
+ case PROP_SETTINGS:
+ g_value_set_object (value, gb_editor_settings_widget_get_settings (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_editor_settings_widget_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbEditorSettingsWidget *self = GB_EDITOR_SETTINGS_WIDGET (object);
+
+ switch (prop_id)
+ {
+ case PROP_SETTINGS:
+ gb_editor_settings_widget_set_settings (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_editor_settings_widget_class_init (GbEditorSettingsWidgetClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gb_editor_settings_widget_finalize;
+ object_class->get_property = gb_editor_settings_widget_get_property;
+ object_class->set_property = gb_editor_settings_widget_set_property;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/builder/ui/gb-editor-settings-widget.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GbEditorSettingsWidget, auto_indent);
+ gtk_widget_class_bind_template_child_private (widget_class, GbEditorSettingsWidget,
highlight_current_line);
+
+ gParamSpecs [PROP_SETTINGS] =
+ g_param_spec_object ("settings",
+ _("Settings"),
+ _("The settings to be configured."),
+ GB_TYPE_EDITOR_SETTINGS,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_SETTINGS,
+ gParamSpecs [PROP_SETTINGS]);
+}
+
+static void
+gb_editor_settings_widget_init (GbEditorSettingsWidget *self)
+{
+ self->priv = gb_editor_settings_widget_get_instance_private (self);
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/editor/gb-editor-settings-widget.h b/src/editor/gb-editor-settings-widget.h
new file mode 100644
index 0000000..f725a60
--- /dev/null
+++ b/src/editor/gb-editor-settings-widget.h
@@ -0,0 +1,55 @@
+/* gb-editor-settings-widget.h
+ *
+ * Copyright (C) 2014 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_EDITOR_SETTINGS_WIDGET_H
+#define GB_EDITOR_SETTINGS_WIDGET_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_EDITOR_SETTINGS_WIDGET (gb_editor_settings_widget_get_type())
+#define GB_EDITOR_SETTINGS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_EDITOR_SETTINGS_WIDGET, GbEditorSettingsWidget))
+#define GB_EDITOR_SETTINGS_WIDGET_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_EDITOR_SETTINGS_WIDGET, GbEditorSettingsWidget const))
+#define GB_EDITOR_SETTINGS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GB_TYPE_EDITOR_SETTINGS_WIDGET, GbEditorSettingsWidgetClass))
+#define GB_IS_EDITOR_SETTINGS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GB_TYPE_EDITOR_SETTINGS_WIDGET))
+#define GB_IS_EDITOR_SETTINGS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GB_TYPE_EDITOR_SETTINGS_WIDGET))
+#define GB_EDITOR_SETTINGS_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GB_TYPE_EDITOR_SETTINGS_WIDGET, GbEditorSettingsWidgetClass))
+
+typedef struct _GbEditorSettingsWidget GbEditorSettingsWidget;
+typedef struct _GbEditorSettingsWidgetClass GbEditorSettingsWidgetClass;
+typedef struct _GbEditorSettingsWidgetPrivate GbEditorSettingsWidgetPrivate;
+
+struct _GbEditorSettingsWidget
+{
+ GtkGrid parent;
+
+ /*< private >*/
+ GbEditorSettingsWidgetPrivate *priv;
+};
+
+struct _GbEditorSettingsWidgetClass
+{
+ GtkGridClass parent;
+};
+
+GType gb_editor_settings_widget_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* GB_EDITOR_SETTINGS_WIDGET_H */
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 11e4f07..9095bb6 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -47,6 +47,8 @@ libgnome_builder_la_SOURCES = \
src/editor/gb-editor-navigation-item.h \
src/editor/gb-editor-settings.c \
src/editor/gb-editor-settings.h \
+ src/editor/gb-editor-settings-widget.c \
+ src/editor/gb-editor-settings-widget.h \
src/editor/gb-editor-tab.c \
src/editor/gb-editor-tab.h \
src/editor/gb-editor-tab-private.h \
diff --git a/src/preferences/gb-preferences-page-language.c b/src/preferences/gb-preferences-page-language.c
index 444cf64..180b844 100644
--- a/src/preferences/gb-preferences-page-language.c
+++ b/src/preferences/gb-preferences-page-language.c
@@ -19,6 +19,8 @@
#include <gtksourceview/gtksource.h>
#include <string.h>
+#include "gb-editor-settings.h"
+#include "gb-editor-settings-widget.h"
#include "gb-preferences-page-language.h"
#include "gb-string.h"
@@ -180,6 +182,8 @@ gb_preferences_page_language_class_init (GbPreferencesPageLanguageClass *klass)
gtk_widget_class_bind_template_child_private (widget_class,
GbPreferencesPageLanguage,
search_entry);
+
+ g_type_ensure (GB_TYPE_EDITOR_SETTINGS_WIDGET);
}
static void
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 6d244be..d00fc49 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -19,6 +19,7 @@
<file>ui/gb-command-bar.ui</file>
<file>ui/gb-command-bar-item.ui</file>
<file>ui/gb-devhelp-tab.ui</file>
+ <file>ui/gb-editor-settings-widget.ui</file>
<file>ui/gb-editor-tab.ui</file>
<file>ui/gb-preferences-window.ui</file>
<file>ui/gb-preferences-page-editor.ui</file>
diff --git a/src/resources/ui/gb-editor-settings-widget.ui b/src/resources/ui/gb-editor-settings-widget.ui
new file mode 100644
index 0000000..c1c3299
--- /dev/null
+++ b/src/resources/ui/gb-editor-settings-widget.ui
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="GbEditorSettingsWidget" parent="GtkGrid">
+ <property name="visible">True</property>
+ <property name="column-spacing">6</property>
+ <property name="row-spacing">3</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="auto_indent">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Auto-Indent</property>
+ </object>
+ <packing>
+ <property name="top-attach">0</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="highlight_current_line">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Highlight Current Line</property>
+ </object>
+ <packing>
+ <property name="top-attach">1</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="highlight_matching_brackets">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Highlight Matching Brackets</property>
+ </object>
+ <packing>
+ <property name="top-attach">2</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="indent_on_tab">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Indent on Tab</property>
+ </object>
+ <packing>
+ <property name="top-attach">3</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="insert_spaces_instead_of_tabs">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Insert Spaces Instead of Tabs</property>
+ </object>
+ <packing>
+ <property name="top-attach">4</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_line_marks">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Show Line Marks</property>
+ </object>
+ <packing>
+ <property name="top-attach">5</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_line_numbers">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Show Line Numbers</property>
+ </object>
+ <packing>
+ <property name="top-attach">6</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show_right_margin">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Display right margin at position</property>
+ </object>
+ <packing>
+ <property name="top-attach">7</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="right_margin_position">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="top-attach">7</property>
+ <property name="left-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="smart_home_end">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Smart Home and End</property>
+ </object>
+ <packing>
+ <property name="top-attach">8</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="indent_width">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="top-attach">9</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="tab_width">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ </object>
+ <packing>
+ <property name="top-attach">11</property>
+ <property name="left-attach">0</property>
+ </packing>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]