[evolution-patches] fix for addressbook #42606



fixes 42606 and a couple of other issues with addresses in the contact
editor.

Chris
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1400
diff -u -r1.1400 ChangeLog
--- ChangeLog	11 May 2003 21:51:42 -0000	1.1400
+++ ChangeLog	12 May 2003 08:46:56 -0000
@@ -1,3 +1,14 @@
+2003-05-12  Chris Toshok  <toshok ximian com>
+
+	* gui/contact-editor/e-contact-editor.c (full_addr_clicked):
+	replace the text_buffer_delete/text_buffer_insert with
+	set_buffer_set_text.  call widget_changed if they clicked OK, so
+	we actually mark the dialog changed.
+	(fill_in_field): make this handle GtkTextViews, because for some
+	reason that escapes rational thought GtkTextView's don't implement
+	GtkEditable.  fixes #42606.
+	(extract_field): same.
+
 2003-05-11  Chris Toshok  <toshok ximian com>
 
 	[ fixes bug #42048 ]
Index: gui/contact-editor/e-contact-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/e-contact-editor.c,v
retrieving revision 1.147
diff -u -r1.147 e-contact-editor.c
--- gui/contact-editor/e-contact-editor.c	18 Apr 2003 17:44:15 -0000	1.147
+++ gui/contact-editor/e-contact-editor.c	12 May 2003 08:46:57 -0000
@@ -781,17 +781,11 @@
 		address_widget = glade_xml_get_widget(editor->gui, "text-address");
 		if (address_widget && GTK_IS_TEXT_VIEW(address_widget)) {
 			GtkTextBuffer *buffer;
-			GtkTextIter start_iter, end_iter;
 			char *string = e_card_delivery_address_to_string(new_address);
 
 			buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (address_widget));
 
-			gtk_text_buffer_get_start_iter (buffer, &start_iter);
-			gtk_text_buffer_get_end_iter (buffer, &end_iter);
-
-			gtk_text_buffer_delete (buffer, &start_iter, &end_iter);
-
-			gtk_text_buffer_insert (buffer, &start_iter, string, strlen (string));
+			gtk_text_buffer_set_text (buffer, string, strlen (string));
 
 			g_free(string);
 		}
@@ -801,6 +795,8 @@
 		e_card_simple_set_delivery_address(editor->simple, editor->address_choice, new_address);
 
 		e_card_delivery_address_unref(new_address);
+
+		widget_changed (NULL, editor);
 	}
 	gtk_widget_destroy (GTK_WIDGET (dialog));
 }
@@ -2134,10 +2130,17 @@
 {
 	GtkWidget *widget = glade_xml_get_widget(editor->gui, id);
 
-	if (widget && E_IS_URL_ENTRY (widget))
-		widget = e_url_entry_get_entry (E_URL_ENTRY (widget));
+	if (!widget)
+		return;
 
-	if (widget && GTK_IS_EDITABLE(widget)) {
+	if (E_IS_URL_ENTRY (widget))
+		widget = e_url_entry_get_entry (E_URL_ENTRY (widget));
+	else if (GTK_IS_TEXT_VIEW (widget)) {
+		if (value)
+			gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)),
+						  value, strlen (value));
+	}
+	else if (GTK_IS_EDITABLE(widget)) {
 		int position = 0;
 		GtkEditable *editable = GTK_EDITABLE(widget);
 		gtk_editable_delete_text(editable, 0, -1);
@@ -2161,6 +2164,7 @@
 {
 	ECardSimple *simple = editor->simple;
 	GtkWidget *widget = glade_xml_get_widget(editor->gui, name);
+
 	if (widget && GTK_IS_EDITABLE(widget)) {
 		int position = 0;
 		GtkEditable *editable = GTK_EDITABLE(widget);
@@ -2503,25 +2507,37 @@
 extract_field(EContactEditor *editor, ECard *card, char *editable_id, char *key)
 {
 	GtkWidget *widget = glade_xml_get_widget(editor->gui, editable_id);
+	char *string = NULL;
+
+	if (!widget)
+		return;
 
-	if (widget && E_IS_URL_ENTRY (widget))
+	if (E_IS_URL_ENTRY (widget))
 		widget = e_url_entry_get_entry (E_URL_ENTRY (widget));
 
-	if (widget && GTK_IS_EDITABLE (widget)) {
-		GtkEditable *editable = GTK_EDITABLE(widget);
-		char *string = gtk_editable_get_chars(editable, 0, -1);
+	if (GTK_IS_EDITABLE (widget))
+		string = gtk_editable_get_chars(GTK_EDITABLE (widget), 0, -1);
+	else if (GTK_IS_TEXT_VIEW (widget)) {
+		GtkTextIter start, end;
+		GtkTextBuffer *buffer;
 
-		if (string && *string)
-			g_object_set (card,
-				      key, string,
-				      NULL);
-		else
-			g_object_set (card,
-				      key, NULL,
-				      NULL);
+		buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
+		gtk_text_buffer_get_start_iter (buffer, &start);
+		gtk_text_buffer_get_end_iter (buffer, &end);
+
+		string = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
+	}
+
+	if (string && *string)
+		g_object_set (card,
+			      key, string,
+			      NULL);
+	else
+		g_object_set (card,
+			      key, NULL,
+			      NULL);
 
-		if (string) g_free(string);
-	}
+	if (string) g_free(string);
 }
 
 static void


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