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



Hi,

Attaching the revised patch with changes done

Thanks
Devashish Sharma
On Tue, 2005-10-04 at 19:06 +0530, Sushma Rai wrote:
> Hi,
> 
> The same menu item should also be added to Actions main menu.
> 
> -Sushma.
> 
> On Tue, 2005-10-04 at 14:54 +0530, Devashish wrote:
> > 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: ui/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/ui/ChangeLog,v
retrieving revision 1.438
diff -u -p -r1.438 ChangeLog
--- ui/ChangeLog	7 Dec 2005 08:30:00 -0000	1.438
+++ ui/ChangeLog	12 Dec 2005 15:22:05 -0000
@@ -1,3 +1,7 @@
+2005-12-12  Devashish Sharma <sdevashish novell com>
+
+	* evolution-addressbook.xml : Added action menu item 'Add to Category'.
+
 2005-12-07  Parthasarathi Susarla <sparthasarathi novell com>
 	
 	* evolution-message-composer.xml: Add menu item for prioritising
Index: ui/evolution-addressbook.xml
===================================================================
RCS file: /cvs/gnome/evolution/ui/evolution-addressbook.xml,v
retrieving revision 1.70
diff -u -p -r1.70 evolution-addressbook.xml
--- ui/evolution-addressbook.xml	6 Oct 2005 18:21:50 -0000	1.70
+++ ui/evolution-addressbook.xml	12 Dec 2005 15:16:18 -0000
@@ -63,6 +63,9 @@
 	 _tip="Show contact preview window"
 	 accel="*Control**Alt*v"
 	 type="toggle"/>
+    
+    <cmd name="AddToCategory" _label="_Add to Categories"
+	    _tip="Add categories to Selected Contacts"/>   
   </commands>
 
   <menu>
@@ -118,6 +121,7 @@
 
 	<menuitem name="ContactsCopyToFolder" _label="_Copy to Folder..." verb=""/>
 	<menuitem name="ContactsMoveToFolder" _label="_Move to Folder..." verb=""/>
+	<menuitem name="AddToCategory" _label="_Add to Categories..." verb=""/>
     </submenu>
     </placeholder>
 
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.2016
diff -u -p -r1.2016 ChangeLog
--- addressbook/ChangeLog	10 Dec 2005 09:52:22 -0000	1.2016
+++ addressbook/ChangeLog	12 Dec 2005 15:22:23 -0000
@@ -1,3 +1,12 @@
+2005-12-12  Devashish Sharma <sdevashish novell com>
+
+	* gui/widgets/e-addressbok-view.[ch] :  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.
+	* gui/component/addressbook-view.c : Added functions to handle
+	callback arising from menu-item 'Add To  Categories'.
+	Fixes #217097
+	
 2005-12-10  Sushma Rai  <rsushma novell com>
 
 	* gui/contact-editor/e-contact-editor.c (fill_in_address_textview):
Index: addressbook/gui/component/addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook-view.c,v
retrieving revision 1.41
diff -u -p -r1.41 addressbook-view.c
--- addressbook/gui/component/addressbook-view.c	26 Nov 2005 01:32:18 -0000	1.41
+++ addressbook/gui/component/addressbook-view.c	12 Dec 2005 15:15:26 -0000
@@ -285,6 +285,15 @@ move_contact_to_cb (BonoboUIComponent *u
 		eab_view_move_to_folder (v);
 }
 
+static void 
+add_to_category_cb (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+	AddressbookView *view = (AddressbookView *) user_data;
+	EABView *v = get_current_view (view);
+	if (v)
+		eab_view_add_to_categories (v);
+}
+
 static void
 forget_passwords_cb (BonoboUIComponent *uih, void *user_data, const char *path)
 {
@@ -382,6 +391,7 @@ update_command_state (EABView *eav, Addr
 		SET_SENSITIVE ("/commands/ContactsSendMessageToContact", eab_view_can_send_to);
 		SET_SENSITIVE ("/commands/ContactsMoveToFolder", eab_view_can_move_to_folder);
 		SET_SENSITIVE ("/commands/ContactsCopyToFolder", eab_view_can_copy_to_folder);
+		SET_SENSITIVE ("/commands/AddToCategory", eab_view_can_add_to_category);
 
 		/* Stop */
 		SET_SENSITIVE ("/commands/ContactStop", eab_view_can_stop);
@@ -410,6 +420,7 @@ static BonoboUIVerb verbs [] = {
 	BONOBO_UI_UNSAFE_VERB ("ContactsMoveToFolder", move_contact_to_cb),
 	BONOBO_UI_UNSAFE_VERB ("ContactsCopyToFolder", copy_contact_to_cb),
 	BONOBO_UI_UNSAFE_VERB ("ContactsForgetPasswords", forget_passwords_cb),
+	BONOBO_UI_UNSAFE_VERB ("AddToCategory", add_to_category_cb),
 	/* ContactsViewPreview is a toggle */
 
 	BONOBO_UI_VERB_END
Index: addressbook/gui/widgets/e-addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.c,v
retrieving revision 1.174
diff -u -p -r1.174 e-addressbook-view.c
--- addressbook/gui/widgets/e-addressbook-view.c	26 Nov 2005 01:51:38 -0000	1.174
+++ addressbook/gui/widgets/e-addressbook-view.c	13 Dec 2005 05:29:27 -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>
@@ -912,6 +913,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;
@@ -945,6 +954,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 },
@@ -2141,6 +2151,60 @@ 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 (!e_contact_get (contact, E_CONTACT_IS_LIST)) {
+				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)
@@ -2234,6 +2298,12 @@ eab_view_can_copy_to_folder (EABView *vi
 
 gboolean
 eab_view_can_move_to_folder (EABView *view)
+{
+	return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE;
+}
+
+gboolean
+eab_view_can_add_to_category (EABView *view)
 {
 	return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE;
 }
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	13 Dec 2005 05:29:27 -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);
@@ -156,6 +157,7 @@ gboolean   eab_view_can_select_all      
 gboolean   eab_view_can_stop            (EABView  *view);
 gboolean   eab_view_can_copy_to_folder  (EABView  *view);
 gboolean   eab_view_can_move_to_folder  (EABView  *view);
+gboolean   eab_view_can_add_to_category (EABView  *view);
 
 struct _EABMenuTargetSelect *eab_view_get_menu_target (EABView *view, struct _EABMenu *menu);
 


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