comparison src/dialog-x.c @ 412:697ef44129c6 r21-2-14

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