00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030 #define DISABLE_DEBUGLOG
00031
00032
00033 #include "dialog_p.h"
00034 #include "widget_l.h"
00035 #include "gui_l.h"
00036
00037 #include <gwenhywfar/text.h>
00038 #include <gwenhywfar/pathmanager.h>
00039 #include <gwenhywfar/debug.h>
00040 #include <gwenhywfar/i18n.h>
00041
00042 #include <assert.h>
00043 #include <ctype.h>
00044
00045
00046 GWEN_INHERIT_FUNCTIONS(GWEN_DIALOG)
00047 GWEN_LIST_FUNCTIONS(GWEN_DIALOG, GWEN_Dialog)
00048 GWEN_LIST2_FUNCTIONS(GWEN_DIALOG, GWEN_Dialog)
00049
00050
00051
00052
00053 GWEN_DIALOG *GWEN_Dialog_new(const char *dialogId) {
00054 GWEN_DIALOG *dlg;
00055 int rv;
00056 GWEN_DB_NODE *db=NULL;
00057
00058 GWEN_NEW_OBJECT(GWEN_DIALOG, dlg);
00059 dlg->refCount=1;
00060 GWEN_INHERIT_INIT(GWEN_DIALOG, dlg);
00061 GWEN_LIST_INIT(GWEN_DIALOG, dlg);
00062
00063 if (dialogId && *dialogId)
00064 dlg->dialogId=strdup(dialogId);
00065
00066 dlg->i18nDomain=strdup(PACKAGE);
00067
00068 dlg->widgets=GWEN_Widget_Tree_new();
00069
00070 dlg->subDialogs=GWEN_Dialog_List_new();
00071
00072
00073 rv=GWEN_Gui_ReadDialogPrefs(dialogId, NULL, &db);
00074 if (rv<0) {
00075 DBG_WARN(GWEN_LOGDOMAIN, "Could not read dialog preferences (%d)", rv);
00076 dlg->dbPreferences=GWEN_DB_Group_new("preferences");
00077 }
00078 else {
00079 dlg->dbPreferences=db;
00080 }
00081 dlg->mediaPaths=GWEN_StringList_new();
00082
00083 return dlg;
00084 }
00085
00086
00087
00088 void GWEN_Dialog_free(GWEN_DIALOG *dlg) {
00089 if (dlg) {
00090 assert(dlg->refCount);
00091
00092 if (dlg->refCount>1) {
00093 dlg->refCount--;
00094 }
00095 else {
00096 int rv;
00097
00098
00099 rv=GWEN_Gui_WriteDialogPrefs(dlg->dialogId, dlg->dbPreferences);
00100 if (rv<0) {
00101 DBG_WARN(GWEN_LOGDOMAIN, "Could not write dialog preferences (%d)", rv);
00102 }
00103
00104 GWEN_INHERIT_FINI(GWEN_DIALOG, dlg);
00105 GWEN_LIST_FINI(GWEN_DIALOG, dlg);
00106 GWEN_Widget_Tree_free(dlg->widgets);
00107 free(dlg->dialogId);
00108 free(dlg->i18nDomain);
00109 dlg->refCount=0;
00110 GWEN_Dialog_List_free(dlg->subDialogs);
00111
00112 GWEN_DB_Group_free(dlg->dbPreferences);
00113 GWEN_StringList_free(dlg->mediaPaths);
00114
00115 GWEN_FREE_OBJECT(dlg);
00116 }
00117 }
00118 }
00119
00120
00121
00122 GWEN_DIALOG *GWEN_Dialog_GetParentDialog(const GWEN_DIALOG *dlg) {
00123 assert(dlg);
00124 assert(dlg->refCount);
00125
00126 return dlg->parentDialog;
00127 }
00128
00129
00130
00131 const char *GWEN_Dialog_GetId(const GWEN_DIALOG *dlg) {
00132 assert(dlg);
00133 assert(dlg->refCount);
00134
00135 return dlg->dialogId;
00136 }
00137
00138
00139
00140 uint32_t GWEN_Dialog_GetGuiId(const GWEN_DIALOG *dlg) {
00141 assert(dlg);
00142 assert(dlg->refCount);
00143
00144 return dlg->guiId;
00145 }
00146
00147
00148
00149 void GWEN_Dialog_SetGuiId(GWEN_DIALOG *dlg, uint32_t guiid) {
00150 assert(dlg);
00151 assert(dlg->refCount);
00152
00153 dlg->guiId=guiid;
00154 }
00155
00156
00157
00158 void GWEN_Dialog_SetI18nDomain(GWEN_DIALOG *dlg, const char *s) {
00159 assert(dlg);
00160 assert(dlg->refCount);
00161
00162 free(dlg->i18nDomain);
00163 if (s) dlg->i18nDomain=strdup(s);
00164 else dlg->i18nDomain=strdup(PACKAGE);
00165 }
00166
00167
00168
00169 const char *GWEN_Dialog_GetI18nDomain(const GWEN_DIALOG *dlg) {
00170 assert(dlg);
00171 assert(dlg->refCount);
00172
00173 return dlg->i18nDomain;
00174 }
00175
00176
00177
00178 const char *GWEN_Dialog_TranslateString(const GWEN_DIALOG *dlg, const char *s) {
00179 assert(dlg);
00180 assert(dlg->refCount);
00181
00182 return GWEN_I18N_Translate(dlg->i18nDomain, s);
00183 }
00184
00185
00186
00187 void GWEN_Dialog_AddMediaPath(GWEN_DIALOG *dlg, const char *s) {
00188 assert(dlg);
00189 assert(dlg->refCount);
00190
00191 GWEN_StringList_AppendString(dlg->mediaPaths, s, 0, 1);
00192 }
00193
00194
00195
00196 void GWEN_Dialog_AddMediaPathsFromPathManager(GWEN_DIALOG *dlg,
00197 const char *destlib,
00198 const char *pathName,
00199 const char *relPath) {
00200 GWEN_STRINGLIST *sl;
00201
00202 sl=GWEN_PathManager_GetPaths(destlib, pathName);
00203 if (sl) {
00204 GWEN_STRINGLISTENTRY *se;
00205 se=GWEN_StringList_FirstEntry(sl);
00206 if (se) {
00207 GWEN_BUFFER *tbuf;
00208
00209 tbuf=GWEN_Buffer_new(0, 256, 0, 1);
00210 while(se) {
00211 const char *s;
00212
00213 s=GWEN_StringListEntry_Data(se);
00214 assert(s);
00215 if (relPath) {
00216 GWEN_Buffer_AppendString(tbuf, s);
00217 GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S);
00218 GWEN_Buffer_AppendString(tbuf, relPath);
00219 GWEN_StringList_AppendString(dlg->mediaPaths, GWEN_Buffer_GetStart(tbuf), 0, 1);
00220 GWEN_Buffer_Reset(tbuf);
00221 }
00222 else
00223 GWEN_StringList_AppendString(dlg->mediaPaths, s, 0, 1);
00224 se=GWEN_StringListEntry_Next(se);
00225 }
00226 GWEN_Buffer_free(tbuf);
00227 }
00228 GWEN_StringList_free(sl);
00229 }
00230 }
00231
00232
00233
00234 GWEN_STRINGLIST *GWEN_Dialog_GetMediaPaths(const GWEN_DIALOG *dlg) {
00235 assert(dlg);
00236 assert(dlg->refCount);
00237
00238 return dlg->mediaPaths;
00239 }
00240
00241
00242
00243 GWEN_DIALOG_SIGNALHANDLER GWEN_Dialog_SetSignalHandler(GWEN_DIALOG *dlg,
00244 GWEN_DIALOG_SIGNALHANDLER fn) {
00245 GWEN_DIALOG_SIGNALHANDLER oh;
00246
00247 assert(dlg);
00248 assert(dlg->refCount);
00249
00250 oh=dlg->signalHandler;
00251 dlg->signalHandler=fn;
00252
00253 return oh;
00254 }
00255
00256
00257
00258 int GWEN_Dialog_EmitSignal(GWEN_DIALOG *dlg,
00259 GWEN_DIALOG_EVENTTYPE t,
00260 const char *sender) {
00261 assert(dlg);
00262 assert(dlg->refCount);
00263
00264 if (dlg->signalHandler)
00265 return (dlg->signalHandler)(dlg, t, sender);
00266 else {
00267 DBG_WARN(GWEN_LOGDOMAIN, "No signal handler in dialog [%s]",
00268 (dlg->dialogId)?(dlg->dialogId):"-unnamed-");
00269 return GWEN_DialogEvent_ResultNotHandled;
00270 }
00271 }
00272
00273
00274
00275 int GWEN_Dialog_EmitSignalToAll(GWEN_DIALOG *dlg,
00276 GWEN_DIALOG_EVENTTYPE t,
00277 const char *sender) {
00278 int rv;
00279 GWEN_DIALOG *subdlg;
00280
00281 assert(dlg);
00282 assert(dlg->refCount);
00283
00284 subdlg=GWEN_Dialog_List_First(dlg->subDialogs);
00285 while(subdlg) {
00286 rv=GWEN_Dialog_EmitSignalToAll(subdlg, t, sender);
00287 if (rv!=GWEN_DialogEvent_ResultHandled &&
00288 rv!=GWEN_DialogEvent_ResultNotHandled)
00289 return rv;
00290 subdlg=GWEN_Dialog_List_Next(subdlg);
00291 }
00292
00293 if (dlg->signalHandler) {
00294 rv=(dlg->signalHandler)(dlg, t, sender);
00295 if (rv!=GWEN_DialogEvent_ResultHandled &&
00296 rv!=GWEN_DialogEvent_ResultNotHandled)
00297 return rv;
00298 }
00299
00300 return GWEN_DialogEvent_ResultHandled;
00301 }
00302
00303
00304
00305 int GWEN_Dialog_AddSubDialog(GWEN_DIALOG *dlg,
00306 const char *parentName,
00307 GWEN_DIALOG *subdlg) {
00308 GWEN_WIDGET *wparent;
00309
00310 wparent=GWEN_Dialog_FindWidgetByName(dlg, parentName);
00311 if (wparent) {
00312 GWEN_WIDGET *subRoot;
00313 GWEN_WIDGET *cw;
00314
00315
00316 subRoot=GWEN_Widget_Tree_GetFirst(subdlg->widgets);
00317 if (subRoot) {
00318 while( (cw=GWEN_Widget_Tree_GetFirstChild(subRoot)) ) {
00319 if (subdlg->firstSubWidget==NULL)
00320 subdlg->firstSubWidget=cw;
00321 GWEN_Widget_Tree_Del(cw);
00322 GWEN_Widget_Tree_AddChild(wparent, cw);
00323 }
00324 }
00325
00326
00327 subdlg->parentWidget=wparent;
00328
00329
00330 subdlg->parentDialog=dlg;
00331
00332 GWEN_Dialog_List_Add(subdlg, dlg->subDialogs);
00333
00334 return 0;
00335 }
00336 else {
00337 DBG_ERROR(GWEN_LOGDOMAIN, "Parent widget [%s] not found", parentName);
00338 return GWEN_ERROR_NOT_FOUND;
00339 }
00340 }
00341
00342
00343
00344 int GWEN_Dialog__ReadXmlWidget(GWEN_DIALOG *dlg,
00345 GWEN_WIDGET *wparent,
00346 GWEN_XMLNODE *node) {
00347 GWEN_XMLNODE *n;
00348 GWEN_WIDGET *w;
00349 int rv;
00350
00351 w=GWEN_Widget_new(dlg);
00352 rv=GWEN_Widget_ReadXml(w, node);
00353 if (rv<0) {
00354 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
00355 GWEN_Widget_free(w);
00356 return rv;
00357 }
00358
00359 if (wparent)
00360 GWEN_Widget_Tree_AddChild(wparent, w);
00361 else
00362 GWEN_Widget_Tree_Add(dlg->widgets, w);
00363
00364
00365 n=GWEN_XMLNode_FindFirstTag(node, "widget", NULL, NULL);
00366 while(n) {
00367 int rv;
00368
00369 rv=GWEN_Dialog__ReadXmlWidget(dlg, w, n);
00370 if (rv<0)
00371 return rv;
00372 n=GWEN_XMLNode_FindNextTag(n, "widget", NULL, NULL);
00373 }
00374
00375 return 0;
00376 }
00377
00378
00379
00380 int GWEN_Dialog_ReadXml(GWEN_DIALOG *dlg, GWEN_XMLNODE *node) {
00381 int rv;
00382 const char *s;
00383
00384 assert(dlg);
00385 assert(dlg->refCount);
00386
00387 assert(dlg->widgets);
00388 GWEN_Widget_Tree_Clear(dlg->widgets);
00389
00390 s=GWEN_XMLNode_GetProperty(node, "i18n", NULL);
00391 if (s && *s)
00392 GWEN_Dialog_SetI18nDomain(dlg, s);
00393
00394 rv=GWEN_Dialog__ReadXmlWidget(dlg, NULL, node);
00395 if (rv<0) {
00396 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
00397 GWEN_Widget_Tree_free(dlg->widgets);
00398 dlg->widgets=NULL;
00399 return rv;
00400 }
00401
00402 return 0;
00403 }
00404
00405
00406
00407 int GWEN_Dialog_ReadXmlFile(GWEN_DIALOG *dlg, const char *fname) {
00408 GWEN_XMLNODE *n;
00409 GWEN_XMLNODE *nDialog;
00410 int rv;
00411
00412 n=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "root");
00413 rv=GWEN_XML_ReadFile(n, fname,
00414 GWEN_XML_FLAGS_DEFAULT |
00415 GWEN_XML_FLAGS_HANDLE_HEADERS);
00416 if (rv<0) {
00417 DBG_ERROR(GWEN_LOGDOMAIN, "here (%d)", rv);
00418 GWEN_XMLNode_free(n);
00419 return rv;
00420 }
00421
00422 nDialog=GWEN_XMLNode_FindFirstTag(n, "dialog", NULL, NULL);
00423 if (nDialog==NULL) {
00424 DBG_ERROR(GWEN_LOGDOMAIN, "Dialog element not found in XML file [%s]", fname);
00425 GWEN_XMLNode_free(n);
00426 return rv;
00427 }
00428
00429 rv=GWEN_Dialog_ReadXml(dlg, nDialog);
00430 if (rv<0) {
00431 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
00432 GWEN_XMLNode_free(n);
00433 return rv;
00434 }
00435
00436 GWEN_XMLNode_free(n);
00437 return 0;
00438 }
00439
00440
00441
00442 GWEN_WIDGET *GWEN_Dialog_FindWidgetByName(const GWEN_DIALOG *dlg, const char *name) {
00443 GWEN_WIDGET *w;
00444
00445 assert(dlg);
00446 assert(dlg->refCount);
00447 assert(dlg->widgets);
00448
00449 #if 0
00450 if (dlg->parentWidget)
00451 w=dlg->parentWidget;
00452 else
00453 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
00454 #else
00455 if (dlg->firstSubWidget)
00456 w=dlg->firstSubWidget;
00457 else {
00458 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
00459
00460 if (name==NULL || *name==0)
00461 return w;
00462 }
00463 #endif
00464
00465 while(w) {
00466 const char *s;
00467
00468 s=GWEN_Widget_GetName(w);
00469 if (s && *s && strcasecmp(s, name)==0)
00470 break;
00471 w=GWEN_Widget_Tree_GetBelow(w);
00472 }
00473
00474 return w;
00475 }
00476
00477
00478
00479 GWEN_WIDGET *GWEN_Dialog_FindWidgetByImplData(const GWEN_DIALOG *dlg, int index, const void *ptr) {
00480 GWEN_WIDGET *w;
00481
00482 assert(dlg);
00483 assert(dlg->refCount);
00484 assert(dlg->widgets);
00485
00486 if (dlg->parentWidget)
00487 w=dlg->parentWidget;
00488 else
00489 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
00490
00491 while(w) {
00492 if (ptr==GWEN_Widget_GetImplData(w, index))
00493 break;
00494 w=GWEN_Widget_Tree_GetBelow(w);
00495 }
00496
00497 return w;
00498 }
00499
00500
00501
00502 GWEN_WIDGET_TREE *GWEN_Dialog_GetWidgets(const GWEN_DIALOG *dlg) {
00503 assert(dlg);
00504 assert(dlg->refCount);
00505 assert(dlg->widgets);
00506
00507 return dlg->widgets;
00508 }
00509
00510
00511
00512 GWEN_DIALOG_SETINTPROPERTY_FN GWEN_Dialog_SetSetIntPropertyFn(GWEN_DIALOG *dlg,
00513 GWEN_DIALOG_SETINTPROPERTY_FN fn) {
00514 GWEN_DIALOG_SETINTPROPERTY_FN oh;
00515
00516 assert(dlg);
00517 assert(dlg->refCount);
00518
00519 oh=dlg->setIntPropertyFn;
00520 dlg->setIntPropertyFn=fn;
00521 return oh;
00522 }
00523
00524
00525
00526 GWEN_DIALOG_GETINTPROPERTY_FN GWEN_Dialog_SetGetIntPropertyFn(GWEN_DIALOG *dlg,
00527 GWEN_DIALOG_GETINTPROPERTY_FN fn) {
00528 GWEN_DIALOG_GETINTPROPERTY_FN oh;
00529
00530 assert(dlg);
00531 assert(dlg->refCount);
00532
00533 oh=dlg->getIntPropertyFn;
00534 dlg->getIntPropertyFn=fn;
00535 return oh;
00536 }
00537
00538
00539
00540 GWEN_DIALOG_SETCHARPROPERTY_FN GWEN_Dialog_SetSetCharPropertyFn(GWEN_DIALOG *dlg,
00541 GWEN_DIALOG_SETCHARPROPERTY_FN fn) {
00542 GWEN_DIALOG_SETCHARPROPERTY_FN oh;
00543
00544 assert(dlg);
00545 assert(dlg->refCount);
00546
00547 oh=dlg->setCharPropertyFn;
00548 dlg->setCharPropertyFn=fn;
00549 return oh;
00550 }
00551
00552
00553
00554 GWEN_DIALOG_GETCHARPROPERTY_FN GWEN_Dialog_SetGetCharPropertyFn(GWEN_DIALOG *dlg,
00555 GWEN_DIALOG_GETCHARPROPERTY_FN fn) {
00556 GWEN_DIALOG_GETCHARPROPERTY_FN oh;
00557
00558 assert(dlg);
00559 assert(dlg->refCount);
00560
00561 oh=dlg->getCharPropertyFn;
00562 dlg->getCharPropertyFn=fn;
00563 return oh;
00564 }
00565
00566
00567
00568
00569
00570
00571 int GWEN_Dialog_SetIntProperty(GWEN_DIALOG *dlg,
00572 const char *name,
00573 GWEN_DIALOG_PROPERTY prop,
00574 int index,
00575 int value,
00576 int doSignal) {
00577 GWEN_WIDGET *w;
00578
00579 assert(dlg);
00580 assert(dlg->refCount);
00581
00582 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00583 if (w) {
00584 if (dlg->setIntPropertyFn)
00585 return dlg->setIntPropertyFn(dlg, w, prop, index, value, doSignal);
00586 else if (dlg->parentDialog && dlg->parentDialog->setIntPropertyFn)
00587 return dlg->parentDialog->setIntPropertyFn(dlg->parentDialog, w, prop, index, value, doSignal);
00588 }
00589 else {
00590 DBG_ERROR(GWEN_LOGDOMAIN, "Widget [%s] not found", name);
00591 return GWEN_ERROR_NOT_FOUND;
00592 }
00593
00594 DBG_ERROR(GWEN_LOGDOMAIN, "Function pointer not set");
00595 return GWEN_ERROR_NOT_IMPLEMENTED;
00596 }
00597
00598
00599
00600 int GWEN_Dialog_GetIntProperty(GWEN_DIALOG *dlg,
00601 const char *name,
00602 GWEN_DIALOG_PROPERTY prop,
00603 int index,
00604 int defaultProperty) {
00605 GWEN_WIDGET *w;
00606
00607 assert(dlg);
00608 assert(dlg->refCount);
00609
00610 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00611 if (w) {
00612 if (dlg->getIntPropertyFn)
00613 return dlg->getIntPropertyFn(dlg, w, prop, index, defaultProperty);
00614 else if (dlg->parentDialog && dlg->parentDialog->getIntPropertyFn)
00615 return dlg->parentDialog->getIntPropertyFn(dlg->parentDialog, w, prop, index, defaultProperty);
00616 }
00617 else {
00618 DBG_ERROR(GWEN_LOGDOMAIN, "Widget [%s] not found", name);
00619 return defaultProperty;
00620 }
00621
00622 DBG_ERROR(GWEN_LOGDOMAIN, "Function pointer not set");
00623 return defaultProperty;
00624 }
00625
00626
00627
00628 int GWEN_Dialog_SetCharProperty(GWEN_DIALOG *dlg,
00629 const char *name,
00630 GWEN_DIALOG_PROPERTY prop,
00631 int index,
00632 const char *value,
00633 int doSignal) {
00634 GWEN_WIDGET *w;
00635
00636 assert(dlg);
00637 assert(dlg->refCount);
00638
00639 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00640 if (w) {
00641 if (dlg->setCharPropertyFn)
00642 return dlg->setCharPropertyFn(dlg, w, prop, index, value, doSignal);
00643 else if (dlg->parentDialog && dlg->parentDialog->setCharPropertyFn)
00644 return dlg->parentDialog->setCharPropertyFn(dlg->parentDialog, w, prop, index, value, doSignal);
00645 }
00646 else {
00647 DBG_ERROR(GWEN_LOGDOMAIN, "Widget [%s] not found", name);
00648 return GWEN_ERROR_NOT_FOUND;
00649 }
00650
00651 DBG_ERROR(GWEN_LOGDOMAIN, "Function pointer not set");
00652 return GWEN_ERROR_NOT_IMPLEMENTED;
00653 }
00654
00655
00656
00657 const char *GWEN_Dialog_GetCharProperty(GWEN_DIALOG *dlg,
00658 const char *name,
00659 GWEN_DIALOG_PROPERTY prop,
00660 int index,
00661 const char *defaultProperty) {
00662 GWEN_WIDGET *w;
00663
00664 assert(dlg);
00665 assert(dlg->refCount);
00666
00667 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00668 if (w) {
00669 if (dlg->getCharPropertyFn)
00670 return dlg->getCharPropertyFn(dlg, w, prop, index, defaultProperty);
00671 else if (dlg->parentDialog && dlg->parentDialog->getCharPropertyFn)
00672 return dlg->parentDialog->getCharPropertyFn(dlg->parentDialog, w, prop, index, defaultProperty);
00673 }
00674 else {
00675 DBG_ERROR(GWEN_LOGDOMAIN, "Widget [%s] not found", name);
00676 return defaultProperty;
00677 }
00678
00679 DBG_ERROR(GWEN_LOGDOMAIN, "Function pointer not set");
00680 return defaultProperty;
00681 }
00682
00683
00684
00685 int GWEN_Dialog_RemoveWidget(GWEN_DIALOG *dlg, const char *name) {
00686 GWEN_WIDGET *w;
00687
00688 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00689 if (w) {
00690 GWEN_Widget_Tree_Del(w);
00691 GWEN_Widget_free(w);
00692 return 0;
00693 }
00694
00695 return GWEN_ERROR_NOT_FOUND;
00696 }
00697
00698
00699 uint32_t GWEN_Dialog_GetWidgetFlags(const GWEN_DIALOG *dlg, const char *name) {
00700 GWEN_WIDGET *w;
00701
00702 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00703 if (w) {
00704 return GWEN_Widget_GetFlags(w);
00705 }
00706
00707 return 0;
00708 }
00709
00710
00711
00712 void GWEN_Dialog_SetWidgetFlags(GWEN_DIALOG *dlg, const char *name, uint32_t fl) {
00713 GWEN_WIDGET *w;
00714
00715 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00716 if (w) {
00717 GWEN_Widget_SetFlags(w, fl);
00718 }
00719 }
00720
00721
00722
00723 void GWEN_Dialog_AddWidgetFlags(GWEN_DIALOG *dlg, const char *name, uint32_t fl) {
00724 GWEN_WIDGET *w;
00725
00726 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00727 if (w) {
00728 GWEN_Widget_AddFlags(w, fl);
00729 }
00730 }
00731
00732
00733
00734 void GWEN_Dialog_SubWidgetFlags(GWEN_DIALOG *dlg, const char *name, uint32_t fl) {
00735 GWEN_WIDGET *w;
00736
00737 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00738 if (w) {
00739 GWEN_Widget_SubFlags(w, fl);
00740 }
00741 }
00742
00743
00744
00745 int GWEN_Dialog_GetWidgetColumns(const GWEN_DIALOG *dlg, const char *name) {
00746 GWEN_WIDGET *w;
00747
00748 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00749 if (w) {
00750 return GWEN_Widget_GetColumns(w);
00751 }
00752
00753 return -1;
00754 }
00755
00756
00757
00758 void GWEN_Dialog_SetWidgetColumns(GWEN_DIALOG *dlg, const char *name, int i) {
00759 GWEN_WIDGET *w;
00760
00761 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00762 if (w) {
00763 GWEN_Widget_SetColumns(w, i);
00764 }
00765 }
00766
00767
00768
00769 int GWEN_Dialog_GetWidgetRows(const GWEN_DIALOG *dlg, const char *name) {
00770 GWEN_WIDGET *w;
00771
00772 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00773 if (w) {
00774 return GWEN_Widget_GetRows(w);
00775 }
00776
00777 return -1;
00778 }
00779
00780
00781
00782 void GWEN_Dialog_SetWidgetRows(GWEN_DIALOG *dlg, const char *name, int i) {
00783 GWEN_WIDGET *w;
00784
00785 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00786 if (w) {
00787 GWEN_Widget_SetRows(w, i);
00788 }
00789 }
00790
00791
00792
00793 void GWEN_Dialog_SetWidgetText(GWEN_DIALOG *dlg, const char *name, const char *t) {
00794 GWEN_WIDGET *w;
00795
00796 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00797 if (w) {
00798 GWEN_Widget_SetText(w, 0, t);
00799 }
00800 }
00801
00802
00803
00804 const char *GWEN_Dialog_GetWidgetText(const GWEN_DIALOG *dlg, const char *name) {
00805 GWEN_WIDGET *w;
00806
00807 w=GWEN_Dialog_FindWidgetByName(dlg, name);
00808 if (w) {
00809 return GWEN_Widget_GetText(w, 0);
00810 }
00811
00812 return NULL;
00813 }
00814
00815
00816
00817 static void GWEN_Dialog_DumpWidget(const GWEN_WIDGET *w, FILE *f, unsigned int indent) {
00818 int i;
00819 const char *s;
00820 const char *dname=NULL;
00821 GWEN_DIALOG *dlg;
00822 const GWEN_WIDGET *c;
00823
00824 for (i=0; i<indent; i++)
00825 fprintf(f, " ");
00826 s=GWEN_Widget_GetName(w);
00827 dlg=GWEN_Widget_GetDialog(w);
00828 if (dlg)
00829 dname=GWEN_Dialog_GetId(dlg);
00830
00831 fprintf(f, "Widget %s: %d [%s]\n", s?s:"unnamed", GWEN_Widget_GetType(w), dname?dname:"no dialog");
00832 c=GWEN_Widget_Tree_GetFirstChild(w);
00833 while(c) {
00834 GWEN_Dialog_DumpWidget(c, f, indent+2);
00835 c=GWEN_Widget_Tree_GetNext(c);
00836 }
00837 }
00838
00839
00840
00841 void GWEN_Dialog_Dump(const GWEN_DIALOG *dlg, FILE *f, unsigned int indent) {
00842 GWEN_WIDGET *w;
00843
00844 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
00845 GWEN_Dialog_DumpWidget(w, f, indent);
00846 }
00847
00848
00849
00850
00851
00852
00853 GWEN_DB_NODE *GWEN_Dialog_GetPreferences(const GWEN_DIALOG *dlg) {
00854 assert(dlg);
00855 assert(dlg->refCount);
00856
00857 return dlg->dbPreferences;
00858 }
00859
00860
00861
00862