[gnome-builder] libide: Add support for show-right-margin setting in ide-file-settings
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: Add support for show-right-margin setting in ide-file-settings
- Date: Sun, 3 May 2015 21:35:47 +0000 (UTC)
commit bce5f97d1fc0b4ea733f9fad70c187f6747e6dec
Author: Dimitris Zenios <dimitris zenios gmail com>
Date: Mon May 4 00:16:56 2015 +0300
libide: Add support for show-right-margin setting in ide-file-settings
https://bugzilla.gnome.org/show_bug.cgi?id=748733
libide/gsettings/ide-gsettings-file-settings.c | 4 ++
libide/ide-file-settings.c | 48 ++++++++++++++++++++++++
libide/ide-file-settings.h | 3 +
libide/ide-source-view.c | 2 +
tests/test-ide-file-settings.c | 5 ++
5 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/libide/gsettings/ide-gsettings-file-settings.c b/libide/gsettings/ide-gsettings-file-settings.c
index 02c72c0..4152432 100644
--- a/libide/gsettings/ide-gsettings-file-settings.c
+++ b/libide/gsettings/ide-gsettings-file-settings.c
@@ -116,6 +116,10 @@ ide_gsettings_file_settings__init_defaults_cb (GObject *object,
g_settings_bind (self->settings, "trim-trailing-whitespace",
self, "trim-trailing-whitespace",
G_SETTINGS_BIND_GET);
+ g_settings_bind (self->settings, "show-right-margin",
+ self, "show-right-margin",
+ G_SETTINGS_BIND_GET);
+
g_task_return_boolean (task, TRUE);
}
diff --git a/libide/ide-file-settings.c b/libide/ide-file-settings.c
index a13eae0..ac89495 100644
--- a/libide/ide-file-settings.c
+++ b/libide/ide-file-settings.c
@@ -34,6 +34,7 @@ typedef struct
guint tab_width : 6;
guint trim_trailing_whitespace : 1;
guint right_margin_position : 10;
+ guint show_right_margin: 1;
GtkSourceNewlineType newline_type : 2;
} IdeFileSettingsPrivate;
@@ -50,6 +51,7 @@ enum {
PROP_RIGHT_MARGIN_POSITION,
PROP_TAB_WIDTH,
PROP_TRIM_TRAILING_WHITESPACE,
+ PROP_SHOW_RIGHT_MARGIN,
LAST_PROP
};
@@ -204,6 +206,34 @@ ide_file_settings_set_insert_trailing_newline (IdeFileSettings *self,
}
}
+gboolean
+ide_file_settings_get_show_right_margin (IdeFileSettings *self)
+{
+ IdeFileSettingsPrivate *priv = ide_file_settings_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_FILE_SETTINGS (self), FALSE);
+
+ return priv->show_right_margin;
+}
+
+void
+ide_file_settings_set_show_right_margin (IdeFileSettings *self,
+ gboolean show_right_margin)
+{
+ IdeFileSettingsPrivate *priv = ide_file_settings_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_FILE_SETTINGS (self));
+
+ show_right_margin = !!show_right_margin;
+
+ if (priv->show_right_margin != show_right_margin)
+ {
+ priv->show_right_margin = show_right_margin;
+ g_object_notify_by_pspec (G_OBJECT (self),
+ gParamSpecs [PROP_SHOW_RIGHT_MARGIN]);
+ }
+}
+
GtkSourceNewlineType
ide_file_settings_get_newline_type (IdeFileSettings *self)
{
@@ -373,6 +403,10 @@ ide_file_settings_get_property (GObject *object,
g_value_set_boolean (value, ide_file_settings_get_trim_trailing_whitespace (self));
break;
+ case PROP_SHOW_RIGHT_MARGIN:
+ g_value_set_boolean (value, ide_file_settings_get_show_right_margin (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -424,6 +458,11 @@ ide_file_settings_set_property (GObject *object,
ide_file_settings_set_trim_trailing_whitespace (self, g_value_get_boolean (value));
break;
+ case PROP_SHOW_RIGHT_MARGIN:
+ ide_file_settings_set_show_right_margin (self, g_value_get_boolean (value));
+ break;
+
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -525,6 +564,15 @@ ide_file_settings_class_init (IdeFileSettingsClass *klass)
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_TRIM_TRAILING_WHITESPACE,
gParamSpecs [PROP_TRIM_TRAILING_WHITESPACE]);
+
+ gParamSpecs [PROP_SHOW_RIGHT_MARGIN] =
+ g_param_spec_boolean ("show-right-margin",
+ _("Show Right Margin"),
+ _("If right margin should be shown."),
+ TRUE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_SHOW_RIGHT_MARGIN,
+ gParamSpecs [PROP_SHOW_RIGHT_MARGIN]);
}
static void
diff --git a/libide/ide-file-settings.h b/libide/ide-file-settings.h
index f3e3b06..7b123e5 100644
--- a/libide/ide-file-settings.h
+++ b/libide/ide-file-settings.h
@@ -46,6 +46,7 @@ GtkSourceNewlineType ide_file_settings_get_newline_type (IdeFileSet
guint ide_file_settings_get_right_margin_position (IdeFileSettings *self);
guint ide_file_settings_get_tab_width (IdeFileSettings *self);
gboolean ide_file_settings_get_trim_trailing_whitespace (IdeFileSettings *self);
+gboolean ide_file_settings_get_show_right_margin (IdeFileSettings *self);
void ide_file_settings_set_encoding (IdeFileSettings *self,
const gchar *encoding);
void ide_file_settings_set_indent_style (IdeFileSettings *self,
@@ -62,6 +63,8 @@ void ide_file_settings_set_tab_width (IdeFileSet
guint tab_width);
void ide_file_settings_set_trim_trailing_whitespace (IdeFileSettings *self,
gboolean
trim_trailing_whitespace);
+void ide_file_settings_set_show_right_margin (IdeFileSettings *self,
+ gboolean
show_right_margin);
G_END_DECLS
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 6d1dee2..4de378c 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -5749,6 +5749,8 @@ ide_source_view_init (IdeSourceView *self)
self, "right-margin-position", G_BINDING_SYNC_CREATE);
egg_binding_set_bind (priv->file_setting_bindings, "indent-style",
self, "indent-style", G_BINDING_SYNC_CREATE);
+ egg_binding_set_bind (priv->file_setting_bindings, "show-right-margin",
+ self, "show-right-margin", G_BINDING_SYNC_CREATE);
priv->buffer_signals = egg_signal_group_new (IDE_TYPE_BUFFER);
diff --git a/tests/test-ide-file-settings.c b/tests/test-ide-file-settings.c
index 3c0ecc5..8e76186 100644
--- a/tests/test-ide-file-settings.c
+++ b/tests/test-ide-file-settings.c
@@ -79,6 +79,11 @@ test_filesettings (void)
ide_file_settings_set_trim_trailing_whitespace (settings, FALSE);
g_assert_cmpint (ide_file_settings_get_trim_trailing_whitespace (settings), ==, FALSE);
+ ide_file_settings_set_show_right_margin (settings, TRUE);
+ g_assert_cmpint (ide_file_settings_get_show_right_margin (settings), ==, TRUE);
+ ide_file_settings_set_show_right_margin (settings, FALSE);
+ g_assert_cmpint (ide_file_settings_get_show_right_margin (settings), ==, FALSE);
+
g_object_unref (settings);
g_assert (settings == NULL);
g_clear_object (&file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]