| 58 |
58 |
| 59 GtkWidget* ui_create_button( |
59 GtkWidget* ui_create_button( |
| 60 UiObject *obj, |
60 UiObject *obj, |
| 61 const char *label, |
61 const char *label, |
| 62 const char *icon, |
62 const char *icon, |
| |
63 const char *tooltip, |
| 63 ui_callback onclick, |
64 ui_callback onclick, |
| 64 void *userdata, |
65 void *userdata, |
| 65 int event_value, |
66 int event_value, |
| 66 bool activate_event) |
67 bool activate_event) |
| 67 { |
68 { |
| 68 GtkWidget *button = gtk_button_new_with_label(label); |
69 GtkWidget *button = gtk_button_new_with_label(label); |
| 69 ui_button_set_icon_name(button, icon); |
70 ui_button_set_icon_name(button, icon); |
| |
71 if(tooltip) { |
| |
72 gtk_widget_set_tooltip_text(button, tooltip); |
| |
73 } |
| 70 |
74 |
| 71 if(onclick) { |
75 if(onclick) { |
| 72 UiEventData *event = malloc(sizeof(UiEventData)); |
76 UiEventData *event = malloc(sizeof(UiEventData)); |
| 73 event->obj = obj; |
77 event->obj = obj; |
| 74 event->userdata = userdata; |
78 event->userdata = userdata; |
| 98 |
102 |
| 99 return button; |
103 return button; |
| 100 } |
104 } |
| 101 |
105 |
| 102 UIWIDGET ui_button_create(UiObject *obj, UiButtonArgs *args) { |
106 UIWIDGET ui_button_create(UiObject *obj, UiButtonArgs *args) { |
| 103 GtkWidget *button = ui_create_button(obj, args->label, args->icon, args->onclick, args->onclickdata, 0, FALSE); |
107 GtkWidget *button = ui_create_button(obj, args->label, args->icon, NULL/*tooltip*/, args->onclick, args->onclickdata, 0, FALSE); |
| 104 ui_set_name_and_style(button, args->name, args->style_class); |
108 ui_set_name_and_style(button, args->name, args->style_class); |
| 105 ui_set_widget_groups(obj->ctx, button, args->groups); |
109 ui_set_widget_groups(obj->ctx, button, args->groups); |
| 106 UiContainerPrivate *ct = (UiContainerPrivate*)obj->container_end; |
110 UiContainerPrivate *ct = (UiContainerPrivate*)obj->container_end; |
| 107 UiLayout layout = UI_ARGS2LAYOUT(args); |
111 UiLayout layout = UI_ARGS2LAYOUT(args); |
| 108 ct->add(ct, button, &layout); |
112 ct->add(ct, button, &layout); |
| 179 void ui_setup_togglebutton( |
183 void ui_setup_togglebutton( |
| 180 UiObject *obj, |
184 UiObject *obj, |
| 181 GtkWidget *togglebutton, |
185 GtkWidget *togglebutton, |
| 182 const char *label, |
186 const char *label, |
| 183 const char *icon, |
187 const char *icon, |
| |
188 const char *tooltip, |
| 184 const char *varname, |
189 const char *varname, |
| 185 UiInteger *value, |
190 UiInteger *value, |
| 186 ui_callback onchange, |
191 ui_callback onchange, |
| 187 void *onchangedata, |
192 void *onchangedata, |
| 188 int enable_state) |
193 int enable_state) |
| 189 { |
194 { |
| 190 if(label) { |
195 if(label) { |
| 191 gtk_button_set_label(GTK_BUTTON(togglebutton), label); |
196 gtk_button_set_label(GTK_BUTTON(togglebutton), label); |
| 192 } |
197 } |
| 193 ui_button_set_icon_name(togglebutton, icon); |
198 ui_button_set_icon_name(togglebutton, icon); |
| |
199 if(tooltip) { |
| |
200 gtk_widget_set_tooltip_text(togglebutton, tooltip); |
| |
201 } |
| 194 |
202 |
| 195 ui_bind_togglebutton( |
203 ui_bind_togglebutton( |
| 196 obj, |
204 obj, |
| 197 togglebutton, |
205 togglebutton, |
| 198 ui_toggle_button_get, |
206 ui_toggle_button_get, |