[evolution-patches] Resubmit patch for bug 45631, "activate popup menu in mail composer's to/cc"
- From: Maxx Cao <maxx cao sun com>
- To: mkestner ximian com, notzed ximian com
- Cc: evolution-patches ximian com
- Subject: [evolution-patches] Resubmit patch for bug 45631, "activate popup menu in mail composer's to/cc"
- Date: Thu, 07 Aug 2003 15:11:45 +0800
Hi,
Corrections made according to Mike's comments. I can't hook this to "popup_menu" event,
because e-text is not inherited from GtkWidget.
Please review this new one. Thank you!
/ On Wed, 2003-08-06 at 03:10, Gilbert Fang wrote:
/>/
/>/ > This patch will enhance the keyboard navigation of evolution which is
/>/ > one part of our group's tasks.
/>/
/>/ Comments in-line. Thanks for the patch. Please resubmit after rework.
/>/
/>/ case GDK_KEY_PRESS: /* Fall Through */
/>/ case GDK_KEY_RELEASE:
/>/ +
/>/ + /* Handle S-F10 key binding here. */
/>/ +
/>/ + if (event->type == GDK_KEY_PRESS
/>/
/>/ You should add this code to the KEY_PRESS case instead and fall through
/>/ to the KEY_RELEASE case if the popup doesn't need to be displayed.
/>/
/>/ + && event->key.keyval == GDK_F10
/>/ + && (event->key.state&GDK_SHIFT_MASK)){
/>/ +
/>/ + /* Simulate a GdkEventButton here, so that we
/>/ can call e_text_do_popup directly */
/>/ +
/>/ + GdkEventButton *button = g_new0 (GdkEventButton,
/>/ 1);
/>/ + button->type = GDK_BUTTON_PRESS;
/>/ + button->time = GDK_CURRENT_TIME;
/>/ + button->button = 0;
/>/
/>/ You should probably use gdk_event_new here instead of just g_new0.
/>/ Also, you need to call gdk_event_free on the event when you are done
/>/ with it. The patch currently leaks the button struct./
--
Best Regards
Maxx
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.798
diff -u -r1.798 ChangeLog
--- ChangeLog 5 Aug 2003 06:29:32 -0000 1.798
+++ ChangeLog 7 Aug 2003 06:57:41 -0000
@@ -1,3 +1,11 @@
+2003-08-07 Maxx Cao <maxx cao sun com>
+
+ * gal/e-text/e-text.c (e_text_event): filter S-F10 key binding, and
+ show popup menu.
+ (popup_menu_placement_cb): function added to adjust popup menu position.
+ (popup_targets_received): show popup menu in different ways, according
+ to whether it's invoked by mouse click or key binding.
+
2003-08-05 Gilbert Fang <gilbert fang sun com>
* gal/a11y/Makefile.am: eliminate -no-undefined option.(#47322)
Index: gal/e-text/e-text.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-text/e-text.c,v
retrieving revision 1.145
diff -u -r1.145 e-text.c
--- gal/e-text/e-text.c 14 May 2003 00:42:36 -0000 1.145
+++ gal/e-text/e-text.c 7 Aug 2003 06:57:43 -0000
@@ -43,6 +43,7 @@
#include <string.h>
#include <glib-object.h>
#include <gdk/gdkx.h> /* for BlackPixel */
+#include <gdk/gdkkeysyms.h>
#include <gtk/gtkclipboard.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkselection.h>
@@ -2147,7 +2148,24 @@
return_val = 0;
break;
case GDK_KEY_PRESS: /* Fall Through */
+
+ /* Handle S-F10 key binding here. */
+
+ if (event->key.keyval == GDK_F10
+ && (event->key.state&GDK_SHIFT_MASK)
+ && text->handle_popup ){
+
+ /* Simulate a GdkEventButton here, so that we can call e_text_do_popup directly */
+
+ GdkEventButton *button = gdk_event_new (GDK_BUTTON_PRESS);
+ button->time = GDK_CURRENT_TIME;
+ button->button = 0;
+ e_text_do_popup (text, button, 0);
+ return TRUE;
+ }
+
case GDK_KEY_RELEASE:
+
if (text->editing) {
GdkEventKey key;
gint ret;
@@ -2517,6 +2535,22 @@
}
static void
+popup_menu_placement_cb (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
+{
+ EText *text = E_TEXT(user_data);
+ GnomeCanvasItem *item = &text->item;
+ GnomeCanvas *parent = item->canvas;
+
+ if (parent){
+ gdk_window_get_origin (((GtkWidget*) parent)->window, x, y);
+ *x += item->x1 + text->width/2;
+ *y += item->y1 + text->height/2;
+ }
+
+ return;
+}
+
+static void
popup_targets_received (GtkClipboard *clipboard,
GtkSelectionData *data,
gpointer user_data)
@@ -2587,9 +2621,17 @@
button, position,
popup_menu);
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL,
- button->button, GDK_CURRENT_TIME);
+ /* If invoked by S-F10 key binding, button will be 0. */
+ if (button->button == 0){
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ popup_menu_placement_cb, (gpointer)text,
+ button->button, GDK_CURRENT_TIME);
+ gdk_event_free (button);
+ } else {
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL,
+ button->button, GDK_CURRENT_TIME);
+ }
g_object_unref (text);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]