[gnome-builder] Add preference for the grid lines
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] Add preference for the grid lines
- Date: Mon, 26 Jan 2015 16:05:15 +0000 (UTC)
commit 0000e73f9bd47a286d17e4e5cc24f467ffeda857
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Jan 21 14:52:33 2015 +0100
Add preference for the grid lines
data/org.gnome.builder.editor.gschema.xml.in | 5 ++
src/editor/gb-source-view.c | 22 +++++++++
src/preferences/gb-preferences-page-editor.c | 12 +++++
src/resources/ui/gb-preferences-page-editor.ui | 55 ++++++++++++++++++++++++
4 files changed, 94 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.builder.editor.gschema.xml.in b/data/org.gnome.builder.editor.gschema.xml.in
index 4900dbf..f1069c9 100644
--- a/data/org.gnome.builder.editor.gschema.xml.in
+++ b/data/org.gnome.builder.editor.gschema.xml.in
@@ -41,6 +41,11 @@
<summary>Smart home end.</summary>
<description>Whether or not home moves to first non-space character.</description>
</key>
+ <key name="show-grid-lines" type="b">
+ <default>true</default>
+ <summary>Show grid lines.</summary>
+ <description>If enabled, the editor will show grid lines in the document.</description>
+ </key>
<key name="font-name" type="s">
<default>"Monospace 11"</default>
</key>
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index 512b5ff..b751c7e 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -99,6 +99,7 @@ enum {
PROP_SEARCH_HIGHLIGHTER,
PROP_SHOW_SHADOW,
PROP_SMART_HOME_END_SIMPLE,
+ PROP_SHOW_GRID_LINES,
LAST_PROP
};
@@ -220,6 +221,7 @@ gb_source_view_disconnect_settings (GbSourceView *view)
if (!GB_IS_EDITOR_DOCUMENT (buffer))
return;
+ g_settings_unbind (buffer, "show-grid-lines");
g_settings_unbind (buffer, "highlight-matching-brackets");
g_settings_unbind (buffer, "style-scheme-name");
@@ -309,6 +311,8 @@ gb_source_view_connect_settings (GbSourceView *view)
buffer, "highlight-matching-brackets",G_SETTINGS_BIND_GET);
g_settings_bind (view->priv->editor_settings, "smart-home-end",
view, "smart-home-end-simple",G_SETTINGS_BIND_GET);
+ g_settings_bind (view->priv->editor_settings, "show-grid-lines",
+ view, "show-grid-lines",G_SETTINGS_BIND_GET);
}
void
@@ -2166,6 +2170,15 @@ gb_source_view_set_property (GObject *object,
GTK_SOURCE_SMART_HOME_END_DISABLED);
break;
+ case PROP_SHOW_GRID_LINES:
+ if (g_value_get_boolean (value))
+ gtk_source_view_set_background_pattern (GTK_SOURCE_VIEW (view),
+ GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID);
+ else
+ gtk_source_view_set_background_pattern (GTK_SOURCE_VIEW (view),
+ GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -2260,6 +2273,15 @@ gb_source_view_class_init (GbSourceViewClass *klass)
g_object_class_install_property (object_class, PROP_SMART_HOME_END_SIMPLE,
gParamSpecs [PROP_SMART_HOME_END_SIMPLE]);
+ gParamSpecs [PROP_SHOW_GRID_LINES] =
+ g_param_spec_boolean ("show-grid-lines",
+ _("Show Grid Lines"),
+ _("Whether to show the grid lines."),
+ TRUE,
+ (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_SHOW_GRID_LINES,
+ gParamSpecs [PROP_SHOW_GRID_LINES]);
+
g_object_class_override_property (object_class,
PROP_AUTO_INDENT,
"auto-indent");
diff --git a/src/preferences/gb-preferences-page-editor.c b/src/preferences/gb-preferences-page-editor.c
index 72960d9..399d798 100644
--- a/src/preferences/gb-preferences-page-editor.c
+++ b/src/preferences/gb-preferences-page-editor.c
@@ -36,6 +36,7 @@ struct _GbPreferencesPageEditorPrivate
GtkSwitch *highlight_current_line_switch;
GtkSwitch *highlight_matching_brackets_switch;
GtkSwitch *smart_home_end_switch;
+ GtkSwitch *show_grid_lines_switch;
GtkFontButton *font_button;
GtkSourceStyleSchemeChooserButton *style_scheme_button;
@@ -47,6 +48,7 @@ struct _GbPreferencesPageEditorPrivate
GtkWidget *highlight_current_line_container;
GtkWidget *highlight_matching_brackets_container;
GtkWidget *smart_home_end_container;
+ GtkWidget *show_grid_lines_container;
};
G_DEFINE_TYPE_WITH_PRIVATE (GbPreferencesPageEditor, gb_preferences_page_editor,
@@ -108,6 +110,9 @@ gb_preferences_page_editor_constructed (GObject *object)
g_settings_bind (priv->settings, "smart-home-end",
priv->smart_home_end_switch, "active",
G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->settings, "show-grid-lines",
+ priv->show_grid_lines_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "font-name",
priv->font_button, "font-name",
G_SETTINGS_BIND_DEFAULT);
@@ -158,6 +163,7 @@ gb_preferences_page_editor_class_init (GbPreferencesPageEditorClass *klass)
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, highlight_current_line_switch);
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, highlight_matching_brackets_switch);
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, smart_home_end_switch);
+ GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, show_grid_lines_switch);
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, restore_insert_mark_container);
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, word_completion_container);
@@ -166,6 +172,7 @@ gb_preferences_page_editor_class_init (GbPreferencesPageEditorClass *klass)
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, highlight_current_line_container);
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, highlight_matching_brackets_container);
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, smart_home_end_container);
+ GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesPageEditor, show_grid_lines_container);
}
static void
@@ -211,6 +218,11 @@ gb_preferences_page_editor_init (GbPreferencesPageEditor *self)
self->priv->smart_home_end_switch,
NULL);
gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
+ _("show grid lines"),
+ self->priv->show_grid_lines_container,
+ self->priv->show_grid_lines_switch,
+ NULL);
+ gb_preferences_page_set_keywords_for_widget (GB_PREFERENCES_PAGE (self),
_("font document editor monospace"),
GTK_WIDGET (self->priv->font_button),
NULL);
diff --git a/src/resources/ui/gb-preferences-page-editor.ui b/src/resources/ui/gb-preferences-page-editor.ui
index d0fa91e..a6db61c 100644
--- a/src/resources/ui/gb-preferences-page-editor.ui
+++ b/src/resources/ui/gb-preferences-page-editor.ui
@@ -92,6 +92,17 @@
</packing>
</child>
<child>
+ <object class="GtkSwitch" id="show_grid_lines_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">8</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkBox" id="restore_insert_mark_container">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -399,6 +410,50 @@
<property name="top_attach">7</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="show_grid_lines_container">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes"><b>Show Grid Lines</b></property>
+ <property name="use_markup">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">Display a grid patten in the
document.</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">8</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]