00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 static GWENHYWFAR_CB
00015 int Gtk2Gui_WCheckBox_SetIntProperty(GWEN_WIDGET *w,
00016 GWEN_DIALOG_PROPERTY prop,
00017 int index,
00018 int value,
00019 int doSignal) {
00020 GtkButton *g;
00021
00022 g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL));
00023 assert(g);
00024
00025 switch(prop) {
00026 case GWEN_DialogProperty_Enabled:
00027 gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
00028 return 0;
00029
00030 case GWEN_DialogProperty_Focus:
00031 gtk_widget_grab_focus(GTK_WIDGET(g));
00032 return 0;
00033
00034 case GWEN_DialogProperty_Width:
00035 case GWEN_DialogProperty_Height:
00036
00037 return 0;
00038
00039 case GWEN_DialogProperty_Value:
00040 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g), (value==0)?FALSE:TRUE);
00041 return 0;
00042
00043 default:
00044 break;
00045 }
00046
00047 DBG_WARN(GWEN_LOGDOMAIN,
00048 "Function is not appropriate for this type of widget (%s)",
00049 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00050 return GWEN_ERROR_INVALID;
00051 }
00052
00053
00054
00055
00056 static GWENHYWFAR_CB
00057 int Gtk2Gui_WCheckBox_GetIntProperty(GWEN_WIDGET *w,
00058 GWEN_DIALOG_PROPERTY prop,
00059 int index,
00060 int defaultValue) {
00061 GtkButton *g;
00062
00063 g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL));
00064 assert(g);
00065
00066 switch(prop) {
00067 case GWEN_DialogProperty_Enabled:
00068 return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
00069
00070 case GWEN_DialogProperty_Focus:
00071 return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
00072
00073 case GWEN_DialogProperty_Width:
00074 case GWEN_DialogProperty_Height:
00075
00076 return 0;
00077
00078 case GWEN_DialogProperty_Value:
00079 return (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g))==TRUE)?1:0;
00080
00081 default:
00082 break;
00083 }
00084
00085 DBG_WARN(GWEN_LOGDOMAIN,
00086 "Function is not appropriate for this type of widget (%s)",
00087 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00088 return defaultValue;
00089 }
00090
00091
00092
00093 static GWENHYWFAR_CB
00094 int Gtk2Gui_WCheckBox_SetCharProperty(GWEN_WIDGET *w,
00095 GWEN_DIALOG_PROPERTY prop,
00096 int index,
00097 const char *value,
00098 int doSignal) {
00099 GtkButton *g;
00100
00101 g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL));
00102 assert(g);
00103
00104 switch(prop) {
00105 case GWEN_DialogProperty_Title:
00106 gtk_button_set_label(g, value);
00107 return 0;
00108 default:
00109 break;
00110 }
00111
00112 DBG_WARN(GWEN_LOGDOMAIN,
00113 "Function is not appropriate for this type of widget (%s)",
00114 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00115 return GWEN_ERROR_INVALID;
00116 }
00117
00118
00119
00120 static GWENHYWFAR_CB
00121 const char* Gtk2Gui_WCheckBox_GetCharProperty(GWEN_WIDGET *w,
00122 GWEN_DIALOG_PROPERTY prop,
00123 int index,
00124 const char *defaultValue) {
00125 GtkButton *g;
00126
00127 g=GTK_BUTTON(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL));
00128 assert(g);
00129
00130 switch(prop) {
00131 case GWEN_DialogProperty_Title:
00132 return gtk_button_get_label(g);
00133 default:
00134 break;
00135 }
00136
00137 DBG_WARN(GWEN_LOGDOMAIN,
00138 "Function is not appropriate for this type of widget (%s)",
00139 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
00140 return defaultValue;
00141 }
00142
00143
00144
00145 static void Gtk2Gui_WCheckBox_Toggled_handler(GtkButton *button, gpointer data) {
00146 GWEN_WIDGET *w;
00147 int rv;
00148
00149 w=data;
00150 assert(w);
00151 rv=GWEN_Dialog_EmitSignal(GWEN_Widget_GetDialog(w),
00152 GWEN_DialogEvent_TypeActivated,
00153 GWEN_Widget_GetName(w));
00154 if (rv==GWEN_DialogEvent_ResultAccept)
00155 Gtk2Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 1);
00156 else if (rv==GWEN_DialogEvent_ResultReject)
00157 Gtk2Gui_Dialog_Leave(GWEN_Widget_GetTopDialog(w), 0);
00158 }
00159
00160
00161
00162 int Gtk2Gui_WCheckBox_Setup(GWEN_WIDGET *w) {
00163 GtkWidget *g;
00164 const char *s;
00165 uint32_t flags;
00166 GWEN_WIDGET *wParent;
00167 gulong toggled_handler_id;
00168
00169 flags=GWEN_Widget_GetFlags(w);
00170 wParent=GWEN_Widget_Tree_GetParent(w);
00171 s=GWEN_Widget_GetText(w, 0);
00172
00173
00174 if (s && *s)
00175 g=gtk_check_button_new_with_mnemonic(s);
00176 else
00177 g=gtk_check_button_new();
00178
00179 GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_REAL, (void*) g);
00180 GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_CONTENT, (void*) g);
00181
00182 GWEN_Widget_SetSetIntPropertyFn(w, Gtk2Gui_WCheckBox_SetIntProperty);
00183 GWEN_Widget_SetGetIntPropertyFn(w, Gtk2Gui_WCheckBox_GetIntProperty);
00184 GWEN_Widget_SetSetCharPropertyFn(w, Gtk2Gui_WCheckBox_SetCharProperty);
00185 GWEN_Widget_SetGetCharPropertyFn(w, Gtk2Gui_WCheckBox_GetCharProperty);
00186
00187 toggled_handler_id=g_signal_connect(g,
00188 "toggled",
00189 G_CALLBACK (Gtk2Gui_WCheckBox_Toggled_handler),
00190 w);
00191
00192 if (wParent)
00193 GWEN_Widget_AddChildGuiWidget(wParent, w);
00194
00195 return 0;
00196 }
00197
00198