[evolution-patches] [addressbook]Patch for Bug #233424



Hi 

Attached patch fixes 233424.

thanks
Devashish
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1991
diff -u -p -r1.1991 ChangeLog
--- addressbook/ChangeLog	14 Sep 2005 10:27:07 -0000	1.1991
+++ addressbook/ChangeLog	14 Sep 2005 11:02:43 -0000
@@ -1,3 +1,10 @@
+2005-09-14  Devashish Sharma <sdevashish novell com>
+
+	* gui/component/addressbook-view.c (addressbook_view_init): Added a
+	callback (source_selector_key_press_event_callback) so that the
+	contact folder can be removed with Del/Delete Key.
+	Fixes #233424.
+
 2005-09-14  Sushma Rai  <rsushma novell com>
 
 	* gui/contact-list-editor/e-contact-list-editor.etspec: Set selection 
Index: addressbook/gui/component/addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook-view.c,v
retrieving revision 1.38
diff -u -p -r1.38 addressbook-view.c
--- addressbook/gui/component/addressbook-view.c	3 Aug 2005 11:40:36 -0000	1.38
+++ addressbook/gui/component/addressbook-view.c	14 Sep 2005 11:02:28 -0000
@@ -1085,6 +1085,47 @@ addressbook_view_class_init (Addressbook
 }
 
 static void
+source_selector_key_press_event_callback(GtkWidget *widget, GdkEventKey *event, AddressbookView *view)
+{
+	if (event->keyval == GDK_Delete) {
+		AddressbookViewPrivate *priv = view->priv;
+		ESource *selected_source;
+		EBook  *book;
+		GError *error = NULL;
+		GtkWindow *toplevel;
+
+		selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector));
+		if (!selected_source) 
+			return;
+
+		toplevel = (GtkWindow *) gtk_widget_get_toplevel (priv->notebook);
+
+		if (e_error_run(toplevel, "addressbook:ask-delete-addressbook", e_source_peek_name(selected_source)) != GTK_RESPONSE_YES)
+		return;
+
+		/* Remove local data */
+		book = e_book_new (selected_source, &error);
+		if (book) {
+			if (e_book_remove (book, NULL)) {
+				if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->selector),
+									  selected_source))
+					e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->selector),
+									   selected_source);
+		
+				e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
+			
+				e_source_list_sync (priv->source_list, NULL);
+			}
+			else
+				e_error_run (toplevel, "addressbook:remove-addressbook", NULL);
+
+			g_object_unref (book);
+		}
+	}
+	return;
+}
+
+static void
 addressbook_view_init (AddressbookView *view)
 {
 	AddressbookViewPrivate *priv;
@@ -1161,6 +1202,8 @@ addressbook_view_init (AddressbookView *
 	g_signal_connect_object (priv->selector, "primary_selection_changed",
 				 G_CALLBACK (primary_source_selection_changed_callback),
 				 G_OBJECT (view), 0);
+	g_signal_connect_after (priv->selector, "key_press_event",
+		       		 G_CALLBACK (source_selector_key_press_event_callback),view);
 	g_signal_connect_object (priv->selector, "popup_event",
 				 G_CALLBACK (popup_event_callback),
 				 G_OBJECT (view), 0);


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