30 #define DISABLE_DEBUGLOG 37 #include <gwenhywfar/text.h> 38 #include <gwenhywfar/pathmanager.h> 39 #include <gwenhywfar/debug.h> 40 #include <gwenhywfar/i18n.h> 64 if (dialogId && *dialogId)
65 dlg->dialogId=strdup(dialogId);
67 dlg->i18nDomain=strdup(PACKAGE);
69 dlg->widgets=GWEN_Widget_Tree_new();
80 dlg->dbPreferences=db;
90 const char *pmLibName,
91 const char *pmDataDir,
139 assert(dlg->refCount);
141 if (dlg->refCount>1) {
155 GWEN_Widget_Tree_free(dlg->widgets);
157 free(dlg->i18nDomain);
174 assert(dlg->refCount);
176 return dlg->parentDialog;
184 assert(dlg->refCount);
186 return dlg->dialogId;
194 assert(dlg->refCount);
204 assert(dlg->refCount);
214 assert(dlg->refCount);
216 free(dlg->i18nDomain);
218 dlg->i18nDomain=strdup(s);
220 dlg->i18nDomain=strdup(PACKAGE);
228 assert(dlg->refCount);
230 return dlg->i18nDomain;
238 assert(dlg->refCount);
248 assert(dlg->refCount);
257 const char *pathName,
297 assert(dlg->refCount);
299 return dlg->mediaPaths;
310 assert(dlg->refCount);
312 oh=dlg->signalHandler;
313 dlg->signalHandler=fn;
325 assert(dlg->refCount);
327 if (dlg->signalHandler)
328 return (dlg->signalHandler)(dlg, t, sender);
331 (dlg->dialogId)?(dlg->dialogId):
"-unnamed-");
346 assert(dlg->refCount);
357 if (dlg->signalHandler) {
358 rv=(dlg->signalHandler)(dlg, t, sender);
370 const char *parentName,
381 subRoot=GWEN_Widget_Tree_GetFirst(subdlg->widgets);
383 while ((cw=GWEN_Widget_Tree_GetFirstChild(subRoot))) {
384 if (subdlg->firstSubWidget==
NULL)
385 subdlg->firstSubWidget=cw;
386 GWEN_Widget_Tree_Del(cw);
387 GWEN_Widget_Tree_AddChild(wparent, cw);
392 subdlg->parentWidget=wparent;
395 subdlg->parentDialog=dlg;
426 GWEN_Widget_Tree_AddChild(wparent, w);
428 GWEN_Widget_Tree_Add(dlg->widgets, w);
452 assert(dlg->refCount);
454 assert(dlg->widgets);
455 GWEN_Widget_Tree_Clear(dlg->widgets);
464 GWEN_Widget_Tree_free(dlg->widgets);
515 assert(dlg->refCount);
516 assert(dlg->widgets);
519 if (dlg->parentWidget)
522 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
524 if (dlg->firstSubWidget)
525 w=dlg->firstSubWidget;
527 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
529 if (name==
NULL || *name==0)
538 if (s && *s && strcasecmp(s, name)==0)
540 w=GWEN_Widget_Tree_GetBelow(w);
553 assert(dlg->refCount);
554 assert(dlg->widgets);
556 if (dlg->parentWidget)
559 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
564 w=GWEN_Widget_Tree_GetBelow(w);
575 assert(dlg->refCount);
576 assert(dlg->widgets);
589 assert(dlg->refCount);
591 oh=dlg->setIntPropertyFn;
592 dlg->setIntPropertyFn=fn;
604 assert(dlg->refCount);
606 oh=dlg->getIntPropertyFn;
607 dlg->getIntPropertyFn=fn;
619 assert(dlg->refCount);
621 oh=dlg->setCharPropertyFn;
622 dlg->setCharPropertyFn=fn;
634 assert(dlg->refCount);
636 oh=dlg->getCharPropertyFn;
637 dlg->getCharPropertyFn=fn;
656 assert(dlg->refCount);
660 if (dlg->setIntPropertyFn)
661 return dlg->setIntPropertyFn(dlg, w, prop, index, value, doSignal);
662 else if (dlg->parentDialog && dlg->parentDialog->setIntPropertyFn)
663 return dlg->parentDialog->setIntPropertyFn(dlg->parentDialog, w, prop, index, value, doSignal);
685 assert(dlg->refCount);
689 if (dlg->getIntPropertyFn)
690 return dlg->getIntPropertyFn(dlg, w, prop, index, defaultProperty);
691 else if (dlg->parentDialog && dlg->parentDialog->getIntPropertyFn)
692 return dlg->parentDialog->getIntPropertyFn(dlg->parentDialog, w, prop, index, defaultProperty);
696 return defaultProperty;
700 return defaultProperty;
715 assert(dlg->refCount);
719 if (dlg->setCharPropertyFn)
720 return dlg->setCharPropertyFn(dlg, w, prop, index, value, doSignal);
721 else if (dlg->parentDialog && dlg->parentDialog->setCharPropertyFn)
722 return dlg->parentDialog->setCharPropertyFn(dlg->parentDialog, w, prop, index, value, doSignal);
739 const char *defaultProperty)
744 assert(dlg->refCount);
748 if (dlg->getCharPropertyFn)
749 return dlg->getCharPropertyFn(dlg, w, prop, index, defaultProperty);
750 else if (dlg->parentDialog && dlg->parentDialog->getCharPropertyFn)
751 return dlg->parentDialog->getCharPropertyFn(dlg->parentDialog, w, prop, index, defaultProperty);
755 return defaultProperty;
759 return defaultProperty;
770 GWEN_Widget_Tree_Del(w);
911 const char *dname=
NULL;
915 for (i=0; i<indent; i++)
922 fprintf(f,
"Widget %s: %d [%s]\n", s?s:
"unnamed",
GWEN_Widget_GetType(w), dname?dname:
"no dialog");
923 c=GWEN_Widget_Tree_GetFirstChild(w);
926 c=GWEN_Widget_Tree_GetNext(c);
936 w=GWEN_Widget_Tree_GetFirst(dlg->widgets);
948 assert(dlg->refCount);
950 return dlg->dbPreferences;
void GWEN_Dialog_SetWidgetColumns(GWEN_DIALOG *dlg, const char *name, int i)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
struct GWEN_STRINGLISTENTRYSTRUCT GWEN_STRINGLISTENTRY
struct GWEN_DB_NODE GWEN_DB_NODE
#define GWEN_INHERIT_FINI(t, element)
#define GWEN_XML_FLAGS_DEFAULT
void GWEN_DB_Group_free(GWEN_DB_NODE *n)
GWEN_DIALOG * GWEN_Dialog_List_Next(const GWEN_DIALOG *element)
#define GWEN_DIR_SEPARATOR_S
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
GWEN_XMLNODE * GWEN_XMLNode_FindNextTag(const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue)
static void GWEN_Dialog_DumpWidget(const GWEN_WIDGET *w, FILE *f, unsigned int indent)
GWEN_WIDGET_TREE * GWEN_Dialog_GetWidgets(const GWEN_DIALOG *dlg)
GWEN_DIALOG_SETINTPROPERTY_FN GWEN_Dialog_SetSetIntPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_SETINTPROPERTY_FN fn)
GWEN_DIALOG * GWEN_Dialog_List_First(const GWEN_DIALOG_LIST *l)
#define GWEN_FREE_OBJECT(varname)
int GWEN_Dialog_RemoveWidget(GWEN_DIALOG *dlg, const char *name)
int GWEN_Gui_WriteDialogPrefs(const char *groupName, GWEN_DB_NODE *db)
GWENHYWFAR_API int GWEN_XML_ReadFile(GWEN_XMLNODE *n, const char *filepath, uint32_t flags)
void GWEN_Dialog_AddWidgetFlags(GWEN_DIALOG *dlg, const char *name, uint32_t fl)
const char *GWENHYWFAR_CB(* GWEN_DIALOG_GETCHARPROPERTY_FN)(GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
#define DBG_WARN(dbg_logger, format, args...)
const char * GWEN_Dialog_TranslateString(const GWEN_DIALOG *dlg, const char *s)
GWEN_DIALOG_SIGNALHANDLER GWEN_Dialog_SetSignalHandler(GWEN_DIALOG *dlg, GWEN_DIALOG_SIGNALHANDLER fn)
GWEN_DB_NODE * GWEN_Dialog_GetPreferences(const GWEN_DIALOG *dlg)
GWEN_XMLNODE * GWEN_XMLNode_new(GWEN_XMLNODE_TYPE t, const char *data)
uint32_t GWEN_Dialog_GetWidgetFlags(const GWEN_DIALOG *dlg, const char *name)
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
struct GWEN_DIALOG GWEN_DIALOG
int GWENHYWFAR_CB(* GWEN_DIALOG_GETINTPROPERTY_FN)(GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
void GWEN_Buffer_Reset(GWEN_BUFFER *bf)
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
int GWEN_Dialog__ReadXmlWidget(GWEN_DIALOG *dlg, GWEN_WIDGET *wparent, GWEN_XMLNODE *node)
const char * GWEN_Dialog_GetId(const GWEN_DIALOG *dlg)
void GWEN_Dialog_List_Add(GWEN_DIALOG *element, GWEN_DIALOG_LIST *list)
void GWEN_Dialog_SetWidgetText(GWEN_DIALOG *dlg, const char *name, const char *t)
GWEN_WIDGET * GWEN_Dialog_FindWidgetByName(const GWEN_DIALOG *dlg, const char *name)
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
GWEN_XMLNODE * GWEN_XMLNode_FindFirstTag(const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue)
GWEN_WIDGET * GWEN_Dialog_FindWidgetByImplData(const GWEN_DIALOG *dlg, int index, const void *ptr)
void GWEN_Dialog_SetWidgetRows(GWEN_DIALOG *dlg, const char *name, int i)
#define GWEN_NEW_OBJECT(typ, varname)
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
int GWEN_Dialog_GetIntProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, int defaultProperty)
int GWEN_Dialog_EmitSignalToAll(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
void GWEN_Dialog_SetI18nDomain(GWEN_DIALOG *dlg, const char *s)
void GWEN_Dialog_SetWidgetFlags(GWEN_DIALOG *dlg, const char *name, uint32_t fl)
GWEN_STRINGLIST * GWEN_Dialog_GetMediaPaths(const GWEN_DIALOG *dlg)
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
void GWEN_Dialog_SetGuiId(GWEN_DIALOG *dlg, uint32_t guiid)
int GWENHYWFAR_CB(* GWEN_DIALOG_SIGNALHANDLER)(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
void GWEN_Dialog_List_free(GWEN_DIALOG_LIST *l)
#define GWEN_INHERIT_INIT(t, element)
GWEN_STRINGLIST * GWEN_PathManager_GetPaths(const char *destLib, const char *pathName)
GWEN_DIALOG_SETCHARPROPERTY_FN GWEN_Dialog_SetSetCharPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_SETCHARPROPERTY_FN fn)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
void GWEN_XMLNode_free(GWEN_XMLNODE *n)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
GWEN_LIST2_FUNCTIONS(TYPEMAKER2_TYPE, Typemaker2_Type)
void GWEN_Dialog_Dump(const GWEN_DIALOG *dlg, FILE *f, unsigned int indent)
GWEN_DIALOG_LIST * GWEN_Dialog_List_new()
const char * GWEN_Dialog_GetI18nDomain(const GWEN_DIALOG *dlg)
int GWENHYWFAR_CB(* GWEN_DIALOG_SETCHARPROPERTY_FN)(GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
int GWEN_Dialog_EmitSignal(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
#define DBG_ERROR(dbg_logger, format, args...)
const char * GWEN_Dialog_GetCharProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultProperty)
int GWEN_Gui_ReadDialogPrefs(const char *groupName, const char *altName, GWEN_DB_NODE **pDb)
int GWEN_Dialog_SetIntProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
int GWEN_Dialog_ReadXml(GWEN_DIALOG *dlg, GWEN_XMLNODE *node)
GWEN_DIALOG * GWEN_Dialog_new(const char *dialogId)
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
int GWENHYWFAR_CB(* GWEN_DIALOG_SETINTPROPERTY_FN)(GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
int GWEN_Dialog_SetCharProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
#define GWEN_ERROR_NOT_FOUND
const char * GWEN_I18N_Translate(const char *txtdom, const char *text)
void GWEN_Dialog_AddMediaPath(GWEN_DIALOG *dlg, const char *s)
int GWEN_Dialog_GetWidgetRows(const GWEN_DIALOG *dlg, const char *name)
const char * GWEN_Dialog_GetWidgetText(const GWEN_DIALOG *dlg, const char *name)
#define DBG_INFO(dbg_logger, format, args...)
void GWEN_Dialog_SubWidgetFlags(GWEN_DIALOG *dlg, const char *name, uint32_t fl)
GWEN_DIALOG * GWEN_Dialog_GetParentDialog(const GWEN_DIALOG *dlg)
int GWEN_Dialog_GetWidgetColumns(const GWEN_DIALOG *dlg, const char *name)
#define GWEN_LIST_INIT(t, element)
int GWEN_Dialog_AddSubDialog(GWEN_DIALOG *dlg, const char *parentName, GWEN_DIALOG *subdlg)
#define GWEN_XML_FLAGS_HANDLE_HEADERS
void GWEN_Dialog_AddMediaPathsFromPathManager(GWEN_DIALOG *dlg, const char *destlib, const char *pathName, const char *relPath)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
void GWEN_Dialog_free(GWEN_DIALOG *dlg)
int GWEN_Dialog_ReadXmlFile(GWEN_DIALOG *dlg, const char *fname)
uint32_t GWEN_Dialog_GetGuiId(const GWEN_DIALOG *dlg)
#define GWEN_LIST_FUNCTIONS(t, pr)
GWEN_DIALOG_GETINTPROPERTY_FN GWEN_Dialog_SetGetIntPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_GETINTPROPERTY_FN fn)
int GWEN_PathManager_FindFile(const char *destLib, const char *pathName, const char *fileName, GWEN_BUFFER *fbuf)
GWEN_STRINGLIST * GWEN_StringList_new(void)
GWEN_DIALOG_GETCHARPROPERTY_FN GWEN_Dialog_SetGetCharPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_GETCHARPROPERTY_FN fn)
GWEN_DIALOG * GWEN_Dialog_CreateAndLoadWithPath(const char *dialogId, const char *pmLibName, const char *pmDataDir, const char *fileName)
#define GWEN_LIST_FINI(t, element)
#define GWEN_INHERIT_FUNCTIONS(t)
struct GWEN__XMLNODE GWEN_XMLNODE
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
#define GWEN_ERROR_NOT_IMPLEMENTED