00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifdef HAVE_CONFIG_H
00011 # include <config.h>
00012 #endif
00013
00014 #include <gwenhywfar/gwenhywfar.h>
00015 #include <gwenhywfar/gui.h>
00016 #include <gwenhywfar/dialog.h>
00017 #include <gwenhywfar/debug.h>
00018 #include <gwenhywfar/pathmanager.h>
00019
00020
00021 #ifdef OS_WIN32
00022 # include <windows.h>
00023 # define sleep(x) Sleep(x)
00024 #endif
00025
00026 #include <unistd.h>
00027
00028
00029
00030
00031
00032 static int GWENHYWFAR_CB _gwenGuiSignalHandler(GWEN_DIALOG *dlg,
00033 GWEN_DIALOG_EVENTTYPE t,
00034 const char *sender) {
00035 fprintf(stderr,
00036 "Received event %d from widget [%s]\n", t, sender);
00037
00038 switch(t) {
00039 case GWEN_DialogEvent_TypeInit:
00040 fprintf(stderr, "Init\n");
00041 GWEN_Dialog_SetCharProperty(dlg, "button1",
00042 GWEN_DialogProperty_Title,
00043 0,
00044 "Click this button to close",
00045 0);
00046
00047 GWEN_Dialog_SetIntProperty(dlg, "",
00048 GWEN_DialogProperty_Width,
00049 0,
00050 640,
00051 0);
00052 GWEN_Dialog_SetIntProperty(dlg, "",
00053 GWEN_DialogProperty_Height,
00054 0,
00055 480,
00056 0);
00057
00058 break;
00059
00060 case GWEN_DialogEvent_TypeFini:
00061 fprintf(stderr, "Fini\n");
00062 break;
00063 case GWEN_DialogEvent_TypeValueChanged:
00064 fprintf(stderr, "ValueChanged\n");
00065 if (strcasecmp(sender, "listbox1")==0) {
00066 fprintf(stderr, "Selected list entry %d\n",
00067 GWEN_Dialog_GetIntProperty(dlg, "listbox1", GWEN_DialogProperty_Value, 0, -1));
00068 }
00069 break;
00070
00071 case GWEN_DialogEvent_TypeActivated:
00072 fprintf(stderr, "Activated\n");
00073 if (strcasecmp(sender, "button1")==0)
00074 return GWEN_DialogEvent_ResultAccept;
00075 break;
00076 case GWEN_DialogEvent_TypeEnabled:
00077 fprintf(stderr, "Enabled\n");
00078 break;
00079 case GWEN_DialogEvent_TypeDisabled:
00080 fprintf(stderr, "Disabled\n");
00081 break;
00082 case GWEN_DialogEvent_TypeClose:
00083 fprintf(stderr, "Close\n");
00084 return GWEN_DialogEvent_ResultNotHandled;
00085 case GWEN_DialogEvent_TypeLast:
00086 fprintf(stderr, "Last, ignored\n");
00087 return GWEN_DialogEvent_ResultNotHandled;
00088 }
00089 return GWEN_DialogEvent_ResultHandled;
00090 }
00091
00092
00093
00094 GWEN_DIALOG *Dlg_Test2_new() {
00095 GWEN_DIALOG *dlg;
00096 int rv;
00097 const char *s;
00098 GWEN_BUFFER *tbuf;
00099
00100 tbuf=GWEN_Buffer_new(0, 256, 0, 1);
00101 s=getenv("DIALOG_DIR");
00102 if (s && *s)
00103 GWEN_Buffer_AppendString(tbuf, s);
00104 else
00105 GWEN_Buffer_AppendString(tbuf, MEDIAPATH);
00106
00107 dlg=GWEN_Dialog_new("dlg_test2");
00108 GWEN_Dialog_SetSignalHandler(dlg, _gwenGuiSignalHandler);
00109 GWEN_Dialog_AddMediaPath(dlg, MEDIAPATH);
00110
00111
00112 GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S "dlg_test2.dlg");
00113 rv=GWEN_Dialog_ReadXmlFile(dlg, GWEN_Buffer_GetStart(tbuf));
00114 GWEN_Buffer_free(tbuf);
00115 if (rv<0) {
00116 DBG_INFO(GWEN_LOGDOMAIN, "here (%d).", rv);
00117 GWEN_Dialog_free(dlg);
00118 return NULL;
00119 }
00120
00121
00122 return dlg;
00123 }
00124
00125
00126
00127
00128