annotate src/menubar-gtk.c @ 851:e7ee5f8bde58

[xemacs-hg @ 2002-05-23 11:46:08 by ben] fix for raymond toy's crash, alloca crashes, some recover-session improvements files.el: Recover-session improvements: Only show session files where some files can actually be recovered, and show in chronological order. subr.el, menubar-items.el: As promised to rms, the functionality in truncate-string-with-continuation-dots has been merged into truncate-string-to-width. Change callers in menubar-items.el. select.el: Document some of these funs better. Fix problem where we were doing own-clipboard twice. Makefile.in.in: Add alloca.o. Ensure that alloca.s doesn't compile into alloca.o, but allocax.o (not that it's currently used or anything.) EmacsFrame.c, abbrev.c, alloc.c, alloca.c, callint.c, callproc.c, config.h.in, device-msw.c, device-x.c, dired.c, doc.c, editfns.c, emacs.c, emodules.c, eval.c, event-Xt.c, event-msw.c, event-stream.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-x.c, input-method-xlib.c, intl-win32.c, lisp.h, lread.c, menubar-gtk.c, menubar-msw.c, menubar.c, mule-wnnfns.c, nt.c, objects-msw.c, process-nt.c, realpath.c, redisplay-gtk.c, redisplay-output.c, redisplay-x.c, redisplay.c, search.c, select-msw.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: Fix Raymond Toy's crash. Repeat to self: 2^21 - 1 is NOT the same as (2 << 21) - 1. Fix crashes due to excessive alloca(). replace alloca() with ALLOCA(), which calls the C alloca() [which uses xmalloc()] when the size is too big. Insert in various places calls to try to flush the C alloca() stored info if there is any. Add MALLOC_OR_ALLOCA(), for places that expect to be alloca()ing large blocks. This xmalloc()s when too large and records an unwind-protect to free -- relying on the caller to unbind_to() elsewhere in the function. Use it in concat(). Use MALLOC instead of ALLOCA in select-msw.c. xemacs.mak: Add alloca.o.
author ben
date Thu, 23 May 2002 11:46:46 +0000
parents ee2d33cfc3c1
children 79c6ff3eef26
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 /* Implements an elisp-programmable menubar -- X interface.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5 This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 later version.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 for more details.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24 /* created 16-dec-91 by jwz */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 #include "console-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 #include "gui-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32 #include "buffer.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 #include "commands.h" /* zmacs_regions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 #include "ui-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35 #include "gui.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36 #include "events.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 #include "frame.h"
809
285f13b079f3 [xemacs-hg @ 2002-04-07 16:01:30 by wmperry]
wmperry
parents: 793
diff changeset
38 #include "device.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 #include "opaque.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 #include "window.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 #ifdef HAVE_GNOME
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 #include <libgnomeui/libgnomeui.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 #define MENUBAR_TYPE 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 #define SUBMENU_TYPE 1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 #define POPUP_TYPE 2
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 static GtkWidget *menu_descriptor_to_widget_1 (Lisp_Object descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 #define FRAME_MENUBAR_DATA(frame) ((frame)->menubar_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 #define XFRAME_MENUBAR_DATA_LASTBUFF(frame) (XCAR ((frame)->menubar_data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 #define XFRAME_MENUBAR_DATA_UPTODATE(frame) (XCDR ((frame)->menubar_data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 /* This is a bogus subclass of GtkMenuBar so that the menu never tries
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 ** to be bigger than the text widget. This prevents weird resizing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 ** when jumping around between buffers with radically different menu
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 ** sizes.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 #define GTK_XEMACS_MENUBAR(obj) GTK_CHECK_CAST (obj, gtk_xemacs_menubar_get_type (), GtkXEmacsMenubar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 #define GTK_XEMACS_MENUBAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_xemacs_menubar_get_type (), GtkXEmacsMenubarClass)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 #define GTK_IS_XEMACS_MENUBAR(obj) GTK_CHECK_TYPE (obj, gtk_xemacs_menubar_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 #define GTK_XEMACS_MENUBAR_FRAME(obj) GTK_XEMACS_MENUBAR (obj)->f
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 typedef struct _GtkXEmacsMenubar GtkXEmacsMenubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 typedef struct _GtkXEmacsMenubarClass GtkXEmacsMenubarClass;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 struct _GtkXEmacsMenubar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 GtkMenuBar menu;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 struct frame *frame;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 struct _GtkXEmacsMenubarClass
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 GtkMenuBarClass parent_class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82 guint gtk_xemacs_menubar_get_type (void);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 GtkWidget *gtk_xemacs_menubar_new (struct frame *f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 static void gtk_xemacs_menubar_class_init (GtkXEmacsMenubarClass *klass);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 static void gtk_xemacs_menubar_init (GtkXEmacsMenubar *xemacs);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 static void gtk_xemacs_menubar_size_request (GtkWidget *widget, GtkRequisition *requisition);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 guint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 gtk_xemacs_menubar_get_type (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 static guint xemacs_menubar_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 if (!xemacs_menubar_type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 static const GtkTypeInfo xemacs_menubar_info =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 "GtkXEmacsMenubar",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 sizeof (GtkXEmacsMenubar),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 sizeof (GtkXEmacsMenubarClass),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 (GtkClassInitFunc) gtk_xemacs_menubar_class_init,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 (GtkObjectInitFunc) gtk_xemacs_menubar_init,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 /* reserved_1 */ NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 /* reserved_2 */ NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 (GtkClassInitFunc) NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 xemacs_menubar_type = gtk_type_unique (gtk_menu_bar_get_type (), &xemacs_menubar_info);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 return xemacs_menubar_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 static GtkWidgetClass *parent_class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 static void gtk_xemacs_menubar_class_init (GtkXEmacsMenubarClass *klass)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118 GtkWidgetClass *widget_class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 widget_class = (GtkWidgetClass*) klass;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 parent_class = (GtkWidgetClass *) gtk_type_class (gtk_menu_bar_get_type ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 widget_class->size_request = gtk_xemacs_menubar_size_request;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 static void gtk_xemacs_menubar_init (GtkXEmacsMenubar *xemacs)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 static void gtk_xemacs_menubar_size_request (GtkWidget *widget, GtkRequisition *requisition)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 GtkXEmacsMenubar *x = GTK_XEMACS_MENUBAR (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 GtkRequisition frame_size;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 parent_class->size_request (widget, requisition);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 /* #### BILL!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 ** We should really only do this if the menu has not been detached!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 ** WMP 9/9/2000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 gtk_widget_size_request (FRAME_GTK_TEXT_WIDGET (x->frame), &frame_size);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 requisition->width = frame_size.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 GtkWidget *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 gtk_xemacs_menubar_new (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 GtkXEmacsMenubar *menubar = gtk_type_new (gtk_xemacs_menubar_get_type ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 menubar->frame = f;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 return (GTK_WIDGET (menubar));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 /* We now return you to your regularly scheduled menus... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 int dockable_menubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162 /* #define TEAR_OFF_MENUS */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 int tear_off_menus;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 /* Converting from XEmacs to GTK representation */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171 menu_name_to_accelerator (char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 while (*name) {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 if (*name=='%') {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 ++name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 if (!(*name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 if (*name=='_' && *(name+1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 int accelerator = (int) (unsigned char) (*(name+1));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 return make_char (tolower (accelerator));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 ++name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 #define XEMACS_MENU_DESCR_TAG "xemacs::menu::description"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 #define XEMACS_MENU_FILTER_TAG "xemacs::menu::filter"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 #define XEMACS_MENU_GUIID_TAG "xemacs::menu::gui_id"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 #define XEMACS_MENU_FIRSTTIME_TAG "xemacs::menu::first_time"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194 static void __activate_menu(GtkMenuItem *, gpointer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 __torn_off_sir(GtkMenuItem *item, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 GtkWidget *menu_item = GTK_WIDGET (user_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 if (GTK_TEAROFF_MENU_ITEM (item)->torn_off)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 /* Menu was just torn off */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 GUI_ID id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 Lisp_Object menu_desc = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 GtkWidget *old_submenu = GTK_MENU_ITEM (menu_item)->submenu;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
209 menu_desc = VOID_TO_LISP (gtk_object_get_data (GTK_OBJECT (menu_item), XEMACS_MENU_DESCR_TAG));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 /* GCPRO all of our very own */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212 gcpro_popup_callbacks (id, menu_desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 /* Hide the now detached menu from the attentions of
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 __activate_menu destroying the old submenu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 gtk_widget_ref (old_submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), gtk_menu_new ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 gtk_widget_show_all (old_submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225 /* This is called when a menu is about to be shown... this is what
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 does the delayed creation of the menu items. We populate the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 submenu and away we go. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229 __maybe_destroy (GtkWidget *child, GtkWidget *precious)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 if (GTK_IS_MENU_ITEM (child) && !GTK_IS_TEAROFF_MENU_ITEM (child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 if (GTK_WIDGET_VISIBLE (child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 /* If we delete the menu item that was 'active' when the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 menu was cancelled, GTK gets upset because it tries to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 remove the focus rectangle from a (now) dead widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 This widget will eventually get killed because it will
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 not be visible the next time the window is shown.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 gtk_widget_set_sensitive (child, FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243 gtk_widget_hide_all (child);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 gtk_widget_destroy (child);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 /* If user_data != 0x00 then we are using a hook to build the menu. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 __activate_menu(GtkMenuItem *item, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 Lisp_Object desc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 gpointer force_clear = gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_FIRSTTIME_TAG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 gtk_object_set_data (GTK_OBJECT (item), XEMACS_MENU_FIRSTTIME_TAG, 0x00);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 /* Delete the old contents of the menu if we are the top level menubar */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 if (GTK_IS_MENU_BAR (GTK_WIDGET (item)->parent) || force_clear)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 GtkWidget *selected = gtk_menu_get_active (GTK_MENU (item->submenu));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 gtk_container_foreach (GTK_CONTAINER (item->submenu),(GtkCallback) __maybe_destroy,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 selected);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 else if (gtk_container_children (GTK_CONTAINER (item->submenu)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
274 desc = VOID_TO_LISP (gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_DESCR_TAG));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 /* Lets stick in a detacher just for giggles */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 if (tear_off_menus && !gtk_container_children (GTK_CONTAINER (item->submenu)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 GtkWidget *w = gtk_tearoff_menu_item_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 gtk_widget_show (w);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 gtk_menu_append (GTK_MENU (item->submenu), w);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 gtk_signal_connect (GTK_OBJECT (w), "activate", GTK_SIGNAL_FUNC (__torn_off_sir), item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 if (user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 GUI_ID id = (GUI_ID) gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_GUIID_TAG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 Lisp_Object hook_fn;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 struct gcpro gcpro1, gcpro2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
293 hook_fn = VOID_TO_LISP (gtk_object_get_data (GTK_OBJECT (item), XEMACS_MENU_FILTER_TAG));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 GCPRO2 (desc, hook_fn);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 desc = call1 (hook_fn, desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 ungcpro_popup_callbacks (id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 gcpro_popup_callbacks (id, desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 /* Build the child widgets */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 for (; !NILP (desc); desc = Fcdr (desc))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 GtkWidget *next = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 Lisp_Object child = Fcar (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 if (NILP (child)) /* the partition */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 /* Signal an error here? The NILP handling is handled a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 layer higher where appropriate */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 next = menu_descriptor_to_widget_1 (child);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 if (!next)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 gtk_widget_show_all (next);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 gtk_menu_append (GTK_MENU (item->submenu), next);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 /* This is called whenever an item with a GUI_ID associated with it is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 destroyed. This allows us to remove the references in gui-gtk.c
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 that made sure callbacks and such were GCPRO-ed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 __remove_gcpro_by_id (gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 ungcpro_popup_callbacks ((GUI_ID) user_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 __kill_stupid_gtk_timer (GtkObject *obj, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 GtkMenuItem *mi = GTK_MENU_ITEM (obj);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
346 if (mi->timer)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
348 gtk_timeout_remove (mi->timer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349 mi->timer = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
353 static char *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 remove_underscores(const char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 char *rval = xmalloc_and_zero (strlen(name) + 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 int i,j;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 for (i = 0, j = 0; name[i]; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
360 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
361 if (name[i]=='%') {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362 i++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 if (!(name[i]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 if ((name[i] == '_'))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
367 continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 rval[j++] = name[i];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 return rval;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 /* This converts an entire menu into a GtkMenuItem (with an attached
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 submenu). A menu is a list of (STRING [:keyword value]+ [DESCR]+)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 DESCR is either a list (meaning a submenu), a vector, or nil (if
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 you include a :filter keyword) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 static GtkWidget *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
379 menu_convert (Lisp_Object desc, GtkWidget *reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
380 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381 GtkWidget *menu_item = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 GtkWidget *submenu = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 Lisp_Object key, val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 Lisp_Object include_p = Qnil, hook_fn = Qnil, config_tag = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 Lisp_Object active_p = Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 Lisp_Object accel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387 int included_spec = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 int active_spec = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 if (STRINGP (XCAR (desc)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
391 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 accel = menu_name_to_accelerator (XSTRING_DATA (XCAR (desc)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394 if (!reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 char *temp_menu_name = remove_underscores (XSTRING_DATA (XCAR (desc)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 menu_item = gtk_menu_item_new_with_label (temp_menu_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398 free (temp_menu_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 menu_item = reuse;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
403 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 submenu = gtk_menu_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 gtk_widget_show (menu_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 gtk_widget_show (submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 if (!reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 gtk_signal_connect (GTK_OBJECT (menu_item), "destroy",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 GTK_SIGNAL_FUNC (__kill_stupid_gtk_timer), NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 /* Without this sometimes a submenu gets left on the screen -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 ** urk
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 if (GTK_MENU_ITEM (menu_item)->submenu)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 gtk_widget_destroy (GTK_MENU_ITEM (menu_item)->submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 /* We put this bogus menu item in so that GTK does the right
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 ** thing when the menu is near the screen border.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 ** Aug 29, 2000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 GtkWidget *bogus_item = gtk_menu_item_new_with_label ("A suitably long label here...");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_FIRSTTIME_TAG, (gpointer)0x01);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 gtk_widget_show_all (bogus_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 gtk_menu_append (GTK_MENU (submenu), bogus_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436 desc = Fcdr (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 while (key = Fcar (desc), KEYWORDP (key))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 Lisp_Object cascade = desc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441 desc = Fcdr (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 if (NILP (desc))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
443 sferror ("keyword in menu lacks a value",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 cascade);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 val = Fcar (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 desc = Fcdr (desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 if (EQ (key, Q_included))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 include_p = val, included_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 else if (EQ (key, Q_config))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 config_tag = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 else if (EQ (key, Q_filter))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 hook_fn = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 else if (EQ (key, Q_active))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 active_p = val, active_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 else if (EQ (key, Q_accelerator))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 if ( SYMBOLP (val)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 || CHARP (val))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 wv->accel = LISP_TO_VOID (val);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
462 invalid_argument ("bad keyboard accelerator", val);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 else if (EQ (key, Q_label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 /* implement in 21.2 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
470 invalid_argument ("unknown menu cascade keyword", cascade);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_DESCR_TAG, LISP_TO_VOID (desc));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_FILTER_TAG, LISP_TO_VOID (hook_fn));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 if ((!NILP (config_tag)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 && NILP (Fmemq (config_tag, Vmenubar_configuration)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 || (included_spec && NILP (Feval (include_p))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 return (NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
483 if (active_spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 active_p = Feval (active_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 gtk_widget_set_sensitive (GTK_WIDGET (menu_item), ! NILP (active_p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
490 invalid_argument ("menu name (first element) must be a string",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
494 /* If we are reusing a widget, we need to make sure we clean
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 ** everything up.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497 if (reuse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499 gpointer id = gtk_object_get_data (GTK_OBJECT (reuse), XEMACS_MENU_GUIID_TAG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 if (id)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 /* If the menu item had a GUI_ID that means it was a filter menu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504 __remove_gcpro_by_id (id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 gtk_signal_disconnect_by_func (GTK_OBJECT (reuse),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 (gpointer) 0x01 );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
508 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
509 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
510 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 gtk_signal_disconnect_by_func (GTK_OBJECT (reuse),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 GTK_MENU_ITEM (reuse)->right_justify = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519 if (NILP (hook_fn))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
521 /* Generic menu builder */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
522 gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
523 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
524 NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
525 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528 GUI_ID id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530 gtk_object_set_data (GTK_OBJECT (menu_item), XEMACS_MENU_GUIID_TAG,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 (gpointer) id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533 /* Make sure we gcpro the menu descriptions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534 gcpro_popup_callbacks (id, desc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 gtk_object_weakref (GTK_OBJECT (menu_item), __remove_gcpro_by_id,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536 (gpointer) id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 GTK_SIGNAL_FUNC (__activate_menu),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540 (gpointer) 0x01);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 return (menu_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 static struct frame *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547 __get_channel (GtkWidget *w)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549 struct frame *f = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 for (; w; w = w->parent)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
553 if ((f = (struct frame *) gtk_object_get_data (GTK_OBJECT (w), "xemacs::frame")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554 return (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 return (selected_frame());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 /* Called whenever a button, radio, or toggle is selected in the menu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563 __generic_button_callback (GtkMenuItem *item, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
564 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 Lisp_Object callback, function, data, channel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
567 channel = wrap_frame (__get_channel (GTK_WIDGET (item)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
569 callback = VOID_TO_LISP (user_data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571 get_gui_callback (callback, &function, &data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573 signal_special_gtk_user_event (channel, function, data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576 /* Convert a single menu item descriptor to a suitable GtkMenuItem */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 /* This function cannot GC.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 It is only called from menu_item_descriptor_to_widget_value, which
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579 prohibits GC. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 static GtkWidget *menu_descriptor_to_widget_1 (Lisp_Object descr)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 if (STRINGP (descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 /* It is a separator. Unfortunately GTK does not allow us to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 specify what our separators look like, so we can't do all the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586 fancy stuff that the X code does.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 return (gtk_menu_item_new ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 else if (LISTP (descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592 /* It is a submenu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 return (menu_convert (descr, NULL));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 else if (VECTORP (descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 /* An actual menu item description! This gets yucky. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598 Lisp_Object name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 Lisp_Object callback = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600 Lisp_Object suffix = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
601 Lisp_Object active_p = Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
602 Lisp_Object include_p = Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
603 Lisp_Object selected_p = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
604 Lisp_Object keys = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
605 Lisp_Object style = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
606 Lisp_Object config_tag = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
607 Lisp_Object accel = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
608 GtkWidget *main_label = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
609 int length = XVECTOR_LENGTH (descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
610 Lisp_Object *contents = XVECTOR_DATA (descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
611 int plist_p;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
612 int selected_spec = 0, included_spec = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
613 GtkWidget *widget = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
614
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
615 if (length < 2)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
616 sferror ("button descriptors must be at least 2 long", descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
617
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
618 /* length 2: [ "name" callback ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
619 length 3: [ "name" callback active-p ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
620 length 4: [ "name" callback active-p suffix ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
621 or [ "name" callback keyword value ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
622 length 5+: [ "name" callback [ keyword value ]+ ]
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
623 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
624 plist_p = (length >= 5 || (length > 2 && KEYWORDP (contents [2])));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
625
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
626 if (!plist_p && length > 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
627 /* the old way */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
628 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
629 name = contents [0];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
630 callback = contents [1];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
631 active_p = contents [2];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
632 if (length == 4)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
633 suffix = contents [3];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
634 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
635 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
636 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
637 /* the new way */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
638 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
639 if (length & 1)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
640 sferror (
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
641 "button descriptor has an odd number of keywords and values",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
642 descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
643
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
644 name = contents [0];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
645 callback = contents [1];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
646 for (i = 2; i < length;)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
647 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
648 Lisp_Object key = contents [i++];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
649 Lisp_Object val = contents [i++];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
650 if (!KEYWORDP (key))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
651 invalid_argument_2 ("not a keyword", key, descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
652
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
653 if (EQ (key, Q_active)) active_p = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
654 else if (EQ (key, Q_suffix)) suffix = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
655 else if (EQ (key, Q_keys)) keys = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
656 else if (EQ (key, Q_key_sequence)) ; /* ignored for FSF compat */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
657 else if (EQ (key, Q_label)) ; /* implement for 21.0 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
658 else if (EQ (key, Q_style)) style = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
659 else if (EQ (key, Q_selected)) selected_p = val, selected_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
660 else if (EQ (key, Q_included)) include_p = val, included_spec = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
661 else if (EQ (key, Q_config)) config_tag = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
662 else if (EQ (key, Q_accelerator))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
663 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
664 if ( SYMBOLP (val) || CHARP (val))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
665 accel = val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
666 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
667 invalid_argument ("bad keyboard accelerator", val);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
668 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
669 else if (EQ (key, Q_filter))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
670 sferror(":filter keyword not permitted on leaf nodes", descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
671 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
672 invalid_argument_2 ("unknown menu item keyword", key, descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
673 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
674 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
675
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
676 #ifdef HAVE_MENUBARS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
677 if ((!NILP (config_tag) && NILP (Fmemq (config_tag, Vmenubar_configuration)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
678 || (included_spec && NILP (Feval (include_p))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
679 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
680 /* the include specification says to ignore this item. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
681 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
682 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
683 #endif /* HAVE_MENUBARS */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
684
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
685 CHECK_STRING (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
686
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
687 if (NILP (accel))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
688 accel = menu_name_to_accelerator (XSTRING_DATA (name));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
689
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
690 if (!NILP (suffix))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
691 suffix = Feval (suffix);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
692
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
693 if (!separator_string_p (XSTRING_DATA (name)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
694 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
695 char *label_buffer = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
696 char *temp_label = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
697
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
698 if (STRINGP (suffix) && XSTRING_LENGTH (suffix))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
699 {
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 833
diff changeset
700 label_buffer = ALLOCA (XSTRING_LENGTH (name) + 15 + XSTRING_LENGTH (suffix));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
701 sprintf (label_buffer, "%s %s ", XSTRING_DATA (name), XSTRING_DATA (suffix));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
702 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
703 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
704 {
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 833
diff changeset
705 label_buffer = ALLOCA (XSTRING_LENGTH (name) + 15);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
706 sprintf (label_buffer, "%s ", XSTRING_DATA (name));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
707 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
708
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
709 temp_label = remove_underscores (label_buffer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
710 main_label = gtk_accel_label_new (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
711 free (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
712 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
713
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
714 /* Evaluate the selected and active items now */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
715 if (selected_spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
716 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
717 if (NILP (selected_p) || EQ (selected_p, Qt))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
718 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
719 /* Do nothing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
720 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
721 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
722 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
723 selected_p = Feval (selected_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
724 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
725 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
726
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
727 if (NILP (active_p) || EQ (active_p, Qt))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
728 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
729 /* Do Nothing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
730 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
731 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
732 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
733 active_p = Feval (active_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
734 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
735
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
736 if (0 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
737 #ifdef HAVE_MENUBARS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
738 menubar_show_keybindings
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
739 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
740 )
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
741 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
742 /* Need to get keybindings */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
743 if (!NILP (keys))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
744 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
745 /* User-specified string to generate key bindings with */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
746 CHECK_STRING (keys);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
747
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
748 keys = Fsubstitute_command_keys (keys);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
749 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
750 else if (SYMBOLP (callback))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
751 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
752 DECLARE_EISTRING_MALLOC (buf);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
753
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
754 /* #### Warning, dependency here on current_buffer and point */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
755 where_is_to_char (callback, buf);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
756
833
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
757 if (eilen (buf) > 0)
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
758 keys = eimake_string (buf);
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
759 else
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
760 {
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
761
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
762 keys = Qnil;
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
763 }
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
764
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
765 eifree (buf);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
766 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
767 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
768
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
769 /* Now we get down to the dirty business of creating the widgets */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
770 if (NILP (style) || EQ (style, Qtext) || EQ (style, Qbutton))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
771 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
772 /* A normal menu item */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
773 widget = gtk_menu_item_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
774 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
775 else if (EQ (style, Qtoggle) || EQ (style, Qradio))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
776 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
777 /* They are radio or toggle buttons.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
778
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
779 XEmacs' menu descriptions are fairly lame in that they do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
780 not have the idea of a 'group' of radio buttons. They
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
781 are exactly like toggle buttons except that they get
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
782 drawn differently.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
783
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
784 GTK rips us a new one again. If you have a radio button
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
785 in a group by itself, it always draws it as highlighted.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
786 So we dummy up and create a second radio button that does
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
787 not get added to the menu, but gets invisibly set/unset
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
788 when the other gets unset/set. *sigh*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
789
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
790 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
791 if (EQ (style, Qradio))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
792 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
793 GtkWidget *dummy_sibling = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
794 GSList *group = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
795
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
796 dummy_sibling = gtk_radio_menu_item_new (group);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
797 group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (dummy_sibling));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
798 widget = gtk_radio_menu_item_new (group);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
799
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
800 /* We need to notice when the 'real' one gets destroyed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
801 so we can clean up the dummy as well. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
802 gtk_object_weakref (GTK_OBJECT (widget),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
803 (GtkDestroyNotify) gtk_widget_destroy,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
804 dummy_sibling);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
805 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
806 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
807 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
808 widget = gtk_check_menu_item_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
809 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
810
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
811 /* What horrible defaults you have GTK dear! The default
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
812 for a toggle menu item is to not show the toggle unless it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
813 is turned on or actively highlighted. How absolutely
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
814 hideous. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
815 gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (widget), TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
816 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
817 NILP (selected_p) ? FALSE : TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
818 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
819 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
820 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
821 invalid_argument_2 ("unknown style", style, descr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
822 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
823
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
824 gtk_widget_set_sensitive (widget, ! NILP (active_p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
825
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
826 gtk_signal_connect (GTK_OBJECT (widget), "activate-item",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
827 GTK_SIGNAL_FUNC (__generic_button_callback),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
828 LISP_TO_VOID (callback));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
829
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
830 gtk_signal_connect (GTK_OBJECT (widget), "activate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
831 GTK_SIGNAL_FUNC (__generic_button_callback),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
832 LISP_TO_VOID (callback));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
833
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
834 /* We cheat here... GtkAccelLabel usually builds its
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
835 `accel_string' from the widget it is attached to, but we do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
836 not want to go thru the overhead of converting our nice
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
837 string back into the modifier + key format that requires,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
838 just so that they can convert it back into a (possibly
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
839 different/wrong) string
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
840
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
841 We set the label string manually, and things should 'just
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
842 work'
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
843
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
844 In an ideal world we would just subclass GtkLabel ourselves,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
845 but I have known for a very long time that this is not an
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
846 ideal world.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
847
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
848 #### Should do menu shortcuts `correctly' one of these days.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
849 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
850
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
851 if (main_label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
852 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
853 GtkAccelLabel *l = GTK_ACCEL_LABEL (main_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
854
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
855 gtk_container_add (GTK_CONTAINER (widget), main_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
856
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
857 gtk_accel_label_set_accel_widget (l, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
858 gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
859
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
860 if (STRINGP (keys) && XSTRING_LENGTH (keys))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
861 {
833
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
862 C_STRING_TO_EXTERNAL_MALLOC (XSTRING_DATA (keys), l->accel_string,
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
863 Qctext);
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
864 stderr_out ("accel: %s\n", l->accel_string);
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
865 }
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
866 else
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
867 {
ee2d33cfc3c1 [xemacs-hg @ 2002-05-09 13:49:39 by wmperry]
wmperry
parents: 826
diff changeset
868 // l->accel_string = "";
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
869 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
870 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
871
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
872 return (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
873 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
874 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
875 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
876 return (NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
877 /* abort (); ???? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
878 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
879 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
880
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
881 static GtkWidget *menu_descriptor_to_widget (Lisp_Object descr)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
882 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
883 GtkWidget *rval = NULL;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 714
diff changeset
884 int count = begin_gc_forbidden ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
885
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
886 /* Cannot GC from here on out... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
887 rval = menu_descriptor_to_widget_1 (descr);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 714
diff changeset
888 unbind_to (count);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
889 return (rval);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
890
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
891 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
892
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
893 static gboolean
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
894 menu_can_reuse_widget (GtkWidget *child, const char *label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
895 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
896 /* Everything up at the top level was done using
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
897 ** gtk_menu_item_new_with_label(), but we still double check to make
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
898 ** sure we don't seriously foobar ourselves.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
899 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
900 char *temp_label = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
901 gpointer possible_child = g_list_nth_data (gtk_container_children (GTK_CONTAINER (child)), 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
902
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
903 if (possible_child && GTK_IS_LABEL (possible_child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
904 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
905 if (!temp_label) temp_label = remove_underscores (label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
906 if (!strcmp (GTK_LABEL (possible_child)->label, temp_label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
907 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
908 free (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
909 return (TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
910 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
911 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
912 if (temp_label) free (temp_label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
913 return (FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
914 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
915
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
916 /* Converts a menubar description into a GtkMenuBar... a menubar is a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
917 list of menus or buttons
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
918 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
919 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
920 menu_create_menubar (struct frame *f, Lisp_Object descr)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
921 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
922 gboolean right_justify = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
923 Lisp_Object tail = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
924 Lisp_Object value = descr;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
925 Lisp_Object item_descr = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
926 GtkWidget *menubar = FRAME_GTK_MENUBAR_WIDGET (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
927 GUI_ID id = (GUI_ID) gtk_object_get_data (GTK_OBJECT (menubar), XEMACS_MENU_GUIID_TAG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
928 guint menu_position = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
929
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
930 /* Remove any existing protection for old menu items */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
931 ungcpro_popup_callbacks (id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
932
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
933 /* GCPRO the whole damn thing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
934 gcpro_popup_callbacks (id, descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
935
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
936 EXTERNAL_LIST_LOOP (tail, value)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
937 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
938 gpointer current_child = g_list_nth_data (GTK_MENU_SHELL (menubar)->children, menu_position);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
939
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
940 item_descr = XCAR (tail);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
941
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
942 if (NILP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
943 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
944 /* Need to start right-justifying menus */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
945 right_justify = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
946 menu_position--;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
947 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
948 else if (VECTORP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
949 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
950 /* It is a button description */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
951 GtkWidget *item;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
952
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
953 item = menu_descriptor_to_widget (item_descr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
954 gtk_widget_set_name (item, "XEmacsMenuButton");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
955
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
956 if (!item)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
957 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
958 item = gtk_menu_item_new_with_label ("ITEM CREATION ERROR");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
959 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
960
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
961 gtk_widget_show_all (item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
962 if (current_child) gtk_widget_destroy (GTK_WIDGET (current_child));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
963 gtk_menu_bar_insert (GTK_MENU_BAR (menubar), item, menu_position);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
964 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
965 else if (LISTP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
966 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
967 /* Need to actually convert it into a menu and slap it in */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
968 GtkWidget *widget;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
969 gboolean reused_p = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
970
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
971 /* We may be able to reuse the widget, let's at least check. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
972 if (current_child && menu_can_reuse_widget (GTK_WIDGET (current_child),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
973 XSTRING_DATA (XCAR (item_descr))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
974 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
975 widget = menu_convert (item_descr, GTK_WIDGET (current_child));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
976 reused_p = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
977 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
978 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
979 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
980 widget = menu_convert (item_descr, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
981 if (current_child) gtk_widget_destroy (GTK_WIDGET (current_child));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
982 gtk_menu_bar_insert (GTK_MENU_BAR (menubar), widget, menu_position);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
983 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
984
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
985 if (widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
986 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
987 if (right_justify) gtk_menu_item_right_justify (GTK_MENU_ITEM (widget));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
988 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
989 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
990 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
991 widget = gtk_menu_item_new_with_label ("ERROR");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
992 /* abort() */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
993 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
994 gtk_widget_show_all (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
995 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
996 else if (STRINGP (item_descr))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
997 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
998 /* Do I really want to be this careful? Anything else in a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
999 menubar description is illegal */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1000 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1001 menu_position++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1002 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1003
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1004 /* Need to delete any menu items that were past the bounds of the new one */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1005 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1006 GList *l = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1007
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1008 while ((l = g_list_nth (GTK_MENU_SHELL (menubar)->children, menu_position)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1009 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1010 gpointer data = l->data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1011 g_list_remove_link (GTK_MENU_SHELL (menubar)->children, l);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1012
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1013 if (data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1014 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1015 gtk_widget_destroy (GTK_WIDGET (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1016 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1017 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1018 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1019 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1020
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1021
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1022 /* Deal with getting/setting the menubar */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1023 #ifndef GNOME_IS_APP
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1024 #define GNOME_IS_APP(x) 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1025 #define gnome_app_set_menus(x,y)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1026 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1027
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1028 static gboolean
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1029 run_menubar_hook (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1030 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1031 if (!GTK_MENU_SHELL(widget)->active)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1032 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1033 run_hook (Qactivate_menubar_hook);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1034 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1035 return(FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1036 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1037
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1038 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1039 create_menubar_widget (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1040 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1041 GUI_ID id = new_gui_id ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1042 GtkWidget *handlebox = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1043 GtkWidget *menubar = gtk_xemacs_menubar_new (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1044
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1045 if (GNOME_IS_APP (FRAME_GTK_SHELL_WIDGET (f)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1046 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1047 gnome_app_set_menus (GNOME_APP (FRAME_GTK_SHELL_WIDGET (f)), GTK_MENU_BAR (menubar));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1048 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1049 else if (dockable_menubar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1050 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1051 handlebox = gtk_handle_box_new ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1052 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (handlebox), GTK_POS_LEFT);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1053 gtk_container_add (GTK_CONTAINER (handlebox), menubar);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1054 gtk_box_pack_start (GTK_BOX (FRAME_GTK_CONTAINER_WIDGET (f)), handlebox, FALSE, FALSE, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1055 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1056 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1057 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1058 gtk_box_pack_start (GTK_BOX (FRAME_GTK_CONTAINER_WIDGET (f)), menubar, FALSE, FALSE, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1059 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1060
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1061 gtk_signal_connect (GTK_OBJECT (menubar), "button-press-event",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1062 GTK_SIGNAL_FUNC (run_menubar_hook), NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1063
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1064 FRAME_GTK_MENUBAR_WIDGET (f) = menubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1065 gtk_object_set_data (GTK_OBJECT (menubar), XEMACS_MENU_GUIID_TAG, (gpointer) id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1066 gtk_object_weakref (GTK_OBJECT (menubar), __remove_gcpro_by_id, (gpointer) id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1067 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1068
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1069 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1070 set_frame_menubar (struct frame *f, int first_time_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1071 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1072 Lisp_Object menubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1073 int menubar_visible;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1074 /* As for the toolbar, the minibuffer does not have its own menubar. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1075 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1076
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1077 if (! FRAME_GTK_P (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1078 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1079
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1080 /***** first compute the contents of the menubar *****/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1081
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1082 if (! first_time_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1083 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1084 /* evaluate `current-menubar' in the buffer of the selected window
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1085 of the frame in question. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1086 menubar = symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1087 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1088 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1089 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1090 /* That's a little tricky the first time since the frame isn't
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1091 fully initialized yet. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1092 menubar = Fsymbol_value (Qcurrent_menubar);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1093 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1094
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1095 if (NILP (menubar))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1096 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1097 menubar = Vblank_menubar;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1098 menubar_visible = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1099 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1100 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1101 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1102 menubar_visible = !NILP (w->menubar_visible_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1103 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1104
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1105 if (!FRAME_GTK_MENUBAR_WIDGET (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1106 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1107 create_menubar_widget (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1108 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1109
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1110 /* Populate the menubar, but nothing is shown yet */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1111 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1112 Lisp_Object old_buffer;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1113 int count = specpdl_depth ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1114
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1115 old_buffer = Fcurrent_buffer ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1116 record_unwind_protect (Fset_buffer, old_buffer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1117 Fset_buffer (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1119 menu_create_menubar (f, menubar);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1120
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1121 Fset_buffer (old_buffer);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 714
diff changeset
1122 unbind_to (count);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1123 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1124
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1125 FRAME_MENUBAR_DATA (f) = Fcons (XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer, Qt);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1126
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1127 return (menubar_visible);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1128 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1129
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1130 /* Called from gtk_create_widgets() to create the inital menubar of a frame
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1131 before it is mapped, so that the window is mapped with the menubar already
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1132 there instead of us tacking it on later and thrashing the window after it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1133 is visible. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1134 int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1135 gtk_initialize_frame_menubar (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1136 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1137 create_menubar_widget (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1138 return set_frame_menubar (f, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1139 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1140
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1141
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1142 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1143 gtk_update_frame_menubar_internal (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1144 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1145 /* We assume the menubar contents has changed if the global flag is set,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1146 or if the current buffer has changed, or if the menubar has never
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1147 been updated before.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1148 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1149 int menubar_contents_changed =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1150 (f->menubar_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1151 || NILP (FRAME_MENUBAR_DATA (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1152 || (!EQ (XFRAME_MENUBAR_DATA_LASTBUFF (f),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1153 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1154
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1155 gboolean menubar_was_visible = GTK_WIDGET_VISIBLE (FRAME_GTK_MENUBAR_WIDGET (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1156 gboolean menubar_will_be_visible = menubar_was_visible;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1157 gboolean menubar_visibility_changed;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1158
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1159 if (menubar_contents_changed)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1160 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1161 menubar_will_be_visible = set_frame_menubar (f, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1162 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1163
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1164 menubar_visibility_changed = menubar_was_visible != menubar_will_be_visible;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1165
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1166 if (!menubar_visibility_changed)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1167 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1168 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1169 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1170
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1171 /* We hide and show the menubar's parent (which is actually the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1172 GtkHandleBox)... this is to simplify the code that destroys old
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1173 menu items, etc. There is no easy way to get the child out of a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1174 handle box, and I didn't want to add yet another stupid widget
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1175 slot to struct gtk_frame. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1176 if (menubar_will_be_visible)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1177 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1178 gtk_widget_show_all (FRAME_GTK_MENUBAR_WIDGET (f)->parent);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1179 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1180 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1181 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1182 gtk_widget_hide_all (FRAME_GTK_MENUBAR_WIDGET (f)->parent);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1183 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1184
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1185 MARK_FRAME_SIZE_SLIPPED (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1186 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1187
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1188 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1189 gtk_update_frame_menubars (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1190 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1191 GtkWidget *menubar = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1192
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1193 assert (FRAME_GTK_P (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1194
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1195 menubar = FRAME_GTK_MENUBAR_WIDGET (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1196
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1197 if ((GTK_MENU_SHELL (menubar)->active) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1198 (GTK_MENU_SHELL (menubar)->have_grab) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1199 (GTK_MENU_SHELL (menubar)->have_xgrab))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1200 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1201 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1202 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1203
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1204 gtk_update_frame_menubar_internal (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1205 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1206
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1207 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1208 gtk_free_frame_menubars (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1209 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1210 GtkWidget *menubar_widget;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1211
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1212 assert (FRAME_GTK_P (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1213
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1214 menubar_widget = FRAME_GTK_MENUBAR_WIDGET (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1215 if (menubar_widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1216 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1217 gtk_widget_destroy (menubar_widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1218 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1219 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1220
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1221 static void popdown_menu_cb (GtkMenuShell *menu, gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1222 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1223 popup_up_p--;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1224 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1225
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1226 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1227 gtk_popup_menu (Lisp_Object menu_desc, Lisp_Object event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1228 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1229 struct Lisp_Event *eev = NULL;
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1230 GtkWidget *widget = NULL;
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1231 GtkWidget *menu = NULL;
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1232 gpointer id = NULL;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1233
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1234 /* Do basic error checking first... */
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1235 if (SYMBOLP (menu_desc))
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1236 menu_desc = Fsymbol_value (menu_desc);
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1237 CHECK_CONS (menu_desc);
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1238 CHECK_STRING (XCAR (menu_desc));
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1239
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1240 /* Now lets get down to business... */
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1241 widget = menu_descriptor_to_widget (menu_desc);
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1242 menu = GTK_MENU_ITEM (widget)->submenu;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1243 gtk_widget_set_name (widget, "XEmacsPopupMenu");
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 563
diff changeset
1244 id = gtk_object_get_data (GTK_OBJECT (widget), XEMACS_MENU_GUIID_TAG);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1245
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1246 __activate_menu (GTK_MENU_ITEM (widget), id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1247
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1248 if (!NILP (event))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1249 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1250 CHECK_LIVE_EVENT (event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1251 eev = XEVENT (event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1252
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1253 if ((eev->event_type != button_press_event) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1254 (eev->event_type != button_release_event))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1255 wrong_type_argument (Qmouse_event_p, event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1256 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1257 else if (!NILP (Vthis_command_keys))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1258 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1259 /* If an event wasn't passed, use the last event of the event
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1260 sequence currently being executed, if that event is a mouse
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1261 event. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1262 eev = XEVENT (Vthis_command_keys);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1263 if ((eev->event_type != button_press_event) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1264 (eev->event_type != button_release_event))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1265 eev = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1266 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1267
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1268 gtk_widget_show (menu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1269
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1270 popup_up_p++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1271 gtk_signal_connect (GTK_OBJECT (menu), "deactivate",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1272 GTK_SIGNAL_FUNC (popdown_menu_cb), NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1273
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1274 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1275 eev ? eev->event.button.button : 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1276 eev ? eev->timestamp : GDK_CURRENT_TIME);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1277 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1278
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1279 DEFUN ("gtk-build-xemacs-menu", Fgtk_build_xemacs_menu, 1, 1, 0, /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1280 Returns a GTK menu item from MENU, a standard XEmacs menu description.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1281 See the definition of `popup-menu' for more information on the format of MENU.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1282 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1283 (menu))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1284 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1285 GtkWidget *w = menu_descriptor_to_widget (menu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1286
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1287 return (w ? build_gtk_object (GTK_OBJECT (w)) : Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1288 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1289
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1290
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1291 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1292 syms_of_menubar_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1293 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1294 DEFSUBR (Fgtk_build_xemacs_menu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1295 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1296
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1297 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1298 console_type_create_menubar_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1299 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1300 CONSOLE_HAS_METHOD (gtk, update_frame_menubars);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1301 CONSOLE_HAS_METHOD (gtk, free_frame_menubars);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1302 CONSOLE_HAS_METHOD (gtk, popup_menu);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1303 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1304
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1305 void reinit_vars_of_menubar_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1306 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1307 dockable_menubar = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1308 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1309 tear_off_menus = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1310 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1311 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1312
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1313 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1314 vars_of_menubar_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1315 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1316 Fprovide (intern ("gtk-menubars"));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1317 DEFVAR_BOOL ("menubar-dockable-p", &dockable_menubar /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1318 If non-nil, the frame menubar can be detached into its own top-level window.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1319 */ );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1320 #ifdef TEAR_OFF_MENUS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1321 DEFVAR_BOOL ("menubar-tearable-p", &tear_off_menus /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1322 If non-nil, menus can be torn off into their own top-level windows.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1323 */ );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1324 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1325 reinit_vars_of_menubar_gtk ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1326 }