[gtksourceview] test-widget: add a draw spaces check button
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] test-widget: add a draw spaces check button
- Date: Sat, 30 Jan 2016 11:49:38 +0000 (UTC)
commit 9c70e21ab725e1d74e63da15117885b5495f4e74
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Jan 30 12:47:22 2016 +0100
test-widget: add a draw spaces check button
tests/test-widget.c | 26 ++++++++++++++++++++++++++
tests/test-widget.ui | 17 +++++++++++++++--
2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/tests/test-widget.c b/tests/test-widget.c
index 23a5626..ae56206 100644
--- a/tests/test-widget.c
+++ b/tests/test-widget.c
@@ -54,6 +54,7 @@ struct _TestWidgetPrivate
GtkSourceFile *file;
GtkSourceMap *map;
GtkCheckButton *show_map_checkbutton;
+ GtkCheckButton *draw_spaces_checkbutton;
GtkCheckButton *smart_backspace_checkbutton;
GtkCheckButton *indent_width_checkbutton;
GtkSpinButton *indent_width_spinbutton;
@@ -967,6 +968,7 @@ test_widget_class_init (TestWidgetClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, TestWidget, view);
gtk_widget_class_bind_template_child_private (widget_class, TestWidget, map);
gtk_widget_class_bind_template_child_private (widget_class, TestWidget, show_map_checkbutton);
+ gtk_widget_class_bind_template_child_private (widget_class, TestWidget, draw_spaces_checkbutton);
gtk_widget_class_bind_template_child_private (widget_class, TestWidget, smart_backspace_checkbutton);
gtk_widget_class_bind_template_child_private (widget_class, TestWidget, indent_width_checkbutton);
gtk_widget_class_bind_template_child_private (widget_class, TestWidget, indent_width_spinbutton);
@@ -975,6 +977,20 @@ test_widget_class_init (TestWidgetClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, TestWidget, background_pattern);
}
+static gboolean
+tranform_boolean_to_draw_spaces_flags (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ gboolean active;
+
+ active = g_value_get_boolean (from_value);
+ g_value_set_flags (to_value, active ? GTK_SOURCE_DRAW_SPACES_ALL : 0);
+
+ return TRUE;
+}
+
static void
test_widget_init (TestWidget *self)
{
@@ -1031,6 +1047,16 @@ test_widget_init (TestWidget *self)
"visible",
G_BINDING_SYNC_CREATE);
+ g_object_bind_property_full (self->priv->draw_spaces_checkbutton,
+ "active",
+ self->priv->view,
+ "draw-spaces",
+ G_BINDING_SYNC_CREATE,
+ tranform_boolean_to_draw_spaces_flags,
+ NULL,
+ NULL,
+ NULL);
+
g_object_bind_property (self->priv->smart_backspace_checkbutton,
"active",
self->priv->view,
diff --git a/tests/test-widget.ui b/tests/test-widget.ui
index 7b54c39..2adb39b 100644
--- a/tests/test-widget.ui
+++ b/tests/test-widget.ui
@@ -212,6 +212,19 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="draw_spaces_checkbutton">
+ <property name="label">Draw Spaces</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="smart_backspace_checkbutton">
<property name="label">Smart Backspace</property>
<property name="visible">True</property>
@@ -221,7 +234,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">10</property>
</packing>
</child>
<child>
@@ -261,7 +274,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">10</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]