[gnome-builder] editor: be extra careful about NULL in GtkEntry property bindings
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: be extra careful about NULL in GtkEntry property bindings
- Date: Tue, 24 Mar 2015 00:40:12 +0000 (UTC)
commit 3aa040ba0d58145d01c1c3292e7ab94a219bffb9
Author: Christian Hergert <christian hergert me>
Date: Mon Mar 23 16:12:43 2015 -0700
editor: be extra careful about NULL in GtkEntry property bindings
src/editor/gb-editor-frame.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 081615b..e6a9d21 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -182,6 +182,23 @@ search_text_transform_to (GBinding *binding,
return TRUE;
}
+static gboolean
+search_text_transform_from (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ g_assert (from_value != NULL);
+ g_assert (to_value != NULL);
+
+ if (g_value_get_string (from_value) == NULL)
+ g_value_set_string (to_value, "");
+ else
+ g_value_copy (from_value, to_value);
+
+ return TRUE;
+}
+
void
gb_editor_frame_set_document (GbEditorFrame *self,
GbEditorDocument *document)
@@ -209,7 +226,8 @@ gb_editor_frame_set_document (GbEditorFrame *self,
search_settings = gtk_source_search_context_get_settings (search_context);
g_object_bind_property_full (self->search_entry, "text", search_settings, "search-text",
(G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL),
- search_text_transform_to, NULL, NULL, NULL);
+ search_text_transform_to, search_text_transform_from,
+ NULL, NULL);
g_signal_connect_object (search_context,
"notify::occurrences-count",
G_CALLBACK (gb_editor_frame_on_search_occurrences_notify),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]