gwenhywfar  4.6.0beta
dlg_test2.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 #ifdef OS_WIN32
22 # include <windows.h>
23 # define sleep(x) Sleep(x)
24 #endif
25 
26 #include <unistd.h>
27 
28 
29 
30 
31 
34  const char *sender) {
35  fprintf(stderr,
36  "Received event %d from widget [%s]\n", t, sender);
37 
38  switch(t) {
40  fprintf(stderr, "Init\n");
41  GWEN_Dialog_SetCharProperty(dlg, "button1",
43  0,
44  "Click this button to close",
45  0);
46 
49  0,
50  640,
51  0);
54  0,
55  480,
56  0);
57 
58  break;
59 
61  fprintf(stderr, "Fini\n");
62  break;
64  fprintf(stderr, "ValueChanged\n");
65  if (strcasecmp(sender, "listbox1")==0) {
66  fprintf(stderr, "Selected list entry %d\n",
67  GWEN_Dialog_GetIntProperty(dlg, "listbox1", GWEN_DialogProperty_Value, 0, -1));
68  }
69  break;
70 
72  fprintf(stderr, "Activated\n");
73  if (strcasecmp(sender, "button1")==0)
75  break;
77  fprintf(stderr, "Enabled\n");
78  break;
80  fprintf(stderr, "Disabled\n");
81  break;
83  fprintf(stderr, "Close\n");
86  fprintf(stderr, "Last, ignored\n");
88  }
90 }
91 
92 
93 
95  GWEN_DIALOG *dlg;
96  int rv;
97  const char *s;
98  GWEN_BUFFER *tbuf;
99 
100  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
101  s=getenv("DIALOG_DIR");
102  if (s && *s)
103  GWEN_Buffer_AppendString(tbuf, s);
104  else
105  GWEN_Buffer_AppendString(tbuf, MEDIAPATH);
106 
107  dlg=GWEN_Dialog_new("dlg_test2");
109  GWEN_Dialog_AddMediaPath(dlg, MEDIAPATH);
110 
111  /* read dialog from dialog description file */
112  GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S "dlg_test2.dlg");
114  GWEN_Buffer_free(tbuf);
115  if (rv<0) {
116  DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv);
117  GWEN_Dialog_free(dlg);
118  return NULL;
119  }
120 
121  /* done */
122  return dlg;
123 }
124 
125 
126 
127 
128