149 |
149 |
150 return button; |
150 return button; |
151 } |
151 } |
152 |
152 |
153 |
153 |
154 UiRadioButtonGroup ui_radiobuttongroup() { |
154 |
155 UiRadioButtonGroup rgroup; |
155 UIWIDGET ui_radiobutton(UiObject *obj, char *label, UiInteger *rgroup) { |
156 rgroup.group = NULL; |
156 GSList *rg = rgroup ? rgroup->obj : NULL; |
157 rgroup.ref = 0; |
157 |
158 return rgroup; |
158 GtkWidget *rbutton = gtk_radio_button_new_with_label(rg, label); |
159 } |
159 rg = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbutton)); |
160 |
160 |
161 void ui_radiobuttongroup_select(UiRadioButtonGroup *rgroup, int index) { |
161 if(rgroup) { |
162 GSList *ls = rgroup->group; |
162 rgroup->obj = rg; |
163 int s = g_slist_length(rgroup->group) - 1 - index; |
163 rgroup->get = ui_radiobutton_get; |
164 int i = 0; |
164 rgroup->set = ui_radiobutton_set; |
165 while(ls) { |
165 if(rgroup->value > 0) { |
166 if(i == s) { |
166 ui_radiobutton_set(rgroup, rgroup->value); |
167 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ls->data), TRUE); |
167 } |
168 break; |
168 } |
169 } |
169 |
170 ls = ls->next; |
170 UiContainer *ct = uic_get_current_container(obj); |
171 i++; |
171 ct->add(ct, rbutton, FALSE); |
172 } |
172 |
173 } |
173 return rbutton; |
174 |
174 } |
175 int ui_radiobuttongroup_selection(UiRadioButtonGroup *rgroup) { |
175 |
176 GSList *ls = rgroup->group; |
176 int ui_radiobutton_get(UiInteger *value) { |
|
177 int selection = 0; |
|
178 GSList *ls = value->obj; |
177 int i = 0; |
179 int i = 0; |
178 while(ls) { |
180 while(ls) { |
179 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ls->data))) { |
181 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ls->data))) { |
180 return g_slist_length(rgroup->group) - i - 1; |
182 selection = g_slist_length(value->obj) - i - 1; |
|
183 break; |
181 } |
184 } |
182 ls = ls->next; |
185 ls = ls->next; |
183 i++; |
186 i++; |
184 } |
187 } |
185 return -1; |
188 |
186 } |
189 value->value = selection; |
187 |
190 return selection; |
188 int io_radiobuttongroup_count(UiRadioButtonGroup *rgroup) { |
191 } |
189 return g_slist_length(rgroup->group); |
192 |
190 } |
193 void ui_radiobutton_set(UiInteger *value, int i) { |
191 |
194 GSList *ls = value->obj; |
192 UIWIDGET ui_radiobutton(UiObject *obj, char *label, UiRadioButtonGroup *rgroup) { |
195 int s = g_slist_length(ls) - 1 - i; |
193 GtkWidget *rbutton = gtk_radio_button_new_with_label(rgroup->group, label); |
196 int j = 0; |
194 rgroup->group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbutton)); |
197 while(ls) { |
195 rgroup->ref++; |
198 if(j == s) { |
196 |
199 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ls->data), TRUE); |
197 UiContainer *ct = uic_get_current_container(obj); |
200 break; |
198 ct->add(ct, rbutton, FALSE); |
201 } |
199 |
202 ls = ls->next; |
200 return rbutton; |
203 j++; |
201 } |
204 } |
202 |
205 |
|
206 value->value = j; |
|
207 } |
|
208 |