diff options
author | Maxx Cao <maxx.cao@sun.com> | 2003-08-13 14:00:20 +0800 |
---|---|---|
committer | Yuedong Du <york@src.gnome.org> | 2003-08-13 14:00:20 +0800 |
commit | a8ef795eb902d073b6975529106de3dd830b32fc (patch) | |
tree | 00b45f9d0be5800668486d7ebdeecda9683acd71 | |
parent | bb2401c0ce0e70dae6a2fcb539a27deb03b40151 (diff) | |
download | gsoc2013-evolution-a8ef795eb902d073b6975529106de3dd830b32fc.tar.gz gsoc2013-evolution-a8ef795eb902d073b6975529106de3dd830b32fc.tar.zst gsoc2013-evolution-a8ef795eb902d073b6975529106de3dd830b32fc.zip |
filter S-F10 key binding, and show popup menu. (popup_menu_placement_cb):
2003-08-10 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.
svn path=/trunk/; revision=22204
-rw-r--r-- | widgets/text/e-text.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index fb2d330baf..668a7315da 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -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> @@ -2146,8 +2147,27 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event) } return_val = 0; break; - case GDK_KEY_PRESS: /* Fall Through */ + case GDK_KEY_PRESS: + + /* 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 = event->key.time; + button->button = 0; + e_text_do_popup (text, button, 0); + return TRUE; + } + + /* Fall Through */ + case GDK_KEY_RELEASE: + if (text->editing) { GdkEventKey key; gint ret; @@ -2517,6 +2537,22 @@ popup_menu_detach (GtkWidget *attach_widget, } 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 +2623,17 @@ popup_targets_received (GtkClipboard *clipboard, 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); } |