static GWENHYWFAR_CB int Gtk2Gui_WTextEdit_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal) { GtkWidget *g; g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK2_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_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: if (value && *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 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_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; }
const char *getCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue) { QWidget *qw; QString str; qw=(QWidget*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); assert(qw); switch(prop) { case GWEN_DialogProperty_Title: str=qw->windowTitle(); if (str.isEmpty()) return defaultValue; else { GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8()); return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE); } break; default: break; } DBG_WARN(GWEN_LOGDOMAIN, "Function is not appropriate for this type of widget (%s)", GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget))); 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 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; }
int setCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal) { QTextEdit *qw; QString text; qw=(QTextEdit*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); assert(qw); if (value) text=QString::fromUtf8(value); switch(prop) { case GWEN_DialogProperty_Value: qw->setText(text); 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(_widget))); return GWEN_ERROR_INVALID; };
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_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_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 *Gtk2Gui_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, GTK2_DIALOG_WIDGET_CONTENT)); assert(g); gs=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK2_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 const char *Gtk2Gui_WTextEdit_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue) { GtkWidget *g; g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK2_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, GTK2_DIALOG_STRING_VALUE, s); g_free(s); return GWEN_Widget_GetText(w, GTK2_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 GWENHYWFAR_CB int Gtk2Gui_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, GTK2_DIALOG_WIDGET_CONTENT)); assert(gContent); g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK2_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* Gtk2Gui_WLabel_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue) { GtkLabel *g; g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK2_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 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 GWENHYWFAR_CB int Gtk2Gui_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, GTK2_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; }
int QT4_GuiDialog::setupTree(GWEN_WIDGET *w) { int rv; Qt4_W_Widget *xw=NULL; switch(GWEN_Widget_GetType(w)) { case GWEN_Widget_TypeDialog: xw=new Qt4_W_Dialog(w); break; case GWEN_Widget_TypeVLayout: xw=new Qt4_W_VLayout(w); break; case GWEN_Widget_TypeHLayout: xw=new Qt4_W_HLayout(w); break; case GWEN_Widget_TypeGridLayout: xw=new Qt4_W_GridLayout(w); break; case GWEN_Widget_TypeLabel: xw=new Qt4_W_Label(w); break; case GWEN_Widget_TypeLineEdit: xw=new Qt4_W_LineEdit(w); break; case GWEN_Widget_TypeVSpacer: case GWEN_Widget_TypeHSpacer: /* abuse widget */ xw=new Qt4_W_Widget(w); break; case GWEN_Widget_TypePushButton: xw=new Qt4_W_PushButton(w); break; case GWEN_Widget_TypeHLine: xw=new Qt4_W_HLine(w); break; case GWEN_Widget_TypeVLine: xw=new Qt4_W_VLine(w); break; case GWEN_Widget_TypeTextEdit: xw=new Qt4_W_TextEdit(w); break; case GWEN_Widget_TypeComboBox: xw=new Qt4_W_ComboBox(w); break; case GWEN_Widget_TypeTabBook: xw=new Qt4_W_TabBook(w); break; case GWEN_Widget_TypeTabPage: xw=new Qt4_W_VLayout(w); break; case GWEN_Widget_TypeCheckBox: xw=new Qt4_W_CheckBox(w); break; case GWEN_Widget_TypeGroupBox: xw=new Qt4_W_GroupBox(w); break; case GWEN_Widget_TypeWidgetStack: xw=new Qt4_W_WidgetStack(w); break; case GWEN_Widget_TypeTextBrowser: xw=new Qt4_W_TextBrowser(w); break; case GWEN_Widget_TypeScrollArea: xw=new Qt4_W_ScrollArea(w); break; case GWEN_Widget_TypeProgressBar: xw=new Qt4_W_ProgressBar(w); break; case GWEN_Widget_TypeListBox: xw=new Qt4_W_ListBox(w); break; case GWEN_Widget_TypeRadioButton: xw=new Qt4_W_RadioButton(w); break; case GWEN_Widget_TypeSpinBox: xw=new Qt4_W_SpinBox(w); break; default: DBG_ERROR(GWEN_LOGDOMAIN, "Unhandled widget type %d (%s)", GWEN_Widget_GetType(w), GWEN_Widget_Type_toString(GWEN_Widget_GetType(w))); break; } if (xw==NULL) { DBG_ERROR(GWEN_LOGDOMAIN, "No widget created."); return GWEN_ERROR_INTERNAL; } rv=xw->setup(); if (rv<0) { DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv); return rv; } else { GWEN_WIDGET *wChild; if (GWEN_Widget_GetType(w)==GWEN_Widget_TypeDialog) _mainWidget=(QT4_DialogBox*) GWEN_Widget_GetImplData(xw->getCInterface(), QT4_DIALOG_WIDGET_REAL); /* handle children */ wChild=GWEN_Widget_Tree_GetFirstChild(w); while(wChild) { /* recursion */ rv=setupTree(wChild); if (rv<0) { DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv); return rv; } wChild=GWEN_Widget_Tree_GetNext(wChild); } } return 0; }