[evolution-patches] [addressbook] Patch for Bug #217097: need an easier way to add multiple contacts to categories



Hi,

 Added a popup item(Add to Categories) to right click popup menu so that
multiple contacts can be selected and categories added to all of them.

thanks
devashish Sharma

Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1998
diff -u -p -r1.1998 ChangeLog
--- addressbook/ChangeLog	3 Oct 2005 08:56:19 -0000	1.1998
+++ addressbook/ChangeLog	4 Oct 2005 09:26:17 -0000
@@ -1,3 +1,10 @@
+2005-10-04   Devashish Sharma <sdevashish novell com>
+
+	*  gui/widgets/e-addressbook-view.c : Added a popup item(Add to
+	Categories) to right click popup menu so that multiple contacts can 
+	be selected and categories added to all of them.
+	Fixes #217097
+
 2005-10-03   Devashish Sharma <sdevashish novell com>
 
 	*  gui/widgets/e-addressbook-view.c (eab_view_print): Get selected 
Index: addressbook/gui/widgets/e-addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.c,v
retrieving revision 1.172
diff -u -p -r1.172 e-addressbook-view.c
--- addressbook/gui/widgets/e-addressbook-view.c	3 Oct 2005 08:56:20 -0000	1.172
+++ addressbook/gui/widgets/e-addressbook-view.c	4 Oct 2005 09:17:43 -0000
@@ -50,6 +50,7 @@
 #include "e-util/e-print.h"
 #include "libedataserver/e-sexp.h"
 #include <libedataserver/e-categories.h>
+#include <libedataserverui/e-categories-dialog.h>
 
 #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
 #include <misc/e-treeview-selection-model.h>
@@ -898,6 +899,14 @@ move_to_folder (EPopup *ep, EPopupItem *
 }
 
 static void
+add_to_categories (EPopup *ep, EPopupItem *pitem, void *data)
+{
+	ContactAndBook *contact_and_book = data;
+
+	eab_view_add_to_categories (contact_and_book->view);
+}
+
+static void
 open_contact (EPopup *ep, EPopupItem *pitem, void *data)
 {
 	ContactAndBook *contact_and_book = data;
@@ -931,6 +940,7 @@ static EPopupItem eabv_popup_items[] = {
 	{ E_POPUP_BAR, "10.bar" },
 	{ E_POPUP_ITEM, "10.new",  N_("New Contact..."), new_card, NULL, "stock_contact", 0, EAB_POPUP_SELECT_EDITABLE},
 	{ E_POPUP_ITEM, "15.newlist", N_("New Contact List..."), new_list, NULL, "stock_contact-list", 0, EAB_POPUP_SELECT_EDITABLE },
+	{ E_POPUP_ITEM, "16.addtocategories", N_("Add To Categories..."), add_to_categories, NULL, NULL, 0, EAB_POPUP_SELECT_EDITABLE },
 
 	{ E_POPUP_BAR, "20.bar" },
 	{ E_POPUP_ITEM, "30.saveas", N_("Save as VCard..."), save_as, NULL, "stock_save-as", 0, EAB_POPUP_SELECT_ANY },
@@ -2122,6 +2132,57 @@ eab_view_move_to_folder (EABView *view)
 	view_transfer_contacts (view, TRUE);
 }
 
+static void
+response (GtkDialog *dialog, int response, EABView *view)
+{
+	GList *list, *l;
+	const char *categories;
+	char *existing_categories;
+	GString *str;
+	
+	list = get_selected_contacts (view);
+
+	if (response == GTK_RESPONSE_OK) {
+		categories = e_categories_dialog_get_categories (E_CATEGORIES_DIALOG (dialog));
+
+		for (l = list; l; l = g_list_next(l)) {
+			EContact *contact = l->data;
+			if ( (existing_categories = e_contact_get (contact, E_CONTACT_CATEGORIES))) {
+				str = g_string_new(existing_categories);
+				str = g_string_append (str, ",");
+				str = g_string_append (str, categories);
+				e_contact_set (contact, E_CONTACT_CATEGORIES, str->str);
+				e_book_commit_contact(view->book, contact, NULL);
+				g_string_free (str, TRUE);
+				g_free (existing_categories);
+			}
+			else {
+				e_contact_set (contact, E_CONTACT_CATEGORIES, (char *)categories);
+				e_book_commit_contact(view->book, contact, NULL);
+			}
+		}
+
+	}
+	e_free_object_list(list);
+	gtk_widget_destroy(GTK_WIDGET (dialog));
+
+}
+
+void
+eab_view_add_to_categories (EABView *view)
+{
+	GtkDialog *dialog;
+
+	if (!(dialog = GTK_DIALOG (e_categories_dialog_new (NULL)))) {
+		e_error_run (NULL, "addressbook:edit-categories", NULL);
+		return ;
+	}
+
+	g_signal_connect (dialog, "response",
+			G_CALLBACK (response), view);
+
+	gtk_widget_show (GTK_WIDGET (dialog));
+}
 
 static gboolean
 eab_view_selection_nonempty (EABView  *view)
Index: addressbook/gui/widgets/e-addressbook-view.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.h,v
retrieving revision 1.37
diff -u -p -r1.37 e-addressbook-view.h
--- addressbook/gui/widgets/e-addressbook-view.h	21 Jul 2005 13:27:36 -0000	1.37
+++ addressbook/gui/widgets/e-addressbook-view.h	4 Oct 2005 09:17:43 -0000
@@ -141,6 +141,7 @@ void       eab_view_show_all            
 void       eab_view_stop                (EABView  *view);
 void       eab_view_copy_to_folder      (EABView  *view);
 void       eab_view_move_to_folder      (EABView  *view);
+void 	   eab_view_add_to_categories   (EABView  *view);
 
 gboolean   eab_view_can_create          (EABView  *view);
 gboolean   eab_view_can_print           (EABView  *view);


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