gwenhywfar 4.0.3
|
00001 /*************************************************************************** 00002 begin : Sun May 16 2010 00003 copyright : (C) 2010 by Martin Preuss 00004 email : martin@libchipcard.de 00005 00006 *************************************************************************** 00007 * Please see toplevel file COPYING for license details * 00008 ***************************************************************************/ 00009 00010 00011 00012 00013 00014 static GWENHYWFAR_CB 00015 int Gtk2Gui_WLabel_SetIntProperty(GWEN_WIDGET *w, 00016 GWEN_DIALOG_PROPERTY prop, 00017 int index, 00018 int value, 00019 int doSignal) { 00020 GtkLabel *g; 00021 00022 g=GTK_LABEL(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 /* just ignore these for now */ 00037 return 0; 00038 00039 default: 00040 break; 00041 } 00042 00043 DBG_WARN(GWEN_LOGDOMAIN, 00044 "Function is not appropriate for this type of widget (%s)", 00045 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w))); 00046 return GWEN_ERROR_INVALID; 00047 } 00048 00049 00050 00051 00052 static GWENHYWFAR_CB 00053 int Gtk2Gui_WLabel_GetIntProperty(GWEN_WIDGET *w, 00054 GWEN_DIALOG_PROPERTY prop, 00055 int index, 00056 int defaultValue) { 00057 GtkLabel *g; 00058 00059 g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL)); 00060 assert(g); 00061 00062 switch(prop) { 00063 case GWEN_DialogProperty_Enabled: 00064 return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0; 00065 00066 case GWEN_DialogProperty_Focus: 00067 return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0; 00068 return 0; 00069 00070 case GWEN_DialogProperty_Width: 00071 case GWEN_DialogProperty_Height: 00072 /* just ignore these for now */ 00073 return 0; 00074 00075 default: 00076 break; 00077 } 00078 00079 DBG_WARN(GWEN_LOGDOMAIN, 00080 "Function is not appropriate for this type of widget (%s)", 00081 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w))); 00082 return defaultValue; 00083 } 00084 00085 00086 00087 static GWENHYWFAR_CB 00088 int Gtk2Gui_WLabel_SetCharProperty(GWEN_WIDGET *w, 00089 GWEN_DIALOG_PROPERTY prop, 00090 int index, 00091 const char *value, 00092 int doSignal) { 00093 GtkLabel *g; 00094 GWEN_BUFFER *tbuf; 00095 00096 g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL)); 00097 assert(g); 00098 00099 tbuf=GWEN_Buffer_new(0, 128, 0, 1); 00100 if (value && *value) 00101 Gtk2Gui_GetRawText(value, tbuf); 00102 00103 switch(prop) { 00104 case GWEN_DialogProperty_Title: 00105 gtk_label_set_text(g, GWEN_Buffer_GetStart(tbuf)); 00106 GWEN_Buffer_free(tbuf); 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 GWEN_Buffer_free(tbuf); 00116 return GWEN_ERROR_INVALID; 00117 } 00118 00119 00120 00121 static GWENHYWFAR_CB 00122 const char* Gtk2Gui_WLabel_GetCharProperty(GWEN_WIDGET *w, 00123 GWEN_DIALOG_PROPERTY prop, 00124 int index, 00125 const char *defaultValue) { 00126 GtkLabel *g; 00127 00128 g=GTK_LABEL(GWEN_Widget_GetImplData(w, GTK2_DIALOG_WIDGET_REAL)); 00129 assert(g); 00130 00131 switch(prop) { 00132 case GWEN_DialogProperty_Title: 00133 return gtk_label_get_label(g); 00134 default: 00135 break; 00136 } 00137 00138 DBG_WARN(GWEN_LOGDOMAIN, 00139 "Function is not appropriate for this type of widget (%s)", 00140 GWEN_Widget_Type_toString(GWEN_Widget_GetType(w))); 00141 return defaultValue; 00142 } 00143 00144 00145 00146 int Gtk2Gui_WLabel_Setup(GWEN_WIDGET *w) { 00147 GtkWidget *g; 00148 const char *s; 00149 uint32_t flags; 00150 GWEN_WIDGET *wParent; 00151 GWEN_BUFFER *tbuf; 00152 00153 flags=GWEN_Widget_GetFlags(w); 00154 wParent=GWEN_Widget_Tree_GetParent(w); 00155 s=GWEN_Widget_GetText(w, 0); 00156 00157 tbuf=GWEN_Buffer_new(0, 128, 0, 1); 00158 if (s && *s) 00159 Gtk2Gui_GetRawText(s, tbuf); 00160 00161 g=gtk_label_new(GWEN_Buffer_GetStart(tbuf)); 00162 GWEN_Buffer_free(tbuf); 00163 GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_REAL, (void*) g); 00164 GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_CONTENT, (void*) g); 00165 00166 GWEN_Widget_SetSetIntPropertyFn(w, Gtk2Gui_WLabel_SetIntProperty); 00167 GWEN_Widget_SetGetIntPropertyFn(w, Gtk2Gui_WLabel_GetIntProperty); 00168 GWEN_Widget_SetSetCharPropertyFn(w, Gtk2Gui_WLabel_SetCharProperty); 00169 GWEN_Widget_SetGetCharPropertyFn(w, Gtk2Gui_WLabel_GetCharProperty); 00170 00171 if (wParent) 00172 GWEN_Widget_AddChildGuiWidget(wParent, w); 00173 00174 return 0; 00175 } 00176 00177