* lwlib/lwlib.h (widget_value): Do not maintain a free list any more.
(malloc_widget_value, free_widget_value): Remove prototypes.
* lwlib/lwlib.c (malloc_widget_value, free_widget_value):
(widget_value_free_list, malloc_cpt): Remove.
(free_widget_value_tree, copy_widget_value_tree): Adjust users.
* src/menu.h (xmalloc_widget_value): Replaced by ...
(make_widget_value): ... new prototype.
* src/menu.c (xmalloc_widget_value): Replaced by ...
(make_widget_value): ... new function.
(free_menubar_widget_value_tree, digest_single_submenu): Adjust users.
* src/gtkutil.c (malloc_widget_value, free_widget_value):
(widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code.
* src/keyboard.h (enum button_type, struct _widget_value):
* src/gtkutil.h, src/nsgui.h, src/w32gui.h (malloc_widget_value):
(free_widget_value): Likewise.
* src/nsmenu.m (ns_update_menubar, ns_menu_show):
* src/w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show):
* src/xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users.
* src/xterm.h (XtParent) [USE_GTK]: Remove unused macro.
+2014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Use common memory management functions for widgets.
+ * lwlib.h (widget_value): Do not maintain a free list any more.
+ (malloc_widget_value, free_widget_value): Remove prototypes.
+ * lwlib.c (malloc_widget_value, free_widget_value):
+ (widget_value_free_list, malloc_cpt): Remove.
+ (free_widget_value_tree, copy_widget_value_tree): Adjust users.
+
2014-05-30 Dmitry Antipov <dmantipov@yandex.ru>
Use common string allocation and freeing functions where applicable.
static Boolean get_one_value (widget_instance *, widget_value *);
static void show_one_widget_busy (Widget, Boolean);
-static widget_value *widget_value_free_list = 0;
-static int malloc_cpt = 0;
-
-widget_value *
-malloc_widget_value (void)
-{
- widget_value *wv;
- if (widget_value_free_list)
- {
- wv = widget_value_free_list;
- widget_value_free_list = wv->free_list;
- wv->free_list = 0;
- }
- else
- {
- wv = (widget_value *) xmalloc (sizeof (widget_value));
- malloc_cpt++;
- }
- memset ((void*) wv, 0, sizeof (widget_value));
- return wv;
-}
-
-/* this is analogous to free(). It frees only what was allocated
- by malloc_widget_value(), and no substructures.
- */
-void
-free_widget_value (widget_value *wv)
-{
- if (wv->free_list)
- abort ();
-
- if (malloc_cpt > 25)
- {
- /* When the number of already allocated cells is too big,
- We free it. */
- xfree (wv);
- malloc_cpt--;
- }
- else
- {
- wv->free_list = widget_value_free_list;
- widget_value_free_list = wv;
- }
-}
-
static void
free_widget_value_tree (widget_value *wv)
{
free_widget_value_tree (wv->next);
wv->next = (widget_value *) 0xDEADBEEF;
}
- free_widget_value (wv);
+ xfree (wv);
}
static widget_value *
if (val == (widget_value *) 1)
return val;
- copy = malloc_widget_value ();
+ copy = xmalloc (sizeof (widget_value));
+ copy->lname = copy->lkey = Qnil;
copy->name = xstrdup (val->name);
copy->value = val->value ? xstrdup (val->value) : NULL;
copy->key = val->key ? xstrdup (val->key) : NULL;
/* tell us if we should free the toolkit data slot when freeing the
widget_value itself. */
Boolean free_toolkit_data;
-
- /* we resource the widget_value structures; this points to the next
- one on the free list if this one has been deallocated.
- */
- struct _widget_value *free_list;
} widget_value;
Boolean lw_get_some_values (LWLIB_ID id, widget_value* val);
void lw_pop_up_all_widgets (LWLIB_ID id);
void lw_pop_down_all_widgets (LWLIB_ID id);
-widget_value *malloc_widget_value (void);
-void free_widget_value (widget_value *);
void lw_popup_menu (Widget, XEvent *);
/* Toolkit independent way of focusing on a Widget at the Xt level. */
+2014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Adjust to match recent lwlib changes.
+ * menu.h (xmalloc_widget_value): Replaced by ...
+ (make_widget_value): ... new prototype.
+ * menu.c (xmalloc_widget_value): Replaced by ...
+ (make_widget_value): ... new function.
+ (free_menubar_widget_value_tree, digest_single_submenu): Adjust users.
+ * gtkutil.c (malloc_widget_value, free_widget_value):
+ (widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code.
+ * keyboard.h (enum button_type, struct _widget_value):
+ * gtkutil.h, nsgui.h, w32gui.h (malloc_widget_value, free_widget_value):
+ Likewise.
+ * nsmenu.m (ns_update_menubar, ns_menu_show):
+ * w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show):
+ * xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users.
+ * xterm.h (XtParent) [USE_GTK]: Remove unused macro.
+
2014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
* image.c (x_query_frame_background_color)
/***********************************************************************
Utility functions
***********************************************************************/
-/* The next two variables and functions are taken from lwlib. */
-static widget_value *widget_value_free_list;
-static int malloc_cpt;
-
-/* Allocate a widget_value structure, either by taking one from the
- widget_value_free_list or by malloc:ing a new one.
-
- Return a pointer to the allocated structure. */
-
-widget_value *
-malloc_widget_value (void)
-{
- widget_value *wv;
- if (widget_value_free_list)
- {
- wv = widget_value_free_list;
- widget_value_free_list = wv->free_list;
- wv->free_list = 0;
- }
- else
- {
- wv = xmalloc (sizeof *wv);
- malloc_cpt++;
- }
- memset (wv, 0, sizeof (widget_value));
- return wv;
-}
-
-/* This is analogous to free. It frees only what was allocated
- by malloc_widget_value, and no substructures. */
-
-void
-free_widget_value (widget_value *wv)
-{
- if (wv->free_list)
- emacs_abort ();
-
- if (malloc_cpt > 25)
- {
- /* When the number of already allocated cells is too big,
- We free it. */
- xfree (wv);
- malloc_cpt--;
- }
- else
- {
- wv->free_list = widget_value_free_list;
- widget_value_free_list = wv;
- }
-}
-
/* Create and return the cursor to be used for popup menus and
scroll bars on display DPY. */
#ifdef USE_GTK
#include <gtk/gtk.h>
+#include "../lwlib/lwlib.h"
#include "frame.h"
#include "xterm.h"
} xg_menu_item_cb_data;
-extern struct _widget_value *malloc_widget_value (void) ATTRIBUTE_MALLOC;
-extern void free_widget_value (struct _widget_value *);
-
extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
extern char *xg_get_file_name (struct frame *f,
#define ENCODE_MENU_STRING(str) (str)
#endif
-#if defined (HAVE_NS) || defined (HAVE_NTGUI) || defined (USE_GTK)
-
-/* Definitions copied from lwlib.h */
-
-enum button_type
-{
- BUTTON_TYPE_NONE,
- BUTTON_TYPE_TOGGLE,
- BUTTON_TYPE_RADIO
-};
-
-/* This structure is based on the one in ../lwlib/lwlib.h, with unused portions
- removed. No term uses these. */
-typedef struct _widget_value
-{
- /* name of widget */
- Lisp_Object lname;
- const char* name;
- /* value (meaning depend on widget type) */
- const char* value;
- /* keyboard equivalent. no implications for XtTranslations */
- Lisp_Object lkey;
- const char* key;
- /* Help string or nil if none.
- GC finds this string through the frame's menu_bar_vector
- or through menu_items. */
- Lisp_Object help;
- /* true if enabled */
- unsigned char enabled;
- /* true if selected */
- unsigned char selected;
- /* The type of a button. */
- enum button_type button_type;
-#if defined (HAVE_NTGUI)
- /* true if menu title */
- unsigned char title;
-#endif
- /* Contents of the sub-widgets, also selected slot for checkbox */
- struct _widget_value* contents;
- /* data passed to callback */
- void *call_data;
- /* next one in the list */
- struct _widget_value* next;
-#ifdef USE_GTK
- struct _widget_value *free_list;
-#endif
-} widget_value;
-
-#endif /* HAVE_NS || HAVE_NTGUI */
-
-\f
/* Macros for dealing with lispy events. */
/* True if EVENT has data fields describing it (i.e. a mouse click). */
\f
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI)
-/* Allocate a widget_value, blocking input. */
+/* Allocate and basically initialize widget_value, blocking input. */
widget_value *
-xmalloc_widget_value (void)
+make_widget_value (const char *name, char *value,
+ bool enabled, Lisp_Object help)
{
- widget_value *value;
+ widget_value *wv;
block_input ();
- value = malloc_widget_value ();
+ wv = xzalloc (sizeof (widget_value));
unblock_input ();
- return value;
+ wv->name = (char *) name;
+ wv->value = value;
+ wv->enabled = enabled;
+ wv->help = help;
+ return wv;
}
-/* This recursively calls free_widget_value on the tree of widgets.
+/* This recursively calls xfree on the tree of widgets.
It must free all data that was malloc'ed for these widget_values.
In Emacs, many slots are pointers into the data of Lisp_Strings, and
must be left alone. */
wv->next = (widget_value *) 0xDEADBEEF;
}
block_input ();
- free_widget_value (wv);
+ xfree (wv);
unblock_input ();
}
struct frame *f = XFRAME (Vmenu_updating_frame);
submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
- wv = xmalloc_widget_value ();
- wv->name = "menu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
save_wv = 0;
prev_wv = 0;
with its items as a submenu beneath it. */
if (strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ /* Set value to 1 so update_submenu_strings can handle '@'. */
+ wv = make_widget_value (NULL, (char *) 1, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
wv->lname = pane_name;
- /* Set value to 1 so update_submenu_strings can handle '@' */
- wv->value = (char *)1;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
}
else
#endif
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (NULL, NULL, !NILP (enable),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
wv->lname = item_name;
if (!NILP (descrip))
wv->lkey = descrip;
- wv->value = 0;
/* The intptr_t cast avoids a warning. There's no problem
as long as pointers have enough bits to hold small integers. */
wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0);
- wv->enabled = !NILP (enable);
if (NILP (type))
wv->button_type = BUTTON_TYPE_NONE;
emacs_abort ();
wv->selected = !NILP (selected);
- if (! STRINGP (help))
- help = Qnil;
-
- wv->help = help;
prev_wv = wv;
if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
{
wv = first_wv->contents;
- free_widget_value (first_wv);
+ xfree (first_wv);
return wv;
}
#define MENU_H
#include "systime.h" /* for Time */
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
+ || defined (HAVE_NS)
+#include "../lwlib/lwlib.h" /* for widget_value */
+#endif
#ifdef HAVE_NTGUI
extern Lisp_Object Qunsupported__w32_dialog;
extern void update_submenu_strings (widget_value *);
extern void find_and_call_menu_selection (struct frame *, int,
Lisp_Object, void *);
-extern widget_value *xmalloc_widget_value (void);
+extern widget_value *make_widget_value (const char *, char *, bool, Lisp_Object);
extern widget_value *digest_single_submenu (int, int, bool);
#endif
#undef _GL_VERIFY_H
#include <verify.h>
-/* menu-related */
-#define free_widget_value(wv) xfree (wv)
-#define malloc_widget_value() ((widget_value *) memset (xmalloc \
- (sizeof (widget_value)), 0, sizeof (widget_value)))
-
/* Emulate XCharStruct. */
typedef struct _XCharStruct
{
/* parse stage 2: insert into lucid 'widget_value' structures
[comments in other terms say not to evaluate lisp code here] */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
for (i = 0; i < 4*n; i += 4)
int n;
Lisp_Object string;
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
/* Make widget-value tree w/ just the top level menu bar strings */
memcpy (previous_strings[i/4], SDATA (string),
min (10, SBYTES (string) + 1));
- wv = xmalloc_widget_value ();
- wv->name = SSDATA (string);
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
wv->call_data = (void *) (intptr_t) (-1);
#ifdef NS_IMPL_COCOA
p.x = x; p.y = y;
/* now parse stage 2 as in ns_update_menubar */
- wv = xmalloc_widget_value ();
- wv->name = "contextmenu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("contextmenu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
#if 0
with its items as a submenu beneath it. */
if (!keymaps && strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (pane_string, NULL, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
if (keymaps && !NILP (prefix))
wv->name++;
- wv->value = 0;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
prev_wv = 0;
}
}
#endif /* not HAVE_MULTILINGUAL_MENU */
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
save_wv->contents = wv;
- wv->name = SSDATA (item_name);
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = 0;
/* If this item has a null value,
make the call_data null so that it won't display a box
when the mouse is on it. */
wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
- wv->enabled = !NILP (enable);
if (NILP (type))
wv->button_type = BUTTON_TYPE_NONE;
wv->selected = !NILP (selected);
- if (! STRINGP (help))
- help = Qnil;
-
- wv->help = help;
-
prev_wv = wv;
i += MENU_ITEMS_ITEM_LENGTH;
if (!NILP (title))
{
- widget_value *wv_title = xmalloc_widget_value ();
- widget_value *wv_sep = xmalloc_widget_value ();
+ widget_value *wv_title;
+ widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
/* Maybe replace this separator with a bitmap or owner-draw item
so that it looks better. Having two separators looks odd. */
- wv_sep->name = "--";
wv_sep->next = first_wv->contents;
- wv_sep->help = Qnil;
#ifndef HAVE_MULTILINGUAL_MENU
if (STRING_MULTIBYTE (title))
title = ENCODE_MENU_STRING (title);
#endif
-
- wv_title->name = SSDATA (title);
- wv_title->enabled = NO;
+ wv_title = make_widget_value (SSDATA (title), NULL, false, Qnil);
wv_title->button_type = BUTTON_TYPE_NONE;
- wv_title->help = Qnil;
wv_title->next = wv_sep;
first_wv->contents = wv_title;
}
#include "systime.h" /* for Time */
-/* Local memory management for menus. */
+/* FIXME: old local memory management for menus. */
#define local_heap (GetProcessHeap ())
#define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
#define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p))))
-#define malloc_widget_value() ((widget_value *) local_alloc (sizeof (widget_value)))
-#define free_widget_value(wv) (local_free ((wv)))
-
/* Emulate X GC's by keeping color and font info in a structure. */
typedef struct _XGCValues
{
/* Convert menu_items into widget_value trees
to display the menu. This cannot evaluate Lisp code. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
for (i = 0; i < last_i; i += 4)
/* Make a widget-value tree containing
just the top level menu bar strings. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
items = FRAME_MENU_BAR_ITEMS (f);
if (NILP (string))
break;
- wv = xmalloc_widget_value ();
- wv->name = SSDATA (string);
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
/* This prevents lwlib from assuming this
menu item is really supposed to be empty. */
/* The EMACS_INT cast avoids a warning.
/* Create a tree of widget_value objects
representing the panes and their items. */
- wv = xmalloc_widget_value ();
- wv->name = "menu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
first_pane = 1;
with its items as a submenu beneath it. */
if (!keymaps && strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (pane_string, NULL, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
if (keymaps && !NILP (prefix))
wv->name++;
- wv->value = 0;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
prev_wv = 0;
}
ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
save_wv->contents = wv;
- wv->name = SSDATA (item_name);
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = 0;
/* Use the contents index as call_data, since we are
restricted to 16-bits. */
wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
- wv->enabled = !NILP (enable);
if (NILP (type))
wv->button_type = BUTTON_TYPE_NONE;
wv->selected = !NILP (selected);
- if (!STRINGP (help))
- help = Qnil;
-
- wv->help = help;
-
prev_wv = wv;
i += MENU_ITEMS_ITEM_LENGTH;
/* Deal with the title, if it is non-nil. */
if (!NILP (title))
{
- widget_value *wv_title = xmalloc_widget_value ();
- widget_value *wv_sep = xmalloc_widget_value ();
+ widget_value *wv_title;
+ widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
/* Maybe replace this separator with a bitmap or owner-draw item
so that it looks better. Having two separators looks odd. */
- wv_sep->name = "--";
wv_sep->next = first_wv->contents;
- wv_sep->help = Qnil;
if (unicode_append_menu)
title = ENCODE_UTF_8 (title);
else if (STRING_MULTIBYTE (title))
title = ENCODE_SYSTEM (title);
- wv_title->name = SSDATA (title);
- wv_title->enabled = TRUE;
+ wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
wv_title->title = TRUE;
wv_title->button_type = BUTTON_TYPE_NONE;
- wv_title->help = Qnil;
wv_title->next = wv_sep;
first_wv->contents = wv_title;
}
pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
pane_string = (NILP (pane_name)
? "" : SSDATA (pane_name));
- prev_wv = xmalloc_widget_value ();
- prev_wv->value = pane_string;
- prev_wv->enabled = 1;
- prev_wv->name = "message";
- prev_wv->help = Qnil;
+ prev_wv = make_widget_value ("message", pane_string, true, Qnil);
first_wv = prev_wv;
/* Loop over all panes and items, filling in the tree. */
return Qnil;
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (button_names[nb_buttons],
+ SSDATA (item_name),
+ !NILP (enable), Qnil);
prev_wv->next = wv;
- wv->name = (char *) button_names[nb_buttons];
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = SSDATA (item_name);
wv->call_data = aref_addr (menu_items, i);
- wv->enabled = !NILP (enable);
- wv->help = Qnil;
prev_wv = wv;
if (! boundary_seen)
if (! boundary_seen)
left_count = nb_buttons - nb_buttons / 2;
- wv = xmalloc_widget_value ();
- wv->name = dialog_name;
- wv->help = Qnil;
+ wv = make_widget_value (dialog_name, NULL, false, Qnil);
/* Frame title: 'Q' = Question, 'I' = Information.
Can also have 'E' = Error if, one day, we want
/* Convert menu_items into widget_value trees
to display the menu. This cannot evaluate Lisp code. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
for (i = 0; submenu_start[i] >= 0; i++)
/* Make a widget-value tree containing
just the top level menu bar strings. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
items = FRAME_MENU_BAR_ITEMS (f);
if (NILP (string))
break;
- wv = xmalloc_widget_value ();
- wv->name = SSDATA (string);
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
/* This prevents lwlib from assuming this
menu item is really supposed to be empty. */
/* The intptr_t cast avoids a warning.
/* Create a tree of widget_value objects
representing the panes and their items. */
- wv = xmalloc_widget_value ();
- wv->name = "menu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help =Qnil;
first_wv = wv;
first_pane = 1;
with its items as a submenu beneath it. */
if (!keymaps && strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (pane_string, NULL, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = (char *) pane_string;
if (keymaps && !NILP (prefix))
wv->name++;
- wv->value = 0;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
prev_wv = 0;
}
}
#endif /* not HAVE_MULTILINGUAL_MENU */
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enable),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
save_wv->contents = wv;
- wv->name = SSDATA (item_name);
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = 0;
/* If this item has a null value,
make the call_data null so that it won't display a box
when the mouse is on it. */
wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
- wv->enabled = !NILP (enable);
if (NILP (type))
wv->button_type = BUTTON_TYPE_NONE;
wv->selected = !NILP (selected);
- if (! STRINGP (help))
- help = Qnil;
-
- wv->help = help;
-
prev_wv = wv;
i += MENU_ITEMS_ITEM_LENGTH;
/* Deal with the title, if it is non-nil. */
if (!NILP (title))
{
- widget_value *wv_title = xmalloc_widget_value ();
- widget_value *wv_sep1 = xmalloc_widget_value ();
- widget_value *wv_sep2 = xmalloc_widget_value ();
+ widget_value *wv_title;
+ widget_value *wv_sep1 = make_widget_value ("--", NULL, false, Qnil);
+ widget_value *wv_sep2 = make_widget_value ("--", NULL, false, Qnil);
- wv_sep2->name = "--";
wv_sep2->next = first_wv->contents;
- wv_sep2->help = Qnil;
-
- wv_sep1->name = "--";
wv_sep1->next = wv_sep2;
- wv_sep1->help = Qnil;
#ifndef HAVE_MULTILINGUAL_MENU
if (STRING_MULTIBYTE (title))
title = ENCODE_MENU_STRING (title);
#endif
- wv_title->name = SSDATA (title);
- wv_title->enabled = true;
+ wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
wv_title->button_type = BUTTON_TYPE_NONE;
- wv_title->help = Qnil;
wv_title->next = wv_sep1;
first_wv->contents = wv_title;
}
pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
pane_string = (NILP (pane_name)
? "" : SSDATA (pane_name));
- prev_wv = xmalloc_widget_value ();
- prev_wv->value = (char *) pane_string;
- prev_wv->enabled = 1;
- prev_wv->name = "message";
- prev_wv->help = Qnil;
+ prev_wv = make_widget_value ("message", (char *) pane_string, true, Qnil);
first_wv = prev_wv;
/* Loop over all panes and items, filling in the tree. */
return Qnil;
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (button_names[nb_buttons],
+ SSDATA (item_name),
+ !NILP (enable), Qnil);
prev_wv->next = wv;
- wv->name = (char *) button_names[nb_buttons];
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = SSDATA (item_name);
wv->call_data = aref_addr (menu_items, i);
- wv->enabled = !NILP (enable);
- wv->help = Qnil;
prev_wv = wv;
if (! boundary_seen)
if (! boundary_seen)
left_count = nb_buttons - nb_buttons / 2;
- wv = xmalloc_widget_value ();
- wv->name = dialog_name;
- wv->help = Qnil;
+ wv = make_widget_value (dialog_name, NULL, false, Qnil);
/* Frame title: 'Q' = Question, 'I' = Information.
Can also have 'E' = Error if, one day, we want
/* Some definitions to reduce conditionals. */
typedef GtkWidget *xt_or_gtk_widget;
-#define XtParent(x) (gtk_widget_get_parent (x))
#undef XSync
#define XSync(d, b) do { gdk_window_process_all_updates (); \
XSync (d, b); } while (false)