gwenhywfar  4.99.8beta
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  fprintf(stderr,
31  "Received event %d from widget [%s]\n", t, sender);
32 
33  switch(t) {
35  fprintf(stderr, "Init\n");
36  GWEN_Dialog_SetCharProperty(dlg, "button1",
38  0,
39  "Click this button to close",
40  0);
41 
44  0,
45  640,
46  0);
49  0,
50  480,
51  0);
52 
53  break;
54 
56  fprintf(stderr, "Fini\n");
57  break;
59  fprintf(stderr, "ValueChanged\n");
60  if (strcasecmp(sender, "listbox1")==0) {
61  fprintf(stderr, "Selected list entry %d\n",
62  GWEN_Dialog_GetIntProperty(dlg, "listbox1", GWEN_DialogProperty_Value, 0, -1));
63  }
64  break;
65 
67  fprintf(stderr, "Activated\n");
68  if (strcasecmp(sender, "button1")==0)
70  break;
72  fprintf(stderr, "Enabled\n");
73  break;
75  fprintf(stderr, "Disabled\n");
76  break;
78  fprintf(stderr, "Close\n");
81  fprintf(stderr, "Last, ignored\n");
83  }
85 }
86 
87 
88 
90  GWEN_DIALOG *dlg;
91  int rv;
92  const char *s;
93  GWEN_BUFFER *tbuf;
94 
95  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
96  s=getenv("DIALOG_DIR");
97  if (s && *s)
98  GWEN_Buffer_AppendString(tbuf, s);
99  else
100  GWEN_Buffer_AppendString(tbuf, MEDIAPATH);
101 
102  dlg=GWEN_Dialog_new("dlg_test2");
104  GWEN_Dialog_AddMediaPath(dlg, MEDIAPATH);
105 
106  /* read dialog from dialog description file */
107  GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S "dlg_test2.dlg");
109  GWEN_Buffer_free(tbuf);
110  if (rv<0) {
111  DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv);
112  GWEN_Dialog_free(dlg);
113  return NULL;
114  }
115 
116  /* done */
117  return dlg;
118 }
119 
120 
121 
122 
123 
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:223
#define GWEN_DIR_SEPARATOR_S
#define NULL
Definition: binreloc.c:290
GWEN_DIALOG_EVENTTYPE
Definition: dialog.h:90
GWEN_DIALOG_SIGNALHANDLER GWEN_Dialog_SetSignalHandler(GWEN_DIALOG *dlg, GWEN_DIALOG_SIGNALHANDLER fn)
Definition: dialog.c:243
#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:38
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:600
#define GWENHYWFAR_CB
Definition: gwenhywfarapi.h:89
GWEN_DIALOG * Dlg_Test2_new()
Definition: dlg_test2.c:89
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:83
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:41
int GWEN_Dialog_SetIntProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
Definition: dialog.c:571
GWEN_DIALOG * GWEN_Dialog_new(const char *dialogId)
Definition: dialog.c:53
int GWEN_Dialog_SetCharProperty(GWEN_DIALOG *dlg, const char *name, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
Definition: dialog.c:628
void GWEN_Dialog_AddMediaPath(GWEN_DIALOG *dlg, const char *s)
Definition: dialog.c:187
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:164
void GWEN_Dialog_free(GWEN_DIALOG *dlg)
Definition: dialog.c:88
int GWEN_Dialog_ReadXmlFile(GWEN_DIALOG *dlg, const char *fname)
Definition: dialog.c:407
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition: buffer.c:1014