[gnome-builder] prefs: add GbPreferencesPageEditor for editor preferences.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] prefs: add GbPreferencesPageEditor for editor preferences.
- Date: Mon, 13 Oct 2014 03:20:26 +0000 (UTC)
commit 2eb60f895ed7591db282fac2faf39478e5a08919
Author: Christian Hergert <christian hergert me>
Date: Sun Oct 12 23:19:59 2014 -0400
prefs: add GbPreferencesPageEditor for editor preferences.
src/preferences/gb-preferences-page-editor.c | 90 +++++++++++++++++++++++
src/preferences/gb-preferences-page-editor.h | 56 ++++++++++++++
src/resources/gnome-builder.gresource.xml | 1 +
src/resources/ui/gb-preferences-page-editor.ui | 92 ++++++++++++++++++++++++
4 files changed, 239 insertions(+), 0 deletions(-)
---
diff --git a/src/preferences/gb-preferences-page-editor.c b/src/preferences/gb-preferences-page-editor.c
new file mode 100644
index 0000000..896199a
--- /dev/null
+++ b/src/preferences/gb-preferences-page-editor.c
@@ -0,0 +1,90 @@
+/* gb-preferences-page-editor.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 "gb-preferences-page-editor.h"
+
+struct _GbPreferencesPageEditorPrivate
+{
+ GSettings *settings;
+
+ GtkSwitch *restore_insert_mark_switch;
+ GtkSwitch *vim_mode_switch;
+ GtkSwitch *word_completion_switch;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GbPreferencesPageEditor, gb_preferences_page_editor,
+ GTK_TYPE_BIN)
+
+static void
+gb_preferences_page_editor_constructed (GObject *object)
+{
+ GbPreferencesPageEditorPrivate *priv;
+ GbPreferencesPageEditor *editor = (GbPreferencesPageEditor *)object;
+
+ g_return_if_fail (GB_IS_PREFERENCES_PAGE_EDITOR (editor));
+
+ priv = editor->priv;
+
+ priv->settings = g_settings_new ("org.gnome.builder.editor");
+
+ g_settings_bind (priv->settings, "vim-mode", priv->vim_mode_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->settings, "restore-insert-mark",
+ priv->restore_insert_mark_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->settings, "word-completion",
+ priv->word_completion_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ G_OBJECT_CLASS (gb_preferences_page_editor_parent_class)->constructed (object);
+}
+
+static void
+gb_preferences_page_editor_finalize (GObject *object)
+{
+ GbPreferencesPageEditorPrivate *priv = GB_PREFERENCES_PAGE_EDITOR (object)->priv;
+
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (gb_preferences_page_editor_parent_class)->finalize (object);
+}
+
+static void
+gb_preferences_page_editor_class_init (GbPreferencesPageEditorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->constructed = gb_preferences_page_editor_constructed;
+ object_class->finalize = gb_preferences_page_editor_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/builder/ui/gb-preferences-page-editor.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, GbPreferencesPageEditor, vim_mode_switch);
+ gtk_widget_class_bind_template_child_private (widget_class, GbPreferencesPageEditor,
restore_insert_mark_switch);
+ gtk_widget_class_bind_template_child_private (widget_class, GbPreferencesPageEditor,
word_completion_switch);
+}
+
+static void
+gb_preferences_page_editor_init (GbPreferencesPageEditor *self)
+{
+ self->priv = gb_preferences_page_editor_get_instance_private (self);
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/preferences/gb-preferences-page-editor.h b/src/preferences/gb-preferences-page-editor.h
new file mode 100644
index 0000000..996597b
--- /dev/null
+++ b/src/preferences/gb-preferences-page-editor.h
@@ -0,0 +1,56 @@
+/* gb-preferences-page-editor.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_PREFERENCES_PAGE_EDITOR_H
+#define GB_PREFERENCES_PAGE_EDITOR_H
+
+#include "gb-preferences-page.h"
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_PREFERENCES_PAGE_EDITOR (gb_preferences_page_editor_get_type())
+#define GB_PREFERENCES_PAGE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_PREFERENCES_PAGE_EDITOR, GbPreferencesPageEditor))
+#define GB_PREFERENCES_PAGE_EDITOR_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GB_TYPE_PREFERENCES_PAGE_EDITOR, GbPreferencesPageEditor const))
+#define GB_PREFERENCES_PAGE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GB_TYPE_PREFERENCES_PAGE_EDITOR, GbPreferencesPageEditorClass))
+#define GB_IS_PREFERENCES_PAGE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GB_TYPE_PREFERENCES_PAGE_EDITOR))
+#define GB_IS_PREFERENCES_PAGE_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GB_TYPE_PREFERENCES_PAGE_EDITOR))
+#define GB_PREFERENCES_PAGE_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GB_TYPE_PREFERENCES_PAGE_EDITOR, GbPreferencesPageEditorClass))
+
+typedef struct _GbPreferencesPageEditor GbPreferencesPageEditor;
+typedef struct _GbPreferencesPageEditorClass GbPreferencesPageEditorClass;
+typedef struct _GbPreferencesPageEditorPrivate GbPreferencesPageEditorPrivate;
+
+struct _GbPreferencesPageEditor
+{
+ GbPreferencesPage parent;
+
+ /*< private >*/
+ GbPreferencesPageEditorPrivate *priv;
+};
+
+struct _GbPreferencesPageEditorClass
+{
+ GbPreferencesPageClass parent;
+};
+
+GType gb_preferences_page_editor_get_type (void) G_GNUC_CONST;
+GbPreferencesPageEditor *gb_preferences_page_editor_new (void);
+
+G_END_DECLS
+
+#endif /* GB_PREFERENCES_PAGE_EDITOR_H */
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 99c2a6c..fe4263d 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -21,6 +21,7 @@
<file>ui/gb-devhelp-tab.ui</file>
<file>ui/gb-editor-tab.ui</file>
<file>ui/gb-preferences-window.ui</file>
+ <file>ui/gb-preferences-page-editor.ui</file>
<file>ui/gb-tab-label.ui</file>
<file>ui/gb-workbench.ui</file>
</gresource>
diff --git a/src/resources/ui/gb-preferences-page-editor.ui b/src/resources/ui/gb-preferences-page-editor.ui
new file mode 100644
index 0000000..fb34e10
--- /dev/null
+++ b/src/resources/ui/gb-preferences-page-editor.ui
@@ -0,0 +1,92 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="GbPreferencesPageEditor" parent="GtkBin">
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="row-spacing">6</property>
+ <property name="column-spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="Yes">Enable VIM compatibility mode</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="width">1</property>
+ <property name="top-attach">0</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="vim_mode_switch">
+ <property name="visible">True</property>
+ <property name="active">False</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="width">1</property>
+ <property name="top-attach">0</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="Yes">Jump to last position when reopening a file.</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="width">1</property>
+ <property name="top-attach">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="restore_insert_mark_switch">
+ <property name="visible">True</property>
+ <property name="active">False</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="width">1</property>
+ <property name="top-attach">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="Yes">Enable auto-completion of words in the
document.</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="width">1</property>
+ <property name="top-attach">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="word_completion_switch">
+ <property name="visible">True</property>
+ <property name="active">False</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="width">1</property>
+ <property name="top-attach">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]