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



Thanks a lot for the comments. Here's the new patch, together with
Changelog, please review.

On Mon, 2003-07-07 at 10:54, Not Zed wrote:
> A few comments, (also, remember a changelog).
> 
> 
> +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);
> 
> This one isn't needed, as you know what you're calling it with.
> 
> +       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);
> 
> Since this is probably a possible normal-case and not a coding error,
> this should just be a return.
> 
> +       first_item = g_list_first (selection);
> +       g_return_if_fail (first_item != NULL);
> 
> All of this is completely redundant, first_item will be set to
> selection, so first_item doesn't need to exist.
> 
> +       gdk_window_get_origin (((GtkWidget*) bar)->window, x, y);
> 
> This should probably come first, so x and y are always set to something.
> 
> +       image = gnome_icon_list_get_icon_pixbuf_item (icon_list,
> (gint)first_item->data);
> +       g_return_if_fail (image != NULL);
> 
> If its possible to have a null icon, this should just be a return, or
> probably an if.
> 
> +       /* 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;
> +
> +}
> 
> On Fri, 2003-07-04 at 21:17, Yiming Cao wrote:
> > 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: ChangeLog.pre-1-4
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog.pre-1-4,v
retrieving revision 1.1
diff -u -r1.1 ChangeLog.pre-1-4
--- ChangeLog.pre-1-4	9 Jun 2003 17:31:08 -0000	1.1
+++ ChangeLog.pre-1-4	7 Jul 2003 05:21:17 -0000
@@ -1,3 +1,18 @@
+2003-07-07  Maxx Cao  <maxx cao sun com>
+
+	For bug #45826
+
+	* e-msg-composer-attachment-bar.c (button_press_event): connect
+	the "popup_menu" signal, so that S-F10 keybinding will work.
+
+	* e-msg-composer-attachment-bar.c (popup_menu_event): funcion added
+	 to handle "popup_menu" signal (S-F10 key)
+
+	* e-msg-composer-attachment-bar.c (popup_menu_placement_callback):
+	function added to place the popup menu to the center of attachment
+	 icon, in case it is activated by keyboard.
+	
+
 2003-05-20  Larry Ewing  <lewing ximian com>
 
 	* e-msg-composer.c (composer_settings_update): set the various
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	7 Jul 2003 05:21:17 -0000
@@ -586,6 +586,54 @@
 
 /* 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;
+
+	bar = E_MSG_COMPOSER_ATTACHMENT_BAR (user_data);
+	icon_list = GNOME_ICON_LIST (user_data);
+
+	gdk_window_get_origin (((GtkWidget*) bar)->window, x, y);
+
+	selection = gnome_icon_list_get_selection (icon_list);
+	if (selection == NULL)
+		return;
+
+	image = gnome_icon_list_get_icon_pixbuf_item (icon_list, (gint)selection->data);
+	if (image == NULL)
+		return;
+
+	/* 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 +679,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]