[evolution-patches] Patch for bug 45826, please review



Hi,

This patch fix bug 45862, "shift+f10 should activate popup menu when
focus on attachment". Now in the composer, if you press S-F10 when the
attachments are focused, popup menu will be available. The menu comes at
the center point of the first focused attachment.

-- 
Yiming Cao <maxx cao sun com>
Index: e-msg-composer-attachment-bar.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-attachment-bar.c,v
retrieving revision 1.67
diff -u -r1.67 e-msg-composer-attachment-bar.c
--- e-msg-composer-attachment-bar.c	9 Jun 2003 18:18:32 -0000	1.67
+++ e-msg-composer-attachment-bar.c	4 Jul 2003 11:37:02 -0000
@@ -586,6 +586,58 @@
 
 /* GtkWidget methods.  */
 
+
+static void
+popup_menu_placement_callback(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
+{
+	EMsgComposerAttachmentBar *bar;
+	GnomeIconList *icon_list;
+	GList *selection;
+	GnomeCanvasPixbuf *image;
+	GList *first_item;
+
+	g_return_if_fail (user_data != NULL);
+
+	bar = E_MSG_COMPOSER_ATTACHMENT_BAR (user_data);
+	icon_list = GNOME_ICON_LIST (user_data);
+
+	selection = gnome_icon_list_get_selection (icon_list);
+	g_return_if_fail (selection != NULL);
+
+	first_item = g_list_first (selection);
+	g_return_if_fail (first_item != NULL);
+
+	gdk_window_get_origin (((GtkWidget*) bar)->window, x, y);
+
+	image = gnome_icon_list_get_icon_pixbuf_item (icon_list, (gint)first_item->data);
+	g_return_if_fail (image != NULL);
+
+	/* Put menu to the center of icon */
+	*x += (gint)(image->item.x1 + image->item.x2)/2;
+	*y += (gint)(image->item.y1 + image->item.y2)/2;
+
+}
+
+static gboolean 
+popup_menu_event (GtkWidget *widget)
+{
+	EMsgComposerAttachmentBar *bar = E_MSG_COMPOSER_ATTACHMENT_BAR (widget);
+	GnomeIconList *icon_list = GNOME_ICON_LIST (widget);
+	GList *selection = gnome_icon_list_get_selection (icon_list);
+	GtkMenu *menu;
+
+	if (selection==NULL)
+		menu = get_context_menu (bar);
+	else
+		menu = get_icon_context_menu (bar);
+
+	gnome_popup_menu_do_popup (menu, popup_menu_placement_callback, 
+				   (gpointer)widget, NULL, (gpointer)widget, NULL);
+
+	return TRUE;
+}
+
+
 static gint
 button_press_event (GtkWidget *widget,
 		    GdkEventButton *event)
@@ -631,6 +683,8 @@
 	object_class->destroy = destroy;
 	
 	widget_class->button_press_event = button_press_event;
+	widget_class->popup_menu = popup_menu_event;
+	
 	
 	/* Setup signals.  */
 	


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