[dia] Enable popup_object_menu() via GDK_Menu key
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Enable popup_object_menu() via GDK_Menu key
- Date: Sat, 26 Apr 2014 17:17:47 +0000 (UTC)
commit e338a6450fe38e8a9a63354a60b2813df3f19a9b
Author: Hans Breuer <hans breuer org>
Date: Fri Apr 25 13:12:59 2014 +0200
Enable popup_object_menu() via GDK_Menu key
app/disp_callbacks.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c
index b8d25bd..305a858 100644
--- a/app/disp_callbacks.c
+++ b/app/disp_callbacks.c
@@ -302,7 +302,7 @@ static DiaMenu empty_menu = {
};
static void
-popup_object_menu(DDisplay *ddisp, GdkEventButton *bevent)
+popup_object_menu(DDisplay *ddisp, GdkEvent *event)
{
Diagram *diagram;
DiaObject *obj;
@@ -386,7 +386,13 @@ popup_object_menu(DDisplay *ddisp, GdkEventButton *bevent)
menu = GTK_MENU(dia_menu->app_data);
/* add the properties menu item to raise the properties from the contextual menu */
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, bevent->button, bevent->time);
+ if (event->type == GDK_BUTTON_PRESS)
+ gtk_menu_popup(menu, NULL, NULL, NULL, NULL,
+ ((GdkEventButton *)event)->button, ((GdkEventButton *)event)->time);
+ else if (event->type == GDK_KEY_PRESS)
+ gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, ((GdkEventKey *)event)->time);
+ else /* warn about unexpected usage of this function */
+ g_warning ("Unhandled GdkEvent type=%d", event->type);
}
gint
@@ -746,17 +752,16 @@ ddisplay_canvas_events (GtkWidget *canvas,
if (active_tool->button_press_func)
(*active_tool->button_press_func) (active_tool, bevent, ddisp);
- /* Detect user holding down the button.
- * Set timeout for 1sec. If timeout is called, user must still
- * be holding. If user releases button, remove timeout. */
- hold_data.event = gdk_event_copy(event); /* need to free later */
- hold_data.ddisp = ddisp;
- hold_data.tag = g_timeout_add(1000, hold_timeout_handler, NULL);
-
+ /* Detect user holding down the button.
+ * Set timeout for 1sec. If timeout is called, user must still
+ * be holding. If user releases button, remove timeout. */
+ hold_data.event = gdk_event_copy(event); /* need to free later */
+ hold_data.ddisp = ddisp;
+ hold_data.tag = g_timeout_add(1000, hold_timeout_handler, NULL);
break;
case 2:
if (ddisp->menu_bar == NULL && !is_integrated_ui()) {
- popup_object_menu(ddisp, bevent);
+ popup_object_menu(ddisp, event);
}
else if (!transient_tool) {
gtk_widget_grab_focus(canvas);
@@ -771,14 +776,14 @@ ddisplay_canvas_events (GtkWidget *canvas,
if (ddisp->menu_bar == NULL) {
if (bevent->state & GDK_CONTROL_MASK || is_integrated_ui ()) {
/* for two button mouse users ... */
- popup_object_menu(ddisp, bevent);
+ popup_object_menu(ddisp, event);
break;
}
ddisplay_popup_menu(ddisp, bevent);
break;
}
else {
- popup_object_menu(ddisp, bevent);
+ popup_object_menu(ddisp, event);
break;
}
default:
@@ -962,6 +967,9 @@ ddisplay_canvas_events (GtkWidget *canvas,
case GDK_Return:
gtk_action_activate (menus_get_action ("ToolsTextedit"));
break;
+ case GDK_Menu:
+ popup_object_menu (ddisp, event);
+ break;
default:
if (kevent->string && kevent->keyval == ' ') {
tool_select_former();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]