changeset 59102:0096c58ce34a

* xmenu.c (popup_get_selection): Pop down on C-g. (set_frame_menubar): Install translations for Lucid/Motif/Lesstif that pops down menu on C-g. (xdialog_show): If dialog popped down and no button in the dialog was pushed, call Fsignal to quit. (xmenu_show): In no toolkit version, if menu returns NO_SELECT call Fsignal to quit. * xfns.c (Fx_file_dialog): Motif/Lesstif version: Pop down on C-g. * gtkutil.c (xg_initialize): Install bindings for C-g so that dialogs and menus pop down.
author Jan Djärv <jan.h.d@swipnet.se>
date Mon, 27 Dec 2004 15:24:12 +0000
parents 8aef5660523e
children 9c9d41548660
files src/ChangeLog src/gtkutil.c src/xfns.c src/xmenu.c
diffstat 4 files changed, 58 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Dec 27 15:23:22 2004 +0000
+++ b/src/ChangeLog	Mon Dec 27 15:24:12 2004 +0000
@@ -1,3 +1,18 @@
+2004-12-27  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xmenu.c (popup_get_selection): Pop down on C-g.
+	(set_frame_menubar): Install translations for Lucid/Motif/Lesstif that
+	pops down menu on C-g.
+	(xdialog_show): If dialog popped down and no button in the dialog was
+	pushed, call Fsignal to quit.
+	(xmenu_show): In no toolkit version, if menu returns NO_SELECT call
+	Fsignal to quit.
+
+	* xfns.c (Fx_file_dialog): Motif/Lesstif version:  Pop down on C-g.
+
+	* gtkutil.c (xg_initialize): Install bindings for C-g so that
+	dialogs and menus pop down.
+
 2004-12-25  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* gtkutil.c (update_frame_tool_bar): Make the value of
--- a/src/gtkutil.c	Mon Dec 27 15:23:22 2004 +0000
+++ b/src/gtkutil.c	Mon Dec 27 15:24:12 2004 +0000
@@ -3578,6 +3578,8 @@
 void
 xg_initialize ()
 {
+  GtkBindingSet *binding_set;
+
   xg_ignore_gtk_scrollbar = 0;
   xg_detached_menus = 0;
   xg_menu_cb_list.prev = xg_menu_cb_list.next =
@@ -3600,6 +3602,17 @@
                                     "gtk-key-theme-name",
                                     "Emacs",
                                     EMACS_CLASS);
+
+  /* Make dialogs close on C-g.  Since file dialog inherits from
+     dialog, this works for them also.  */
+  binding_set = gtk_binding_set_by_class (gtk_type_class (GTK_TYPE_DIALOG));
+  gtk_binding_entry_add_signal (binding_set, GDK_g, GDK_CONTROL_MASK,
+                                "close", 0);
+
+  /* Make menus close on C-g.  */
+  binding_set = gtk_binding_set_by_class (gtk_type_class (GTK_TYPE_MENU_SHELL));
+  gtk_binding_entry_add_signal (binding_set, GDK_g, GDK_CONTROL_MASK,
+                                "cancel", 0);
 }
 
 #endif /* USE_GTK */
--- a/src/xfns.c	Mon Dec 27 15:23:22 2004 +0000
+++ b/src/xfns.c	Mon Dec 27 15:24:12 2004 +0000
@@ -5243,6 +5243,16 @@
       XEvent event;
       x_menu_wait_for_event (0);
       XtAppNextEvent (Xt_app_con, &event);
+      if (event.type == KeyPress
+          && FRAME_X_DISPLAY (f) == event.xkey.display)
+        {
+          KeySym keysym = XLookupKeysym (&event.xkey, 0);
+
+          /* Pop down on C-g.  */
+          if (keysym == XK_g && (event.xkey.state & ControlMask) != 0)
+            XtUnmanageChild (dialog);
+        }
+  
       (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f));
     }
 
--- a/src/xmenu.c	Mon Dec 27 15:23:22 2004 +0000
+++ b/src/xmenu.c	Mon Dec 27 15:24:12 2004 +0000
@@ -1243,6 +1243,11 @@
                && dpyinfo->display == event.xbutton.display)
         {
           KeySym keysym = XLookupKeysym (&event.xkey, 0);
+
+          /* Pop down on C-g.  */
+          if (keysym == XK_g && (event.xkey.state & ControlMask) != 0)
+            popup_activated_flag = 0;
+
           if (!IsModifierKey (keysym)
               && x_any_window_to_frame (dpyinfo, event.xany.window) != NULL)
 	    popup_activated_flag = 0;
@@ -2226,6 +2231,9 @@
     }
   else
     {
+      char menuOverride[] = "Ctrl<KeyPress>g: MenuGadgetEscape()";
+      XtTranslations  override = XtParseTranslationTable (menuOverride);
+
       menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv,
 					 f->output_data.x->column_widget,
 					 0,
@@ -2234,6 +2242,9 @@
 					 popup_deactivate_callback,
 					 menu_highlight_callback);
       f->output_data.x->menubar_widget = menubar_widget;
+
+      /* Make menu pop down on C-g.  */
+      XtOverrideTranslations (menubar_widget, override);
     }
 
   {
@@ -3155,6 +3166,9 @@
 	    }
 	}
     }
+  else
+    /* Make "Cancel" equivalent to C-g.  */
+    Fsignal (Qquit, Qnil);
 
   return Qnil;
 }
@@ -3500,7 +3514,13 @@
     case XM_FAILURE:
       *error = "Can't activate menu";
     case XM_IA_SELECT:
+      entry = Qnil;
+      break;
     case XM_NO_SELECT:
+      /* Make "Cancel" equivalent to C-g unless this menu was popped up by
+         a mouse press.  */
+      if (! for_click)
+        Fsignal (Qquit, Qnil);
       entry = Qnil;
       break;
     }