[evolution-ews/evolution-ews-3-12] Bug #684425 - Do not pass NULL text to gtk_entry_set_text()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/evolution-ews-3-12] Bug #684425 - Do not pass NULL text to gtk_entry_set_text()
- Date: Fri, 11 Apr 2014 09:01:31 +0000 (UTC)
commit 88e9c9601565fe05dedab269b8905e5ed8b7b1fa
Author: Milan Crha <mcrha redhat com>
Date: Fri Apr 11 11:01:04 2014 +0200
Bug #684425 - Do not pass NULL text to gtk_entry_set_text()
src/configuration/e-mail-config-ews-backend.c | 62 +++++++++++++++++++++++--
1 files changed, 58 insertions(+), 4 deletions(-)
---
diff --git a/src/configuration/e-mail-config-ews-backend.c b/src/configuration/e-mail-config-ews-backend.c
index 74c35a7..d75c840 100644
--- a/src/configuration/e-mail-config-ews-backend.c
+++ b/src/configuration/e-mail-config-ews-backend.c
@@ -54,6 +54,60 @@ G_DEFINE_DYNAMIC_TYPE (
e_mail_config_ews_backend,
E_TYPE_MAIL_CONFIG_SERVICE_BACKEND)
+static gboolean
+e_ews_binding_transform_text_non_null (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer user_data)
+{
+ const gchar *str;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+ g_return_val_if_fail (source_value != NULL, FALSE);
+ g_return_val_if_fail (target_value != NULL, FALSE);
+
+ str = g_value_get_string (source_value);
+ if (!str)
+ str = "";
+
+ g_value_set_string (target_value, str);
+
+ return TRUE;
+}
+
+static GBinding *
+e_ews_binding_bind_object_text_property (gpointer source,
+ const gchar *source_property,
+ gpointer target,
+ const gchar *target_property,
+ GBindingFlags flags)
+{
+ GObjectClass *klass;
+ GParamSpec *property;
+
+ g_return_val_if_fail (G_IS_OBJECT (source), NULL);
+ g_return_val_if_fail (source_property != NULL, NULL);
+ g_return_val_if_fail (G_IS_OBJECT (target), NULL);
+ g_return_val_if_fail (target_property != NULL, NULL);
+
+ klass = G_OBJECT_GET_CLASS (source);
+ property = g_object_class_find_property (klass, source_property);
+ g_return_val_if_fail (property != NULL, NULL);
+ g_return_val_if_fail (property->value_type == G_TYPE_STRING, NULL);
+
+ klass = G_OBJECT_GET_CLASS (target);
+ property = g_object_class_find_property (klass, target_property);
+ g_return_val_if_fail (property != NULL, NULL);
+ g_return_val_if_fail (property->value_type == G_TYPE_STRING, NULL);
+
+ return g_object_bind_property_full (source, source_property,
+ target, target_property,
+ flags,
+ e_ews_binding_transform_text_non_null,
+ e_ews_binding_transform_text_non_null,
+ NULL, NULL);
+}
+
static ESource *
mail_config_ews_backend_new_collection (EMailConfigServiceBackend *backend)
{
@@ -226,7 +280,7 @@ mail_config_ews_backend_insert_widgets (EMailConfigServiceBackend *backend,
gtk_widget_show (widget);
priv->impersonate_user_entry = widget; /* do not reference */
- g_object_bind_property (
+ e_ews_binding_bind_object_text_property (
settings, "impersonate-user",
widget, "text",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -263,19 +317,19 @@ mail_config_ews_backend_insert_widgets (EMailConfigServiceBackend *backend,
priv->auth_check = widget; /* do not reference */
gtk_widget_show (widget);
- g_object_bind_property (
+ e_ews_binding_bind_object_text_property (
settings, "user",
priv->user_entry, "text",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
- g_object_bind_property (
+ e_ews_binding_bind_object_text_property (
settings, "hosturl",
priv->host_entry, "text",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
- g_object_bind_property (
+ e_ews_binding_bind_object_text_property (
settings, "oaburl",
priv->oab_entry, "text",
G_BINDING_BIDIRECTIONAL |
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]