This is the most broken part of estron - lots of work needed to remove Gtk1.2 and deprecated GtkCTree support.
Definition in file duifield-gtk.c.
#include "config.h"
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gnome.h>
#include "duifield.h"
#include "duifield-gtk.h"
#include "duifilter.h"
#include "duiresolver.h"
#include "perr.h"
#include "util.h"
#include "util-gtk.h"
#include "window.h"
Go to the source code of this file.
Functions | |
| static void | widget_field_clear (DuiField *f) |
| static void | widata_field_clear (DuiField *f) |
| static void | widarg_field_clear (DuiField *f) |
| static void | where_field_clear (DuiField *f) |
| static const char * | widget_get_value (DuiField *fs) |
| static void | widget_set_value (DuiField *fs, const char *val) |
| static const char * | widget_get_data (DuiField *fs) |
| static void | widget_set_data (DuiField *fs, const char *val) |
| static void | ctree_pre (DuiField *fld, gboolean do_clear) |
| static void | ctree_post (DuiField *fld) |
| static GtkCTreeNode * | ctree_recur (GtkCTree *ctree, GtkCTreeNode *start_ctn, int match_col, const char *match_value) |
| static gboolean | ctree_iter (DuiField *fld) |
| static void | clist_pre (DuiField *fld, gboolean do_clear) |
| static void | clist_post (DuiField *fld) |
| static gboolean | clist_iter (DuiField *fld) |
| static void | resolve_target (DuiField *target, DuiField *matcher) |
| static void | set_match_value (DuiField *fld, const char *val) |
| void | dui_field_set_widget (DuiField *fs, const char *widname, int colnum) |
| void | dui_field_set_wid_data (DuiField *fs, const char *widname, int colnum, const char *datakey) |
| void | dui_field_set_wid_arg (DuiField *fs, const char *widname, int colnum, const char *arg) |
| void | dui_field_set_wid_where (DuiField *fs, const char *widname, int colnum, const char *compareop) |
| static void | get_clist_row (GtkCList *clist, gint row, gint column, GdkEvent *event, DuiField *fs) |
| static void | unget_clist_row (GtkCList *clist, gint row, gint column, GdkEvent *event, DuiField *fs) |
| static void | get_ctree_row (GtkCList *clist, GtkCTreeNode *ctn, gint column, DuiField *fs) |
| static void | unget_ctree_row (GtkCList *clist, GtkCTreeNode *ctn, gint column, DuiField *fs) |
| static void | add_watcher (DuiField *fs, GtkWidget *w) |
| static void | clist_sort_column (GtkCList *clist, gint column, DuiField *f) |
| static void | add_sorter (DuiField *fld, GtkWidget *w) |
| static void | resolve_where (DuiField *fld) |
| static void | resolve_widget (DuiField *fs, GtkWidget *w) |
| void | dui_field_resolve_widget (DuiField *fld, gpointer ud) |
| static const char* widget_get_value | ( | DuiField * | fs | ) | [static] |
Definition at line 150 of file duifield-gtk.c.
00151 { 00152 GtkWidget *widget; 00153 const gchar * val = NULL; 00154 struct gtk_widget_s * gw = (struct gtk_widget_s *) get_gobj_field (fs); 00155 00156 /* ft->type is a const char, as is DUI_FIELD_WIDGET, 00157 but this condition should still never happen */ 00158 if (0 != g_ascii_strncasecmp(DUI_FIELD_WIDGET, fs->type, 0)) return NULL; 00159 00160 widget = gw->widget; 00161 if (!widget) return NULL; /* this shouldn't happen, really */ 00162 00163 /* Supported GTK-1.2 widgets, in pseudo-alpha order; 00164 * Gotta handle ctree first */ 00165 if (GTK_IS_CTREE(widget)) 00166 { 00167 if (NULL == gw->ctn) return NULL; 00168 gtk_ctree_node_get_text (GTK_CTREE(widget), gw->ctn, gw->column, (gchar **) &val); 00169 } 00170 else 00171 if (GTK_IS_CLIST(widget)) 00172 { 00173 if (0 > gw->row) return NULL; 00174 gtk_clist_get_text (GTK_CLIST(widget), gw->row, gw->column, (gchar **) &val); 00175 } 00176 else 00177 if (GTK_IS_MENU(widget)) 00178 { 00179 static char menuval[18]; 00180 GList *node; 00181 int i=0; 00182 GtkWidget *w = gtk_menu_get_active (GTK_MENU(widget)); 00183 for (node=GTK_MENU_SHELL(widget)->children; node; node=node->next) 00184 { 00185 if (w == node->data) 00186 { 00187 snprintf (menuval, 18, "%d", i); 00188 return menuval; 00189 } 00190 i++; 00191 } 00192 } 00193 else 00194 if (GTK_IS_OPTION_MENU(widget)) 00195 { 00196 DuiField dfs; 00197 dfs = *fs; 00198 struct gtk_widget_s * dgw; 00199 00200 dgw = (struct gtk_widget_s *) get_gobj_field (&dfs); 00201 dgw->widget = GTK_OPTION_MENU(widget)->menu; 00202 00203 /* pass-through on menu, let the child report */ 00204 val = widget_get_value (&dfs); 00205 } 00206 else 00207 if (GTK_IS_RADIO_BUTTON(widget)) 00208 { 00209 GSList *node; 00210 00211 /* loop over buttons in group, get data for the one that was pushed */ 00212 node = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget)); 00213 for ( ; node; node=node->next) 00214 { 00215 gboolean pushed; 00216 pushed = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(node->data)); 00217 if (pushed) break; 00218 } 00219 if (!node) return NULL; 00220 val = gtk_object_get_data (GTK_OBJECT(node->data), "/system/data"); 00221 } 00222 else 00223 if (GTK_IS_TOGGLE_BUTTON(widget)) 00224 { 00225 static char togbuff[2]; /* XXX hack alert not thread safe */ 00226 gboolean state; 00227 state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 00228 if (state) togbuff[0] = '1'; else togbuff[0] = '0'; 00229 togbuff[1] = 0; 00230 val = togbuff; 00231 } 00232 else 00233 if (GTK_IS_SPIN_BUTTON(widget)) 00234 { 00235 static char spinbuff[40]; /* hack alert not thread safe */ 00236 gdouble dbl = gtk_spin_button_get_value (GTK_SPIN_BUTTON(widget)); 00237 snprintf (spinbuff, 40, "%24.18g", dbl); 00238 return spinbuff; 00239 } 00240 else 00241 if (GTK_IS_ENTRY(widget)) 00242 { 00243 val = gtk_entry_get_text (GTK_ENTRY(widget)); 00244 } 00245 else 00246 if (GTK_IS_LABEL(widget)) 00247 { 00248 gtk_label_get (GTK_LABEL(widget), (gchar **) &val); 00249 } 00250 else 00251 if (GTK_IS_TEXT_VIEW(widget)) 00252 { 00253 val = xxxgtk_textview_get_text (GTK_TEXT_VIEW(widget)); 00254 } 00255 else 00256 if (GTK_IS_COMBO(widget)) 00257 { 00258 val = gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(widget)->entry)); 00259 } 00260 else 00261 if (GTK_IS_RANGE(widget)) 00262 { 00263 GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE(widget)); 00264 double flt = adj->value; 00265 static char rangebuff[40]; 00266 snprintf (rangebuff, 40, "%24.18g", flt); 00267 val = rangebuff; 00268 } 00269 else 00270 if (GNOME_IS_FILE_ENTRY (widget)) 00271 { 00272 GtkWidget * entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY(widget)); 00273 val = gtk_entry_get_text (GTK_ENTRY (entry)); 00274 } 00275 else 00276 if (GTK_IS_FILE_SELECTION (widget)) 00277 { 00278 val = gtk_entry_get_text (GTK_ENTRY (GTK_FILE_SELECTION 00279 (widget)->selection_entry)); 00280 } 00281 else 00282 if (GNOME_IS_DATE_EDIT(widget)) 00283 { 00284 static char datebuff[50]; 00285 time_t thyme = gnome_date_edit_get_time (GNOME_DATE_EDIT(widget)); 00286 xxxgnc_secs_to_iso8601_buff (thyme, datebuff); 00287 return datebuff; 00288 } 00289 else 00290 if (GTK_IS_BIN(widget)) 00291 { 00292 /* catch-all handles both GtkButton and GtkOptionMenu */ 00293 DuiField dfs; 00294 dfs = *fs; 00295 struct gtk_widget_s * dgw = (struct gtk_widget_s *) get_gobj_field (&dfs); 00296 dgw->widget = GTK_BIN(widget)->child; 00297 00298 /* pass-through on bin, let the child report */ 00299 val = widget_get_value (&dfs); 00300 } 00301 else 00302 { 00303 PERR ("unsupported <where> or <update> widget type %s", 00304 gtk_type_name(GTK_OBJECT_TYPE(widget))); 00305 } 00306 return val; 00307 }
| static void widget_set_data | ( | DuiField * | fs, | |
| const char * | val | |||
| ) | [static] |
Definition at line 586 of file duifield-gtk.c.
00587 { 00588 GtkWidget *widget; 00589 struct gtk_widata_s *gw = (struct gtk_widata_s*) get_gobj_field (fs); 00590 const char * datakey; 00591 00592 /* ft->type is a const char, as is DUI_FIELD_WID_DATA 00593 but this condition should still never happen */ 00594 if (0 != g_ascii_strncasecmp(DUI_FIELD_WID_DATA, fs->type, 0)) return; 00595 00596 widget = gw->widget; 00597 if (!widget) return; /* this shouldn't happen, really */ 00598 00599 datakey = gw->datakey; 00600 00601 if (GTK_IS_CTREE(widget)) 00602 { 00603 GHashTable *tbl; 00604 if (NULL == gw->ctn) return; 00605 tbl = gtk_ctree_node_get_row_data (GTK_CTREE(widget), gw->ctn); 00606 if (!tbl) 00607 { 00610 tbl = g_hash_table_new (g_str_hash, g_str_equal); 00611 00612 /* gtk_ctree_set_row_data_full() has destructor */ 00613 gtk_ctree_node_set_row_data (GTK_CTREE(widget), gw->ctn, tbl); 00614 } 00615 g_hash_table_insert (tbl, g_strdup(datakey), g_strdup(val)); 00616 } 00617 else 00618 if (GTK_IS_CLIST(widget)) 00619 { 00620 GHashTable *tbl; 00621 if (0 > gw->row) return; 00622 tbl = gtk_clist_get_row_data (GTK_CLIST(widget), gw->row); 00623 if (!tbl) 00624 { 00627 tbl = g_hash_table_new (g_str_hash, g_str_equal); 00628 00629 /* gtk_clist_set_row_data_full() has destructor */ 00630 gtk_clist_set_row_data (GTK_CLIST(widget), gw->row, tbl); 00631 } 00632 g_hash_table_insert (tbl, g_strdup(datakey), g_strdup(val)); 00633 } 00634 #if 0 00635 else 00636 if (GTK_IS_RADIO_BUTTON(widget)) 00637 { 00638 /* XXX uhh, we are supposed to do something special here ... !? */ 00639 } 00640 #endif 00641 else 00642 { 00643 gtk_object_set_data (GTK_OBJECT (widget), datakey, g_strdup(val)); 00644 } 00645 }
1.5.5