gwenhywfar  4.6.0beta
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  GWEN_DIALOG *dlg;
42  GWEN_DLGSHOWBOX *xdlg;
43  GWEN_BUFFER *fbuf;
44  int rv;
45 
46  dlg=GWEN_Dialog_new("dlg_gwen_showbox");
47  GWEN_NEW_OBJECT(GWEN_DLGSHOWBOX, xdlg);
48 
49  GWEN_INHERIT_SETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg, xdlg,
51 
53 
54  /* get path of dialog description file */
55  fbuf=GWEN_Buffer_new(0, 256, 0, 1);
57  "gwenhywfar/dialogs/dlg_showbox.dlg",
58  fbuf);
59  if (rv<0) {
60  DBG_INFO(GWEN_LOGDOMAIN, "Dialog description file not found (%d).", rv);
61  GWEN_Buffer_free(fbuf);
62  GWEN_Dialog_free(dlg);
63  return NULL;
64  }
65 
66  /* read dialog from dialog description file */
68  if (rv<0) {
69  DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv);
70  GWEN_Buffer_free(fbuf);
71  GWEN_Dialog_free(dlg);
72  return NULL;
73  }
74  GWEN_Buffer_free(fbuf);
75 
76  xdlg->flags=flags;
77  if (title)
78  xdlg->title=strdup(title);
79  if (text)
80  xdlg->text=strdup(text);
81 
82  return dlg;
83 }
84 
85 
86 
87 void GWENHYWFAR_CB GWEN_DlgShowBox_FreeData(void *bp, void *p) {
88  GWEN_DLGSHOWBOX *xdlg;
89 
90  xdlg=(GWEN_DLGSHOWBOX*) p;
91 
92  free(xdlg->title);
93  free(xdlg->text);
94 
95  GWEN_FREE_OBJECT(xdlg);
96 }
97 
98 
99 
101  GWEN_DLGSHOWBOX *xdlg;
102  int i;
103  GWEN_DB_NODE *dbParams;
104 
105  assert(dlg);
106  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg);
107  assert(xdlg);
108 
109  dbParams=GWEN_Dialog_GetPreferences(dlg);
110  assert(dbParams);
111 
112  /* read width */
113  i=GWEN_DB_GetIntValue(dbParams, "dialog_width", 0, -1);
114  if (i>=DIALOG_MINWIDTH)
116 
117  /* read height */
118  i=GWEN_DB_GetIntValue(dbParams, "dialog_height", 0, -1);
119  if (i>=DIALOG_MINHEIGHT)
121 
122  /* special stuff */
123  if (xdlg->title)
124  GWEN_Dialog_SetCharProperty(dlg, "", GWEN_DialogProperty_Title, 0, xdlg->title, 0);
125 
126  if (xdlg->text)
127  GWEN_Dialog_SetCharProperty(dlg, "descrLabel", GWEN_DialogProperty_Title, 0, xdlg->text, 0);
128 
129 
130  xdlg->wasInit=1;
131 }
132 
133 
134 
136  GWEN_DLGSHOWBOX *xdlg;
137  int i;
138  GWEN_DB_NODE *dbParams;
139 
140  assert(dlg);
141  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg);
142  assert(xdlg);
143 
144  dbParams=GWEN_Dialog_GetPreferences(dlg);
145  assert(dbParams);
146 
147  /* store dialog width */
149  if (i<DIALOG_MINWIDTH)
150  i=DIALOG_MINWIDTH;
151  GWEN_DB_SetIntValue(dbParams,
153  "dialog_width",
154  i);
155 
156  /* store dialog height */
158  if (i<DIALOG_MINHEIGHT)
160  GWEN_DB_SetIntValue(dbParams,
162  "dialog_height",
163  i);
164 }
165 
166 
167 
168 
171  const char *sender) {
172  GWEN_DLGSHOWBOX *xdlg;
173 
174  assert(dlg);
175  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GWEN_DLGSHOWBOX, dlg);
176  assert(xdlg);
177 
178  switch(t) {
182 
186 
191 
194 
197  }
198 
200 
201 }
202 
203 
204 
205