gwenhywfar  5.10.1
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 #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, "button1",
39  0,
40  "Click this button to close",
41  0);
42 
45  0,
46  640,
47  0);
50  0,
51  480,
52  0);
53 
54  break;
55 
57  fprintf(stderr, "Fini\n");
58  break;
60  fprintf(stderr, "ValueChanged\n");
61  if (strcasecmp(sender, "listbox1")==0) {
62  fprintf(stderr, "Selected list entry %d\n",
63  GWEN_Dialog_GetIntProperty(dlg, "listbox1", GWEN_DialogProperty_Value, 0, -1));
64  }
65  break;
66 
68  fprintf(stderr, "Activated\n");
69  if (strcasecmp(sender, "button1")==0)
71  break;
73  fprintf(stderr, "Enabled\n");
74  break;
76  fprintf(stderr, "Disabled\n");
77  break;
79  fprintf(stderr, "Close\n");
82  fprintf(stderr, "Last, ignored\n");
86  fprintf(stderr, "Key events ignored\n");
88  }
90 }
91 
92 
93 
95 {
96  GWEN_DIALOG *dlg;
97  int rv;
98  const char *s;
99  GWEN_BUFFER *tbuf;
100 
101  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
102  s=getenv("DIALOG_DIR");
103  if (s && *s)
104  GWEN_Buffer_AppendString(tbuf, s);
105  else
106  GWEN_Buffer_AppendString(tbuf, MEDIAPATH);
107 
108  dlg=GWEN_Dialog_new("dlg_test2");
110  GWEN_Dialog_AddMediaPath(dlg, MEDIAPATH);
111 
112  /* read dialog from dialog description file */
113  GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S "dlg_test2.dlg");
115  GWEN_Buffer_free(tbuf);
116  if (rv<0) {
117  DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv);
118  GWEN_Dialog_free(dlg);
119  return NULL;
120  }
121 
122  /* done */
123  return dlg;
124 }
125 
126 
127 
128 
129 
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:235
#define GWEN_DIR_SEPARATOR_S
#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_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
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
GWEN_DIALOG * Dlg_Test2_new()
Definition: dlg_test2.c:94
static int GWENHYWFAR_CB _gwenGuiSignalHandler(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
Definition: dlg_test2.c:27
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
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
void GWEN_Dialog_AddMediaPath(GWEN_DIALOG *dlg, const char *s)
Definition: dialog.c:246
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:181
void GWEN_Dialog_free(GWEN_DIALOG *dlg)
Definition: dialog.c:137
int GWEN_Dialog_ReadXmlFile(GWEN_DIALOG *dlg, const char *fname)
Definition: dialog.c:531
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition: buffer.c:989