gwenhywfar  5.10.1
dlg_showbox.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Wed Feb 17 2010
3  copyright : (C) 2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 #ifdef HAVE_CONFIG_H
12 # include <config.h>
13 #endif
14 
15 #define DISABLE_DEBUGLOG
16 
17 
18 #include "dlg_showbox_p.h"
19 
20 #include <gwenhywfar/gwenhywfar.h>
21 #include <gwenhywfar/pathmanager.h>
22 #include <gwenhywfar/gui.h>
23 #include <gwenhywfar/debug.h>
24 
25 
26 
27 #define DIALOG_MINWIDTH 200
28 #define DIALOG_MINHEIGHT 50
29 
30 
31 
32 GWEN_INHERIT(GWEN_DIALOG, GWEN_DLGSHOWBOX)
33 
34 
35 
36 
37 
39  const char *title,
40  const char *text)
41 {
42  GWEN_DIALOG *dlg;
43  GWEN_DLGSHOWBOX *xdlg;
44  GWEN_BUFFER *fbuf;
45  int rv;
46 
47  dlg=GWEN_Dialog_new("dlg_gwen_showbox");
48  GWEN_NEW_OBJECT(GWEN_DLGSHOWBOX, xdlg);
49 
50  GWEN_INHERIT_SETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg, xdlg,
52 
54 
55  /* get path of dialog description file */
56  fbuf=GWEN_Buffer_new(0, 256, 0, 1);
58  "gwenhywfar/dialogs/dlg_showbox.dlg",
59  fbuf);
60  if (rv<0) {
61  DBG_INFO(GWEN_LOGDOMAIN, "Dialog description file not found (%d).", rv);
62  GWEN_Buffer_free(fbuf);
63  GWEN_Dialog_free(dlg);
64  return NULL;
65  }
66 
67  /* read dialog from dialog description file */
69  if (rv<0) {
70  DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv);
71  GWEN_Buffer_free(fbuf);
72  GWEN_Dialog_free(dlg);
73  return NULL;
74  }
75  GWEN_Buffer_free(fbuf);
76 
77  xdlg->flags=flags;
78  if (title)
79  xdlg->title=strdup(title);
80  if (text)
81  xdlg->text=strdup(text);
82 
83  return dlg;
84 }
85 
86 
87 
89 {
90  GWEN_DLGSHOWBOX *xdlg;
91 
92  xdlg=(GWEN_DLGSHOWBOX *) p;
93 
94  free(xdlg->title);
95  free(xdlg->text);
96 
97  GWEN_FREE_OBJECT(xdlg);
98 }
99 
100 
101 
103 {
104  GWEN_DLGSHOWBOX *xdlg;
105  int i;
106  GWEN_DB_NODE *dbParams;
107 
108  assert(dlg);
109  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg);
110  assert(xdlg);
111 
112  dbParams=GWEN_Dialog_GetPreferences(dlg);
113  assert(dbParams);
114 
115  /* read width */
116  i=GWEN_DB_GetIntValue(dbParams, "dialog_width", 0, -1);
117  if (i>=DIALOG_MINWIDTH)
119 
120  /* read height */
121  i=GWEN_DB_GetIntValue(dbParams, "dialog_height", 0, -1);
122  if (i>=DIALOG_MINHEIGHT)
124 
125  /* special stuff */
126  if (xdlg->title)
127  GWEN_Dialog_SetCharProperty(dlg, "", GWEN_DialogProperty_Title, 0, xdlg->title, 0);
128 
129  if (xdlg->text)
130  GWEN_Dialog_SetCharProperty(dlg, "descrLabel", GWEN_DialogProperty_Title, 0, xdlg->text, 0);
131 
132 
133  xdlg->wasInit=1;
134 }
135 
136 
137 
139 {
140  GWEN_DLGSHOWBOX *xdlg;
141  int i;
142  GWEN_DB_NODE *dbParams;
143 
144  assert(dlg);
145  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg);
146  assert(xdlg);
147 
148  dbParams=GWEN_Dialog_GetPreferences(dlg);
149  assert(dbParams);
150 
151  /* store dialog width */
153  if (i<DIALOG_MINWIDTH)
154  i=DIALOG_MINWIDTH;
155  GWEN_DB_SetIntValue(dbParams,
157  "dialog_width",
158  i);
159 
160  /* store dialog height */
162  if (i<DIALOG_MINHEIGHT)
164  GWEN_DB_SetIntValue(dbParams,
166  "dialog_height",
167  i);
168 }
169 
170 
171 
172 
175  GWEN_UNUSED const char *sender)
176 {
177  GWEN_DLGSHOWBOX *xdlg;
178 
179  assert(dlg);
180  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg);
181  assert(xdlg);
182 
183  switch (t) {
187 
191 
196 
199 
204  }
205 
207 
208 }
209 
210 
211 
212 
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:235
#define GWEN_DB_FLAGS_OVERWRITE_VARS
Definition: db.h:121
#define DIALOG_MINHEIGHT
Definition: dlg_showbox.c:28
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
#define GWEN_PM_SYSDATADIR
Definition: gwenhywfar.h:66
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:300
GWEN_DIALOG_EVENTTYPE
Definition: dialog.h:98
GWEN_DIALOG_SIGNALHANDLER GWEN_Dialog_SetSignalHandler(GWEN_DIALOG *dlg, GWEN_DIALOG_SIGNALHANDLER fn)
Definition: dialog.c:305
#define GWEN_LOGDOMAIN
Definition: logger.h:35
GWEN_DB_NODE * GWEN_Dialog_GetPreferences(const GWEN_DIALOG *dlg)
Definition: dialog.c:1002
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:42
struct GWEN_DIALOG GWEN_DIALOG
Definition: dialog.h:54
void GWEN_DlgShowBox_Init(GWEN_DIALOG *dlg)
Definition: dlg_showbox.c:102
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
int GWEN_Dialog_GetIntProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, int defaultProperty)
Definition: dialog.c:733
#define GWENHYWFAR_CB
Definition: gwenhywfarapi.h:89
void GWEN_DlgShowBox_Fini(GWEN_DIALOG *dlg)
Definition: dlg_showbox.c:138
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:89
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:38
GWEN_DIALOG * GWEN_DlgShowBox_new(uint32_t flags, const char *title, const char *text)
Definition: dlg_showbox.c:38
int GWEN_Dialog_SetIntProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
Definition: dialog.c:703
GWEN_DIALOG * GWEN_Dialog_new(const char *dialogId)
Definition: dialog.c:54
int GWEN_Dialog_SetCharProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
Definition: dialog.c:762
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:181
#define GWEN_PM_LIBNAME
Definition: gwenhywfar.h:42
#define DIALOG_MINWIDTH
Definition: dlg_showbox.c:27
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
Definition: db.c:1163
void GWENHYWFAR_CB GWEN_DlgShowBox_FreeData(GWEN_UNUSED void *bp, void *p)
Definition: dlg_showbox.c:88
void GWEN_Dialog_free(GWEN_DIALOG *dlg)
Definition: dialog.c:137
#define GWEN_INHERIT(bt, t)
Definition: inherit.h:264
int GWEN_Dialog_ReadXmlFile(GWEN_DIALOG *dlg, const char *fname)
Definition: dialog.c:531
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
Definition: db.c:1202
int GWEN_PathManager_FindFile(const char *destLib, const char *pathName, const char *fileName, GWEN_BUFFER *fbuf)
Definition: pathmanager.c:541
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
Definition: inherit.h:292
int GWENHYWFAR_CB GWEN_DlgShowBox_SignalHandler(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, GWEN_UNUSED const char *sender)
Definition: dlg_showbox.c:173
#define GWEN_UNUSED
#define GWEN_INHERIT_GETDATA(bt, t, element)
Definition: inherit.h:271