Mercurial > emacs
annotate lwlib/lwlib.c @ 108988:65de28008783
* lisp/image-mode.el (image-mode-map): Remap left-char and right-char.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 13 Jun 2010 23:19:46 -0400 |
parents | 1d1d5d9bd884 |
children | 2bc9a0c04c87 376148b31b5e |
rev | line source |
---|---|
5626 | 1 /* A general interface to the widgets of different toolkits. |
76177 | 2 Copyright (C) 1992, 1993 Lucid, Inc. |
3 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003, 2004, | |
106815 | 4 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
5626 | 5 |
6 This file is part of the Lucid Widget Library. | |
7 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
8 The Lucid Widget Library is free software; you can redistribute it and/or |
5626 | 9 modify it under the terms of the GNU General Public License as published by |
76221
3cceb2f916b0
Revert previous change, since not sure it was correct.
Glenn Morris <rgm@gnu.org>
parents:
76217
diff
changeset
|
10 the Free Software Foundation; either version 2, or (at your option) |
5626 | 11 any later version. |
12 | |
13 The Lucid Widget Library is distributed in the hope that it will be useful, | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
5626 | 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with GNU Emacs; see the file COPYING. If not, write to | |
64083 | 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 Boston, MA 02110-1301, USA. */ | |
5626 | 22 |
26087
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25718
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25718
diff
changeset
|
24 #include <config.h> |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25718
diff
changeset
|
25 #endif |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25718
diff
changeset
|
26 |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100957
diff
changeset
|
27 #include <setjmp.h> |
41765
27b70bc263d6
Include ../src/lisp.h. Don't declare xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
32040
diff
changeset
|
28 #include "../src/lisp.h" |
27b70bc263d6
Include ../src/lisp.h. Don't declare xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
32040
diff
changeset
|
29 |
5626 | 30 #include <sys/types.h> |
31 #include <stdio.h> | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
32 #include <ctype.h> |
5627
7ff2d6076466
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
33 #include "lwlib-int.h" |
5626 | 34 #include "lwlib-utils.h" |
5706
75570af32e92
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5627
diff
changeset
|
35 #include <X11/StringDefs.h> |
5626 | 36 |
37 #if defined (USE_LUCID) | |
38 #include "lwlib-Xlw.h" | |
39 #endif | |
40 #if defined (USE_MOTIF) | |
41 #include "lwlib-Xm.h" | |
6306
19fc40b33f52
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6305
diff
changeset
|
42 #else /* not USE_MOTIF */ |
19fc40b33f52
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6305
diff
changeset
|
43 #if defined (USE_LUCID) |
19fc40b33f52
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6305
diff
changeset
|
44 #define USE_XAW |
19fc40b33f52
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6305
diff
changeset
|
45 #endif /* not USE_MOTIF && USE_LUCID */ |
5626 | 46 #endif |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
47 #if defined (USE_XAW) |
81371
477e245e6cf5
Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents:
76221
diff
changeset
|
48 #ifdef HAVE_XAW3D |
477e245e6cf5
Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents:
76221
diff
changeset
|
49 #include <X11/Xaw3d/Paned.h> |
477e245e6cf5
Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents:
76221
diff
changeset
|
50 #else /* !HAVE_XAW3D */ |
21391 | 51 #include <X11/Xaw/Paned.h> |
81371
477e245e6cf5
Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents:
76221
diff
changeset
|
52 #endif /* HAVE_XAW3D */ |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
53 #include "lwlib-Xaw.h" |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
54 #endif |
5626 | 55 |
48480 | 56 #if !defined (USE_LUCID) && !defined (USE_MOTIF) |
57 #error At least one of USE_LUCID or USE_MOTIF must be defined. | |
5626 | 58 #endif |
59 | |
8785 | 60 #ifndef max |
61 #define max(x, y) ((x) > (y) ? (x) : (y)) | |
62 #endif | |
63 | |
5626 | 64 /* List of all widgets managed by the library. */ |
65 static widget_info* | |
66 all_widget_info = NULL; | |
67 | |
12187
18d061c3d0dd
(lwlib_toolkit_type): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
11861
diff
changeset
|
68 #ifdef USE_MOTIF |
18d061c3d0dd
(lwlib_toolkit_type): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
11861
diff
changeset
|
69 char *lwlib_toolkit_type = "motif"; |
18d061c3d0dd
(lwlib_toolkit_type): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
11861
diff
changeset
|
70 #else |
18d061c3d0dd
(lwlib_toolkit_type): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
11861
diff
changeset
|
71 char *lwlib_toolkit_type = "lucid"; |
18d061c3d0dd
(lwlib_toolkit_type): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
11861
diff
changeset
|
72 #endif |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
73 |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
74 static widget_value *merge_widget_value P_ ((widget_value *, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
75 widget_value *, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
76 int, int *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
77 static void instantiate_widget_instance P_ ((widget_instance *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
78 static int my_strcasecmp P_ ((char *, char *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
79 static void safe_free_str P_ ((char *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
80 static void free_widget_value_tree P_ ((widget_value *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
81 static widget_value *copy_widget_value_tree P_ ((widget_value *, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
82 change_type)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
83 static widget_info *allocate_widget_info P_ ((char *, char *, LWLIB_ID, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
84 widget_value *, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
85 lw_callback, lw_callback, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
86 lw_callback, lw_callback)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
87 static void free_widget_info P_ ((widget_info *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
88 static void mark_widget_destroyed P_ ((Widget, XtPointer, XtPointer)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
89 static widget_instance *allocate_widget_instance P_ ((widget_info *, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
90 Widget, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
91 static void free_widget_instance P_ ((widget_instance *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
92 static widget_info *get_widget_info P_ ((LWLIB_ID, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
93 static widget_instance *get_widget_instance P_ ((Widget, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
94 static widget_instance *find_instance P_ ((LWLIB_ID, Widget, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
95 static Boolean safe_strcmp P_ ((char *, char *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
96 static Widget name_to_widget P_ ((widget_instance *, char *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
97 static void set_one_value P_ ((widget_instance *, widget_value *, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
98 static void update_one_widget_instance P_ ((widget_instance *, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
99 static void update_all_widget_values P_ ((widget_info *, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
100 static void initialize_widget_instance P_ ((widget_instance *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
101 static widget_creation_function find_in_table P_ ((char *, widget_creation_entry *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
102 static Boolean dialog_spec_p P_ ((char *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
103 static void destroy_one_instance P_ ((widget_instance *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
104 static void lw_pop_all_widgets P_ ((LWLIB_ID, Boolean)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
105 static Boolean get_one_value P_ ((widget_instance *, widget_value *)); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
106 static void show_one_widget_busy P_ ((Widget, Boolean)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
107 |
21391 | 108 void |
7515
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
109 lwlib_memset (address, value, length) |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
110 char *address; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
111 int value; |
48480 | 112 size_t length; |
7515
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
113 { |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
114 int i; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
115 |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
116 for (i = 0; i < length; i++) |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
117 address[i] = value; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
118 } |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
119 |
21391 | 120 void |
7515
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
121 lwlib_bcopy (from, to, length) |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
122 char *from; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
123 char *to; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
124 int length; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
125 { |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
126 int i; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
127 |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
128 for (i = 0; i < length; i++) |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
129 to[i] = from[i]; |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
130 } |
5626 | 131 /* utility functions for widget_instance and widget_info */ |
7423
4a5d0d109242
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6333
diff
changeset
|
132 char * |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
133 safe_strdup (s) |
29468 | 134 const char *s; |
5626 | 135 { |
136 char *result; | |
137 if (! s) return 0; | |
138 result = (char *) malloc (strlen (s) + 1); | |
139 if (! result) | |
140 return 0; | |
141 strcpy (result, s); | |
142 return result; | |
143 } | |
144 | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
145 /* Like strcmp but ignore differences in case. */ |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
146 |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
147 static int |
5853 | 148 my_strcasecmp (s1, s2) |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
149 char *s1, *s2; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
150 { |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
151 while (1) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
152 { |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
153 int c1 = *s1++; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
154 int c2 = *s2++; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
155 if (isupper (c1)) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
156 c1 = tolower (c1); |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
157 if (isupper (c2)) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
158 c2 = tolower (c2); |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
159 if (c1 != c2) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
160 return (c1 > c2 ? 1 : -1); |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
161 if (c1 == 0) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
162 return 0; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
163 } |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
164 } |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
165 |
5626 | 166 static void |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
167 safe_free_str (s) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
168 char *s; |
5626 | 169 { |
95479
9588c3703f38
remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents:
87649
diff
changeset
|
170 free (s); |
5626 | 171 } |
172 | |
173 static widget_value *widget_value_free_list = 0; | |
5993
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
174 static int malloc_cpt = 0; |
5626 | 175 |
176 widget_value * | |
177 malloc_widget_value () | |
178 { | |
179 widget_value *wv; | |
180 if (widget_value_free_list) | |
181 { | |
182 wv = widget_value_free_list; | |
183 widget_value_free_list = wv->free_list; | |
184 wv->free_list = 0; | |
185 } | |
186 else | |
187 { | |
188 wv = (widget_value *) malloc (sizeof (widget_value)); | |
5993
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
189 malloc_cpt++; |
5626 | 190 } |
48480 | 191 lwlib_memset ((void*) wv, 0, sizeof (widget_value)); |
5626 | 192 return wv; |
193 } | |
194 | |
14163
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
195 /* this is analogous to free(). It frees only what was allocated |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
196 by malloc_widget_value(), and no substructures. |
5626 | 197 */ |
198 void | |
199 free_widget_value (wv) | |
200 widget_value *wv; | |
201 { | |
202 if (wv->free_list) | |
203 abort (); | |
5993
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
204 |
5999
b135bb2b4bfe
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5993
diff
changeset
|
205 if (malloc_cpt > 25) |
5993
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
206 { |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
207 /* When the number of already allocated cells is too big, |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
208 We free it. */ |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
209 free (wv); |
5999
b135bb2b4bfe
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5993
diff
changeset
|
210 malloc_cpt--; |
5993
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
211 } |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
212 else |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
213 { |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
214 wv->free_list = widget_value_free_list; |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
215 widget_value_free_list = wv; |
5feb28cb62c8
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5853
diff
changeset
|
216 } |
5626 | 217 } |
218 | |
219 static void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
220 free_widget_value_tree (wv) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
221 widget_value *wv; |
5626 | 222 { |
223 if (!wv) | |
224 return; | |
225 | |
95479
9588c3703f38
remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents:
87649
diff
changeset
|
226 free (wv->name); |
9588c3703f38
remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents:
87649
diff
changeset
|
227 free (wv->value); |
9588c3703f38
remove useless if-before-free tests
Jim Meyering <jim@meyering.net>
parents:
87649
diff
changeset
|
228 free (wv->key); |
5626 | 229 |
41765
27b70bc263d6
Include ../src/lisp.h. Don't declare xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
32040
diff
changeset
|
230 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF; |
5626 | 231 |
232 if (wv->toolkit_data && wv->free_toolkit_data) | |
233 { | |
14611
69fca906f068
(free_widget_value_tree, merge_widget_value):
Karl Heuer <kwzh@gnu.org>
parents:
14594
diff
changeset
|
234 XtFree (wv->toolkit_data); |
5626 | 235 wv->toolkit_data = (void *) 0xDEADBEEF; |
236 } | |
237 | |
238 if (wv->contents && (wv->contents != (widget_value*)1)) | |
239 { | |
240 free_widget_value_tree (wv->contents); | |
241 wv->contents = (widget_value *) 0xDEADBEEF; | |
242 } | |
243 if (wv->next) | |
244 { | |
245 free_widget_value_tree (wv->next); | |
246 wv->next = (widget_value *) 0xDEADBEEF; | |
247 } | |
248 free_widget_value (wv); | |
249 } | |
250 | |
251 static widget_value * | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
252 copy_widget_value_tree (val, change) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
253 widget_value* val; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
254 change_type change; |
5626 | 255 { |
256 widget_value* copy; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
257 |
5626 | 258 if (!val) |
259 return NULL; | |
260 if (val == (widget_value *) 1) | |
261 return val; | |
262 | |
263 copy = malloc_widget_value (); | |
264 copy->name = safe_strdup (val->name); | |
265 copy->value = safe_strdup (val->value); | |
266 copy->key = safe_strdup (val->key); | |
41765
27b70bc263d6
Include ../src/lisp.h. Don't declare xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
32040
diff
changeset
|
267 copy->help = val->help; |
5626 | 268 copy->enabled = val->enabled; |
25036 | 269 copy->button_type = val->button_type; |
5626 | 270 copy->selected = val->selected; |
271 copy->edited = False; | |
272 copy->change = change; | |
14879
70f79ccb9875
(merge_widget_value): Set the this_one_change field.
Richard M. Stallman <rms@gnu.org>
parents:
14663
diff
changeset
|
273 copy->this_one_change = change; |
5626 | 274 copy->contents = copy_widget_value_tree (val->contents, change); |
275 copy->call_data = val->call_data; | |
276 copy->next = copy_widget_value_tree (val->next, change); | |
277 copy->toolkit_data = NULL; | |
278 copy->free_toolkit_data = False; | |
279 return copy; | |
280 } | |
281 | |
282 static widget_info * | |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
283 allocate_widget_info (type, name, id, val, pre_activate_cb, |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
284 selection_cb, post_activate_cb, highlight_cb) |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
285 char* type; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
286 char* name; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
287 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
288 widget_value* val; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
289 lw_callback pre_activate_cb; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
290 lw_callback selection_cb; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
291 lw_callback post_activate_cb; |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
292 lw_callback highlight_cb; |
5626 | 293 { |
294 widget_info* info = (widget_info*)malloc (sizeof (widget_info)); | |
295 info->type = safe_strdup (type); | |
296 info->name = safe_strdup (name); | |
297 info->id = id; | |
298 info->val = copy_widget_value_tree (val, STRUCTURAL_CHANGE); | |
299 info->busy = False; | |
300 info->pre_activate_cb = pre_activate_cb; | |
301 info->selection_cb = selection_cb; | |
302 info->post_activate_cb = post_activate_cb; | |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
303 info->highlight_cb = highlight_cb; |
5626 | 304 info->instances = NULL; |
305 | |
306 info->next = all_widget_info; | |
307 all_widget_info = info; | |
308 | |
309 return info; | |
310 } | |
311 | |
312 static void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
313 free_widget_info (info) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
314 widget_info* info; |
5626 | 315 { |
316 safe_free_str (info->type); | |
317 safe_free_str (info->name); | |
318 free_widget_value_tree (info->val); | |
7515
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
319 lwlib_memset ((void*)info, 0xDEADBEEF, sizeof (widget_info)); |
5626 | 320 free (info); |
321 } | |
322 | |
323 static void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
324 mark_widget_destroyed (widget, closure, call_data) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
325 Widget widget; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
326 XtPointer closure; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
327 XtPointer call_data; |
5626 | 328 { |
329 widget_instance* instance = (widget_instance*)closure; | |
330 | |
331 /* be very conservative */ | |
332 if (instance->widget == widget) | |
333 instance->widget = NULL; | |
334 } | |
335 | |
48480 | 336 /* The messy #ifdef PROTOTYPES here and elsewhere are prompted by a |
337 flood of warnings about argument promotion from proprietary ISO C | |
338 compilers. (etags still only makes one entry for each function.) */ | |
5626 | 339 static widget_instance * |
48480 | 340 #ifdef PROTOTYPES |
341 allocate_widget_instance (widget_info* info, Widget parent, Boolean pop_up_p) | |
342 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
343 allocate_widget_instance (info, parent, pop_up_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
344 widget_info* info; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
345 Widget parent; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
346 Boolean pop_up_p; |
48480 | 347 #endif |
5626 | 348 { |
349 widget_instance* instance = | |
350 (widget_instance*)malloc (sizeof (widget_instance)); | |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
351 bzero (instance, sizeof *instance); |
5626 | 352 instance->parent = parent; |
353 instance->pop_up_p = pop_up_p; | |
354 instance->info = info; | |
355 instance->next = info->instances; | |
356 info->instances = instance; | |
357 | |
14163
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
358 instantiate_widget_instance (instance); |
5626 | 359 |
360 XtAddCallback (instance->widget, XtNdestroyCallback, | |
361 mark_widget_destroyed, (XtPointer)instance); | |
362 return instance; | |
363 } | |
364 | |
365 static void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
366 free_widget_instance (instance) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
367 widget_instance* instance; |
5626 | 368 { |
7515
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
369 lwlib_memset ((void*)instance, 0xDEADBEEF, sizeof (widget_instance)); |
5626 | 370 free (instance); |
371 } | |
372 | |
373 static widget_info * | |
48480 | 374 #ifdef PROTOTYPES |
375 get_widget_info (LWLIB_ID id, Boolean remove_p) | |
376 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
377 get_widget_info (id, remove_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
378 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
379 Boolean remove_p; |
48480 | 380 #endif |
5626 | 381 { |
382 widget_info* info; | |
383 widget_info* prev; | |
384 for (prev = NULL, info = all_widget_info; | |
385 info; | |
386 prev = info, info = info->next) | |
387 if (info->id == id) | |
388 { | |
389 if (remove_p) | |
390 { | |
391 if (prev) | |
392 prev->next = info->next; | |
393 else | |
394 all_widget_info = info->next; | |
395 } | |
396 return info; | |
397 } | |
398 return NULL; | |
399 } | |
400 | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
401 /* Internal function used by the library dependent implementation to get the |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
402 widget_value for a given widget in an instance */ |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
403 widget_info * |
6333
f3fe542e8cd7
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6306
diff
changeset
|
404 lw_get_widget_info (id) |
f3fe542e8cd7
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6306
diff
changeset
|
405 LWLIB_ID id; |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
406 { |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
407 return get_widget_info (id, 0); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
408 } |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
409 |
5626 | 410 static widget_instance * |
48480 | 411 #ifdef PROTOTYPES |
412 get_widget_instance (Widget widget, Boolean remove_p) | |
413 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
414 get_widget_instance (widget, remove_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
415 Widget widget; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
416 Boolean remove_p; |
48480 | 417 #endif |
5626 | 418 { |
419 widget_info* info; | |
420 widget_instance* instance; | |
421 widget_instance* prev; | |
422 for (info = all_widget_info; info; info = info->next) | |
423 for (prev = NULL, instance = info->instances; | |
424 instance; | |
425 prev = instance, instance = instance->next) | |
426 if (instance->widget == widget) | |
427 { | |
428 if (remove_p) | |
429 { | |
430 if (prev) | |
431 prev->next = instance->next; | |
432 else | |
433 info->instances = instance->next; | |
434 } | |
435 return instance; | |
436 } | |
437 return (widget_instance *) 0; | |
438 } | |
439 | |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
440 /* Value is a pointer to the widget_instance corresponding to |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
441 WIDGET, or null if WIDGET is not a lwlib widget. */ |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
442 |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
443 widget_instance * |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
444 lw_get_widget_instance (widget) |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
445 Widget widget; |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
446 { |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
447 return get_widget_instance (widget, False); |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
448 } |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
449 |
5626 | 450 static widget_instance* |
48480 | 451 #ifdef PROTOTYPES |
452 find_instance (LWLIB_ID id, Widget parent, Boolean pop_up_p) | |
453 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
454 find_instance (id, parent, pop_up_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
455 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
456 Widget parent; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
457 Boolean pop_up_p; |
48480 | 458 #endif |
5626 | 459 { |
460 widget_info* info = get_widget_info (id, False); | |
461 widget_instance* instance; | |
462 | |
463 if (info) | |
464 for (instance = info->instances; instance; instance = instance->next) | |
465 if (instance->parent == parent && instance->pop_up_p == pop_up_p) | |
466 return instance; | |
467 | |
468 return NULL; | |
469 } | |
470 | |
471 | |
472 /* utility function for widget_value */ | |
473 static Boolean | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
474 safe_strcmp (s1, s2) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
475 char* s1; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
476 char* s2; |
5626 | 477 { |
478 if (!!s1 ^ !!s2) return True; | |
479 return (s1 && s2) ? strcmp (s1, s2) : s1 ? False : !!s2; | |
480 } | |
481 | |
482 | |
483 #if 0 | |
484 # define EXPLAIN(name, oc, nc, desc, a1, a2) \ | |
485 printf ("Change: \"%s\"\tmax(%s=%d,%s=%d)\t%s %d %d\n", \ | |
486 name, \ | |
487 (oc == NO_CHANGE ? "none" : \ | |
488 (oc == INVISIBLE_CHANGE ? "invisible" : \ | |
489 (oc == VISIBLE_CHANGE ? "visible" : \ | |
490 (oc == STRUCTURAL_CHANGE ? "structural" : "???")))), \ | |
491 oc, \ | |
492 (nc == NO_CHANGE ? "none" : \ | |
493 (nc == INVISIBLE_CHANGE ? "invisible" : \ | |
494 (nc == VISIBLE_CHANGE ? "visible" : \ | |
495 (nc == STRUCTURAL_CHANGE ? "structural" : "???")))), \ | |
496 nc, desc, a1, a2) | |
497 #else | |
498 # define EXPLAIN(name, oc, nc, desc, a1, a2) | |
499 #endif | |
500 | |
501 | |
502 static widget_value * | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
503 merge_widget_value (val1, val2, level, change_p) |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
504 widget_value* val1; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
505 widget_value* val2; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
506 int level; |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
507 int *change_p; |
5626 | 508 { |
14879
70f79ccb9875
(merge_widget_value): Set the this_one_change field.
Richard M. Stallman <rms@gnu.org>
parents:
14663
diff
changeset
|
509 change_type change, this_one_change; |
5626 | 510 widget_value* merged_next; |
511 widget_value* merged_contents; | |
512 | |
513 if (!val1) | |
514 { | |
515 if (val2) | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
516 { |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
517 *change_p = 1; |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
518 return copy_widget_value_tree (val2, STRUCTURAL_CHANGE); |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
519 } |
5626 | 520 else |
521 return NULL; | |
522 } | |
523 if (!val2) | |
524 { | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
525 *change_p = 1; |
5626 | 526 free_widget_value_tree (val1); |
527 return NULL; | |
528 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
529 |
5626 | 530 change = NO_CHANGE; |
531 | |
532 if (safe_strcmp (val1->name, val2->name)) | |
533 { | |
534 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "name change", | |
535 val1->name, val2->name); | |
536 change = max (change, STRUCTURAL_CHANGE); | |
537 safe_free_str (val1->name); | |
538 val1->name = safe_strdup (val2->name); | |
539 } | |
540 if (safe_strcmp (val1->value, val2->value)) | |
541 { | |
542 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "value change", | |
543 val1->value, val2->value); | |
544 change = max (change, VISIBLE_CHANGE); | |
545 safe_free_str (val1->value); | |
546 val1->value = safe_strdup (val2->value); | |
547 } | |
548 if (safe_strcmp (val1->key, val2->key)) | |
549 { | |
550 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "key change", | |
551 val1->key, val2->key); | |
552 change = max (change, VISIBLE_CHANGE); | |
553 safe_free_str (val1->key); | |
554 val1->key = safe_strdup (val2->key); | |
555 } | |
41765
27b70bc263d6
Include ../src/lisp.h. Don't declare xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
32040
diff
changeset
|
556 if (! EQ (val1->help, val2->help)) |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
557 { |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
558 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "help change", |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
559 val1->help, val2->help); |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
560 change = max (change, VISIBLE_CHANGE); |
41765
27b70bc263d6
Include ../src/lisp.h. Don't declare xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
32040
diff
changeset
|
561 val1->help = val2->help; |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
562 } |
5626 | 563 if (val1->enabled != val2->enabled) |
564 { | |
565 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "enablement change", | |
566 val1->enabled, val2->enabled); | |
567 change = max (change, VISIBLE_CHANGE); | |
568 val1->enabled = val2->enabled; | |
569 } | |
25036 | 570 if (val1->button_type != val2->button_type) |
571 { | |
572 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "button type change", | |
573 val1->button_type, val2->button_type); | |
574 change = max (change, VISIBLE_CHANGE); | |
575 val1->button_type = val2->button_type; | |
576 } | |
5626 | 577 if (val1->selected != val2->selected) |
578 { | |
579 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "selection change", | |
580 val1->selected, val2->selected); | |
581 change = max (change, VISIBLE_CHANGE); | |
582 val1->selected = val2->selected; | |
583 } | |
584 if (val1->call_data != val2->call_data) | |
585 { | |
586 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "call-data change", | |
587 val1->call_data, val2->call_data); | |
588 change = max (change, INVISIBLE_CHANGE); | |
589 val1->call_data = val2->call_data; | |
590 } | |
591 | |
592 if (level > 0) | |
593 { | |
594 merged_contents = | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
595 merge_widget_value (val1->contents, val2->contents, level - 1, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
596 change_p); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
597 |
5626 | 598 if (val1->contents && !merged_contents) |
599 { | |
14163
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
600 /* This used to say INVISIBLE_CHANGE, |
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
601 but it is visible and vitally important when |
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
602 the contents of the menu bar itself are entirely deleted. |
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
603 |
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
604 But maybe it doesn't matter. This fails to fix the bug. */ |
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
605 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(contents gone)", |
5626 | 606 0, 0); |
14163
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
607 change = max (change, STRUCTURAL_CHANGE); |
5626 | 608 } |
609 else if (merged_contents && merged_contents->change != NO_CHANGE) | |
610 { | |
611 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "(contents change)", | |
612 0, 0); | |
613 change = max (change, INVISIBLE_CHANGE); | |
15854
184808f2a73c
(merge_widget_value): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
15790
diff
changeset
|
614 #if 0 /* This was replaced by the August 9 1996 change in lwlib-Xm.c. */ |
15790
fb5e87397205
(merge_widget_value) [USE_MOTIF]: Pass along the change flag from
Richard M. Stallman <rms@gnu.org>
parents:
15630
diff
changeset
|
615 #ifdef USE_MOTIF |
fb5e87397205
(merge_widget_value) [USE_MOTIF]: Pass along the change flag from
Richard M. Stallman <rms@gnu.org>
parents:
15630
diff
changeset
|
616 change = max (merged_contents->change, change); |
fb5e87397205
(merge_widget_value) [USE_MOTIF]: Pass along the change flag from
Richard M. Stallman <rms@gnu.org>
parents:
15630
diff
changeset
|
617 #endif |
15854
184808f2a73c
(merge_widget_value): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
15790
diff
changeset
|
618 #endif |
5626 | 619 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
620 |
5626 | 621 val1->contents = merged_contents; |
622 } | |
623 | |
14879
70f79ccb9875
(merge_widget_value): Set the this_one_change field.
Richard M. Stallman <rms@gnu.org>
parents:
14663
diff
changeset
|
624 this_one_change = change; |
70f79ccb9875
(merge_widget_value): Set the this_one_change field.
Richard M. Stallman <rms@gnu.org>
parents:
14663
diff
changeset
|
625 |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
626 merged_next = merge_widget_value (val1->next, val2->next, level, change_p); |
5626 | 627 |
628 if (val1->next && !merged_next) | |
629 { | |
630 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(following gone)", | |
631 0, 0); | |
632 change = max (change, STRUCTURAL_CHANGE); | |
633 } | |
634 else if (merged_next) | |
635 { | |
636 if (merged_next->change) | |
637 EXPLAIN (val1->name, change, merged_next->change, "(following change)", | |
638 0, 0); | |
639 change = max (change, merged_next->change); | |
640 } | |
641 | |
642 val1->next = merged_next; | |
643 | |
14879
70f79ccb9875
(merge_widget_value): Set the this_one_change field.
Richard M. Stallman <rms@gnu.org>
parents:
14663
diff
changeset
|
644 val1->this_one_change = this_one_change; |
5626 | 645 val1->change = change; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
646 |
5626 | 647 if (change > NO_CHANGE && val1->toolkit_data) |
648 { | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
649 *change_p = 1; |
5626 | 650 if (val1->free_toolkit_data) |
14611
69fca906f068
(free_widget_value_tree, merge_widget_value):
Karl Heuer <kwzh@gnu.org>
parents:
14594
diff
changeset
|
651 XtFree (val1->toolkit_data); |
5626 | 652 val1->toolkit_data = NULL; |
653 } | |
654 | |
655 return val1; | |
656 } | |
657 | |
658 | |
659 /* modifying the widgets */ | |
660 static Widget | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
661 name_to_widget (instance, name) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
662 widget_instance* instance; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
663 char* name; |
5626 | 664 { |
665 Widget widget = NULL; | |
666 | |
667 if (!instance->widget) | |
668 return NULL; | |
669 | |
670 if (!strcmp (XtName (instance->widget), name)) | |
671 widget = instance->widget; | |
672 else | |
673 { | |
674 int length = strlen (name) + 2; | |
7515
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
675 char* real_name = (char *) xmalloc (length); |
5626 | 676 real_name [0] = '*'; |
677 strcpy (real_name + 1, name); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
678 |
5626 | 679 widget = XtNameToWidget (instance->widget, real_name); |
7515
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
680 |
d31babe815e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7423
diff
changeset
|
681 free (real_name); |
5626 | 682 } |
683 return widget; | |
684 } | |
685 | |
686 static void | |
48480 | 687 #ifdef PROTOTYPES |
688 set_one_value (widget_instance* instance, widget_value* val, Boolean deep_p) | |
689 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
690 set_one_value (instance, val, deep_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
691 widget_instance* instance; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
692 widget_value* val; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
693 Boolean deep_p; |
48480 | 694 #endif |
5626 | 695 { |
696 Widget widget = name_to_widget (instance, val->name); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
697 |
5626 | 698 if (widget) |
699 { | |
700 #if defined (USE_LUCID) | |
701 if (lw_lucid_widget_p (instance->widget)) | |
702 xlw_update_one_widget (instance, widget, val, deep_p); | |
703 #endif | |
704 #if defined (USE_MOTIF) | |
705 if (lw_motif_widget_p (instance->widget)) | |
706 xm_update_one_widget (instance, widget, val, deep_p); | |
707 #endif | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
708 #if defined (USE_XAW) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
709 if (lw_xaw_widget_p (instance->widget)) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
710 xaw_update_one_widget (instance, widget, val, deep_p); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
711 #endif |
5626 | 712 } |
713 } | |
714 | |
715 static void | |
48480 | 716 #ifdef PROTOTYPES |
717 update_one_widget_instance (widget_instance* instance, Boolean deep_p) | |
718 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
719 update_one_widget_instance (instance, deep_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
720 widget_instance* instance; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
721 Boolean deep_p; |
48480 | 722 #endif |
5626 | 723 { |
724 widget_value *val; | |
725 | |
726 if (!instance->widget) | |
727 /* the widget was destroyed */ | |
728 return; | |
729 | |
730 for (val = instance->info->val; val; val = val->next) | |
731 if (val->change != NO_CHANGE) | |
732 set_one_value (instance, val, deep_p); | |
733 } | |
734 | |
735 static void | |
48480 | 736 #ifdef PROTOTYPES |
737 update_all_widget_values (widget_info* info, Boolean deep_p) | |
738 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
739 update_all_widget_values (info, deep_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
740 widget_info* info; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
741 Boolean deep_p; |
48480 | 742 #endif |
5626 | 743 { |
744 widget_instance* instance; | |
745 widget_value* val; | |
746 | |
747 for (instance = info->instances; instance; instance = instance->next) | |
748 update_one_widget_instance (instance, deep_p); | |
749 | |
750 for (val = info->val; val; val = val->next) | |
751 val->change = NO_CHANGE; | |
752 } | |
753 | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
754 int |
48480 | 755 #ifdef PROTOTYPES |
756 lw_modify_all_widgets (LWLIB_ID id, widget_value* val, Boolean deep_p) | |
757 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
758 lw_modify_all_widgets (id, val, deep_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
759 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
760 widget_value* val; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
761 Boolean deep_p; |
48480 | 762 #endif |
5626 | 763 { |
764 widget_info* info = get_widget_info (id, False); | |
765 widget_value* new_val; | |
766 widget_value* next_new_val; | |
767 widget_value* cur; | |
768 widget_value* prev; | |
769 widget_value* next; | |
770 int found; | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
771 int change_p = 0; |
5626 | 772 |
773 if (!info) | |
29468 | 774 return 0; |
5626 | 775 |
776 for (new_val = val; new_val; new_val = new_val->next) | |
777 { | |
778 next_new_val = new_val->next; | |
779 new_val->next = NULL; | |
780 found = False; | |
781 for (prev = NULL, cur = info->val; cur; prev = cur, cur = cur->next) | |
782 if (!strcmp (cur->name, new_val->name)) | |
783 { | |
784 found = True; | |
785 next = cur->next; | |
786 cur->next = NULL; | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
787 cur = merge_widget_value (cur, new_val, deep_p ? 1000 : 1, |
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
788 &change_p); |
5626 | 789 if (prev) |
790 prev->next = cur ? cur : next; | |
791 else | |
792 info->val = cur ? cur : next; | |
793 if (cur) | |
794 cur->next = next; | |
795 break; | |
796 } | |
797 if (!found) | |
798 { | |
799 /* Could not find it, add it */ | |
800 if (prev) | |
801 prev->next = copy_widget_value_tree (new_val, STRUCTURAL_CHANGE); | |
802 else | |
803 info->val = copy_widget_value_tree (new_val, STRUCTURAL_CHANGE); | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
804 change_p = 1; |
5626 | 805 } |
806 new_val->next = next_new_val; | |
807 } | |
808 | |
809 update_all_widget_values (info, deep_p); | |
27997
7ff6dc4c3775
(lw_modify_all_widgets): Return non-zero if widget
Gerd Moellmann <gerd@gnu.org>
parents:
27756
diff
changeset
|
810 return change_p; |
5626 | 811 } |
812 | |
813 | |
814 /* creating the widgets */ | |
815 | |
816 static void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
817 initialize_widget_instance (instance) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
818 widget_instance* instance; |
5626 | 819 { |
820 widget_value* val; | |
821 | |
822 for (val = instance->info->val; val; val = val->next) | |
823 val->change = STRUCTURAL_CHANGE; | |
824 | |
825 update_one_widget_instance (instance, True); | |
826 | |
827 for (val = instance->info->val; val; val = val->next) | |
828 val->change = NO_CHANGE; | |
829 } | |
830 | |
831 | |
832 static widget_creation_function | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
833 find_in_table (type, table) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
834 char* type; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
835 widget_creation_entry* table; |
5626 | 836 { |
837 widget_creation_entry* cur; | |
838 for (cur = table; cur->type; cur++) | |
5853 | 839 if (!my_strcasecmp (type, cur->type)) |
5626 | 840 return cur->function; |
841 return NULL; | |
842 } | |
843 | |
844 static Boolean | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
845 dialog_spec_p (name) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
846 char* name; |
5626 | 847 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
848 /* return True if name matches [EILPQeilpq][1-9][Bb] or |
5626 | 849 [EILPQeilpq][1-9][Bb][Rr][1-9] */ |
850 if (!name) | |
851 return False; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
852 |
5626 | 853 switch (name [0]) |
854 { | |
855 case 'E': case 'I': case 'L': case 'P': case 'Q': | |
856 case 'e': case 'i': case 'l': case 'p': case 'q': | |
857 if (name [1] >= '0' && name [1] <= '9') | |
858 { | |
859 if (name [2] != 'B' && name [2] != 'b') | |
860 return False; | |
861 if (!name [3]) | |
862 return True; | |
863 if ((name [3] == 'T' || name [3] == 't') && !name [4]) | |
864 return True; | |
865 if ((name [3] == 'R' || name [3] == 'r') | |
866 && name [4] >= '0' && name [4] <= '9' && !name [5]) | |
867 return True; | |
868 return False; | |
869 } | |
870 else | |
871 return False; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
872 |
5626 | 873 default: |
874 return False; | |
875 } | |
876 } | |
877 | |
878 static void | |
14163
2422ceecd9d2
(instantiate_widget_instance): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
12744
diff
changeset
|
879 instantiate_widget_instance (instance) |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
880 widget_instance* instance; |
5626 | 881 { |
882 widget_creation_function function = NULL; | |
883 | |
884 #if defined (USE_LUCID) | |
885 if (!function) | |
886 function = find_in_table (instance->info->type, xlw_creation_table); | |
887 #endif | |
888 #if defined(USE_MOTIF) | |
889 if (!function) | |
890 function = find_in_table (instance->info->type, xm_creation_table); | |
891 #endif | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
892 #if defined (USE_XAW) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
893 if (!function) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
894 function = find_in_table (instance->info->type, xaw_creation_table); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
895 #endif |
5626 | 896 |
897 if (!function) | |
898 { | |
899 if (dialog_spec_p (instance->info->type)) | |
900 { | |
901 #if defined (USE_LUCID) | |
902 /* not yet */ | |
903 #endif | |
904 #if defined(USE_MOTIF) | |
905 if (!function) | |
906 function = xm_create_dialog; | |
907 #endif | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
908 #if defined (USE_XAW) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
909 if (!function) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
910 function = xaw_create_dialog; |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
911 #endif |
5626 | 912 } |
913 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
914 |
5626 | 915 if (!function) |
916 { | |
917 printf ("No creation function for widget type %s\n", | |
918 instance->info->type); | |
919 abort (); | |
920 } | |
921 | |
922 instance->widget = (*function) (instance); | |
923 | |
924 if (!instance->widget) | |
925 abort (); | |
926 | |
927 /* XtRealizeWidget (instance->widget);*/ | |
928 } | |
929 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
930 void |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
931 lw_register_widget (type, name, id, val, pre_activate_cb, |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
932 selection_cb, post_activate_cb, highlight_cb) |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
933 char* type; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
934 char* name; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
935 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
936 widget_value* val; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
937 lw_callback pre_activate_cb; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
938 lw_callback selection_cb; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
939 lw_callback post_activate_cb; |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
940 lw_callback highlight_cb; |
5626 | 941 { |
942 if (!get_widget_info (id, False)) | |
943 allocate_widget_info (type, name, id, val, pre_activate_cb, selection_cb, | |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
944 post_activate_cb, highlight_cb); |
5626 | 945 } |
946 | |
947 Widget | |
48480 | 948 #ifdef PROTOTYPES |
949 lw_get_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p) | |
950 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
951 lw_get_widget (id, parent, pop_up_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
952 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
953 Widget parent; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
954 Boolean pop_up_p; |
48480 | 955 #endif |
5626 | 956 { |
957 widget_instance* instance; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
958 |
5626 | 959 instance = find_instance (id, parent, pop_up_p); |
960 return instance ? instance->widget : NULL; | |
961 } | |
962 | |
963 Widget | |
48480 | 964 #ifdef PROTOTYPES |
965 lw_make_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p) | |
966 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
967 lw_make_widget (id, parent, pop_up_p) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
968 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
969 Widget parent; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
970 Boolean pop_up_p; |
48480 | 971 #endif |
5626 | 972 { |
973 widget_instance* instance; | |
974 widget_info* info; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
975 |
5626 | 976 instance = find_instance (id, parent, pop_up_p); |
977 if (!instance) | |
978 { | |
979 info = get_widget_info (id, False); | |
980 if (!info) | |
981 return NULL; | |
982 instance = allocate_widget_instance (info, parent, pop_up_p); | |
983 initialize_widget_instance (instance); | |
984 } | |
985 if (!instance->widget) | |
986 abort (); | |
987 return instance->widget; | |
988 } | |
989 | |
990 Widget | |
48480 | 991 #ifdef PROTOTYPES |
992 lw_create_widget (char* type, char* name, LWLIB_ID id, widget_value* val, | |
993 Widget parent, Boolean pop_up_p, | |
994 lw_callback pre_activate_cb, lw_callback selection_cb, | |
995 lw_callback post_activate_cb, lw_callback highlight_cb) | |
996 #else | |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
997 lw_create_widget (type, name, id, val, parent, pop_up_p, pre_activate_cb, |
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
998 selection_cb, post_activate_cb, highlight_cb) |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
999 char* type; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1000 char* name; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1001 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1002 widget_value* val; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1003 Widget parent; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1004 Boolean pop_up_p; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1005 lw_callback pre_activate_cb; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1006 lw_callback selection_cb; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1007 lw_callback post_activate_cb; |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
1008 lw_callback highlight_cb; |
48480 | 1009 #endif |
5626 | 1010 { |
1011 lw_register_widget (type, name, id, val, pre_activate_cb, selection_cb, | |
27335
314e947f85ea
(copy_widget_value_tree): Copy help string.
Gerd Moellmann <gerd@gnu.org>
parents:
26087
diff
changeset
|
1012 post_activate_cb, highlight_cb); |
5626 | 1013 return lw_make_widget (id, parent, pop_up_p); |
1014 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
1015 |
5626 | 1016 |
1017 /* destroying the widgets */ | |
1018 static void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1019 destroy_one_instance (instance) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1020 widget_instance* instance; |
5626 | 1021 { |
1022 /* Remove the destroy callback on the widget; that callback will try to | |
1023 dereference the instance object (to set its widget slot to 0, since the | |
1024 widget is dead.) Since the instance is now dead, we don't have to worry | |
1025 about the fact that its widget is dead too. | |
1026 | |
1027 This happens in the Phase2Destroy of the widget, so this callback would | |
1028 not have been run until arbitrarily long after the instance was freed. | |
1029 */ | |
1030 if (instance->widget) | |
1031 XtRemoveCallback (instance->widget, XtNdestroyCallback, | |
1032 mark_widget_destroyed, (XtPointer)instance); | |
1033 | |
1034 if (instance->widget) | |
1035 { | |
1036 /* The else are pretty tricky here, including the empty statement | |
1037 at the end because it would be very bad to destroy a widget | |
1038 twice. */ | |
1039 #if defined (USE_LUCID) | |
1040 if (lw_lucid_widget_p (instance->widget)) | |
1041 xlw_destroy_instance (instance); | |
1042 else | |
1043 #endif | |
1044 #if defined (USE_MOTIF) | |
1045 if (lw_motif_widget_p (instance->widget)) | |
1046 xm_destroy_instance (instance); | |
1047 else | |
1048 #endif | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1049 #if defined (USE_XAW) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1050 if (lw_xaw_widget_p (instance->widget)) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1051 xaw_destroy_instance (instance); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
1052 else |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1053 #endif |
5626 | 1054 /* do not remove the empty statement */ |
1055 ; | |
1056 } | |
1057 | |
1058 free_widget_instance (instance); | |
1059 } | |
1060 | |
1061 void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1062 lw_destroy_widget (w) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1063 Widget w; |
5626 | 1064 { |
1065 widget_instance* instance = get_widget_instance (w, True); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
1066 |
5626 | 1067 if (instance) |
1068 { | |
1069 widget_info *info = instance->info; | |
1070 /* instance has already been removed from the list; free it */ | |
1071 destroy_one_instance (instance); | |
1072 /* if there are no instances left, free the info too */ | |
1073 if (!info->instances) | |
1074 lw_destroy_all_widgets (info->id); | |
1075 } | |
1076 } | |
1077 | |
1078 void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1079 lw_destroy_all_widgets (id) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1080 LWLIB_ID id; |
5626 | 1081 { |
1082 widget_info* info = get_widget_info (id, True); | |
1083 widget_instance* instance; | |
1084 widget_instance* next; | |
1085 | |
1086 if (info) | |
1087 { | |
1088 for (instance = info->instances; instance; ) | |
1089 { | |
1090 next = instance->next; | |
1091 destroy_one_instance (instance); | |
1092 instance = next; | |
1093 } | |
1094 free_widget_info (info); | |
1095 } | |
1096 } | |
1097 | |
1098 void | |
1099 lw_destroy_everything () | |
1100 { | |
1101 while (all_widget_info) | |
1102 lw_destroy_all_widgets (all_widget_info->id); | |
1103 } | |
1104 | |
1105 void | |
1106 lw_destroy_all_pop_ups () | |
1107 { | |
1108 widget_info* info; | |
1109 widget_info* next; | |
1110 widget_instance* instance; | |
1111 | |
1112 for (info = all_widget_info; info; info = next) | |
1113 { | |
1114 next = info->next; | |
1115 instance = info->instances; | |
1116 if (instance && instance->pop_up_p) | |
1117 lw_destroy_all_widgets (info->id); | |
1118 } | |
1119 } | |
1120 | |
1121 #ifdef USE_MOTIF | |
11861 | 1122 extern Widget first_child (/* Widget */); /* garbage */ |
5626 | 1123 #endif |
1124 | |
1125 Widget | |
1126 lw_raise_all_pop_up_widgets () | |
1127 { | |
1128 widget_info* info; | |
1129 widget_instance* instance; | |
1130 Widget result = NULL; | |
1131 | |
1132 for (info = all_widget_info; info; info = info->next) | |
1133 for (instance = info->instances; instance; instance = instance->next) | |
1134 if (instance->pop_up_p) | |
1135 { | |
1136 Widget widget = instance->widget; | |
1137 if (widget) | |
1138 { | |
1139 if (XtIsManaged (widget) | |
1140 #ifdef USE_MOTIF | |
1141 /* What a complete load of crap!!!! | |
1142 When a dialogShell is on the screen, it is not managed! | |
1143 */ | |
1144 || (lw_motif_widget_p (instance->widget) && | |
1145 XtIsManaged (first_child (widget))) | |
1146 #endif | |
1147 ) | |
1148 { | |
1149 if (!result) | |
1150 result = widget; | |
1151 XMapRaised (XtDisplay (widget), XtWindow (widget)); | |
1152 } | |
1153 } | |
1154 } | |
1155 return result; | |
1156 } | |
1157 | |
1158 static void | |
48480 | 1159 #ifdef PROTOTYPES |
1160 lw_pop_all_widgets (LWLIB_ID id, Boolean up) | |
1161 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1162 lw_pop_all_widgets (id, up) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1163 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1164 Boolean up; |
48480 | 1165 #endif |
5626 | 1166 { |
1167 widget_info* info = get_widget_info (id, False); | |
1168 widget_instance* instance; | |
1169 | |
1170 if (info) | |
1171 for (instance = info->instances; instance; instance = instance->next) | |
1172 if (instance->pop_up_p && instance->widget) | |
1173 { | |
1174 #if defined (USE_LUCID) | |
1175 if (lw_lucid_widget_p (instance->widget)) | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1176 { |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1177 XtRealizeWidget (instance->widget); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1178 xlw_pop_instance (instance, up); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1179 } |
5626 | 1180 #endif |
1181 #if defined (USE_MOTIF) | |
1182 if (lw_motif_widget_p (instance->widget)) | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1183 { |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1184 XtRealizeWidget (instance->widget); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1185 xm_pop_instance (instance, up); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1186 } |
5626 | 1187 #endif |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1188 #if defined (USE_XAW) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1189 if (lw_xaw_widget_p (instance->widget)) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1190 { |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1191 XtRealizeWidget (XtParent (instance->widget)); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1192 XtRealizeWidget (instance->widget); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1193 xaw_pop_instance (instance, up); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1194 } |
5626 | 1195 #endif |
1196 } | |
1197 } | |
1198 | |
1199 void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1200 lw_pop_up_all_widgets (id) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1201 LWLIB_ID id; |
5626 | 1202 { |
1203 lw_pop_all_widgets (id, True); | |
1204 } | |
1205 | |
1206 void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1207 lw_pop_down_all_widgets (id) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1208 LWLIB_ID id; |
5626 | 1209 { |
1210 lw_pop_all_widgets (id, False); | |
1211 } | |
1212 | |
1213 void | |
12744
0c5625e91a11
(lw_popup_menu): New arg event, passed along.
Richard M. Stallman <rms@gnu.org>
parents:
12187
diff
changeset
|
1214 lw_popup_menu (widget, event) |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1215 Widget widget; |
12744
0c5625e91a11
(lw_popup_menu): New arg event, passed along.
Richard M. Stallman <rms@gnu.org>
parents:
12187
diff
changeset
|
1216 XEvent *event; |
5626 | 1217 { |
1218 #if defined (USE_LUCID) | |
1219 if (lw_lucid_widget_p (widget)) | |
12744
0c5625e91a11
(lw_popup_menu): New arg event, passed along.
Richard M. Stallman <rms@gnu.org>
parents:
12187
diff
changeset
|
1220 xlw_popup_menu (widget, event); |
5626 | 1221 #endif |
1222 #if defined (USE_MOTIF) | |
1223 if (lw_motif_widget_p (widget)) | |
12744
0c5625e91a11
(lw_popup_menu): New arg event, passed along.
Richard M. Stallman <rms@gnu.org>
parents:
12187
diff
changeset
|
1224 xm_popup_menu (widget, event); |
5626 | 1225 #endif |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1226 #if defined (USE_XAW) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1227 if (lw_xaw_widget_p (widget)) |
12744
0c5625e91a11
(lw_popup_menu): New arg event, passed along.
Richard M. Stallman <rms@gnu.org>
parents:
12187
diff
changeset
|
1228 xaw_popup_menu (widget, event); |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1229 #endif |
5626 | 1230 } |
1231 | |
1232 /* get the values back */ | |
1233 static Boolean | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1234 get_one_value (instance, val) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1235 widget_instance* instance; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1236 widget_value* val; |
5626 | 1237 { |
1238 Widget widget = name_to_widget (instance, val->name); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
1239 |
5626 | 1240 if (widget) |
1241 { | |
1242 #if defined (USE_LUCID) | |
1243 if (lw_lucid_widget_p (instance->widget)) | |
1244 xlw_update_one_value (instance, widget, val); | |
1245 #endif | |
1246 #if defined (USE_MOTIF) | |
1247 if (lw_motif_widget_p (instance->widget)) | |
1248 xm_update_one_value (instance, widget, val); | |
1249 #endif | |
6305
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1250 #if defined (USE_XAW) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1251 if (lw_xaw_widget_p (instance->widget)) |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1252 xaw_update_one_value (instance, widget, val); |
65beaa9aa1e4
*** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5999
diff
changeset
|
1253 #endif |
5626 | 1254 return True; |
1255 } | |
1256 else | |
1257 return False; | |
1258 } | |
1259 | |
1260 Boolean | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1261 lw_get_some_values (id, val_out) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1262 LWLIB_ID id; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1263 widget_value* val_out; |
5626 | 1264 { |
1265 widget_info* info = get_widget_info (id, False); | |
1266 widget_instance* instance; | |
1267 widget_value* val; | |
1268 Boolean result = False; | |
1269 | |
1270 if (!info) | |
1271 return False; | |
1272 | |
1273 instance = info->instances; | |
1274 if (!instance) | |
1275 return False; | |
1276 | |
1277 for (val = val_out; val; val = val->next) | |
1278 if (get_one_value (instance, val)) | |
1279 result = True; | |
1280 | |
1281 return result; | |
1282 } | |
1283 | |
1284 widget_value* | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1285 lw_get_all_values (id) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1286 LWLIB_ID id; |
5626 | 1287 { |
1288 widget_info* info = get_widget_info (id, False); | |
1289 widget_value* val = info->val; | |
1290 if (lw_get_some_values (id, val)) | |
1291 return val; | |
1292 else | |
1293 return NULL; | |
1294 } | |
1295 | |
1296 /* internal function used by the library dependent implementation to get the | |
1297 widget_value for a given widget in an instance */ | |
1298 widget_value* | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1299 lw_get_widget_value_for_widget (instance, w) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1300 widget_instance* instance; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1301 Widget w; |
5626 | 1302 { |
1303 char* name = XtName (w); | |
1304 widget_value* cur; | |
1305 for (cur = instance->info->val; cur; cur = cur->next) | |
1306 if (!strcmp (cur->name, name)) | |
1307 return cur; | |
1308 return NULL; | |
1309 } | |
1310 | |
1311 /* update other instances value when one thing changed */ | |
14594
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1312 |
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1313 /* To forbid recursive calls */ |
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1314 static Boolean lwlib_updating; |
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1315 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
1316 /* This function can be used as a an XtCallback for the widgets that get |
5626 | 1317 modified to update other instances of the widgets. Closure should be the |
1318 widget_instance. */ | |
1319 void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1320 lw_internal_update_other_instances (widget, closure, call_data) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1321 Widget widget; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1322 XtPointer closure; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1323 XtPointer call_data; |
5626 | 1324 { |
1325 widget_instance* instance = (widget_instance*)closure; | |
1326 char* name = XtName (widget); | |
1327 widget_info* info; | |
1328 widget_instance* cur; | |
1329 widget_value* val; | |
1330 | |
14594
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1331 /* Avoid possibly infinite recursion. */ |
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1332 if (lwlib_updating) |
5626 | 1333 return; |
1334 | |
1335 /* protect against the widget being destroyed */ | |
1336 if (XtWidgetBeingDestroyedP (widget)) | |
1337 return; | |
1338 | |
1339 /* Return immediately if there are no other instances */ | |
1340 info = instance->info; | |
1341 if (!info->instances->next) | |
1342 return; | |
1343 | |
14594
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1344 lwlib_updating = True; |
5626 | 1345 |
1346 for (val = info->val; val && strcmp (val->name, name); val = val->next); | |
1347 | |
1348 if (val && get_one_value (instance, val)) | |
1349 for (cur = info->instances; cur; cur = cur->next) | |
1350 if (cur != instance) | |
1351 set_one_value (cur, val, True); | |
1352 | |
14594
37d38d8040a1
(lw_internal_update_other_instances): Move static var
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
1353 lwlib_updating = False; |
5626 | 1354 } |
1355 | |
1356 | |
1357 /* get the id */ | |
1358 | |
1359 LWLIB_ID | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1360 lw_get_widget_id (w) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1361 Widget w; |
5626 | 1362 { |
1363 widget_instance* instance = get_widget_instance (w, False); | |
1364 | |
1365 return instance ? instance->info->id : 0; | |
1366 } | |
1367 | |
1368 /* set the keyboard focus */ | |
1369 void | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1370 lw_set_keyboard_focus (parent, w) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1371 Widget parent; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1372 Widget w; |
5626 | 1373 { |
1374 #if defined (USE_MOTIF) | |
1375 xm_set_keyboard_focus (parent, w); | |
1376 #else | |
1377 XtSetKeyboardFocus (parent, w); | |
1378 #endif | |
1379 } | |
1380 | |
1381 /* Show busy */ | |
1382 static void | |
48480 | 1383 #ifdef PROTOTYPES |
1384 show_one_widget_busy (Widget w, Boolean flag) | |
1385 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1386 show_one_widget_busy (w, flag) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1387 Widget w; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1388 Boolean flag; |
48480 | 1389 #endif |
5626 | 1390 { |
1391 Pixel foreground = 0; | |
1392 Pixel background = 1; | |
1393 Widget widget_to_invert = XtNameToWidget (w, "*sheet"); | |
1394 if (!widget_to_invert) | |
1395 widget_to_invert = w; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
1396 |
5626 | 1397 XtVaGetValues (widget_to_invert, |
1398 XtNforeground, &foreground, | |
1399 XtNbackground, &background, | |
30571 | 1400 NULL); |
5626 | 1401 XtVaSetValues (widget_to_invert, |
1402 XtNforeground, background, | |
1403 XtNbackground, foreground, | |
30571 | 1404 NULL); |
5626 | 1405 } |
1406 | |
1407 void | |
48480 | 1408 #ifdef PROTOTYPES |
1409 lw_show_busy (Widget w, Boolean busy) | |
1410 #else | |
5724
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1411 lw_show_busy (w, busy) |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1412 Widget w; |
02a4aeb69cae
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5706
diff
changeset
|
1413 Boolean busy; |
48480 | 1414 #endif |
5626 | 1415 { |
1416 widget_instance* instance = get_widget_instance (w, False); | |
1417 widget_info* info; | |
1418 widget_instance* next; | |
1419 | |
1420 if (instance) | |
1421 { | |
1422 info = instance->info; | |
1423 if (info->busy != busy) | |
1424 { | |
1425 for (next = info->instances; next; next = next->next) | |
1426 if (next->widget) | |
1427 show_one_widget_busy (next->widget, busy); | |
1428 info->busy = busy; | |
1429 } | |
1430 } | |
1431 } | |
8785 | 1432 |
1433 /* This hack exists because Lucid/Athena need to execute the strange | |
1434 function below to support geometry management. */ | |
1435 void | |
48480 | 1436 #ifdef PROTOTYPES |
1437 lw_refigure_widget (Widget w, Boolean doit) | |
1438 #else | |
8785 | 1439 lw_refigure_widget (w, doit) |
1440 Widget w; | |
1441 Boolean doit; | |
48480 | 1442 #endif |
8785 | 1443 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48480
diff
changeset
|
1444 #if defined (USE_XAW) |
8785 | 1445 XawPanedSetRefigureMode (w, doit); |
1446 #endif | |
1447 #if defined (USE_MOTIF) | |
1448 if (doit) | |
11714
b62d02709ec7
(lw_refigure_widget) [USE_MOTIF]: Fix backward if.
Richard M. Stallman <rms@gnu.org>
parents:
11676
diff
changeset
|
1449 XtManageChild (w); |
8785 | 1450 else |
11714
b62d02709ec7
(lw_refigure_widget) [USE_MOTIF]: Fix backward if.
Richard M. Stallman <rms@gnu.org>
parents:
11676
diff
changeset
|
1451 XtUnmanageChild (w); |
8785 | 1452 #endif |
1453 } | |
1454 | |
1455 /* Toolkit independent way of determining if an event window is in the | |
1456 menubar. */ | |
1457 Boolean | |
1458 lw_window_is_in_menubar (win, menubar_widget) | |
1459 Window win; | |
1460 Widget menubar_widget; | |
1461 { | |
1462 return menubar_widget | |
1463 #if defined (USE_LUCID) | |
1464 && XtWindow (menubar_widget) == win; | |
1465 #endif | |
1466 #if defined (USE_MOTIF) | |
14663
d9cafe0ebb7d
(lw_window_is_in_menubar) [USE_MOTIF]:
Richard M. Stallman <rms@gnu.org>
parents:
14611
diff
changeset
|
1467 && ((XtWindow (menubar_widget) == win) |
d9cafe0ebb7d
(lw_window_is_in_menubar) [USE_MOTIF]:
Richard M. Stallman <rms@gnu.org>
parents:
14611
diff
changeset
|
1468 || (XtWindowToWidget (XtDisplay (menubar_widget), win) |
d9cafe0ebb7d
(lw_window_is_in_menubar) [USE_MOTIF]:
Richard M. Stallman <rms@gnu.org>
parents:
14611
diff
changeset
|
1469 && (XtParent (XtWindowToWidget (XtDisplay (menubar_widget), win)) |
d9cafe0ebb7d
(lw_window_is_in_menubar) [USE_MOTIF]:
Richard M. Stallman <rms@gnu.org>
parents:
14611
diff
changeset
|
1470 == menubar_widget))); |
8785 | 1471 #endif |
1472 } | |
1473 | |
1474 /* Motif hack to set the main window areas. */ | |
1475 void | |
1476 lw_set_main_areas (parent, menubar, work_area) | |
1477 Widget parent; | |
1478 Widget menubar; | |
1479 Widget work_area; | |
1480 { | |
1481 #if defined (USE_MOTIF) | |
9093
f8546f467db6
(lw_set_main_areas): Move call to XmMainSetAreas() to `lwlib-Xm.c'.
Paul Reilly <pmr@pajato.com>
parents:
8785
diff
changeset
|
1482 xm_set_main_areas (parent, menubar, work_area); |
8785 | 1483 #endif |
1484 } | |
1485 | |
1486 /* Manage resizing for Motif. This disables resizing when the menubar | |
1487 is about to be modified. */ | |
1488 void | |
48480 | 1489 #ifdef PROTOTYPES |
1490 lw_allow_resizing (Widget w, Boolean flag) | |
1491 #else | |
8785 | 1492 lw_allow_resizing (w, flag) |
1493 Widget w; | |
1494 Boolean flag; | |
48480 | 1495 #endif |
8785 | 1496 { |
1497 #if defined (USE_MOTIF) | |
9226
fc3f748ccf9e
(lw_set_main_areas): Use xm_set_main_areas().
Paul Reilly <pmr@pajato.com>
parents:
9093
diff
changeset
|
1498 xm_manage_resizing (w, flag); |
8785 | 1499 #endif |
1500 } | |
25036 | 1501 |
1502 | |
1503 /* Value is non-zero if LABEL is a menu separator. If it is, *TYPE is | |
1504 set to an appropriate enumerator of type enum menu_separator. | |
1505 MOTIF_P non-zero means map separator types not supported by Motif | |
1506 to similar ones that are supported. */ | |
1507 | |
1508 int | |
1509 lw_separator_p (label, type, motif_p) | |
1510 char *label; | |
1511 enum menu_separator *type; | |
1512 int motif_p; | |
1513 { | |
32040
02773dbde247
(lw_separator_p): Init separator_p (bug with "-- some text").
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30571
diff
changeset
|
1514 int separator_p = 0; |
25036 | 1515 |
1516 if (strlen (label) >= 3 | |
1517 && bcmp (label, "--:", 3) == 0) | |
1518 { | |
1519 static struct separator_table | |
1520 { | |
1521 char *name; | |
1522 enum menu_separator type; | |
1523 } | |
1524 separator_names[] = | |
1525 { | |
42120
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1526 {"space", SEPARATOR_NO_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1527 {"noLine", SEPARATOR_NO_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1528 {"singleLine", SEPARATOR_SINGLE_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1529 {"doubleLine", SEPARATOR_DOUBLE_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1530 {"singleDashedLine", SEPARATOR_SINGLE_DASHED_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1531 {"doubleDashedLine", SEPARATOR_DOUBLE_DASHED_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1532 {"shadowEtchedIn", SEPARATOR_SHADOW_ETCHED_IN}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1533 {"shadowEtchedOut", SEPARATOR_SHADOW_ETCHED_OUT}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1534 {"shadowEtchedInDash", SEPARATOR_SHADOW_ETCHED_IN_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1535 {"shadowEtchedOutDash", SEPARATOR_SHADOW_ETCHED_OUT_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1536 {"shadowDoubleEtchedIn", SEPARATOR_SHADOW_DOUBLE_ETCHED_IN}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1537 {"shadowDoubleEtchedOut", SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1538 {"shadowDoubleEtchedInDash", SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1539 {"shadowDoubleEtchedOutDash", SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1540 {0,0} |
25036 | 1541 }; |
1542 | |
1543 int i; | |
1544 | |
1545 label += 3; | |
1546 for (i = 0; separator_names[i].name; ++i) | |
1547 if (strcmp (label, separator_names[i].name) == 0) | |
1548 { | |
1549 separator_p = 1; | |
1550 *type = separator_names[i].type; | |
1551 | |
1552 /* If separator type is not supported under Motif, | |
1553 use a similar one. */ | |
1554 if (motif_p && *type >= SEPARATOR_SHADOW_DOUBLE_ETCHED_IN) | |
1555 *type -= 4; | |
1556 break; | |
1557 } | |
1558 } | |
25562
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1559 else if (strlen (label) > 3 |
25718
096f3085e905
(lw_separator_p): Check for new-style separators
Gerd Moellmann <gerd@gnu.org>
parents:
25627
diff
changeset
|
1560 && bcmp (label, "--", 2) == 0 |
096f3085e905
(lw_separator_p): Check for new-style separators
Gerd Moellmann <gerd@gnu.org>
parents:
25627
diff
changeset
|
1561 && label[2] != '-') |
25562
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1562 { |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1563 /* Alternative, more Emacs-style names. */ |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1564 static struct separator_table |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1565 { |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1566 char *name; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1567 enum menu_separator type; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1568 } |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1569 separator_names[] = |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1570 { |
42120
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1571 {"space", SEPARATOR_NO_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1572 {"no-line", SEPARATOR_NO_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1573 {"single-line", SEPARATOR_SINGLE_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1574 {"double-line", SEPARATOR_DOUBLE_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1575 {"single-dashed-line", SEPARATOR_SINGLE_DASHED_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1576 {"double-dashed-line", SEPARATOR_DOUBLE_DASHED_LINE}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1577 {"shadow-etched-in", SEPARATOR_SHADOW_ETCHED_IN}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1578 {"shadow-etched-out", SEPARATOR_SHADOW_ETCHED_OUT}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1579 {"shadow-etched-in-dash", SEPARATOR_SHADOW_ETCHED_IN_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1580 {"shadow-etched-out-dash", SEPARATOR_SHADOW_ETCHED_OUT_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1581 {"shadow-double-etched-in", SEPARATOR_SHADOW_DOUBLE_ETCHED_IN}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1582 {"shadow-double-etched-out", SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1583 {"shadow-double-etched-in-dash", SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1584 {"shadow-double-etched-out-dash",SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH}, |
87f989b9dad5
(separator_names): Add missing braces around initializers.
Pavel Janík <Pavel@Janik.cz>
parents:
41765
diff
changeset
|
1585 {0,0} |
25562
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1586 }; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1587 |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1588 int i; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1589 |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1590 label += 2; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1591 for (i = 0; separator_names[i].name; ++i) |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1592 if (strcmp (label, separator_names[i].name) == 0) |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1593 { |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1594 separator_p = 1; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1595 *type = separator_names[i].type; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1596 |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1597 /* If separator type is not supported under Motif, |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1598 use a similar one. */ |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1599 if (motif_p && *type >= SEPARATOR_SHADOW_DOUBLE_ETCHED_IN) |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1600 *type -= 4; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1601 break; |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1602 } |
374f4e51615c
(lw_separator_p): Add alternative separator type names.
Gerd Moellmann <gerd@gnu.org>
parents:
25036
diff
changeset
|
1603 } |
25036 | 1604 else |
1605 { | |
1606 /* Old-style separator, maybe. It's a separator if it contains | |
1607 only dashes. */ | |
1608 while (*label == '-') | |
1609 ++label; | |
1610 separator_p = *label == 0; | |
1611 *type = SEPARATOR_SHADOW_ETCHED_IN; | |
1612 } | |
1613 | |
1614 return separator_p; | |
1615 } | |
1616 | |
52401 | 1617 /* arch-tag: 3d730f36-a441-4a71-9971-48ef3b5a4d9f |
1618 (do not change this comment) */ |