gwenhywfar  4.7.0beta
w_spinbox.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Sun May 16 2010
3  copyright : (C) 2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 
12 typedef struct W_SPINBOX W_SPINBOX;
13 struct W_SPINBOX {
14  GtkAdjustment *adjustment;
15 };
16 
17 
19 
20 
21 
22 static GWENHYWFAR_CB
25  int index,
26  int value,
27  int doSignal) {
28  GtkWidget *g;
29  W_SPINBOX *xw;
30 
31  assert(w);
33  assert(xw);
34 
36  assert(g);
37 
38  switch(prop) {
40  gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
41  return 0;
42 
44  gtk_widget_grab_focus(GTK_WIDGET(g));
45  return 0;
46 
49  /* just ignore these for now */
50  return 0;
51 
53  gtk_adjustment_set_value(GTK_ADJUSTMENT(xw->adjustment), value);
54  return 0;
55 
57  gtk_adjustment_set_lower(GTK_ADJUSTMENT(xw->adjustment), value);
58  return 0;
59 
61  gtk_adjustment_set_upper(GTK_ADJUSTMENT(xw->adjustment), value);
62  return 0;
63 
64  default:
65  break;
66  }
67 
69  "Function is not appropriate for this type of widget (%s)",
71  return GWEN_ERROR_INVALID;
72 }
73 
74 
75 
76 
77 static GWENHYWFAR_CB
80  int index,
81  int defaultValue) {
82  GtkWidget *g;
83  W_SPINBOX *xw;
84 
85  assert(w);
87  assert(xw);
88 
90  assert(g);
91 
92  switch(prop) {
94  return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
95 
97  return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
98  return 0;
99 
102  /* just ignore these for now */
103  return 0;
104 
106  return gtk_adjustment_get_value(GTK_ADJUSTMENT(xw->adjustment));
107 
109  return gtk_adjustment_get_lower(GTK_ADJUSTMENT(xw->adjustment));
110 
112  return gtk_adjustment_get_upper(GTK_ADJUSTMENT(xw->adjustment));
113 
114  default:
115  break;
116  }
117 
119  "Function is not appropriate for this type of widget (%s)",
121  return defaultValue;
122 }
123 
124 
125 
126 static GWENHYWFAR_CB
129  int index,
130  const char *value,
131  int doSignal) {
133  "Function is not appropriate for this type of widget (%s)",
135  return GWEN_ERROR_INVALID;
136 }
137 
138 
139 
140 static GWENHYWFAR_CB
143  int index,
144  const char *defaultValue) {
146  "Function is not appropriate for this type of widget (%s)",
148  return defaultValue;
149 }
150 
151 
152 
153 static void GWENHYWFAR_CB Gtk2Gui_WSpinBox_FreeData(void *bp, void *p) {
154  W_SPINBOX *xw;
155 
156  xw=(W_SPINBOX*) p;
157  GWEN_FREE_OBJECT(xw);
158 }
159 
160 
161 
162 static void Gtk2Gui_WSpinBox_Changed_handler(GtkAdjustment *adjustment, gpointer data) {
163  GWEN_WIDGET *w;
164  int rv;
165 
166  w=data;
167  assert(w);
173  else if (rv==GWEN_DialogEvent_ResultReject)
175 }
176 
177 
178 
180  GtkWidget *g;
181  const char *s;
182  uint32_t flags;
183  GWEN_WIDGET *wParent;
184  W_SPINBOX *xw;
185  gulong changed_handler_id;
186 
189 
190  flags=GWEN_Widget_GetFlags(w);
191  wParent=GWEN_Widget_Tree_GetParent(w);
192  s=GWEN_Widget_GetText(w, 0);
193 
194  xw->adjustment=GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 1.0, 5.0, 5.0));
195  g=gtk_spin_button_new(xw->adjustment, 1.0, 0);
198 
203 
204  changed_handler_id=g_signal_connect(g,
205  "value-changed",
207  w);
208 
209  if (wParent)
210  GWEN_Widget_AddChildGuiWidget(wParent, w);
211 
212  return 0;
213 }
214 
215