Mercurial > hg > xemacs-beta
comparison lwlib/lwlib.c @ 400:a86b2b5e0111 r21-2-30
Import from CVS: tag r21-2-30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:14:34 +0200 |
parents | 74fd4e045ea6 |
children | b8cc9ab3f761 |
comparison
equal
deleted
inserted
replaced
399:376370fb5946 | 400:a86b2b5e0111 |
---|---|
259 } | 259 } |
260 else if (new->args && old->args) | 260 else if (new->args && old->args) |
261 { | 261 { |
262 /* #### Do something more sensible here than just copying the | 262 /* #### Do something more sensible here than just copying the |
263 new values (like actually merging the values). */ | 263 new values (like actually merging the values). */ |
264 free_widget_value_args (old); | |
265 lw_copy_widget_value_args (new, old); | 264 lw_copy_widget_value_args (new, old); |
266 changed = True; | 265 changed = True; |
267 } | 266 } |
268 | 267 |
269 return changed; | 268 return changed; |
1363 } | 1362 } |
1364 } | 1363 } |
1365 | 1364 |
1366 void lw_add_widget_value_arg (widget_value* wv, String name, XtArgVal value) | 1365 void lw_add_widget_value_arg (widget_value* wv, String name, XtArgVal value) |
1367 { | 1366 { |
1367 int i = 0; | |
1368 if (!wv->args) | 1368 if (!wv->args) |
1369 { | 1369 { |
1370 wv->args = (widget_args *) malloc (sizeof (widget_args)); | 1370 wv->args = (widget_args *) malloc (sizeof (widget_args)); |
1371 memset (wv->args, '\0', sizeof (widget_args)); | 1371 memset (wv->args, '\0', sizeof (widget_args)); |
1372 wv->args->ref_count = 1; | 1372 wv->args->ref_count = 1; |
1376 } | 1376 } |
1377 | 1377 |
1378 if (wv->args->nargs > 10) | 1378 if (wv->args->nargs > 10) |
1379 return; | 1379 return; |
1380 | 1380 |
1381 XtSetArg (wv->args->args [wv->args->nargs], name, value); wv->args->nargs++; | 1381 /* If the arg is already there then we must replace it. */ |
1382 for (i = 0; i < wv->args->nargs; i++) | |
1383 { | |
1384 if (!strcmp (wv->args->args[i].name, name)) | |
1385 { | |
1386 XtSetArg (wv->args->args [i], name, value); | |
1387 break; | |
1388 } | |
1389 } | |
1390 if (i >= wv->args->nargs) | |
1391 { | |
1392 XtSetArg (wv->args->args [wv->args->nargs], name, value); wv->args->nargs++; | |
1393 } | |
1382 } | 1394 } |
1383 | 1395 |
1384 static void free_widget_value_args (widget_value* wv) | 1396 static void free_widget_value_args (widget_value* wv) |
1385 { | 1397 { |
1386 if (wv->args) | 1398 if (wv->args) |
1395 XmFontListFree ((XmFontList)wv->args->args[i].value); | 1407 XmFontListFree ((XmFontList)wv->args->args[i].value); |
1396 } | 1408 } |
1397 #endif | 1409 #endif |
1398 free (wv->args->args); | 1410 free (wv->args->args); |
1399 free (wv->args); | 1411 free (wv->args); |
1400 wv->args = (widget_args*)0xDEADBEEF; | 1412 wv->args = 0; |
1401 } | 1413 } |
1402 } | 1414 } |
1403 } | 1415 } |
1404 | 1416 |
1405 void lw_copy_widget_value_args (widget_value* val, widget_value* copy) | 1417 void lw_copy_widget_value_args (widget_value* val, widget_value* copy) |
1406 { | 1418 { |
1407 if (!val->args) | 1419 if (val == copy || val->args == copy->args) |
1408 { | 1420 return; |
1409 if (copy->args) | 1421 |
1410 free_widget_value_args (copy); | 1422 if (copy->args) |
1411 copy->args = 0; | 1423 { |
1412 } | 1424 free_widget_value_args (copy); |
1413 else | 1425 } |
1426 | |
1427 if (val->args) | |
1414 { | 1428 { |
1415 copy->args = val->args; | 1429 copy->args = val->args; |
1416 copy->args->ref_count++; | 1430 copy->args->ref_count++; |
1417 } | 1431 } |
1418 } | 1432 } |