[evolution-patches] Fix for 9605 (Let "Delete" remove selected contact from the mailer contacts selector)



Hi, Hpj and Siva,
   Attached is the patch for 9605. Please review it.
   Thanks!
      Harry
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/ChangeLog,v
retrieving revision 1.28
diff -u -r1.28 ChangeLog
--- ChangeLog	7 Feb 2005 10:23:16 -0000	1.28
+++ ChangeLog	21 Feb 2005 07:19:50 -0000
@@ -1,3 +1,10 @@
+2005-02-21  Harry Lu <harry lu sun com>
+
+	Fix for 9605.
+	* e-name-selector-dialog.c: (add_section),(destination_key_press):
+	add key-press-event handler to delete contact from the list if user
+	press Delete key.
+
 2005-02-07  Ross Burton  <ross openedhand com>
 
 	* test-source-option-menu.c:
Index: e-name-selector-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-name-selector-dialog.c,v
retrieving revision 1.9
diff -u -r1.9 e-name-selector-dialog.c
--- e-name-selector-dialog.c	3 Feb 2005 16:35:02 -0000	1.9
+++ e-name-selector-dialog.c	21 Feb 2005 07:19:56 -0000
@@ -23,6 +23,7 @@
 
 #include <config.h>
 #include <string.h>
+#include <gdk/gdkkeysyms.h>
 #include <gtk/gtkalignment.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkentry.h>
@@ -53,6 +54,7 @@
 static void     contact_activated             (ENameSelectorDialog *name_selector_dialog, GtkTreePath *path);
 static void     destination_activated         (ENameSelectorDialog *name_selector_dialog, GtkTreePath *path,
 					       GtkTreeViewColumn *column, GtkTreeView *tree_view);
+static gboolean destination_key_press         (ENameSelectorDialog *name_selector_dialog, GdkEventKey *event, GtkTreeView *tree_view);
 static void     remove_books                  (ENameSelectorDialog *name_selector_dialog);
 static void     contact_column_formatter      (GtkTreeViewColumn *column, GtkCellRenderer *cell,
 					       GtkTreeModel *model, GtkTreeIter *iter,
@@ -448,6 +450,8 @@
 	gtk_box_pack_start (section.section_box, widget, TRUE, TRUE, 0);
 	g_signal_connect_swapped (section.destination_view, "row-activated",
 				  G_CALLBACK (destination_activated), name_selector_dialog);
+	g_signal_connect_swapped (section.destination_view, "key-press-event",
+				  G_CALLBACK (destination_key_press), name_selector_dialog);
 
 	gtk_widget_show_all (GTK_WIDGET (section.section_box));
 
@@ -660,6 +664,44 @@
 	g_assert (destination);
 
 	e_destination_store_remove_destination (destination_store, destination);
+}
+
+static gboolean 
+destination_key_press (ENameSelectorDialog *name_selector_dialog, 
+		       GdkEventKey *event, GtkTreeView *tree_view)
+{
+	gint               section_index;
+	EDestinationStore *destination_store;
+	EDestination      *destination;
+	Section           *section;
+	GtkTreeIter        iter;
+
+	/* we only care about DEL key */
+	if (event->keyval != GDK_Delete)
+		return FALSE;
+
+	section_index = find_section_by_tree_view (name_selector_dialog, tree_view);
+	if (section_index < 0) {
+		g_warning ("ENameSelectorDialog got key press from unknown view!");
+		return FALSE;
+	}
+
+	section = &g_array_index (name_selector_dialog->sections, Section, section_index);
+	if (!e_name_selector_model_peek_section (name_selector_dialog->name_selector_model,
+						 section->name, NULL, &destination_store)) {
+		g_warning ("ENameSelectorDialog has a section unknown to the model!");
+		return FALSE;
+	}
+
+	if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection (tree_view), NULL, &iter))
+		return FALSE;
+
+	destination = e_destination_store_get_destination (destination_store, &iter);
+	g_assert (destination);
+
+	e_destination_store_remove_destination (destination_store, destination);
+
+	return TRUE;
 }
 
 static void


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