Temporarily include building libgwengui-gtk3 in GnuCash.

Revert this commit when it's widely available in distributed packages.
This commit is contained in:
John Ralls 2017-08-25 15:09:20 -07:00
parent 35752e5929
commit 2ee5b202bf
40 changed files with 5989 additions and 9 deletions

View File

@ -290,7 +290,6 @@ IF (WITH_AQBANKING)
GNC_PKG_CHECK_MODULES (GWENHYWFAR REQUIRED gwenhywfar)
GNC_PKG_CHECK_MODULES (AQBANKING REQUIRED aqbanking)
IF(WITH_GNUCASH)
GNC_PKG_CHECK_MODULES (GWENGUI_GTK3 REQUIRED gwengui-gtk3)
GNC_PKG_CHECK_MODULES (KTOBLZCHECK ktoblzcheck)
IF(KTOBLZCHECK_FOUND)
SET(HAVE_KTOBLZCHECK_H 1)

View File

@ -1,5 +1,6 @@
ADD_SUBDIRECTORY(libc)
ADD_SUBDIRECTORY(goffice)
ADD_SUBDIRECTORY(gwengui-gtk3)
SET_LOCAL_DIST(borrowed_DIST_local CMakeLists.txt Makefile.am README)
SET(borrowed_DIST ${borrowed_DIST_local} ${libc_DIST} ${goffice_DIST} PARENT_SCOPE)

View File

@ -1,5 +1,5 @@
if GNUCASH_ENABLE_GUI
SUBDIRS = libc goffice
SUBDIRS = libc goffice gwengui-gtk3
else
SUBDIRS = libc
endif

View File

@ -0,0 +1,56 @@
SET (gwengui_gtk3_noinst_HEADERS
gtk3_gui_p.h
gtk3_gui_dialog_l.h
gtk3_gui_dialog_p.h
)
SET (gwengui_gtk3_SOURCES
gtk3_gui_dialog.c
gtk3_gui.c
)
SET (gwengui_gtk3_EXTRA_DIST
w_combobox.c
w_label.c
w_dialog.c
w_gridlayout.c
w_groupbox.c
w_hlayout.c
w_hline.c
w_hspacer.c
w_lineedit.c
w_vlayout.c
w_vline.c
w_vspacer.c
w_pushbutton.c
w_textbrowser.c
w_textedit.c
w_stack.c
w_tabbook.c
w_progressbar.c
w_listbox.c
w_checkbox.c
w_scrollarea.c
w_radiobutton.c
w_spinbox.c
)
SET_DIST_LIST(gwengui_gtk3_DIST CMakeLists.txt Makefile.am
${gwengui_gtk3_SOURCES}
${gwengui_gtk3_noinst_HEADERS}
${gwengui_gtk3_EXTRA_DIST}
)
ADD_LIBRARY(gwengui-gtk3 ${gwengui_gtk3_SOURCES})
TARGET_COMPILE_DEFINITIONS(gwengui-gtk3 PRIVATE BUILDING_GTK3_GUI=True)
TARGET_INCLUDE_DIRECTORIES(gwengui-gtk3 PUBLIC
${GTK3_INCLUDE_DIRS}
${GWENHYWFAR_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(gwengui-gtk3 ${GWENHYWFAR_LDFLAGS} ${GTK3_LDFLAGS})
INSTALL(TARGETS gwengui-gtk3
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

View File

@ -0,0 +1,43 @@
AM_CPPFLAGS=$(GWEN_CFLAGS) $(GTK_CFLAGS)
DEFS+=-DBUILDING_GTK3_GUI -DPACKAGE=\"$(PACKAGE)\"
lib_LTLIBRARIES=libgwengui-gtk3.la
libgwengui_gtk3_la_LIBADD=$(GTK_LIBS) $(GWEN_LIBS)
libgwengui_gtk3_la_LDFLAGS = -no-undefined
noinst_HEADERS=\
gtk3_gui_p.h \
gtk3_gui_dialog_l.h \
gtk3_gui_dialog_p.h
libgwengui_gtk3_la_SOURCES=\
gtk3_gui_dialog.c \
gtk3_gui.c
EXTRA_DIST=\
w_combobox.c \
w_label.c \
w_dialog.c \
w_gridlayout.c \
w_groupbox.c \
w_hlayout.c \
w_hline.c \
w_hspacer.c \
w_lineedit.c \
w_vlayout.c \
w_vline.c \
w_vspacer.c \
w_pushbutton.c \
w_textbrowser.c \
w_textedit.c \
w_stack.c \
w_tabbook.c \
w_progressbar.c \
w_listbox.c \
w_checkbox.c \
w_scrollarea.c \
w_radiobutton.c \
w_spinbox.c

View File

@ -0,0 +1,293 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#include "gtk3_gui_p.h"
#include "gtk3_gui_dialog_l.h"
#include <assert.h>
#include <gwenhywfar/inherit.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/gui_be.h>
#include <gwenhywfar/i18n.h>
#include <gwenhywfar/text.h>
#include <gwenhywfar/mdigest.h>
#include <gwenhywfar/debug.h>
#define PACKAGE "gnucash"
#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg)
GWEN_INHERIT(GWEN_GUI, GTK3_GUI)
GWEN_GUI *Gtk3_Gui_new() {
GWEN_GUI *gui;
GTK3_GUI *xgui;
gui=GWEN_Gui_new();
GWEN_NEW_OBJECT(GTK3_GUI, xgui);
GWEN_INHERIT_SETDATA(GWEN_GUI, GTK3_GUI, gui, xgui, Gtk3_Gui_FreeData);
GWEN_Gui_AddFlags(gui, GWEN_GUI_FLAGS_DIALOGSUPPORTED);
GWEN_Gui_UseDialogs(gui);
xgui->execDialogFn=GWEN_Gui_SetExecDialogFn(gui, GTK3_Gui_ExecDialog);
xgui->openDialogFn=GWEN_Gui_SetOpenDialogFn(gui, GTK3_Gui_OpenDialog);
xgui->closeDialogFn=GWEN_Gui_SetCloseDialogFn(gui, GTK3_Gui_CloseDialog);
xgui->runDialogFn=GWEN_Gui_SetRunDialogFn(gui, GTK3_Gui_RunDialog);
xgui->getFileNameDialogFn=GWEN_Gui_SetGetFileNameFn(gui, GTK3_Gui_GetFileName);
return gui;
}
GWENHYWFAR_CB void Gtk3_Gui_FreeData(void *bp, void *p) {
GTK3_GUI *xgui;
xgui=(GTK3_GUI*) p;
GWEN_FREE_OBJECT(xgui);
}
GWENHYWFAR_CB int GTK3_Gui_ExecDialog(GWEN_GUI *gui,
GWEN_DIALOG *dlg,
uint32_t guiid) {
int rv;
assert(dlg);
rv=GTK3_Gui_OpenDialog(gui, dlg, guiid);
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
return rv;
}
rv=GTK3_Gui_RunDialog(gui, dlg, 1);
GTK3_Gui_CloseDialog(gui, dlg);
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
return rv;
}
return rv;
}
GWENHYWFAR_CB int GTK3_Gui_OpenDialog(GWEN_GUI *gui,
GWEN_DIALOG *dlg,
uint32_t guiid) {
int rv;
GtkWidget *g;
assert(dlg);
Gtk3Gui_Dialog_Extend(dlg);
rv=Gtk3Gui_Dialog_Setup(dlg, NULL);
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
Gtk3Gui_Dialog_Unextend(dlg);
return rv;
}
g=Gtk3Gui_Dialog_GetMainWidget(dlg);
if (g==NULL) {
DBG_ERROR(GWEN_LOGDOMAIN, "No main widget");
Gtk3Gui_Dialog_Unextend(dlg);
return GWEN_ERROR_INVALID;
}
rv=GWEN_Dialog_EmitSignalToAll(dlg, GWEN_DialogEvent_TypeInit, "");
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "Error initializing dialog: %d", rv);
Gtk3Gui_Dialog_Unextend(dlg);
return rv;
}
/* show dialog */
gtk_widget_show_all(g);
return 0;
}
GWENHYWFAR_CB int GTK3_Gui_CloseDialog(GWEN_GUI *gui, GWEN_DIALOG *dlg) {
GtkWidget *g;
int rv;
assert(dlg);
g=Gtk3Gui_Dialog_GetMainWidget(dlg);
if (g==NULL) {
DBG_ERROR(GWEN_LOGDOMAIN, "No main widget");
Gtk3Gui_Dialog_Unextend(dlg);
return GWEN_ERROR_INVALID;
}
/* hide dialog */
gtk_widget_hide(g);
/* send fini signal to dialog */
rv=GWEN_Dialog_EmitSignalToAll(dlg, GWEN_DialogEvent_TypeFini, "");
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "Error deinitializing dialog: %d", rv);
Gtk3Gui_Dialog_Unextend(dlg);
return rv;
}
Gtk3Gui_Dialog_Unextend(dlg);
return 0;
}
GWENHYWFAR_CB int GTK3_Gui_RunDialog(GWEN_GUI *gui, GWEN_DIALOG *dlg, int untilEnd) {
int rv;
assert(dlg);
rv=GTK3_Gui_Dialog_Run(dlg, untilEnd);
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
return rv;
}
return rv;
}
GWENHYWFAR_CB int GTK3_Gui_GetFileName(GWEN_GUI *gui,
const char *caption,
GWEN_GUI_FILENAME_TYPE fnt,
uint32_t flags,
const char *patterns,
GWEN_BUFFER *pathBuffer,
uint32_t guiid) {
char *folder=NULL;
char *fileName=NULL;
if (GWEN_Buffer_GetUsedBytes(pathBuffer)) {
folder=strdup(GWEN_Buffer_GetStart(pathBuffer));
fileName=strchr(folder, GWEN_DIR_SEPARATOR);
if (fileName) {
*fileName=0;
fileName++;
if (*fileName==0)
fileName=NULL;
}
}
switch(fnt) {
case GWEN_Gui_FileNameType_OpenFileName: {
GtkWidget *dialog;
if (!(caption && *caption))
caption=I18N("Open File");
dialog=gtk_file_chooser_dialog_new (caption,
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Open", GTK_RESPONSE_ACCEPT,
NULL);
if (folder && *folder)
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), folder);
if (fileName && *fileName)
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fileName);
if (gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_ACCEPT) {
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
GWEN_Buffer_Reset(pathBuffer);
GWEN_Buffer_AppendString(pathBuffer, filename);
g_free (filename);
gtk_widget_destroy (dialog);
free(folder);
return 0;
}
gtk_widget_destroy (dialog);
free(folder);
return GWEN_ERROR_USER_ABORTED;
}
case GWEN_Gui_FileNameType_SaveFileName: {
GtkWidget *dialog;
if (!(caption && *caption))
caption=I18N("Save File");
dialog=gtk_file_chooser_dialog_new (caption,
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Open", GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
if (folder && *folder)
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), folder);
if (fileName && *fileName)
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fileName);
if (gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_ACCEPT) {
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
GWEN_Buffer_Reset(pathBuffer);
GWEN_Buffer_AppendString(pathBuffer, filename);
g_free(filename);
gtk_widget_destroy(dialog);
free(folder);
return 0;
}
gtk_widget_destroy (dialog);
free(folder);
return GWEN_ERROR_USER_ABORTED;
}
case GWEN_Gui_FileNameType_OpenDirectory: {
GtkWidget *dialog;
if (!(caption && *caption))
caption=I18N("Select Folder");
dialog=gtk_file_chooser_dialog_new (caption,
NULL,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Open", GTK_RESPONSE_ACCEPT,
NULL);
if (gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_ACCEPT) {
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
GWEN_Buffer_Reset(pathBuffer);
GWEN_Buffer_AppendString(pathBuffer, filename);
g_free (filename);
gtk_widget_destroy (dialog);
free(folder);
return 0;
}
gtk_widget_destroy (dialog);
free(folder);
return GWEN_ERROR_USER_ABORTED;
}
default:
break;
}
free(folder);
return GWEN_ERROR_USER_ABORTED;
}

View File

@ -0,0 +1,37 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifndef GTK3_GUI_H
#define GTK3_GUI_H
#include <gtk/gtk.h>
#if defined __GNUC__ && (! defined (__sun)) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
# ifdef BUILDING_GTK3_GUI
# define GTK3GUI_API __attribute__ ((visibility("default")))
# else
# define GTK3GUI_API
# endif
#else
# define GTK3GUI_API
#endif
#include <gwenhywfar/gui.h>
GTK3GUI_API GWEN_GUI *Gtk3_Gui_new(void);
#endif

View File

@ -0,0 +1,551 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#include "gtk3_gui_dialog_p.h"
#include <assert.h>
#include <gwenhywfar/inherit.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/gui_be.h>
#include <gwenhywfar/i18n.h>
#include <gwenhywfar/text.h>
#include <gwenhywfar/mdigest.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/directory.h>
#include <ctype.h>
#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg)
#define GTK3_DIALOG_WIDGET_REAL 0
#define GTK3_DIALOG_WIDGET_CONTENT 1
#define GTK3_DIALOG_WIDGET_DATA 2
#define GTK3_DIALOG_STRING_TITLE 0
#define GTK3_DIALOG_STRING_VALUE 1
#include "w_combobox.c"
#include "w_label.c"
#include "w_dialog.c"
#include "w_gridlayout.c"
#include "w_hlayout.c"
#include "w_hline.c"
#include "w_hspacer.c"
#include "w_vlayout.c"
#include "w_vline.c"
#include "w_vspacer.c"
#include "w_pushbutton.c"
#include "w_lineedit.c"
#include "w_textedit.c"
#include "w_textbrowser.c"
#include "w_stack.c"
#include "w_tabbook.c"
#include "w_groupbox.c"
#include "w_progressbar.c"
#include "w_listbox.c"
#include "w_checkbox.c"
#include "w_scrollarea.c"
#include "w_radiobutton.c"
#include "w_spinbox.c"
GWEN_INHERIT(GWEN_DIALOG, GTK3_GUI_DIALOG)
void Gtk3Gui_Dialog_Extend(GWEN_DIALOG *dlg) {
GTK3_GUI_DIALOG *xdlg;
GWEN_NEW_OBJECT(GTK3_GUI_DIALOG, xdlg);
GWEN_INHERIT_SETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg, xdlg, Gtk3Gui_Dialog_FreeData);
/* set virtual functions */
xdlg->setIntPropertyFn=GWEN_Dialog_SetSetIntPropertyFn(dlg, Gtk3Gui_Dialog_SetIntProperty);
xdlg->getIntPropertyFn=GWEN_Dialog_SetGetIntPropertyFn(dlg, Gtk3Gui_Dialog_GetIntProperty);
xdlg->setCharPropertyFn=GWEN_Dialog_SetSetCharPropertyFn(dlg, Gtk3Gui_Dialog_SetCharProperty);
xdlg->getCharPropertyFn=GWEN_Dialog_SetGetCharPropertyFn(dlg, Gtk3Gui_Dialog_GetCharProperty);
}
void Gtk3Gui_Dialog_Unextend(GWEN_DIALOG *dlg) {
GTK3_GUI_DIALOG *xdlg;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
/* reset virtual functions */
GWEN_Dialog_SetSetIntPropertyFn(dlg, xdlg->setIntPropertyFn);
GWEN_Dialog_SetGetIntPropertyFn(dlg, xdlg->getIntPropertyFn);
GWEN_Dialog_SetSetCharPropertyFn(dlg, xdlg->setCharPropertyFn);
GWEN_Dialog_SetGetCharPropertyFn(dlg, xdlg->getCharPropertyFn);
GWEN_INHERIT_UNLINK(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
}
void GWENHYWFAR_CB Gtk3Gui_Dialog_FreeData(void *bp, void *p) {
GTK3_GUI_DIALOG *xdlg;
xdlg=(GTK3_GUI_DIALOG*) p;
if (xdlg->mainWidget)
gtk_widget_destroy(xdlg->mainWidget);
GWEN_FREE_OBJECT(xdlg);
}
GtkWidget *Gtk3Gui_Dialog_GetMainWidget(const GWEN_DIALOG *dlg) {
GTK3_GUI_DIALOG *xdlg;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
return xdlg->mainWidget;
}
GWENHYWFAR_CB int Gtk3Gui_Dialog_SetIntProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
return GWEN_Widget_SetIntProperty(w, prop, index, value, doSignal);
}
GWENHYWFAR_CB int Gtk3Gui_Dialog_GetIntProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
return GWEN_Widget_GetIntProperty(w, prop, index, defaultValue);
}
GWENHYWFAR_CB int Gtk3Gui_Dialog_SetCharProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
return GWEN_Widget_SetCharProperty(w, prop, index, value, doSignal);
}
GWENHYWFAR_CB const char *Gtk3Gui_Dialog_GetCharProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
return GWEN_Widget_GetCharProperty(w, prop, index, defaultValue);
}
int Gtk3Gui_Dialog_Setup(GWEN_DIALOG *dlg, GtkWidget *parentWindow) {
GTK3_GUI_DIALOG *xdlg;
GWEN_WIDGET_TREE *wtree;
GWEN_WIDGET *w;
GtkWindow *gw;
int rv;
GList *tll;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
wtree=GWEN_Dialog_GetWidgets(dlg);
if (wtree==NULL) {
DBG_ERROR(GWEN_LOGDOMAIN, "No widget tree in dialog");
return GWEN_ERROR_NOT_FOUND;
}
w=GWEN_Widget_Tree_GetFirst(wtree);
if (w==NULL) {
DBG_ERROR(GWEN_LOGDOMAIN, "No widgets in dialog");
return GWEN_ERROR_NOT_FOUND;
}
rv=Gtk3Gui_Dialog_SetupTree(w);
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
return rv;
}
gw=GTK_WINDOW(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
gtk_window_set_type_hint(GTK_WINDOW(gw), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_position (GTK_WINDOW (gw), GTK_WIN_POS_CENTER_ON_PARENT);
/*gtk_window_set_keep_above(GTK_WINDOW(gw), TRUE);*/
xdlg->mainWidget=GTK_WIDGET(gw);
tll=gtk_window_list_toplevels();
if (tll) {
GList* element;
GtkWindow *topLevel=NULL;
for (element = tll; element; element = g_list_next(element)) {
GtkWindow* win = GTK_WINDOW(element->data);
if (gtk_window_is_active(win)) {
topLevel=win;
break;
}
}
g_list_free(tll);
if (topLevel) {
DBG_NOTICE(GWEN_LOGDOMAIN, "Found active window [%s]",
gtk_window_get_title(topLevel));
gtk_window_set_transient_for(gw, topLevel);
}
else {
DBG_ERROR(GWEN_LOGDOMAIN, "No active window found...");
}
}
return 0;
}
void Gtk3Gui_Dialog_Leave(GWEN_DIALOG *dlg, int result) {
GTK3_GUI_DIALOG *xdlg;
GWEN_DIALOG *parent;
/* get toplevel dialog, the one which actually is the GUI dialog */
while( (parent=GWEN_Dialog_GetParentDialog(dlg)) )
dlg=parent;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
xdlg->response=result;
if (g_main_loop_is_running(xdlg->loop))
g_main_loop_quit(xdlg->loop);
}
static void
run_unmap_handler (GtkWindow *window, gpointer data) {
GWEN_DIALOG *dlg;
GTK3_GUI_DIALOG *xdlg;
dlg=data;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
Gtk3Gui_Dialog_Leave(dlg, 0);
}
static gint
run_delete_handler(GtkWindow *window,
GdkEventAny *event,
gpointer data) {
GWEN_DIALOG *dlg;
GTK3_GUI_DIALOG *xdlg;
dlg=data;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
Gtk3Gui_Dialog_Leave(dlg, 0);
return TRUE; /* Do not destroy */
}
static void
run_destroy_handler(GtkWindow *window, gpointer data) {
GWEN_DIALOG *dlg;
GTK3_GUI_DIALOG *xdlg;
dlg=data;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
xdlg->destroyed=1;
}
int GTK3_Gui_Dialog_Run(GWEN_DIALOG *dlg, int untilEnd) {
GTK3_GUI_DIALOG *xdlg;
GtkWidget *g;
assert(dlg);
xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, GTK3_GUI_DIALOG, dlg);
assert(xdlg);
g=Gtk3Gui_Dialog_GetMainWidget(dlg);
if (g==NULL) {
DBG_ERROR(GWEN_LOGDOMAIN, "No main widget");
Gtk3Gui_Dialog_Unextend(dlg);
return GWEN_ERROR_INVALID;
}
xdlg->unmap_handler =
g_signal_connect(g,
"unmap",
G_CALLBACK (run_unmap_handler),
dlg);
xdlg->delete_handler =
g_signal_connect(g,
"delete-event",
G_CALLBACK (run_delete_handler),
dlg);
xdlg->destroy_handler =
g_signal_connect(g,
"destroy",
G_CALLBACK (run_destroy_handler),
dlg);
xdlg->loop=g_main_loop_new(NULL, FALSE);
if (untilEnd)
g_main_loop_run(xdlg->loop);
else {
GMainContext *ctx;
ctx=g_main_loop_get_context(xdlg->loop);
while(g_main_context_pending(ctx))
g_main_context_iteration(ctx, FALSE);
}
g_main_loop_unref(xdlg->loop);
if (!xdlg->destroyed) {
g_signal_handler_disconnect(g, xdlg->unmap_handler);
g_signal_handler_disconnect(g, xdlg->delete_handler);
g_signal_handler_disconnect(g, xdlg->destroy_handler);
}
return xdlg->response;
}
int Gtk3Gui_Dialog_SetupTree(GWEN_WIDGET *w) {
int rv;
switch(GWEN_Widget_GetType(w)) {
case GWEN_Widget_TypeDialog:
rv=Gtk3Gui_WDialog_Setup(w);
break;
case GWEN_Widget_TypeLabel:
rv=Gtk3Gui_WLabel_Setup(w);
break;
case GWEN_Widget_TypeGridLayout:
rv=Gtk3Gui_WGridLayout_Setup(w);
break;
case GWEN_Widget_TypeVLayout:
rv=Gtk3Gui_WVLayout_Setup(w);
break;
case GWEN_Widget_TypeHLayout:
rv=Gtk3Gui_WHLayout_Setup(w);
break;
case GWEN_Widget_TypePushButton:
rv=Gtk3Gui_WPushButton_Setup(w);
break;
case GWEN_Widget_TypeLineEdit:
rv=Gtk3Gui_WLineEdit_Setup(w);
break;
case GWEN_Widget_TypeHLine:
rv=Gtk3Gui_WHLine_Setup(w);
break;
case GWEN_Widget_TypeVLine:
rv=Gtk3Gui_WVLine_Setup(w);
break;
case GWEN_Widget_TypeVSpacer:
rv=Gtk3Gui_WVSpacer_Setup(w);
break;
case GWEN_Widget_TypeHSpacer:
rv=Gtk3Gui_WHSpacer_Setup(w);
break;
case GWEN_Widget_TypeComboBox:
rv=Gtk3Gui_WComboBox_Setup(w);
break;
case GWEN_Widget_TypeTextEdit:
rv=Gtk3Gui_WTextEdit_Setup(w);
break;
case GWEN_Widget_TypeWidgetStack:
rv=Gtk3Gui_WStack_Setup(w);
break;
case GWEN_Widget_TypeTabBook:
rv=Gtk3Gui_WTabBook_Setup(w);
break;
case GWEN_Widget_TypeTabPage:
/* just re-use vbox */
GWEN_Widget_AddFlags(w, GWEN_WIDGET_FLAGS_FILLX | GWEN_WIDGET_FLAGS_FILLY);
rv=Gtk3Gui_WVLayout_Setup(w);
break;
case GWEN_Widget_TypeGroupBox:
rv=Gtk3Gui_WGroupBox_Setup(w);
break;
case GWEN_Widget_TypeTextBrowser:
rv=Gtk3Gui_WTextBrowser_Setup(w);
break;
case GWEN_Widget_TypeProgressBar:
rv=Gtk3Gui_WProgressBar_Setup(w);
break;
case GWEN_Widget_TypeSpinBox:
rv=Gtk3Gui_WSpinBox_Setup(w);
break;
case GWEN_Widget_TypeListBox:
rv=Gtk3Gui_WListBox_Setup(w);
break;
case GWEN_Widget_TypeCheckBox:
rv=Gtk3Gui_WCheckBox_Setup(w);
break;
case GWEN_Widget_TypeScrollArea:
rv=Gtk3Gui_WScrollArea_Setup(w);
break;
case GWEN_Widget_TypeRadioButton:
rv=Gtk3Gui_WRadioButton_Setup(w);
break;
default:
DBG_ERROR(GWEN_LOGDOMAIN, "Unhandled widget type %d", GWEN_Widget_GetType(w));
rv=GWEN_ERROR_INVALID;
break;
}
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
return rv;
}
else {
GWEN_WIDGET *wChild;
/* handle children */
wChild=GWEN_Widget_Tree_GetFirstChild(w);
while(wChild) {
/* recursion */
rv=Gtk3Gui_Dialog_SetupTree(wChild);
if (rv<0) {
DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
return rv;
}
wChild=GWEN_Widget_Tree_GetNext(wChild);
}
}
return 0;
}
int Gtk3Gui_GetRawText(const char *text, GWEN_BUFFER *tbuf) {
const char *p=0;
const char *p2=0;
if (text==NULL)
return 0;
/* find begin of HTML area */
p=text;
while ((p=strchr(p, '<'))) {
const char *t;
t=p;
t++;
if (toupper(*t)=='H') {
t++;
if (toupper(*t)=='T') {
t++;
if (toupper(*t)=='M') {
t++;
if (toupper(*t)=='L') {
t++;
if (toupper(*t)=='>') {
break;
}
}
}
}
}
p++;
} /* while */
/* find end of HTML area */
if (p) {
p2=p;
p2+=6; /* skip "<html>" */
while ((p2=strchr(p2, '<'))) {
const char *t;
t=p2;
t++;
if (toupper(*t)=='/') {
t++;
if (toupper(*t)=='H') {
t++;
if (toupper(*t)=='T') {
t++;
if (toupper(*t)=='M') {
t++;
if (toupper(*t)=='L') {
t++;
if (toupper(*t)=='>') {
break;
}
}
}
}
}
}
p2++;
} /* while */
}
if (p && p2) {
int startPos;
int endPos;
p2+=7; /* skip "</html>" */
startPos=(p-text);
endPos=(p2-text);
/* append stuff before startPos */
if (startPos)
GWEN_Buffer_AppendBytes(tbuf, text, startPos);
if (*p2)
GWEN_Buffer_AppendString(tbuf, p2);
return 0;
}
else {
GWEN_Buffer_AppendString(tbuf, text);
return 0;
}
}

View File

@ -0,0 +1,51 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifndef GTK3_GUI_DIALOG_L_H
#define GTK3_GUI_DIALOG_L_H
#include "gtk3_gui.h"
#include <gtk/gtk.h>
#include <gwenhywfar/dialog_be.h>
#define GTK3_GUI_DIALOG_DEFAULT_BOX_SPACING 3
typedef struct {
GWEN_DIALOG *dialog;
GtkWindow *window;
int response;
GMainLoop *loop;
int destroyed;
} RunInfo;
void Gtk3Gui_Dialog_Extend(GWEN_DIALOG *dlg);
void Gtk3Gui_Dialog_Unextend(GWEN_DIALOG *dlg);
int Gtk3Gui_Dialog_Setup(GWEN_DIALOG *dlg, GtkWidget *parentWindow);
GtkWidget *Gtk3Gui_Dialog_GetMainWidget(const GWEN_DIALOG *dlg);
int GTK3_Gui_Dialog_Run(GWEN_DIALOG *dlg, int timeout);
void Gtk3Gui_Dialog_Leave(GWEN_DIALOG *dlg, int result);
int Gtk3Gui_GetRawText(const char *text, GWEN_BUFFER *tbuf);
#endif

View File

@ -0,0 +1,72 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifndef GTK3_GUI_DIALOG_P_H
#define GTK3_GUI_DIALOG_P_H
#include "gtk3_gui_dialog_l.h"
typedef struct GTK3_GUI_DIALOG GTK3_GUI_DIALOG;
struct GTK3_GUI_DIALOG {
GWEN_DIALOG_SETINTPROPERTY_FN setIntPropertyFn;
GWEN_DIALOG_GETINTPROPERTY_FN getIntPropertyFn;
GWEN_DIALOG_SETCHARPROPERTY_FN setCharPropertyFn;
GWEN_DIALOG_GETCHARPROPERTY_FN getCharPropertyFn;
GtkWidget *mainWidget;
int response;
GMainLoop *loop;
int destroyed;
gulong unmap_handler;
gulong destroy_handler;
gulong delete_handler;
};
static void GWENHYWFAR_CB Gtk3Gui_Dialog_FreeData(void *bp, void *p);
static int GWENHYWFAR_CB Gtk3Gui_Dialog_SetIntProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal);
static int GWENHYWFAR_CB Gtk3Gui_Dialog_GetIntProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue);
static int GWENHYWFAR_CB Gtk3Gui_Dialog_SetCharProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal);
static const char * GWENHYWFAR_CB Gtk3Gui_Dialog_GetCharProperty(GWEN_DIALOG *dlg,
GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue);
static int Gtk3Gui_Dialog_SetupTree(GWEN_WIDGET *w);
#endif

View File

@ -0,0 +1,64 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#ifndef GTK3_GUI_P_H
#define GTK3_GUI_P_H
#include "gtk3_gui.h"
#include <gwenhywfar/gui_be.h>
typedef struct GTK3_GUI GTK3_GUI;
struct GTK3_GUI {
GWEN_GUI_EXEC_DIALOG_FN execDialogFn;
GWEN_GUI_OPEN_DIALOG_FN openDialogFn;
GWEN_GUI_CLOSE_DIALOG_FN closeDialogFn;
GWEN_GUI_RUN_DIALOG_FN runDialogFn;
GWEN_GUI_GET_FILENAME_FN getFileNameDialogFn;
};
static GWENHYWFAR_CB
void Gtk3_Gui_FreeData(void *bp, void *p);
static GWENHYWFAR_CB
int GTK3_Gui_ExecDialog(GWEN_GUI *gui,
GWEN_DIALOG *dlg,
uint32_t guiid);
static GWENHYWFAR_CB
int GTK3_Gui_OpenDialog(GWEN_GUI *gui,
GWEN_DIALOG *dlg,
uint32_t guiid);
static GWENHYWFAR_CB
int GTK3_Gui_CloseDialog(GWEN_GUI *gui, GWEN_DIALOG *dlg);
static GWENHYWFAR_CB
int GTK3_Gui_RunDialog(GWEN_GUI *gui, GWEN_DIALOG *dlg, int timeout);
static GWENHYWFAR_CB
int GTK3_Gui_GetFileName(GWEN_GUI *gui,
const char *caption,
GWEN_GUI_FILENAME_TYPE fnt,
uint32_t flags,
const char *patterns,
GWEN_BUFFER *pathBuffer,
uint32_t guiid);
#endif

View File

@ -0,0 +1,23 @@
# pkg-config configuration for gwengui_gtk3
# For information about the syntax, see pkg-config(1)
# General installation directories
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
pkgincludedir=@includedir@/gwenhywfar
datarootdir=@datarootdir@
datadir=@datadir@
bindir=@bindir@
sysconfdir=@sysconfdir@
# Human-readable name
Name: gwengui-gtk3
# Human-readable description
Description: GTK3 Implementation of the GWEN_DIALOG framework.
Version: @VERSION@
Libs: -L@libdir@ -lgwengui-gtk3
Cflags: -I@includedir@

View File

@ -0,0 +1,198 @@
/***************************************************************************
begin : Mon Jul 12 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WCheckBox_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g), (value==0)?FALSE:TRUE);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WCheckBox_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value:
return (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g))==TRUE)?1:0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WCheckBox_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
gtk_button_set_label(g, value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WCheckBox_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
return gtk_button_get_label(g);
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void Gtk3Gui_WCheckBox_Toggled_handler(GtkButton *button, gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeActivated,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static int Gtk3Gui_WCheckBox_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
gulong toggled_handler_id;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
/* create widget */
if (s && *s)
g=gtk_check_button_new_with_mnemonic(s);
else
g=gtk_check_button_new();
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WCheckBox_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WCheckBox_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WCheckBox_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WCheckBox_GetCharProperty);
toggled_handler_id=g_signal_connect(g,
"toggled",
G_CALLBACK (Gtk3Gui_WCheckBox_Toggled_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,294 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
typedef struct W_COMBOBOX W_COMBOBOX;
struct W_COMBOBOX {
GWEN_STRINGLIST *entries;
};
GWEN_INHERIT(GWEN_WIDGET, W_COMBOBOX)
static GWENHYWFAR_CB
int Gtk3Gui_WComboBox_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
W_COMBOBOX *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, W_COMBOBOX, w);
assert(xw);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Value:
gtk_combo_box_set_active(GTK_COMBO_BOX(g), value);
return 0;
case GWEN_DialogProperty_ClearValues: {
GtkListStore *store;
store=GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(g)));
assert(store);
gtk_list_store_clear(store);
GWEN_StringList_Clear(xw->entries);
return 0;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WComboBox_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Value: {
gint i;
i=gtk_combo_box_get_active(GTK_COMBO_BOX(g));
if (i==-1)
return defaultValue;
else
return i;
}
case GWEN_DialogProperty_ValueCount: {
GtkListStore *store;
gint i;
store=GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(g)));
assert(store);
i=gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
return i;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WComboBox_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
W_COMBOBOX *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, W_COMBOBOX, w);
assert(xw);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Value:
/* undefined */
break;
case GWEN_DialogProperty_AddValue: {
GtkListStore *store;
GtkTreeIter iter;
store=GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(g)));
assert(store);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, value, -1);
GWEN_StringList_AppendString(xw->entries, value, 0, 0);
return 0;
}
case GWEN_DialogProperty_ClearValues: {
GtkListStore *store;
store=GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(g)));
assert(store);
gtk_list_store_clear(store);
GWEN_StringList_Clear(xw->entries);
return 0;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WComboBox_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
W_COMBOBOX *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, W_COMBOBOX, w);
assert(xw);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Value: {
const char *s;
s=GWEN_StringList_StringAt(xw->entries, index);
if (s && *s)
return s;
else
return defaultValue;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void changed_handler(GtkWidget *comboBox, gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeActivated,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static void GWENHYWFAR_CB Gtk3Gui_WComboBox_FreeData(void *bp, void *p) {
W_COMBOBOX *xw;
xw=(W_COMBOBOX*) p;
GWEN_StringList_free(xw->entries);
GWEN_FREE_OBJECT(xw);
}
static
int Gtk3Gui_WComboBox_Setup(GWEN_WIDGET *w) {
W_COMBOBOX *xw;
GtkWidget *g;
GtkCellRenderer *cr;
GtkListStore *store;
uint32_t flags;
GWEN_WIDGET *wParent;
gulong changed_handler_id;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
/* create widget */
store=gtk_list_store_new(1, G_TYPE_STRING);
if (flags & GWEN_WIDGET_FLAGS_READONLY)
g=gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
else
/* TODO: why the heck does *this* combo box have two columns in the list?? */
g=gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
g_object_unref(store);
cr=gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (g), cr, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(g), cr, "text", 0, NULL);
GWEN_NEW_OBJECT(W_COMBOBOX, xw);
GWEN_INHERIT_SETDATA(GWEN_WIDGET, W_COMBOBOX, w, xw, Gtk3Gui_WComboBox_FreeData);
xw->entries=GWEN_StringList_new();
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WComboBox_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WComboBox_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WComboBox_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WComboBox_GetCharProperty);
changed_handler_id=g_signal_connect(g,
"changed",
G_CALLBACK (changed_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,202 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WDialog_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWindow *g;
g=GTK_WINDOW(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width: {
gint width, height;
gtk_window_get_size(GTK_WINDOW(g), &width, &height);
gtk_window_resize(GTK_WINDOW(g), value, height);
return 0;
}
case GWEN_DialogProperty_Height: {
gint width, height;
gtk_window_get_size(GTK_WINDOW(g), &width, &height);
gtk_window_resize(GTK_WINDOW(g), width, value);
return 0;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WDialog_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWindow *g;
g=GTK_WINDOW(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width: {
gint width, height;
gtk_window_get_size(GTK_WINDOW(g), &width, &height);
return width;
}
case GWEN_DialogProperty_Height: {
gint width, height;
gtk_window_get_size(GTK_WINDOW(g), &width, &height);
return height;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WDialog_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWindow *g;
g=GTK_WINDOW(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
gtk_window_set_title(GTK_WINDOW(g), value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WDialog_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWindow *g;
g=GTK_WINDOW(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
return gtk_window_get_title(GTK_WINDOW(g));
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WDialog_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GtkWidget *g;
GtkWidget *gChild;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
gtk_container_add(GTK_CONTAINER(g), gChild);
return 0;
}
static int Gtk3Gui_WDialog_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
flags=GWEN_Widget_GetFlags(w);
s=GWEN_Widget_GetText(w, 0);
g=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_modal(GTK_WINDOW(g), TRUE);
if (s && *s)
gtk_window_set_title(GTK_WINDOW(g), s);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WDialog_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WDialog_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WDialog_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WDialog_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WDialog_AddChildGuiWidget);
return 0;
}

View File

@ -0,0 +1,239 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
typedef struct {
int sortByRow;
int allocatedColumns;
int allocatedRows;
int currentColumn;
int currentRow;
} GTK3_GRIDLAYOUT_WIDGET;
GWEN_INHERIT(GWEN_WIDGET, GTK3_GRIDLAYOUT_WIDGET)
static GWENHYWFAR_CB
int Gtk3Gui_WGridLayout_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WGridLayout_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WGridLayout_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WGridLayout_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WGridLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GTK3_GRIDLAYOUT_WIDGET *xw;
GtkWidget *g;
GtkWidget *gChild;
uint32_t cflags;
int x;
int y;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, GTK3_GRIDLAYOUT_WIDGET, w);
assert(xw);
cflags=GWEN_Widget_GetFlags(wChild);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
if (xw->sortByRow) {
/* fill rows, enter next column if column full */
y=(xw->currentRow)++;
if (y>=xw->allocatedRows) {
xw->currentRow=0;
y=(xw->currentRow)++;
xw->currentColumn++;
}
x=xw->currentColumn;
if (x>=xw->allocatedColumns) {
xw->allocatedColumns=x+1;
}
}
else {
/* fill columns, enter next row if row full */
x=(xw->currentColumn)++;
if (x>=xw->allocatedColumns) {
xw->currentColumn=0;
x=(xw->currentColumn)++;
xw->currentRow++;
}
y=xw->currentRow;
if (y>=xw->allocatedRows) {
xw->allocatedRows=y+1;
}
}
gtk_grid_attach(GTK_GRID(g), gChild, x, y, 1, 1);
return 0;
}
static GWENHYWFAR_CB
void Gtk3Gui_WGridLayout_FreeData(void *bp, void *p) {
GTK3_GRIDLAYOUT_WIDGET *xw;
xw=(GTK3_GRIDLAYOUT_WIDGET*) p;
GWEN_FREE_OBJECT(xw);
}
static int Gtk3Gui_WGridLayout_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
GTK3_GRIDLAYOUT_WIDGET *xw;
int rows;
int cols;
GWEN_NEW_OBJECT(GTK3_GRIDLAYOUT_WIDGET, xw);
GWEN_INHERIT_SETDATA(GWEN_WIDGET, GTK3_GRIDLAYOUT_WIDGET, w, xw, Gtk3Gui_WGridLayout_FreeData);
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
cols=GWEN_Widget_GetColumns(w);
rows=GWEN_Widget_GetRows(w);
if (rows>0) {
xw->sortByRow=1;
xw->allocatedRows=rows;
xw->allocatedColumns=1;
}
else {
xw->sortByRow=0;
xw->allocatedColumns=cols;
xw->allocatedRows=1;
}
g=gtk_grid_new();
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WGridLayout_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WGridLayout_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WGridLayout_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WGridLayout_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WGridLayout_AddChildGuiWidget);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,195 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WGroupBox_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WGroupBox_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WGroupBox_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
gtk_frame_set_label(GTK_FRAME(g), value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WGroupBox_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
return gtk_frame_get_label(GTK_FRAME(g));
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WGroupBox_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GtkWidget *g;
GtkWidget *gChild;
uint32_t cflags;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
cflags=GWEN_Widget_GetFlags(wChild);
gtk_box_pack_start(GTK_BOX(g), gChild,
(cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
(cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
0);
return 0;
}
static int Gtk3Gui_WGroupBox_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
GtkWidget *gContent;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
g=gtk_frame_new(s);
gContent=gtk_box_new(GTK_ORIENTATION_VERTICAL,
GTK3_GUI_DIALOG_DEFAULT_BOX_SPACING);
gtk_container_add(GTK_CONTAINER(g), gContent);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) gContent);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WGroupBox_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WGroupBox_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WGroupBox_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WGroupBox_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WGroupBox_AddChildGuiWidget);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,164 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WHLayout_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WHLayout_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WHLayout_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WHLayout_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WHLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GtkWidget *g;
GtkWidget *gChild;
uint32_t cflags;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
cflags=GWEN_Widget_GetFlags(wChild);
gtk_box_pack_start(GTK_BOX(g), gChild,
(cflags & GWEN_WIDGET_FLAGS_FILLX)?TRUE:FALSE,
(cflags & GWEN_WIDGET_FLAGS_FILLX)?TRUE:FALSE,
0);
return 0;
}
static int Gtk3Gui_WHLayout_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,
GTK3_GUI_DIALOG_DEFAULT_BOX_SPACING);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WHLayout_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WHLayout_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WHLayout_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WHLayout_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WHLayout_AddChildGuiWidget);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,98 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WHLine_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WHLine_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static int Gtk3Gui_WHLine_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WHLine_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WHLine_GetIntProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,100 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WHSpacer_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WHSpacer_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static int Gtk3Gui_WHSpacer_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
GWEN_Widget_AddFlags(w, GWEN_WIDGET_FLAGS_FILLX);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WHSpacer_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WHSpacer_GetIntProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,118 @@
/***************************************************************************
begin : Mon Jul 12 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WImage_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WImage_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static int Gtk3Gui_WImage_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
const char *s;
GWEN_BUFFER *tbuf;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
s=GWEN_Widget_GetImageFileName(w);
if (s && *s) {
GWEN_STRINGLIST *sl;
sl=GWEN_Dialog_GetMediaPaths(GWEN_Widget_GetDialog(w));
if (sl) {
int rv;
rv=GWEN_Directory_FindFileInPaths(sl, s, tbuf);
if (rv<0) {
DBG_ERROR(GWEN_LOGDOMAIN, "Image file [%s] not found (%d)", s, rv);
/* ignore result here, instead create GtkImage with "broken mage" later */
}
}
}
g=gtk_image_new_from_file(GWEN_Buffer_GetStart(tbuf));
GWEN_Buffer_free(tbuf);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WImage_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WImage_GetIntProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,177 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WLabel_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkLabel *g;
g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WLabel_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkLabel *g;
g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WLabel_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkLabel *g;
GWEN_BUFFER *tbuf;
g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
tbuf=GWEN_Buffer_new(0, 128, 0, 1);
if (value && *value)
Gtk3Gui_GetRawText(value, tbuf);
switch(prop) {
case GWEN_DialogProperty_Title:
gtk_label_set_text(g, GWEN_Buffer_GetStart(tbuf));
GWEN_Buffer_free(tbuf);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
GWEN_Buffer_free(tbuf);
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WLabel_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkLabel *g;
g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
return gtk_label_get_label(g);
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static int Gtk3Gui_WLabel_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
GWEN_BUFFER *tbuf;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
tbuf=GWEN_Buffer_new(0, 128, 0, 1);
if (s && *s)
Gtk3Gui_GetRawText(s, tbuf);
g=gtk_label_new(GWEN_Buffer_GetStart(tbuf));
GWEN_Buffer_free(tbuf);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WLabel_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WLabel_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WLabel_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WLabel_GetCharProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,224 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WLineEdit_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WLineEdit_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WLineEdit_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Value:
gtk_entry_set_text(GTK_ENTRY(g), value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WLineEdit_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Value:
return gtk_entry_get_text(GTK_ENTRY(g));
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void Gtk3Gui_WLineEdit_Deleted_text_handler(GtkEntryBuffer *entrybuffer,
guint arg1,
guint arg2,
gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeValueChanged,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static void Gtk3Gui_WLineEdit_Inserted_text_handler(GtkEntryBuffer *entrybuffer,
guint arg1,
gchar *arg2,
guint arg3,
gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeValueChanged,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static int Gtk3Gui_WLineEdit_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
gulong deleted_text_handler_id;
gulong inserted_text_handler_id;
gboolean text_is_visible;
flags=GWEN_Widget_GetFlags(w);
text_is_visible = (flags & GWEN_WIDGET_FLAGS_PASSWORD) == 0;
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
/* create widget */
g=gtk_entry_new();
if (s && *s)
gtk_entry_set_text(GTK_ENTRY(g), s);
gtk_entry_set_visibility(GTK_ENTRY(g), text_is_visible);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WLineEdit_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WLineEdit_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WLineEdit_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WLineEdit_GetCharProperty);
deleted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
"deleted-text",
G_CALLBACK (Gtk3Gui_WLineEdit_Deleted_text_handler),
w);
inserted_text_handler_id=g_signal_connect(gtk_entry_get_buffer(GTK_ENTRY(g)),
"inserted-text",
G_CALLBACK (Gtk3Gui_WLineEdit_Inserted_text_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,540 @@
/***************************************************************************
begin : Fri Jul 09 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
#define W_LISTBOX_MAX_TYPES 256
static GWENHYWFAR_CB
int Gtk3Gui_WListBox_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Value: {
GtkTreePath *path;
path=gtk_tree_path_new_from_indices(value, -1);
gtk_tree_view_set_cursor(GTK_TREE_VIEW(g), path, NULL, FALSE);
gtk_tree_path_free(path);
return 0;
}
case GWEN_DialogProperty_SelectionMode: {
GtkTreeSelection *sel;
sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(g));
if (sel) {
switch(value) {
case GWEN_Dialog_SelectionMode_None:
gtk_tree_selection_set_mode(sel, GTK_SELECTION_NONE);
return 0;
case GWEN_Dialog_SelectionMode_Single:
gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
return 0;
case GWEN_Dialog_SelectionMode_Multi:
gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
return 0;
}
DBG_ERROR(GWEN_LOGDOMAIN, "Unknown SelectionMode %d", value);
return GWEN_ERROR_INVALID;
}
break;
}
case GWEN_DialogProperty_ColumnWidth: {
GtkTreeViewColumn *col;
col=gtk_tree_view_get_column(GTK_TREE_VIEW(g), index);
if (col) {
gtk_tree_view_column_set_fixed_width(col, value);
return 0;
}
/* no width */
return GWEN_ERROR_INVALID;
}
case GWEN_DialogProperty_SortDirection: {
GtkTreeViewColumn *col;
int i;
int cols;
/* remove sort indicator from all columns */
cols=GWEN_Widget_GetColumns(w);
for (i=0; i<cols; i++) {
col=gtk_tree_view_get_column(GTK_TREE_VIEW(g), index);
if (col) {
if (gtk_tree_view_column_get_sort_indicator(col)==TRUE)
gtk_tree_view_column_set_sort_indicator(col, FALSE);
}
}
if (value!=GWEN_DialogSortDirection_None) {
/* set sort indicator on given column */
col=gtk_tree_view_get_column(GTK_TREE_VIEW(g), index);
if (col) {
switch(value) {
case GWEN_DialogSortDirection_Up:
gtk_tree_view_column_set_sort_order(col, GTK_SORT_ASCENDING);
break;
case GWEN_DialogSortDirection_Down:
gtk_tree_view_column_set_sort_order(col, GTK_SORT_DESCENDING);
break;
default:
break;
}
}
}
return 0;
}
case GWEN_DialogProperty_ClearValues: {
GtkListStore *sto;
sto=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(g)));
if (sto)
gtk_list_store_clear(sto);
return 0;
}
case GWEN_DialogProperty_Sort:
/* NOOP, we use auto-sorting for now (TODO: figure out how to manually sort) */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WListBox_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Value: {
GtkTreePath *path=NULL;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(g), &path, NULL);
if (path!=NULL) {
gint *idxlist;
idxlist=gtk_tree_path_get_indices(path);
if (idxlist!=NULL) {
int res;
res=idxlist[0];
gtk_tree_path_free(path);
return res;
}
gtk_tree_path_free(path);
}
/* no cursor */
return -1;
}
case GWEN_DialogProperty_ColumnWidth: {
GtkTreeViewColumn *col;
col=gtk_tree_view_get_column(GTK_TREE_VIEW(g), index);
if (col)
return gtk_tree_view_column_get_width(col);
/* no width */
return -1;
}
case GWEN_DialogProperty_SortDirection: {
GtkTreeViewColumn *col;
col=gtk_tree_view_get_column(GTK_TREE_VIEW(g), index);
if (col) {
if (gtk_tree_view_column_get_sort_indicator(col)==TRUE) {
switch(gtk_tree_view_column_get_sort_order(col)) {
case GTK_SORT_ASCENDING:
return GWEN_DialogSortDirection_Up;
case GTK_SORT_DESCENDING:
return GWEN_DialogSortDirection_Down;
default:
break;
}
}
/*break; <- this is wrong here, isn't it? */
}
return GWEN_DialogSortDirection_None;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function %d is not appropriate for this type of widget (%s)",
prop,
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WListBox_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title: {
int cols=0;
if (value && *value) {
int i;
int l;
l=strlen(value);
cols=1;
for (i=0; i<l; i++) {
if (value[i]=='\t')
cols++;
}
}
if (cols) {
GType types[W_LISTBOX_MAX_TYPES];
GtkListStore *sto;
int i;
const char *s;
GtkTreeViewColumn *col;
char *vcopy;
char *p;
if (cols>W_LISTBOX_MAX_TYPES)
cols=W_LISTBOX_MAX_TYPES;
for (i=0; i<cols; i++)
types[i]=G_TYPE_STRING;
sto=gtk_list_store_newv(cols, types);
s=value;
/* clear current headers in tree view */
while( (col=gtk_tree_view_get_column(GTK_TREE_VIEW(g), 0)) )
gtk_tree_view_remove_column(GTK_TREE_VIEW(g), col);
/* set new model */
gtk_tree_view_set_model(GTK_TREE_VIEW(g), GTK_TREE_MODEL(sto));
/* insert new headers */
i=0;
vcopy=strdup(value);
p=vcopy;
while(*p && i<cols) {
char *pT;
GtkCellRenderer *renderer;
pT=strchr(p, '\t');
if (pT)
*pT=0;
renderer=gtk_cell_renderer_text_new();
col=gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, p);
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_set_sort_column_id(col, i);
gtk_tree_view_column_set_resizable(col, TRUE);
gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_attributes(col, renderer, "text", i, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(g), col);
if (pT)
p=pT+1;
else
/* no more tab, all columns done */
break;
i++;
}
free(vcopy);
GWEN_Widget_SetColumns(w, cols);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(g), TRUE);
}
else {
DBG_ERROR(GWEN_LOGDOMAIN, "No columns (empty title)");
return GWEN_ERROR_INVALID;
}
return 0;
}
case GWEN_DialogProperty_ClearValues: {
GtkListStore *sto;
sto=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(g)));
if (sto)
gtk_list_store_clear(sto);
return 0;
}
case GWEN_DialogProperty_AddValue: {
GtkListStore *sto;
sto=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(g)));
if (sto) {
GtkTreeIter iter;
int cols;
int i;
char *vcopy;
char *p;
cols=GWEN_Widget_GetColumns(w);
vcopy=strdup(value);
p=vcopy;
i=0;
gtk_list_store_append(sto, &iter);
while(*p && i<cols) {
char *pT;
GValue val= {0};
g_value_init(&val, G_TYPE_STRING);
pT=strchr(p, '\t');
if (pT)
*pT=0;
g_value_set_string(&val, p);
gtk_list_store_set_value(sto, &iter, i, &val);
g_value_unset(&val);
if (pT)
p=pT+1;
else
/* no more tabs, all columns done */
break;
i++;
}
free(vcopy);
}
return 0;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WListBox_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title: {
GList *cols;
cols=gtk_tree_view_get_columns(GTK_TREE_VIEW(g));
if (cols) {
GList *le;
GWEN_BUFFER *tbuf;
int cnt=0;
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
le=g_list_first(cols);
while(le) {
const gchar *s;
if (cnt)
GWEN_Buffer_AppendByte(tbuf, '\t');
s=gtk_tree_view_column_get_title(GTK_TREE_VIEW_COLUMN(le->data));
if (s && *s)
GWEN_Buffer_AppendString(tbuf, s);
cnt++;
le=g_list_next(le);
} /* while */
GWEN_Widget_SetText(w, GTK3_DIALOG_STRING_TITLE, GWEN_Buffer_GetStart(tbuf));
GWEN_Buffer_free(tbuf);
g_list_free(cols);
return GWEN_Widget_GetText(w, GTK3_DIALOG_STRING_TITLE);
}
return defaultValue;
}
case GWEN_DialogProperty_Value: {
GtkTreePath *path;
path=gtk_tree_path_new_from_indices(index, -1);
if (path!=NULL) {
GtkListStore *sto;
GtkTreeIter iter;
sto=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(g)));
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(sto), &iter, path)) {
GList *cols;
cols=gtk_tree_view_get_columns(GTK_TREE_VIEW(g));
if (cols) {
GList *le;
GWEN_BUFFER *tbuf;
int cnt=0;
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
le=g_list_first(cols);
while(le) {
gchar *s;
if (cnt)
GWEN_Buffer_AppendByte(tbuf, '\t');
gtk_tree_model_get(GTK_TREE_MODEL(sto), &iter, cnt, &s, -1, NULL);
if (s) {
GWEN_Buffer_AppendString(tbuf, s);
g_free(s);
}
cnt++;
le=g_list_next(le);
} /* while */
GWEN_Widget_SetText(w, GTK3_DIALOG_STRING_VALUE, GWEN_Buffer_GetStart(tbuf));
GWEN_Buffer_free(tbuf);
g_list_free(cols);
return GWEN_Widget_GetText(w, GTK3_DIALOG_STRING_VALUE);
}
}
gtk_tree_path_free(path);
}
return defaultValue;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void Gtk3Gui_WListBox_CursorChanged_handler(GtkTreeView *g, gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeActivated,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static int Gtk3Gui_WListBox_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
GtkWidget *gScroll;
uint32_t flags;
GWEN_WIDGET *wParent;
gulong changed_handler_id;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
gScroll=gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gScroll),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
g=gtk_tree_view_new();
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(g), TRUE);
/* gtk_tree_view_set_rules_hint is deprecated in gtk-3.14 on the
* grounds that it's really up to the theme and the user whether the
* treeview should be drawn with alternating background colors. */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(g), TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_container_add(GTK_CONTAINER(gScroll), GTK_WIDGET(g));
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) gScroll);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WListBox_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WListBox_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WListBox_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WListBox_GetCharProperty);
changed_handler_id=g_signal_connect(g,
"cursor-changed",
G_CALLBACK (Gtk3Gui_WListBox_CursorChanged_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,239 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
typedef struct W_PROGRESSBAR W_PROGRESSBAR;
struct W_PROGRESSBAR {
int minValue;
int maxValue;
int currentValue;
};
GWEN_INHERIT(GWEN_WIDGET, W_PROGRESSBAR)
static GWENHYWFAR_CB
int Gtk3Gui_WProgressBar_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkProgressBar *g;
W_PROGRESSBAR *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, W_PROGRESSBAR, w);
assert(xw);
g=GTK_PROGRESS_BAR(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value: {
xw->currentValue=value;
if (xw->maxValue) {
gdouble d;
char numbuf[32];
d=(gdouble)(xw->currentValue-xw->minValue)/(gdouble)(xw->maxValue);
gtk_progress_bar_set_fraction(g, d);
snprintf(numbuf, sizeof(numbuf)-1, "%d %%", (int)(d*100.0));
numbuf[sizeof(numbuf)-1]=0;
gtk_progress_bar_set_text(g, numbuf);
}
else {
gtk_progress_bar_set_fraction(g, 0.0);
gtk_progress_bar_set_text(g, "");
}
return 0;
}
case GWEN_DialogProperty_MinValue: {
xw->minValue=value;
if (xw->maxValue) {
gdouble d;
char numbuf[32];
d=(gdouble)(xw->currentValue-xw->minValue)/(gdouble)(xw->maxValue);
gtk_progress_bar_set_fraction(g, d);
snprintf(numbuf, sizeof(numbuf)-1, "%d %%", (int)(d*100.0));
numbuf[sizeof(numbuf)-1]=0;
gtk_progress_bar_set_text(g, numbuf);
}
else {
gtk_progress_bar_set_fraction(g, 0.0);
gtk_progress_bar_set_text(g, "");
}
return 0;
}
case GWEN_DialogProperty_MaxValue: {
xw->maxValue=value;
if (xw->maxValue) {
gdouble d;
char numbuf[32];
d=(gdouble)(xw->currentValue-xw->minValue)/(gdouble)(xw->maxValue);
gtk_progress_bar_set_fraction(g, d);
snprintf(numbuf, sizeof(numbuf)-1, "%d %%", (int)(d*100.0));
numbuf[sizeof(numbuf)-1]=0;
gtk_progress_bar_set_text(g, numbuf);
return 0;
}
else {
gtk_progress_bar_set_fraction(g, 0.0);
gtk_progress_bar_set_text(g, "");
}
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WProgressBar_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkProgressBar *g;
W_PROGRESSBAR *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, W_PROGRESSBAR, w);
assert(xw);
g=GTK_PROGRESS_BAR(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value:
return xw->currentValue;
case GWEN_DialogProperty_MinValue:
return xw->minValue;
case GWEN_DialogProperty_MaxValue:
return xw->maxValue;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WProgressBar_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WProgressBar_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void GWENHYWFAR_CB Gtk3Gui_WProgressBar_FreeData(void *bp, void *p) {
W_PROGRESSBAR *xw;
xw=(W_PROGRESSBAR*) p;
GWEN_FREE_OBJECT(xw);
}
static int Gtk3Gui_WProgressBar_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
W_PROGRESSBAR *xw;
GWEN_NEW_OBJECT(W_PROGRESSBAR, xw);
GWEN_INHERIT_SETDATA(GWEN_WIDGET, W_PROGRESSBAR, w, xw, Gtk3Gui_WProgressBar_FreeData);
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
g=gtk_progress_bar_new();
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WProgressBar_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WProgressBar_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WProgressBar_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WProgressBar_GetCharProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,218 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WPushButton_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WPushButton_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WPushButton_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
gtk_button_set_label(g, value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WPushButton_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
return gtk_button_get_label(g);
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void Gtk3Gui_WPushButton_Clicked_handler(GtkButton *button, gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeActivated,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static int Gtk3Gui_WPushButton_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
gulong clicked_handler_id;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
/* create widget */
if (s && *s)
g=gtk_button_new_with_mnemonic(s);
else
g=gtk_button_new();
s=GWEN_Widget_GetIconFileName(w);
if (s && *s) {
GWEN_STRINGLIST *sl;
sl=GWEN_Dialog_GetMediaPaths(GWEN_Widget_GetDialog(w));
if (sl) {
int rv;
GWEN_BUFFER *tbuf;
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
rv=GWEN_Directory_FindFileInPaths(sl, s, tbuf);
if (rv<0) {
DBG_ERROR(GWEN_LOGDOMAIN, "Image file [%s] not found (%d)", s, rv);
/* ignore result here, instead create GtkImage with "broken mage" later */
}
else {
GtkWidget *gImage;
gImage=gtk_image_new_from_file(GWEN_Buffer_GetStart(tbuf));
gtk_button_set_image(GTK_BUTTON(g), gImage);
gtk_button_set_image_position(GTK_BUTTON(g), GTK_POS_LEFT);
}
GWEN_Buffer_free(tbuf);
}
}
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WPushButton_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WPushButton_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WPushButton_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WPushButton_GetCharProperty);
clicked_handler_id=g_signal_connect(g,
"clicked",
G_CALLBACK (Gtk3Gui_WPushButton_Clicked_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,222 @@
/***************************************************************************
begin : Mon Jul 12 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WRadioButton_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g), (value==0)?FALSE:TRUE);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WRadioButton_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value:
return (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g))==TRUE)?1:0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WRadioButton_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
gtk_button_set_label(g, value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WRadioButton_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkButton *g;
g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Title:
return gtk_button_get_label(g);
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void Gtk3Gui_WRadioButton_Toggled_handler(GtkButton *button, gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeActivated,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static int Gtk3Gui_WRadioButton_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
GWEN_WIDGET *wT;
gulong toggled_handler_id;
int groupId;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
groupId=GWEN_Widget_GetGroupId(w);
s=GWEN_Widget_GetText(w, 0);
/* create widget */
if (s && *s)
g=gtk_radio_button_new_with_mnemonic(NULL, s);
else
g=gtk_radio_button_new(NULL);
/* get root widget */
wT=wParent;
while(GWEN_Widget_Tree_GetParent(wT))
wT=GWEN_Widget_Tree_GetParent(wT);
/* get first radio button of the same group */
while(wT) {
if ((GWEN_Widget_GetType(wT)==GWEN_Widget_TypeRadioButton) &&
GWEN_Widget_GetGroupId(wT)==groupId)
break;
wT=GWEN_Widget_Tree_GetBelow(wT);
}
if (wT && wT!=w) {
GSList *grp;
grp=gtk_radio_button_get_group(GTK_RADIO_BUTTON(GWEN_Widget_GetImplData(wT, GTK3_DIALOG_WIDGET_REAL)));
gtk_radio_button_set_group(GTK_RADIO_BUTTON(g), grp);
}
/* set pointers */
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WRadioButton_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WRadioButton_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WRadioButton_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WRadioButton_GetCharProperty);
toggled_handler_id=g_signal_connect(g,
"toggled",
G_CALLBACK (Gtk3Gui_WRadioButton_Toggled_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,192 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WScrollArea_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g; /* text view */
GtkWidget *gs; /* scrollable window */
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(gs);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(gs), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(gs));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WScrollArea_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g; /* text view */
GtkWidget *gs; /* scrollable window */
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(gs);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(gs))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(gs))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WScrollArea_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g; /* scrollable window */
GtkWidget *gContent; /* vbox */
gContent=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(gContent);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WScrollArea_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *gs; /* scrollable window */
GtkWidget *g; /* vbox */
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(gs);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WScrollArea_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GtkWidget *g;
GtkWidget *gChild;
uint32_t cflags;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
cflags=GWEN_Widget_GetFlags(wChild);
gtk_box_pack_start(GTK_BOX(g), gChild,
(cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
(cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
0);
return 0;
}
static int Gtk3Gui_WScrollArea_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
GtkWidget *gContent;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
/* create widget */
g=gtk_scrolled_window_new(NULL, NULL);
gContent=gtk_box_new(GTK_ORIENTATION_VERTICAL,
GTK3_GUI_DIALOG_DEFAULT_BOX_SPACING);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) gContent);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WScrollArea_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WScrollArea_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WScrollArea_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WScrollArea_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WScrollArea_AddChildGuiWidget);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,215 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
typedef struct W_SPINBOX W_SPINBOX;
struct W_SPINBOX {
GtkAdjustment *adjustment;
};
GWEN_INHERIT(GWEN_WIDGET, W_SPINBOX)
static GWENHYWFAR_CB
int Gtk3Gui_WSpinBox_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
W_SPINBOX *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, W_SPINBOX, w);
assert(xw);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value:
gtk_adjustment_set_value(GTK_ADJUSTMENT(xw->adjustment), value);
return 0;
case GWEN_DialogProperty_MinValue:
gtk_adjustment_set_lower(GTK_ADJUSTMENT(xw->adjustment), value);
return 0;
case GWEN_DialogProperty_MaxValue:
gtk_adjustment_set_upper(GTK_ADJUSTMENT(xw->adjustment), value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WSpinBox_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
W_SPINBOX *xw;
assert(w);
xw=GWEN_INHERIT_GETDATA(GWEN_WIDGET, W_SPINBOX, w);
assert(xw);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
case GWEN_DialogProperty_Value:
return gtk_adjustment_get_value(GTK_ADJUSTMENT(xw->adjustment));
case GWEN_DialogProperty_MinValue:
return gtk_adjustment_get_lower(GTK_ADJUSTMENT(xw->adjustment));
case GWEN_DialogProperty_MaxValue:
return gtk_adjustment_get_upper(GTK_ADJUSTMENT(xw->adjustment));
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WSpinBox_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WSpinBox_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void GWENHYWFAR_CB Gtk3Gui_WSpinBox_FreeData(void *bp, void *p) {
W_SPINBOX *xw;
xw=(W_SPINBOX*) p;
GWEN_FREE_OBJECT(xw);
}
static void Gtk3Gui_WSpinBox_Changed_handler(GtkAdjustment *adjustment, gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeValueChanged,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static int Gtk3Gui_WSpinBox_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
W_SPINBOX *xw;
gulong changed_handler_id;
GWEN_NEW_OBJECT(W_SPINBOX, xw);
GWEN_INHERIT_SETDATA(GWEN_WIDGET, W_SPINBOX, w, xw, Gtk3Gui_WSpinBox_FreeData);
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
xw->adjustment=GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 5.0, 5.0));
g=gtk_spin_button_new(xw->adjustment, 1.0, 0);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WSpinBox_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WSpinBox_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WSpinBox_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WSpinBox_GetCharProperty);
changed_handler_id=g_signal_connect(g,
"value-changed",
G_CALLBACK (Gtk3Gui_WSpinBox_Changed_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,175 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
/*
* Note: This is a special use case for gtk_notebook.
* To use it as a WidgetStack we have to disable drawing od tabs
* and borders by calling:
* - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(g), FALSE);
* - gtk_notebook_set_show_border(GTK_NOTEBOOK(g), FALSE);
*
*/
static GWENHYWFAR_CB
int Gtk3Gui_WStack_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Value:
gtk_notebook_set_current_page(GTK_NOTEBOOK(g), value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WStack_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Value:
return gtk_notebook_get_current_page(GTK_NOTEBOOK(g));
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WStack_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WStack_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WStack_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GtkWidget *g;
GtkWidget *gChild;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
gtk_notebook_append_page(GTK_NOTEBOOK(g), gChild, NULL);
return 0;
}
static int Gtk3Gui_WStack_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_notebook_new();
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(g), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(g), FALSE);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WStack_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WStack_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WStack_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WStack_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WStack_AddChildGuiWidget);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,166 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WTabBook_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Value:
gtk_notebook_set_current_page(GTK_NOTEBOOK(g), value);
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WTabBook_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Value:
return gtk_notebook_get_current_page(GTK_NOTEBOOK(g));
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WTabBook_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WTabBook_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WTabBook_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GtkWidget *g;
GtkWidget *gChild;
const char *s;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
s=GWEN_Widget_GetText(wChild, 0);
gtk_notebook_append_page(GTK_NOTEBOOK(g), gChild, (s && *s)?gtk_label_new(s):NULL);
return 0;
}
static int Gtk3Gui_WTabBook_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_notebook_new();
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WTabBook_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WTabBook_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WTabBook_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WTabBook_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WTabBook_AddChildGuiWidget);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,230 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WTextBrowser_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g; /* text view */
GtkWidget *gs; /* scrollable window */
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(gs);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(gs), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(gs));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WTextBrowser_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g; /* text view */
GtkWidget *gs; /* scrollable window */
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(gs);
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(gs))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(gs))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WTextBrowser_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g; /* text view */
GtkWidget *gs; /* scrollable window */
GWEN_BUFFER *tbuf;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(gs);
tbuf=GWEN_Buffer_new(0, 128, 0, 1);
if (value && *value)
Gtk3Gui_GetRawText(value, tbuf);
switch(prop) {
case GWEN_DialogProperty_Value: {
GtkTextBuffer *tb;
GtkAdjustment *va;
tb=gtk_text_view_get_buffer(GTK_TEXT_VIEW(g));
assert(tb);
gtk_text_buffer_set_text(tb, GWEN_Buffer_GetStart(tbuf), -1);
/* scroll to end */
va=gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(gs));
if (va)
gtk_adjustment_set_value(va, gtk_adjustment_get_upper(va));
GWEN_Buffer_free(tbuf);
return 0;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
GWEN_Buffer_free(tbuf);
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WTextBrowser_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g; /* text view */
GtkWidget *gs; /* scrollable window */
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_CONTENT));
assert(g);
gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(gs);
switch(prop) {
case GWEN_DialogProperty_Value: {
GtkTextBuffer *tb;
GtkTextIter startIter;
GtkTextIter endIter;
gchar *s;
tb=gtk_text_view_get_buffer(GTK_TEXT_VIEW(g));
assert(tb);
gtk_text_buffer_get_start_iter(tb, &startIter);
gtk_text_buffer_get_end_iter(tb, &endIter);
s=gtk_text_buffer_get_text(tb, &startIter, &endIter, FALSE);
if (s) {
GWEN_Widget_SetText(w, GTK3_DIALOG_STRING_VALUE, s);
g_free(s);
return GWEN_Widget_GetText(w, GTK3_DIALOG_STRING_VALUE);
}
return defaultValue;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static int Gtk3Gui_WTextBrowser_Setup(GWEN_WIDGET *w) {
GtkWidget *gs;
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
/* create widget */
gs=gtk_scrolled_window_new(NULL, NULL);
g=gtk_text_view_new();
if (s && *s) {
GWEN_BUFFER *tbuf;
tbuf=GWEN_Buffer_new(0, 128, 0, 1);
Gtk3Gui_GetRawText(s, tbuf);
gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(g)), GWEN_Buffer_GetStart(tbuf), -1);
GWEN_Buffer_free(tbuf);
}
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) gs);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WTextBrowser_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WTextBrowser_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WTextBrowser_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WTextBrowser_GetCharProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,222 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WTextEdit_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WTextEdit_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
case GWEN_DialogProperty_Width:
case GWEN_DialogProperty_Height:
/* just ignore these for now */
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WTextEdit_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Value: {
GtkTextBuffer *tb;
GtkTextIter endIter;
tb=gtk_text_view_get_buffer(GTK_TEXT_VIEW(g));
assert(tb);
if (value && *value)
gtk_text_buffer_set_text(tb, value, -1);
else
gtk_text_buffer_set_text(tb, "", -1);
gtk_text_buffer_get_end_iter(tb, &endIter);
gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(g), &endIter, 0.5, FALSE, 0.0, 0.0);
return 0;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WTextEdit_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Value: {
GtkTextBuffer *tb;
GtkTextIter startIter;
GtkTextIter endIter;
gchar *s;
tb=gtk_text_view_get_buffer(GTK_TEXT_VIEW(g));
assert(tb);
gtk_text_buffer_get_start_iter(tb, &startIter);
gtk_text_buffer_get_end_iter(tb, &endIter);
s=gtk_text_buffer_get_text(tb, &startIter, &endIter, FALSE);
if (s) {
GWEN_Widget_SetText(w, GTK3_DIALOG_STRING_VALUE, s);
g_free(s);
return GWEN_Widget_GetText(w, GTK3_DIALOG_STRING_VALUE);
}
return defaultValue;
}
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static void Gtk3Gui_WTextEdit_Changed_handler(GtkTextBuffer *buffer, gpointer data) {
GWEN_WIDGET *w;
int rv;
w=data;
assert(w);
rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
GWEN_DialogEvent_TypeValueChanged,
GWEN_Widget_GetName(w));
if (rv==GWEN_DialogEvent_ResultAccept)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
else if (rv==GWEN_DialogEvent_ResultReject)
Gtk3Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
}
static int Gtk3Gui_WTextEdit_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
gulong changed_handler_id;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
s=GWEN_Widget_GetText(w, 0);
/* create widget */
g=gtk_text_view_new();
if (s && *s)
gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(g)), s, -1);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WTextEdit_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WTextEdit_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WTextEdit_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WTextEdit_GetCharProperty);
changed_handler_id=g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(g)),
"changed",
G_CALLBACK (Gtk3Gui_WTextEdit_Changed_handler),
w);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,161 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WVLayout_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WVLayout_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WVLayout_SetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
const char* Gtk3Gui_WVLayout_GetCharProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
const char *defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static GWENHYWFAR_CB
int Gtk3Gui_WVLayout_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild) {
GtkWidget *g;
GtkWidget *gChild;
uint32_t cflags;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
gChild=GTK_WIDGET(GWEN_Widget_GetImplData(wChild, GTK3_DIALOG_WIDGET_REAL));
assert(gChild);
cflags=GWEN_Widget_GetFlags(wChild);
gtk_box_pack_start(GTK_BOX(g), gChild,
(cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
(cflags & GWEN_WIDGET_FLAGS_FILLY)?TRUE:FALSE,
0);
return 0;
}
static int Gtk3Gui_WVLayout_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_box_new(GTK_ORIENTATION_VERTICAL,
GTK3_GUI_DIALOG_DEFAULT_BOX_SPACING);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WVLayout_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WVLayout_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk3Gui_WVLayout_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk3Gui_WVLayout_GetCharProperty);
GWEN_Widget_SetAddChildGuiWidgetFn(w, Gtk3Gui_WVLayout_AddChildGuiWidget);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,98 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WVLine_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WVLine_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static int Gtk3Gui_WVLine_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_separator_new(GTK_ORIENTATION_VERTICAL);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WVLine_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WVLine_GetIntProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -0,0 +1,98 @@
/***************************************************************************
begin : Sun May 16 2010
copyright : (C) 2010 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* Please see toplevel file COPYING for license details *
***************************************************************************/
static GWENHYWFAR_CB
int Gtk3Gui_WVSpacer_SetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int value,
int doSignal) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
return 0;
case GWEN_DialogProperty_Focus:
gtk_widget_grab_focus(GTK_WIDGET(g));
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return GWEN_ERROR_INVALID;
}
static GWENHYWFAR_CB
int Gtk3Gui_WVSpacer_GetIntProperty(GWEN_WIDGET *w,
GWEN_DIALOG_PROPERTY prop,
int index,
int defaultValue) {
GtkWidget *g;
g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL));
assert(g);
switch(prop) {
case GWEN_DialogProperty_Enabled:
return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
case GWEN_DialogProperty_Focus:
return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
return 0;
default:
break;
}
DBG_WARN(GWEN_LOGDOMAIN,
"Function is not appropriate for this type of widget (%s)",
GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
return defaultValue;
}
static int Gtk3Gui_WVSpacer_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
uint32_t flags;
GWEN_WIDGET *wParent;
flags=GWEN_Widget_GetFlags(w);
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
GWEN_Widget_AddFlags(w, GWEN_WIDGET_FLAGS_FILLY);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK3_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk3Gui_WVSpacer_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk3Gui_WVSpacer_GetIntProperty);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, w);
return 0;
}

View File

@ -1076,7 +1076,7 @@ then
AC_MSG_ERROR([Could not find aqbanking >= 4.0.0. If you use --enable-aqbanking, you MUST have aqbanking installed!])
])
# For libgwenhywfar > 3.99.20, look for its library gwengui-gtk2.
PKG_CHECK_MODULES([GWENGUI_GTK3], [gwengui-gtk3 gwenhywfar], [has_gwengui_gtk3=1], [has_gwengui_gtk2=0])
PKG_CHECK_MODULES([GWEN], [gwenhywfar], [has_gwen=1], [has_gwen=0])
# also check for ktoblzcheck
AC_CHECK_HEADERS(ktoblzcheck.h)
@ -1646,6 +1646,7 @@ AC_CONFIG_FILES(
borrowed/Makefile
borrowed/goffice/Makefile
borrowed/libc/Makefile
borrowed/gwengui-gtk3/Makefile
common/Makefile
common/debug/Makefile
common/debug/valgrind/Makefile

View File

@ -56,15 +56,18 @@ IF(WITH_AQBANKING)
TARGET_LINK_LIBRARIES(gncmod-aqbanking gnc-gnome gncmod-gnome-utils
gncmod-generic-import gncmod-register-core
gncmod-register-gnome gncmod-ledger-core gncmod-engine
gncmod-register-gnome gncmod-ledger-core gncmod-engine gwengui-gtk3
${AQB_EXPORT_SYMBOLS} ${AQBANKING_LDFLAGS}
${GWENHYWFAR_LDFLAGS} ${GWENGUI_GTK3_LDFLAGS}
${GWENHYWFAR_LDFLAGS}
${GNOME_LDFLAGS} ${KTOBLZCHECK_LDFLAGS} ${AQB_LIBSTDCXX})
TARGET_COMPILE_DEFINITIONS(gncmod-aqbanking PRIVATE -DG_LOG_DOMAIN=\"gnc.import.aqbanking\")
TARGET_INCLUDE_DIRECTORIES(gncmod-aqbanking PRIVATE ${AQBANKING_INCLUDE_DIRS}
${GWENHYWFAR_INCLUDE_DIRS} ${KTOBLZCHECK_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES(gncmod-aqbanking PRIVATE
${CMAKE_SOURCE_DIR}/borrowed/gwengui-gtk3
${AQBANKING_INCLUDE_DIRS}
${GWENHYWFAR_INCLUDE_DIRS}
${KTOBLZCHECK_INCLUDE_DIRS})
INSTALL(TARGETS gncmod-aqbanking
LIBRARY DESTINATION lib/gnucash

View File

@ -41,13 +41,14 @@ libgncmod_aqbanking_la_LIBADD = \
${top_builddir}/libgnucash/engine/libgncmod-engine.la \
${top_builddir}/libgnucash/core-utils/libgnc-core-utils.la \
${top_builddir}/libgnucash/gnc-module/libgnc-module.la \
${top_builddir}/borrowed/gwengui-gtk3/libgwengui-gtk3.la \
${GTK_LIBS} \
${GLIB_LIBS} \
${GWENGUI_GTK3_LIBS} \
${AQBANKING_LIBS}
AM_CPPFLAGS = \
-I${top_srcdir}/common \
-I${top_srcdir}/borrowed/gwengui-gtk3 \
-I${top_srcdir}/gnucash/import-export \
-I${top_srcdir}/gnucash/gnome \
-I${top_srcdir}/gnucash/register/ledger-core \

View File

@ -61,7 +61,7 @@
#define GNC_PREF_REMEMBER_PIN "remember-pin"
#ifdef USING_GWENHYWFAR_GTK3_GUI
# include <gwen-gui-gtk3/gtk3_gui.h>
# include <gtk3_gui.h>
#endif
/* This static indicates the debugging module that this .o belongs to. */