gwenhywfar  4.6.0beta
w_radiobutton.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Mon Jul 12 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 
13 
14 static GWENHYWFAR_CB
17  int index,
18  int value,
19  int doSignal) {
20  GtkButton *g;
21 
23  assert(g);
24 
25  switch(prop) {
27  gtk_widget_set_sensitive(GTK_WIDGET(g), (value==0)?FALSE:TRUE);
28  return 0;
29 
31  gtk_widget_grab_focus(GTK_WIDGET(g));
32  return 0;
33 
36  /* just ignore these for now */
37  return 0;
38 
40  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g), (value==0)?FALSE:TRUE);
41  return 0;
42 
43  default:
44  break;
45  }
46 
48  "Function is not appropriate for this type of widget (%s)",
50  return GWEN_ERROR_INVALID;
51 }
52 
53 
54 
55 
56 static GWENHYWFAR_CB
59  int index,
60  int defaultValue) {
61  GtkButton *g;
62 
64  assert(g);
65 
66  switch(prop) {
68  return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0;
69 
71  return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0;
72 
75  /* just ignore these for now */
76  return 0;
77 
79  return (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g))==TRUE)?1:0;
80 
81  default:
82  break;
83  }
84 
86  "Function is not appropriate for this type of widget (%s)",
88  return defaultValue;
89 }
90 
91 
92 
93 static GWENHYWFAR_CB
96  int index,
97  const char *value,
98  int doSignal) {
99  GtkButton *g;
100 
102  assert(g);
103 
104  switch(prop) {
106  gtk_button_set_label(g, value);
107  return 0;
108  default:
109  break;
110  }
111 
113  "Function is not appropriate for this type of widget (%s)",
115  return GWEN_ERROR_INVALID;
116 }
117 
118 
119 
120 static GWENHYWFAR_CB
123  int index,
124  const char *defaultValue) {
125  GtkButton *g;
126 
128  assert(g);
129 
130  switch(prop) {
132  return gtk_button_get_label(g);
133  default:
134  break;
135  }
136 
138  "Function is not appropriate for this type of widget (%s)",
140  return defaultValue;
141 }
142 
143 
144 
145 static void Gtk2Gui_WRadioButton_Toggled_handler(GtkButton *button, gpointer data) {
146  GWEN_WIDGET *w;
147  int rv;
148 
149  w=data;
150  assert(w);
156  else if (rv==GWEN_DialogEvent_ResultReject)
158 }
159 
160 
161 
163  GtkWidget *g;
164  const char *s;
165  uint32_t flags;
166  GWEN_WIDGET *wParent;
167  GWEN_WIDGET *wT;
168  gulong toggled_handler_id;
169  int groupId;
170 
171  flags=GWEN_Widget_GetFlags(w);
172  wParent=GWEN_Widget_Tree_GetParent(w);
173  groupId=GWEN_Widget_GetGroupId(w);
174 
175  s=GWEN_Widget_GetText(w, 0);
176 
177  /* create widget */
178  if (s && *s)
179  g=gtk_radio_button_new_with_mnemonic(NULL, s);
180  else
181  g=gtk_radio_button_new(NULL);
182 
183  /* get root widget */
184  wT=wParent;
185  while(GWEN_Widget_Tree_GetParent(wT))
186  wT=GWEN_Widget_Tree_GetParent(wT);
187 
188  /* get first radio button of the same group */
189  while(wT) {
191  GWEN_Widget_GetGroupId(wT)==groupId)
192  break;
193  wT=GWEN_Widget_Tree_GetBelow(wT);
194  }
195  if (wT && wT!=w) {
196  GSList *grp;
197 
198  grp=gtk_radio_button_get_group(GTK_RADIO_BUTTON(GWEN_Widget_GetImplData(wT, GTK2_DIALOG_WIDGET_REAL)));
199  gtk_radio_button_set_group(GTK_RADIO_BUTTON(g), grp);
200  }
201 
202  /* set pointers */
205 
210 
211  toggled_handler_id=g_signal_connect(g,
212  "toggled",
214  w);
215 
216  if (wParent)
217  GWEN_Widget_AddChildGuiWidget(wParent, w);
218 
219  return 0;
220 }
221 
222