[evolution-patches] Seeking review for bug 41839



Hi,
  This patch is for bug 41839, and now the attachment in the mail body
can be accessed by keyboard. 

  
  1. Attachment buttons made focusable. This reverses bug 3094, but I
don't see any inconvinience. Please give comments.
  2. popup button: The button, which pops up the attachment context
menu, is originally connected with signal "button_press_event". I think
"clicked" signal of gtkbutton is a better choice, so that it can be
accessed both by mouse and by keyboard. So pixmap_press function is
changed to a signal callback. 
  3. A callback to place context menu is added, because originally the
menu is opened at the position of pointer, and this is confusing when
menu is popped up by keyboard. I dropped e_popup_menu_run and use
gtk_menu_popup directly, with which I can ensure the menu opens beside
the button.

-- 
Yiming Cao <maxx cao sun com>
Index: mail-display.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-display.c,v
retrieving revision 1.282
diff -u -r1.282 mail-display.c
--- mail-display.c	11 Jun 2003 16:19:34 -0000	1.282
+++ mail-display.c	2 Jul 2003 06:01:54 -0000
@@ -450,10 +450,23 @@
 	mail_display_queue_redisplay (md);
 }
 
+static void
+popup_menu_placement_callback(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
+{
+	GtkWidget *widget = (GtkWidget*) user_data;
+
+	gdk_window_get_origin (gtk_widget_get_parent_window (widget), x, y);
+	*x += widget->allocation.x;
+	*y += widget->allocation.y;
+
+	return;
+}
+
 static gboolean
-pixmap_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+pixmap_press (GtkWidget *widget, gpointer user_data) 
 {
 	EPopupMenu *menu;
+	GtkMenu *gtk_menu;
 	EPopupMenu save_item = E_POPUP_ITEM (N_("Save Attachment..."), G_CALLBACK (save_cb), 0);
 	EPopupMenu view_item = E_POPUP_ITEM (N_("View Inline"), G_CALLBACK (inline_cb), 2);
 	EPopupMenu open_item = E_POPUP_ITEM (N_("Open in %s..."), G_CALLBACK (launch_cb), 1);
@@ -462,24 +475,6 @@
 	MailMimeHandler *handler;
 	int mask = 0, i, nitems;
 	
-#ifdef USE_OLD_DISPLAY_STYLE
-	if (event->button != 3) {
-		gtk_propagate_event (GTK_WIDGET (user_data),
-				     (GdkEvent *)event);
-		return TRUE;
-	}
-#endif
-	
-	if (event->button != 1 && event->button != 3) {
-		gtk_propagate_event (GTK_WIDGET (user_data),
-				     (GdkEvent *)event);
-		return TRUE;
-	}
-	
-	/* Stop the signal, since we don't want the button's class method to
-	   mess up our popup. */
-	g_signal_stop_emission_by_name (widget, "button_press_event");
-	
 	part = g_object_get_data ((GObject *) widget, "CamelMimePart");
 	handler = mail_lookup_handler (g_object_get_data ((GObject *) widget, "mime_type"));
 	
@@ -540,8 +535,9 @@
 		mask |= 1;
 	}
 	
-	e_popup_menu_run (menu, (GdkEvent *)event, mask, 0, widget);
-	
+	gtk_menu = e_popup_menu_create (menu, mask, 0, widget);
+	gtk_menu_popup (gtk_menu, NULL, NULL, popup_menu_placement_callback, (gpointer)widget, 0, GDK_CURRENT_TIME);
+
 	for (i = 1; i < nitems; i++)
 		g_free (menu[i].name);
 	g_free (menu);
@@ -1039,7 +1035,6 @@
 	mainbox = gtk_hbox_new (FALSE, 0);
 	
 	button = gtk_button_new ();
-	GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
 	g_object_set_data ((GObject *) button, "MailDisplay", md);
 	
 	handler = mail_lookup_handler (eb->type);
@@ -1072,7 +1067,6 @@
 	gtk_container_add (GTK_CONTAINER (button), hbox);
 	
 	popup = gtk_button_new ();
-	GTK_WIDGET_UNSET_FLAGS (popup, GTK_CAN_FOCUS);
 	gtk_container_add (GTK_CONTAINER (popup),
 			   gtk_arrow_new (GTK_ARROW_DOWN,
 					  GTK_SHADOW_ETCHED_IN));
@@ -1081,7 +1075,7 @@
 	g_object_set_data ((GObject *) popup, "CamelMimePart", part);
 	g_object_set_data_full ((GObject *) popup, "mime_type", g_strdup (eb->type), (GDestroyNotify) g_free);
 	
-	g_signal_connect (popup, "button_press_event", G_CALLBACK (pixmap_press), md->scroll);
+	g_signal_connect (popup, "clicked", G_CALLBACK (pixmap_press), md->scroll);
 	
 	gtk_box_pack_start (GTK_BOX (mainbox), button, TRUE, TRUE, 0);
 	gtk_box_pack_start (GTK_BOX (mainbox), popup, TRUE, TRUE, 0);


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