[gnome-builder] libide: add IdeSourceView:show-grid-lines gproperty
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add IdeSourceView:show-grid-lines gproperty
- Date: Mon, 23 Mar 2015 23:40:17 +0000 (UTC)
commit 1b9abbff418e2af927ad8f61a26acbbb582b5f70
Author: Christian Hergert <christian hergert me>
Date: Tue Feb 24 16:45:02 2015 -0800
libide: add IdeSourceView:show-grid-lines gproperty
libide/ide-source-view.c | 52 ++++++++++++++++++++++++++++++++++++++++++
libide/ide-source-view.h | 5 +++-
tests/test-ide-source-view.c | 1 +
3 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 7f3a8d5..5429f6c 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -39,6 +39,7 @@ typedef struct
PangoFontDescription *font_desc;
GtkSourceGutterRenderer *line_change_renderer;
+ guint show_grid_lines : 1;
guint show_line_changes : 1;
} IdeSourceViewPrivate;
@@ -48,6 +49,7 @@ enum {
PROP_0,
PROP_FONT_NAME,
PROP_FONT_DESC,
+ PROP_SHOW_GRID_LINES,
PROP_SHOW_LINE_CHANGES,
LAST_PROP
};
@@ -233,6 +235,10 @@ ide_source_view_get_property (GObject *object,
g_value_set_boxed (value, ide_source_view_get_font_desc (self));
break;
+ case PROP_SHOW_GRID_LINES:
+ g_value_set_boolean (value, ide_source_view_get_show_grid_lines (self));
+ break;
+
case PROP_SHOW_LINE_CHANGES:
g_value_set_boolean (value, ide_source_view_get_show_line_changes (self));
break;
@@ -260,6 +266,10 @@ ide_source_view_set_property (GObject *object,
ide_source_view_set_font_desc (self, g_value_get_boxed (value));
break;
+ case PROP_SHOW_GRID_LINES:
+ ide_source_view_set_show_grid_lines (self, g_value_get_boolean (value));
+ break;
+
case PROP_SHOW_LINE_CHANGES:
ide_source_view_set_show_line_changes (self, g_value_get_boolean (value));
break;
@@ -297,6 +307,15 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
g_object_class_install_property (object_class, PROP_FONT_NAME,
gParamSpecs [PROP_FONT_NAME]);
+ gParamSpecs [PROP_SHOW_GRID_LINES] =
+ g_param_spec_boolean ("show-grid-lines",
+ _("Show Grid Lines"),
+ _("If the background grid should be shown."),
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_SHOW_GRID_LINES,
+ gParamSpecs [PROP_SHOW_GRID_LINES]);
+
gParamSpecs [PROP_SHOW_LINE_CHANGES] =
g_param_spec_boolean ("show-line-changes",
_("Show Line Changes"),
@@ -390,3 +409,36 @@ ide_source_view_set_show_line_changes (IdeSourceView *self,
g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_SHOW_LINE_CHANGES]);
}
}
+
+gboolean
+ide_source_view_get_show_grid_lines (IdeSourceView *self)
+{
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_SOURCE_VIEW (self), FALSE);
+
+ return priv->show_grid_lines;
+}
+
+void
+ide_source_view_set_show_grid_lines (IdeSourceView *self,
+ gboolean show_grid_lines)
+{
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
+
+ show_grid_lines = !!show_grid_lines;
+
+ if (show_grid_lines != priv->show_grid_lines)
+ {
+ priv->show_grid_lines = show_grid_lines;
+ if (show_grid_lines)
+ gtk_source_view_set_background_pattern (GTK_SOURCE_VIEW (self),
+ GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID);
+ else
+ gtk_source_view_set_background_pattern (GTK_SOURCE_VIEW (self),
+ GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE);
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_SHOW_GRID_LINES]);
+ }
+}
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 3e356a8..6cd9095 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -47,11 +47,14 @@ struct _IdeSourceViewClass
GType ide_source_view_get_type (void);
const PangoFontDescription *ide_source_view_get_font_desc (IdeSourceView *self);
-gboolean ide_source_view_get_show_line_changes (IdeSourceView *self);
+gboolean ide_source_view_get_show_grid_lines (IdeSourceView *self);
+gboolean ide_source_view_get_show_line_changes (IdeSourceView *self);
void ide_source_view_set_font_desc (IdeSourceView *self,
const PangoFontDescription *font_desc);
void ide_source_view_set_font_name (IdeSourceView *self,
const gchar *font_name);
+void ide_source_view_set_show_grid_lines (IdeSourceView *self,
+ gboolean
show_grid_lines);
void ide_source_view_set_show_line_changes (IdeSourceView *self,
gboolean
show_line_changes);
diff --git a/tests/test-ide-source-view.c b/tests/test-ide-source-view.c
index fbed1cc..c03496e 100644
--- a/tests/test-ide-source-view.c
+++ b/tests/test-ide-source-view.c
@@ -117,6 +117,7 @@ main (gint argc,
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (scroller));
source_view = g_object_new (IDE_TYPE_SOURCE_VIEW,
"sensitive", FALSE,
+ "show-grid-lines", TRUE,
"show-line-changes", TRUE,
"show-line-numbers", TRUE,
"visible", TRUE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]