gwenhywfar 5.12.0
dlg_test.c
Go to the documentation of this file.
1/***************************************************************************
2 begin : Sun May 16 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#ifdef HAVE_CONFIG_H
11# include <config.h>
12#endif
13
14#include <gwenhywfar/gwenhywfar.h>
15#include <gwenhywfar/gui.h>
16#include <gwenhywfar/dialog.h>
17#include <gwenhywfar/debug.h>
18#include <gwenhywfar/pathmanager.h>
19
20
21#include <unistd.h>
22
23
24
25
26
29 const char *sender)
30{
31 fprintf(stderr,
32 "Received event %d from widget [%s]\n", t, sender);
33
34 switch (t) {
36 fprintf(stderr, "Init\n");
37 GWEN_Dialog_SetCharProperty(dlg, "combo1",
39 0,
40 "Erster Text in Combo1",
41 0);
42 GWEN_Dialog_SetCharProperty(dlg, "combo1",
44 0,
45 "Zweiter Text in Combo1",
46 0);
47 GWEN_Dialog_SetIntProperty(dlg, "combo1",
49 0,
50 0,
51 0);
52
53
54 GWEN_Dialog_SetCharProperty(dlg, "combo2",
56 0,
57 "Erster Text in Combo2",
58 0);
59 GWEN_Dialog_SetCharProperty(dlg, "combo2",
61 0,
62 "Zweiter Text in Combo2",
63 0);
64 GWEN_Dialog_SetIntProperty(dlg, "combo2",
66 0,
67 0,
68 0);
69
70 GWEN_Dialog_SetCharProperty(dlg, "listbox1",
72 0,
73 "Column1\tColumn2\tColumn3",
74 0);
75
76 GWEN_Dialog_SetCharProperty(dlg, "listbox1",
78 0,
79 "Zeile 1 Spalte 1\tZeile 1 Spalte 2\tZeile 1 Spalte 3",
80 0);
81 GWEN_Dialog_SetCharProperty(dlg, "listbox1",
83 0,
84 "Zeile 2 Spalte 1\tZeile 2 Spalte 2\tZeile 2 Spalte 3",
85 0);
86 GWEN_Dialog_SetIntProperty(dlg, "listbox1",
88 0,
89 100,
90 0);
91 GWEN_Dialog_SetIntProperty(dlg, "listbox1",
93 1,
94 200,
95 0);
96
97 GWEN_Dialog_SetCharProperty(dlg, "labelWithHtmlImage",
99 0,
100 "<html>This label contains text which should also contain an image:"
101 "<img src=\"chipcard.png\">"
102 "<p>And here the text should continue, followed by another image:"
103 "<img src=\"disk.png\"></p>"
104 "And again, this should be on the following line.</html>"
105 "This label would contain an image if it were able to use "
106 "HTML.",
107 0);
108
109 GWEN_Dialog_SetCharProperty(dlg, "textBrowser1",
111 0,
112 "<html>"
113 "<p>This is <b>bold</b> text, while this one is <i>italic</i>.</p>"
114 "This is a list:"
115 "<ul>"
116 "<li>first item</li>"
117 "<li>second item</li>"
118 "<li>third item</li>"
119 "<li>fourth item</li>"
120 "</ul>"
121 "<p>This paragraph should follow the list.</p>"
122 "</html>"
123 "This is BOLD text, while this one is would be i t a l i c.\n"
124 "This is a list:\n"
125 "- first item\n"
126 "- second item\n"
127 "- third item\n"
128 "- fourth item\n"
129 "This paragraph should follow the list.",
130 0);
131
132 GWEN_Dialog_SetIntProperty(dlg, "progressBar1",
134 0,
135 0,
136 0);
137 GWEN_Dialog_SetIntProperty(dlg, "progressBar1",
139 0,
140 10,
141 0);
142
143
146 0,
147 640,
148 0);
151 0,
152 480,
153 0);
154
155 break;
156
158 fprintf(stderr, "Fini\n");
159 break;
161 fprintf(stderr, "ValueChanged\n");
162 if (strcasecmp(sender, "listbox1")==0) {
163 fprintf(stderr, "Selected list entry %d\n",
165 }
166 else if (strcasecmp(sender, "editPass1")==0) {
167 const char *s;
168
170 if (!(s && *s))
171 s="<empty>";
172 GWEN_Dialog_SetCharProperty(dlg, "editPass2", GWEN_DialogProperty_Value, 0, s, 0);
173 }
174 break;
175
177 fprintf(stderr, "Activated\n");
178 if (strcasecmp(sender, "listbox1")==0) {
179 int idx;
180
181 idx=GWEN_Dialog_GetIntProperty(dlg, "listbox1", GWEN_DialogProperty_Value, 0, -1);
182 fprintf(stderr, "Selected list entry %d\n", idx);
183 if (idx>=0) {
184 const char *s;
185
187 if (s && *s) {
188 fprintf(stderr, "Text of selected list entry %d: [%s]\n", idx, s);
189 }
190 }
191 }
192 else if (strcasecmp(sender, "combo1")==0) {
193 int idx;
194
195 idx=GWEN_Dialog_GetIntProperty(dlg, "combo1", GWEN_DialogProperty_Value, 0, -1);
196 fprintf(stderr, "Selected list entry %d\n", idx);
197 if (idx>=0) {
198 const char *s;
199
201 if (s && *s) {
202 fprintf(stderr, "Text of selected list entry %d: [%s]\n", idx, s);
203 }
204 }
205
206 }
207 else if (strcasecmp(sender, "okButton")==0)
209 else if (strcasecmp(sender, "abortButton")==0)
211 else if (strcasecmp(sender, "progressMinus")==0) {
212 int v;
213
214 v=GWEN_Dialog_GetIntProperty(dlg, "progressBar1", GWEN_DialogProperty_Value, 0, -1);
215 if (v>0)
216 GWEN_Dialog_SetIntProperty(dlg, "progressBar1", GWEN_DialogProperty_Value, 0, v-1, 0);
218 }
219 else if (strcasecmp(sender, "progressPlus")==0) {
220 int v;
221
222 v=GWEN_Dialog_GetIntProperty(dlg, "progressBar1", GWEN_DialogProperty_Value, 0, -1);
223 if (v<10)
224 GWEN_Dialog_SetIntProperty(dlg, "progressBar1", GWEN_DialogProperty_Value, 0, v+1, 0);
226 }
227 else if (strcasecmp(sender, "prevPageButton")==0) {
228 int v;
229
231 if (v>0)
232 GWEN_Dialog_SetIntProperty(dlg, "stack1", GWEN_DialogProperty_Value, 0, v-1, 0);
234 }
235 else if (strcasecmp(sender, "nextPageButton")==0) {
236 int v;
237
239 if (v<3)
240 GWEN_Dialog_SetIntProperty(dlg, "stack1", GWEN_DialogProperty_Value, 0, v+1, 0);
242 }
243 break;
244
246 fprintf(stderr, "Enabled\n");
247 break;
249 fprintf(stderr, "Disabled\n");
250 break;
252 fprintf(stderr, "Close\n");
255 fprintf(stderr, "Last, ignored\n");
257
260 fprintf(stderr, "Key events ignored\n");
262
263 }
265}
266
267
268
270{
271 GWEN_DIALOG *dlg;
272 int rv;
273 const char *s;
274 GWEN_BUFFER *tbuf;
275
276 tbuf=GWEN_Buffer_new(0, 256, 0, 1);
277 s=getenv("DIALOG_DIR");
278 if (s && *s)
280 else
281 GWEN_Buffer_AppendString(tbuf, MEDIAPATH);
282 dlg=GWEN_Dialog_new("dlg_test");
285
286 /* read dialog from dialog description file */
289 GWEN_Buffer_free(tbuf);
290 if (rv<0) {
291 DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv);
292 GWEN_Dialog_free(dlg);
293 return NULL;
294 }
295
296 /* done */
297 return dlg;
298}
299
300
301
302
303
#define NULL
Definition binreloc.c:300
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition buffer.c:42
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition buffer.c:89
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition buffer.c:992
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition buffer.c:235
#define DBG_INFO(dbg_logger, format,...)
Definition debug.h:181
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_SIGNALHANDLER GWEN_Dialog_SetSignalHandler(GWEN_DIALOG *dlg, GWEN_DIALOG_SIGNALHANDLER fn)
Definition dialog.c:305
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
void GWEN_Dialog_AddMediaPath(GWEN_DIALOG *dlg, const char *s)
Definition dialog.c:246
void GWEN_Dialog_free(GWEN_DIALOG *dlg)
Definition dialog.c:137
GWEN_DIALOG * GWEN_Dialog_new(const char *dialogId)
Definition dialog.c:54
int GWEN_Dialog_GetIntProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, int defaultProperty)
Definition dialog.c:733
int GWEN_Dialog_ReadXmlFile(GWEN_DIALOG *dlg, const char *fname)
Definition dialog.c:531
const char * GWEN_Dialog_GetCharProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultProperty)
Definition dialog.c:792
struct GWEN_DIALOG GWEN_DIALOG
Definition dialog.h:54
@ GWEN_DialogProperty_AddValue
Definition dialog.h:268
@ GWEN_DialogProperty_MinValue
Definition dialog.h:265
@ GWEN_DialogProperty_ColumnWidth
Definition dialog.h:271
@ GWEN_DialogProperty_MaxValue
Definition dialog.h:266
@ GWEN_DialogProperty_Title
Definition dialog.h:263
@ GWEN_DialogProperty_Height
Definition dialog.h:273
@ GWEN_DialogProperty_Value
Definition dialog.h:264
@ GWEN_DialogProperty_Width
Definition dialog.h:272
GWEN_DIALOG_EVENTTYPE
Definition dialog.h:98
@ GWEN_DialogEvent_TypeKeyPressed
Definition dialog.h:106
@ GWEN_DialogEvent_TypeValueChanged
Definition dialog.h:101
@ GWEN_DialogEvent_TypeInit
Definition dialog.h:99
@ GWEN_DialogEvent_TypeFini
Definition dialog.h:100
@ GWEN_DialogEvent_TypeClose
Definition dialog.h:105
@ GWEN_DialogEvent_TypeKeyReleased
Definition dialog.h:107
@ GWEN_DialogEvent_TypeActivated
Definition dialog.h:102
@ GWEN_DialogEvent_TypeEnabled
Definition dialog.h:103
@ GWEN_DialogEvent_TypeDisabled
Definition dialog.h:104
@ GWEN_DialogEvent_TypeLast
Definition dialog.h:109
@ GWEN_DialogEvent_ResultHandled
Definition dialog.h:120
@ GWEN_DialogEvent_ResultAccept
Definition dialog.h:122
@ GWEN_DialogEvent_ResultNotHandled
Definition dialog.h:121
@ GWEN_DialogEvent_ResultReject
Definition dialog.h:123
GWEN_DIALOG * Dlg_Test1_new()
Definition dlg_test.c:269
static int GWENHYWFAR_CB _gwenGuiSignalHandler(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
Definition dlg_test.c:27
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition buffer.h:38
#define GWEN_DIR_SEPARATOR_S
#define GWENHYWFAR_CB
#define GWEN_LOGDOMAIN
Definition logger.h:35