gwenhywfar 5.12.0
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",
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)
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
#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
struct GWEN_DIALOG GWEN_DIALOG
Definition dialog.h:54
@ 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_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
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