[evolution] Could not set custom port for LDAP addressbook



commit d98b94b16b0fcf853d260f9ebf042275060ee61c
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 14 11:38:20 2012 +0200

    Could not set custom port for LDAP addressbook

 .../book-config-ldap/evolution-book-config-ldap.c  |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/modules/book-config-ldap/evolution-book-config-ldap.c b/modules/book-config-ldap/evolution-book-config-ldap.c
index 01f6e5d..3aa83de 100644
--- a/modules/book-config-ldap/evolution-book-config-ldap.c
+++ b/modules/book-config-ldap/evolution-book-config-ldap.c
@@ -314,16 +314,16 @@ book_config_ldap_active_to_port (GBinding *binding,
 	}
 
 	if (active == -1) {
-		GObject *source;
+		GObject *target;
 		GtkWidget *entry;
 		const gchar *text;
 		glong v_long;
 
-		source = g_binding_get_source (binding);
-		entry = gtk_bin_get_child (GTK_BIN (source));
+		target = g_binding_get_target (binding);
+		entry = gtk_bin_get_child (GTK_BIN (target));
 		text = gtk_entry_get_text (GTK_ENTRY (entry));
 
-		v_long = strtol (text, NULL, 10);
+		v_long = text ? strtol (text, NULL, 10) : 0;
 		if (v_long != 0 && v_long == CLAMP (v_long, 0, G_MAXUINT16))
 			port = (guint) v_long;
 	}
@@ -333,6 +333,13 @@ book_config_ldap_active_to_port (GBinding *binding,
 	return TRUE;
 }
 
+static void
+book_config_ldap_port_combo_changed (GtkComboBox *combo_box)
+{
+	if (gtk_combo_box_get_active (combo_box) == -1)
+		g_object_notify (G_OBJECT (combo_box), "active");
+}
+
 static gboolean
 book_config_ldap_port_to_security (GBinding *binding,
                                    const GValue *source_value,
@@ -864,6 +871,11 @@ book_config_ldap_insert_widgets (ESourceConfigBackend *backend,
 		book_config_ldap_active_to_port,
 		NULL, (GDestroyNotify) NULL);
 
+	/* "active" doesn't change when setting custom port in entry,
+	   thus check also on the "changed" signal */
+	g_signal_connect (context->port_combo, "changed",
+		G_CALLBACK (book_config_ldap_port_combo_changed), NULL);
+
 	g_object_bind_property (
 		extension, "user",
 		context->auth_entry, "text",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]