emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: message-box is not for questions


From: Nick Roberts
Subject: Re: message-box is not for questions
Date: Sun, 22 May 2005 01:51:21 +1200

 >     message-box like y-or-n-p calls x_popup_dialog which calls xdialog_show
 >     which has the line dialog_name[0] = 'Q' which gives the frame the title
 >     "Question".
 > 
 >     However, unlike y-or-n-p, message-box does not ask a question but
 >     provides information, so I think in this case it should do
 >     dialog_name[0] = 'I'.
 > 
 > Can you possibly fix it?

I've tried to do this.

Fx_popup_dialog in xmenu.c takes an extra optional argument which defaults to
"Q" for Question so x-popup-dialog, y-or-no-p, yes-or-no-p are unchanged.

Fmessage_box in editfns.c calls Fx_popup_dialog with a value of "I" to give
the frame the title Information.

I guess the changes in xmenu.c need to be copied to w32menu.c and macmenu.c
but I'll wait for these changes to be reviewed. I've not made such changes
before so there is a bit of guesswork and someone who is familar with the
C code really  needs to review them carefully.

It might be useful at some stage to add a lisp primitive called error-box.

Nick

*** /home/nick/emacs/src/xmenu.c.~1.289.~       2005-05-11 00:05:26.000000000 
+1200
--- /home/nick/emacs/src/xmenu.c        2005-05-22 01:33:33.000000000 +1200
***************
*** 116,122 ****
  extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
  extern XtAppContext Xt_app_con;
  
! static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, char **));
  static void popup_get_selection P_ ((XEvent *, struct x_display_info *,
                                       LWLIB_ID, int));
  
--- 116,123 ----
  extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
  extern XtAppContext Xt_app_con;
  
! static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, Lisp_Object,
!                                    char **));
  static void popup_get_selection P_ ((XEvent *, struct x_display_info *,
                                       LWLIB_ID, int));
  
***************
*** 129,135 ****
  #include "gtkutil.h"
  #define HAVE_BOXES 1
  extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
! static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, char **));
  #endif
  
  /* This is how to deal with multibyte text if HAVE_MULTILINGUAL_MENU
--- 130,137 ----
  #include "gtkutil.h"
  #define HAVE_BOXES 1
  extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
! static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, Lisp_Object,
!                                    char **));
  #endif
  
  /* This is how to deal with multibyte text if HAVE_MULTILINGUAL_MENU
***************
*** 999,1005 ****
  
  #ifdef HAVE_MENUS
  
! DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0,
         doc: /* Pop up a dialog box and return user's selection.
  POSITION specifies which frame to use.
  This is normally a mouse button event or a window or frame.
--- 1001,1007 ----
  
  #ifdef HAVE_MENUS
  
! DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0,
         doc: /* Pop up a dialog box and return user's selection.
  POSITION specifies which frame to use.
  This is normally a mouse button event or a window or frame.
***************
*** 1007,1013 ****
  The dialog box appears in the middle of the specified frame.
  
  CONTENTS specifies the alternatives to display in the dialog box.
! It is a list of the form (TITLE ITEM1 ITEM2...).
  Each ITEM is a cons cell (STRING . VALUE).
  The return value is VALUE from the chosen item.
  
--- 1009,1015 ----
  The dialog box appears in the middle of the specified frame.
  
  CONTENTS specifies the alternatives to display in the dialog box.
! It is a list of the form (DIALOG ITEM1 ITEM2...).
  Each ITEM is a cons cell (STRING . VALUE).
  The return value is VALUE from the chosen item.
  
***************
*** 1016,1030 ****
  on the left of the dialog box and all following items on the right.
  \(By default, approximately half appear on each side.)
  
  If the user gets rid of the dialog box without making a valid choice,
  for instance using the window manager, then this produces a quit and
  `x-popup-dialog' does not return.  */)
!      (position, contents)
!      Lisp_Object position, contents;
  {
    FRAME_PTR f = NULL;
    Lisp_Object window;
  
    check_x ();
  
    /* Decode the first argument: find the window or frame to use.  */
--- 1018,1043 ----
  on the left of the dialog box and all following items on the right.
  \(By default, approximately half appear on each side.)
  
+ Optional third argument HEADER specifies the title for the frame:
+ 
+  "E" = Error, "I" = Information, "P" = Prompt, "Q" = Question
+ 
+ When it is not specified, it defaults to Question.
+ 
  If the user gets rid of the dialog box without making a valid choice,
  for instance using the window manager, then this produces a quit and
  `x-popup-dialog' does not return.  */)
!      (position, contents, header)
!      Lisp_Object position, contents, header;
  {
    FRAME_PTR f = NULL;
    Lisp_Object window;
  
+   if (NILP (header))
+     header = build_string ("Q");
+   else
+     CHECK_STRING (header);
+ 
    check_x ();
  
    /* Decode the first argument: find the window or frame to use.  */
***************
*** 1115,1121 ****
  
      /* Display them in a dialog box.  */
      BLOCK_INPUT;
!     selection = xdialog_show (f, 0, title, &error_name);
      UNBLOCK_INPUT;
  
      unbind_to (specpdl_count, Qnil);
--- 1128,1134 ----
  
      /* Display them in a dialog box.  */
      BLOCK_INPUT;
!     selection = xdialog_show (f, 0, title, header, &error_name);
      UNBLOCK_INPUT;
  
      unbind_to (specpdl_count, Qnil);
***************
*** 3020,3029 ****
    "button6", "button7", "button8", "button9", "button10" };
  
  static Lisp_Object
! xdialog_show (f, keymaps, title, error)
       FRAME_PTR f;
       int keymaps;
!      Lisp_Object title;
       char **error;
  {
    int i, nb_buttons=0;
--- 3033,3042 ----
    "button6", "button7", "button8", "button9", "button10" };
  
  static Lisp_Object
! xdialog_show (f, keymaps, title, header, error)
       FRAME_PTR f;
       int keymaps;
!      Lisp_Object title, header;
       char **error;
  {
    int i, nb_buttons=0;
***************
*** 3125,3131 ****
         which specifies how many buttons to use
         and how many buttons are on the right.
         The Q means something also.  */
!     dialog_name[0] = 'Q';
      dialog_name[1] = '0' + nb_buttons;
      dialog_name[2] = 'B';
      dialog_name[3] = 'R';
--- 3138,3151 ----
         which specifies how many buttons to use
         and how many buttons are on the right.
         The Q means something also.  */
!     if (strcmp ("E",  XSTRING (header)->data) == 0)
!       dialog_name[0] = 'E';
!     else if (strcmp ("I",  XSTRING (header)->data) == 0)
!       dialog_name[0] = 'I';
!     else if (strcmp ("P",  XSTRING (header)->data) == 0)
!       dialog_name[0] = 'P';
!     else if (strcmp ("Q",  XSTRING (header)->data) == 0)
!       dialog_name[0] = 'Q';
      dialog_name[1] = '0' + nb_buttons;
      dialog_name[2] = 'B';
      dialog_name[3] = 'R';

*** /home/nick/emacs/src/editfns.c~     2005-04-21 09:08:26.000000000 +1200
--- /home/nick/emacs/src/editfns.c      2005-05-20 11:54:44.000000000 +1200
***************
*** 3175,3181 ****
        pane = Fcons (Fcons (build_string ("OK"), Qt), Qnil);
        GCPRO1 (pane);
        menu = Fcons (val, pane);
!       obj = Fx_popup_dialog (Qt, menu);
        UNGCPRO;
        return val;
        }
--- 3175,3181 ----
        pane = Fcons (Fcons (build_string ("OK"), Qt), Qnil);
        GCPRO1 (pane);
        menu = Fcons (val, pane);
!       obj = Fx_popup_dialog (Qt, menu, build_string ("I"));
        UNGCPRO;
        return val;
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]