[gnome-builder/tweak] GbEditorView: add property for show-right-margin and wire up tweak
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/tweak] GbEditorView: add property for show-right-margin and wire up tweak
- Date: Wed, 17 Dec 2014 09:43:07 +0000 (UTC)
commit 4440256e6d7fca92c921bfc8dbd81e3f39671ea4
Author: Christian Hergert <christian hergert me>
Date: Wed Dec 17 01:42:56 2014 -0800
GbEditorView: add property for show-right-margin and wire up tweak
src/editor/gb-editor-view.c | 51 ++++++++++++++++++++++++++-
src/resources/ui/gb-editor-tweak-widget.ui | 1 +
2 files changed, 50 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index 7aacbdc..a051373 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -54,6 +54,7 @@ struct _GbEditorViewPrivate
guint auto_indent : 1;
guint highlight_current_line : 1;
+ guint show_right_margin : 1;
guint use_spaces : 1;
};
@@ -64,6 +65,7 @@ enum {
PROP_AUTO_INDENT,
PROP_DOCUMENT,
PROP_HIGHLIGHT_CURRENT_LINE,
+ PROP_SHOW_RIGHT_MARGIN,
PROP_SPLIT_ENABLED,
PROP_USE_SPACES,
LAST_PROP
@@ -140,6 +142,29 @@ gb_editor_view_set_highlight_current_line (GbEditorView *view,
}
gboolean
+gb_editor_view_get_show_right_margin (GbEditorView *view)
+{
+ g_return_val_if_fail (GB_IS_EDITOR_VIEW (view), FALSE);
+
+ return view->priv->show_right_margin;
+}
+
+void
+gb_editor_view_set_show_right_margin (GbEditorView *view,
+ gboolean show_right_margin)
+{
+ GVariant *variant;
+
+ g_return_if_fail (GB_IS_EDITOR_VIEW (view));
+
+ view->priv->show_right_margin = show_right_margin;
+ variant = g_variant_new_boolean (show_right_margin);
+ gb_editor_view_action_set_state (view, "show-right-margin", variant);
+ g_object_notify_by_pspec (G_OBJECT (view),
+ gParamSpecs [PROP_SHOW_RIGHT_MARGIN]);
+}
+
+gboolean
gb_editor_view_get_use_spaces (GbEditorView *view)
{
g_return_val_if_fail (GB_IS_EDITOR_VIEW (view), FALSE);
@@ -651,6 +676,7 @@ gb_editor_view_grab_focus (GtkWidget *widget)
STATE_HANDLER_BOOLEAN (auto_indent)
STATE_HANDLER_BOOLEAN (highlight_current_line)
+STATE_HANDLER_BOOLEAN (show_right_margin)
STATE_HANDLER_BOOLEAN (split_enabled)
STATE_HANDLER_BOOLEAN (use_spaces)
@@ -687,6 +713,10 @@ gb_editor_view_get_property (GObject *object,
gb_editor_view_get_highlight_current_line (self));
break;
+ case PROP_SHOW_RIGHT_MARGIN:
+ g_value_set_boolean (value, gb_editor_view_get_show_right_margin (self));
+ break;
+
case PROP_SPLIT_ENABLED:
g_value_set_boolean (value, gb_editor_view_get_split_enabled (self));
break;
@@ -722,6 +752,10 @@ gb_editor_view_set_property (GObject *object,
gb_editor_view_set_highlight_current_line (self, g_value_get_boolean (value));
break;
+ case PROP_SHOW_RIGHT_MARGIN:
+ gb_editor_view_set_show_right_margin (self, g_value_get_boolean (value));
+ break;
+
case PROP_SPLIT_ENABLED:
gb_editor_view_set_split_enabled (self, g_value_get_boolean (value));
break;
@@ -779,6 +813,15 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
g_object_class_install_property (object_class, PROP_HIGHLIGHT_CURRENT_LINE,
gParamSpecs [PROP_HIGHLIGHT_CURRENT_LINE]);
+ gParamSpecs [PROP_SHOW_RIGHT_MARGIN] =
+ g_param_spec_boolean ("show-right-margin",
+ _("Show Right Margin"),
+ _("If we should show the right margin."),
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_SHOW_RIGHT_MARGIN,
+ gParamSpecs [PROP_SHOW_RIGHT_MARGIN]);
+
gParamSpecs [PROP_SPLIT_ENABLED] =
g_param_spec_boolean ("split-enabled",
_("Split Enabled"),
@@ -822,6 +865,8 @@ gb_editor_view_init (GbEditorView *self)
{ "auto-indent", NULL, NULL, "false", apply_state_auto_indent },
{ "highlight-current-line", NULL, NULL, "false",
apply_state_highlight_current_line },
+ { "show-right-margin", NULL, NULL, "false",
+ apply_state_show_right_margin },
{ "switch-pane", gb_editor_view_switch_pane },
{ "toggle-split", NULL, NULL, "false", apply_state_split_enabled },
{ "use-spaces", NULL, NULL, "false", apply_state_use_spaces },
@@ -850,13 +895,15 @@ gb_editor_view_init (GbEditorView *self)
"insert-spaces-instead-of-tabs",
self, "use-spaces",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
g_object_bind_property (self->priv->frame->priv->source_view, "auto-indent",
self, "auto-indent",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
g_object_bind_property (self->priv->frame->priv->source_view,
"highlight-current-line",
self, "highlight-current-line",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ g_object_bind_property (self->priv->frame->priv->source_view,
+ "show-right-margin",
+ self, "show-right-margin",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
}
diff --git a/src/resources/ui/gb-editor-tweak-widget.ui b/src/resources/ui/gb-editor-tweak-widget.ui
index 4c55cd3..0644aff 100644
--- a/src/resources/ui/gb-editor-tweak-widget.ui
+++ b/src/resources/ui/gb-editor-tweak-widget.ui
@@ -61,6 +61,7 @@
<property name="role">check</property>
<property name="halign">fill</property>
<property name="xalign">0.0</property>
+ <property name="action-name">editor-view.show-right-margin</property>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]