[evolution-patches] Patch to add open menu to right click popup for attachment(s) in meetings.



Hi,

Patch attached below adds open menu, when user right click's on an
attachment attached to meeting(s) and it's associated call back.






Thanks,
Viren
Index: gui/dialogs/comp-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/comp-editor.c,v
retrieving revision 1.143
diff -u -p -r1.143 comp-editor.c
--- gui/dialogs/comp-editor.c	20 Jul 2005 11:18:54 -0000	1.143
+++ gui/dialogs/comp-editor.c	26 Jul 2005 04:47:59 -0000
@@ -1016,6 +1016,47 @@ attachment_bar_icon_clicked_cb (EAttachm
 }
 
 /* Callbacks.  */
+static void
+cab_open(EPopup *ep, EPopupItem *item, void *data)
+{
+	 EAttachmentBar *bar = data;
+        CompEditor *editor = COMP_EDITOR (gtk_widget_get_toplevel (GTK_WIDGET (bar)));
+ 	 GnomeIconList *icon_list;
+        GList *p;
+        int num;
+        char *attach_file_url;
+        GError *error = NULL;
+
+ 	 icon_list = GNOME_ICON_LIST (bar);
+        p = gnome_icon_list_get_selection (icon_list);
+        if (p) {
+		 EAttachment *attachment;
+                GSList *list;
+                const char *comp_uid= NULL;
+                const char *local_store = e_cal_get_local_attachment_store (editor->priv->client);
+
+                e_cal_component_get_uid (editor->priv->comp, &comp_uid);
+                num = GPOINTER_TO_INT (p->data);
+                list = e_attachment_bar_get_attachment (bar, num);
+                attachment = list->data;
+		 g_slist_free (list);
+
+                attach_file_url = g_strconcat (local_store,
+						comp_uid,
+                                                "-",
+                                                camel_mime_part_get_filename(attachment->body),
+                                                NULL);
+
+                         /* launch the url now */
+                         /* TODO should send GError and handle error conditions
+                          * here */
+    		 gnome_url_show (attach_file_url, &error);
+		
+                if (error)
+        		g_message ("DEBUG: Launch failed :(\n");
+		 g_free (attach_file_url); 
+	}		
+}	
 
 static void
 cab_add(EPopup *ep, EPopupItem *item, void *data)
@@ -1056,10 +1097,11 @@ cab_remove(EPopup *ep, EPopupItem *item,
 
 /* Popup menu handling.  */
 static EPopupItem cab_popups[] = {
-	{ E_POPUP_ITEM, "10.attach", N_("_Remove"), cab_remove, NULL, GTK_STOCK_REMOVE, E_CAL_POPUP_ATTACHMENTS_MANY },
-	{ E_POPUP_ITEM, "20.attach", N_("_Properties"), cab_properties, NULL, GTK_STOCK_PROPERTIES, E_CAL_POPUP_ATTACHMENTS_ONE },
-	{ E_POPUP_BAR, "30.attach.00", NULL, NULL, NULL, NULL, E_CAL_POPUP_ATTACHMENTS_MANY|E_CAL_POPUP_ATTACHMENTS_ONE },
-	{ E_POPUP_ITEM, "30.attach.01", N_("_Add attachment..."), cab_add, NULL, GTK_STOCK_ADD, 0 },
+	{ E_POPUP_ITEM, "10.attach", N_("_Open"), cab_open, NULL, GTK_STOCK_OPEN, E_CAL_POPUP_ATTACHMENTS_ONE | E_CAL_POPUP_ATTACHMENTS_MANY },
+	{ E_POPUP_ITEM, "20.attach", N_("_Remove"), cab_remove, NULL, GTK_STOCK_REMOVE, E_CAL_POPUP_ATTACHMENTS_MANY },
+	{ E_POPUP_ITEM, "30.attach", N_("_Properties"), cab_properties, NULL, GTK_STOCK_PROPERTIES, E_CAL_POPUP_ATTACHMENTS_ONE },
+	{ E_POPUP_BAR, "40.attach.00", NULL, NULL, NULL, NULL, E_CAL_POPUP_ATTACHMENTS_MANY|E_CAL_POPUP_ATTACHMENTS_ONE },
+	{ E_POPUP_ITEM, "40.attach.01", N_("_Add attachment..."), cab_add, NULL, GTK_STOCK_ADD, 0 },
 };
 
 static void
@@ -1100,11 +1142,21 @@ cab_popup(EAttachmentBar *bar, GdkEventB
 	ECalPopup *ecp;
 	ECalPopupTargetAttachments *t;
 	GtkMenu *menu;
-
+	CompEditorFlags flags;
+       CompEditor *editor;
+	      
+	editor = COMP_EDITOR (gtk_widget_get_toplevel (GTK_WIDGET (bar)));
+       flags = comp_editor_get_flags (editor);
         attachments = e_attachment_bar_get_attachment(bar, id);
 
-	for (i=0;i<sizeof(cab_popups)/sizeof(cab_popups[0]);i++)
+	for (i=0;i<sizeof(cab_popups)/sizeof(cab_popups[0]);i++) {
+		if (!(flags & COMP_EDITOR_USER_ORG) &&
+                               (!strcmp (cab_popups[i].path, "20.attach") ||
+                                !strcmp (cab_popups[i].path, "40.attach.01")))
+                       continue;
+	        else 
 		menus = g_slist_prepend(menus, &cab_popups[i]);
+	}		
 
 	/** @HookPoint-ECalPopup: Calendar Attachment Bar Context Menu
 	 * @Id: org.gnome.evolution.calendar.attachmentbar.popup
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2777
diff -u -p -r1.2777 ChangeLog
--- ChangeLog	22 Jul 2005 11:41:35 -0000	1.2777
+++ ChangeLog	26 Jul 2005 04:48:06 -0000
@@ -1,3 +1,8 @@
+2005-07-26  Viren.l  <lviren novell com>
+	* gui/dialogs/comp-editor.c: (cab_open), (cab_popup):
+	 Added Open to right click popup and cab_open callback.
+	 Append Remove and Add attachments menus to popup if user is organizer.
+	 
 2005-07-22  Chenthill Palanisamy  <pchenthill novell com>
 
 	Fixes #309991


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