comparison src/dialog-x.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 8626e4521993
children b8cc9ab3f761
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
42 { 42 {
43 /* !!#### This function has not been Mule-ized */ 43 /* !!#### This function has not been Mule-ized */
44 widget_value *wv; 44 widget_value *wv;
45 int got_some; 45 int got_some;
46 wv = xmalloc_widget_value (); 46 wv = xmalloc_widget_value ();
47 wv->name = (char *) "value"; 47 wv->name = xstrdup ("value");
48 got_some = lw_get_some_values (id, wv); 48 got_some = lw_get_some_values (id, wv);
49 if (got_some) 49 if (got_some)
50 { 50 {
51 Lisp_Object text_field_callback; 51 Lisp_Object text_field_callback;
52 char *text_field_value = wv->value; 52 char *text_field_value = wv->value;
54 if (text_field_value) 54 if (text_field_value)
55 { 55 {
56 void *tmp = LISP_TO_VOID (list2 (text_field_callback, 56 void *tmp = LISP_TO_VOID (list2 (text_field_callback,
57 build_string (text_field_value))); 57 build_string (text_field_value)));
58 popup_selection_callback (0, id, (XtPointer) tmp); 58 popup_selection_callback (0, id, (XtPointer) tmp);
59 xfree (text_field_value);
60 } 59 }
61 } 60 }
62 free_widget_value (wv); 61 /* This code tried to optimize, newing/freeing. This is generally
62 unsafe so we will alwats strdup and always use
63 free_widget_value_tree. */
64 free_widget_value_tree (wv);
63 } 65 }
64 66
65 static void 67 static void
66 dbox_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data) 68 dbox_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
67 { 69 {
98 if (f) 100 if (f)
99 #endif 101 #endif
100 lw_set_keyboard_focus (FRAME_X_SHELL_WIDGET (f), FRAME_X_TEXT_WIDGET (f)); 102 lw_set_keyboard_focus (FRAME_X_SHELL_WIDGET (f), FRAME_X_TEXT_WIDGET (f));
101 } 103 }
102 104
103 static CONST char * CONST button_names [] = { 105 static const char * const button_names [] = {
104 "button1", "button2", "button3", "button4", "button5", 106 "button1", "button2", "button3", "button4", "button5",
105 "button6", "button7", "button8", "button9", "button10" }; 107 "button6", "button7", "button8", "button9", "button10" };
106 108
107 /* can't have static frame locals because of some broken compilers */ 109 /* can't have static frame locals because of some broken compilers */
108 static char tmp_dbox_name [255]; 110 static char tmp_dbox_name [255];
118 int text_field_p = 0; 120 int text_field_p = 0;
119 int allow_text_p = 1; 121 int allow_text_p = 1;
120 widget_value *prev = 0, *kids = 0; 122 widget_value *prev = 0, *kids = 0;
121 int n = 0; 123 int n = 0;
122 int count = specpdl_depth (); 124 int count = specpdl_depth ();
123 Lisp_Object wv_closure; 125 Lisp_Object wv_closure, gui_item;
124 126
125 CHECK_CONS (desc); 127 CHECK_CONS (desc);
126 CHECK_STRING (XCAR (desc)); 128 CHECK_STRING (XCAR (desc));
127 name = (char *) XSTRING_DATA (LISP_GETTEXT (XCAR (desc))); 129 name = (char *) XSTRING_DATA (LISP_GETTEXT (XCAR (desc)));
128 desc = XCDR (desc); 130 desc = XCDR (desc);
142 /* Also make sure that we free the partially-created widget_value 144 /* Also make sure that we free the partially-created widget_value
143 tree on Lisp error. */ 145 tree on Lisp error. */
144 146
145 wv_closure = make_opaque_ptr (kids); 147 wv_closure = make_opaque_ptr (kids);
146 record_unwind_protect (widget_value_unwind, wv_closure); 148 record_unwind_protect (widget_value_unwind, wv_closure);
147 prev->name = (char *) "message"; 149 prev->name = xstrdup ("message");
148 prev->value = xstrdup (name); 150 prev->value = xstrdup (name);
149 prev->enabled = 1; 151 prev->enabled = 1;
150 152
151 for (; !NILP (desc); desc = Fcdr (desc)) 153 for (; !NILP (desc); desc = Fcdr (desc))
152 { 154 {
161 continue; 163 continue;
162 } 164 }
163 CHECK_VECTOR (button); 165 CHECK_VECTOR (button);
164 wv = xmalloc_widget_value (); 166 wv = xmalloc_widget_value ();
165 167
166 if (!button_item_to_widget_value (button, wv, allow_text_p, 1)) 168 gui_item = gui_parse_item_keywords (button);
167 { 169 if (!button_item_to_widget_value (gui_item, wv, allow_text_p, 1))
168 free_widget_value (wv); 170 {
171 free_widget_value_tree (wv);
169 continue; 172 continue;
170 } 173 }
171 174
172 if (wv->type == TEXT_TYPE) 175 if (wv->type == TEXT_TYPE)
173 { 176 {
175 allow_text_p = 0; /* only allow one */ 178 allow_text_p = 0; /* only allow one */
176 } 179 }
177 else /* it's a button */ 180 else /* it's a button */
178 { 181 {
179 allow_text_p = 0; /* only allow text field at the front */ 182 allow_text_p = 0; /* only allow text field at the front */
180 wv->value = xstrdup (wv->name); /* what a mess... */ 183 if (wv->value) xfree (wv->value);
181 wv->name = (char *) button_names [n]; 184 wv->value = wv->name; /* what a mess... */
185 wv->name = xstrdup (button_names [n]);
182 186
183 if (partition_seen) 187 if (partition_seen)
184 rbuttons++; 188 rbuttons++;
185 else 189 else
186 lbuttons++; 190 lbuttons++;
199 { 203 {
200 char type = (text_field_p ? 'P' : 'Q'); 204 char type = (text_field_p ? 'P' : 'Q');
201 widget_value *dbox; 205 widget_value *dbox;
202 sprintf (tmp_dbox_name, "%c%dBR%d", type, lbuttons + rbuttons, rbuttons); 206 sprintf (tmp_dbox_name, "%c%dBR%d", type, lbuttons + rbuttons, rbuttons);
203 dbox = xmalloc_widget_value (); 207 dbox = xmalloc_widget_value ();
204 dbox->name = tmp_dbox_name; 208 dbox->name = xstrdup (tmp_dbox_name);
205 dbox->contents = kids; 209 dbox->contents = kids;
206 210
207 /* No more need to free the half-filled-in structures. */ 211 /* No more need to free the half-filled-in structures. */
208 set_opaque_ptr (wv_closure, 0); 212 set_opaque_ptr (wv_closure, 0);
209 unbind_to (count, Qnil); 213 unbind_to (count, Qnil);