ui/gtk/button.c

changeset 107
9aff1dc3990d
parent 94
d51e334c1439
child 108
fcf6d5fac8f5
equal deleted inserted replaced
106:a4f4123ca12a 107:9aff1dc3990d
148 ct->add(ct, button, FALSE); 148 ct->add(ct, button, FALSE);
149 149
150 return button; 150 return button;
151 } 151 }
152 152
153
154 UiRadioButtonGroup ui_radiobuttongroup() {
155 UiRadioButtonGroup rgroup;
156 rgroup.group = NULL;
157 rgroup.ref = 0;
158 return rgroup;
159 }
160
161 void ui_radiobuttongroup_select(UiRadioButtonGroup *rgroup, int index) {
162 GSList *ls = rgroup->group;
163 int s = g_slist_length(rgroup->group) - 1 - index;
164 int i = 0;
165 while(ls) {
166 if(i == s) {
167 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ls->data), TRUE);
168 break;
169 }
170 ls = ls->next;
171 i++;
172 }
173 }
174
175 int ui_radiobuttongroup_selection(UiRadioButtonGroup *rgroup) {
176 GSList *ls = rgroup->group;
177 int i = 0;
178 while(ls) {
179 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ls->data))) {
180 return g_slist_length(rgroup->group) - i - 1;
181 }
182 ls = ls->next;
183 i++;
184 }
185 return -1;
186 }
187
188 int io_radiobuttongroup_count(UiRadioButtonGroup *rgroup) {
189 return g_slist_length(rgroup->group);
190 }
191
192 UIWIDGET ui_radiobutton(UiObject *obj, char *label, UiRadioButtonGroup *rgroup) {
193 GtkWidget *rbutton = gtk_radio_button_new_with_label(rgroup->group, label);
194 rgroup->group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(rbutton));
195 rgroup->ref++;
196
197 UiContainer *ct = uic_get_current_container(obj);
198 ct->add(ct, rbutton, FALSE);
199
200 return rbutton;
201 }
202

mercurial