| 126 #endif |
126 #endif |
| 127 } |
127 } |
| 128 |
128 |
| 129 void add_toolitem_widget(GtkToolbar *tb, UiToolbarItem *item, UiObject *obj) { |
129 void add_toolitem_widget(GtkToolbar *tb, UiToolbarItem *item, UiObject *obj) { |
| 130 GtkToolItem *button; |
130 GtkToolItem *button; |
| 131 if(item->args.stockid) { |
131 button = gtk_tool_button_new(NULL, item->args.label); |
| 132 #ifdef UI_GTK2 |
132 if(item->args.tooltip) { |
| 133 button = gtk_tool_button_new_from_stock(item->args.stockid); |
133 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(button), item->args.tooltip); |
| 134 #else |
|
| 135 // TODO: gtk3 stock |
|
| 136 button = gtk_tool_button_new(NULL, item->args.label); |
|
| 137 #endif |
|
| 138 } else { |
|
| 139 button = gtk_tool_button_new(NULL, item->args.label); |
|
| 140 } |
134 } |
| 141 |
135 |
| 142 gtk_tool_item_set_homogeneous(button, FALSE); |
136 gtk_tool_item_set_homogeneous(button, FALSE); |
| 143 if(item->args.icon) { |
137 if(item->args.icon) { |
| 144 set_toolbutton_icon(button, item->args.icon); |
138 set_toolbutton_icon(button, item->args.icon); |
| 174 */ |
168 */ |
| 175 } |
169 } |
| 176 |
170 |
| 177 void add_toolitem_toggle_widget(GtkToolbar *tb, UiToolbarToggleItem *item, UiObject *obj) { |
171 void add_toolitem_toggle_widget(GtkToolbar *tb, UiToolbarToggleItem *item, UiObject *obj) { |
| 178 GtkToolItem *button; |
172 GtkToolItem *button; |
| 179 if(item->args.stockid) { |
173 button = gtk_toggle_tool_button_new(); |
| 180 #ifdef UI_GTK2 |
174 gtk_tool_item_set_homogeneous(button, FALSE); |
| 181 button = gtk_toggle_tool_button_new_from_stock(item->args.stockid); |
175 if(item->args.label) { |
| 182 #else |
176 gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), item->args.label); |
| 183 button = gtk_toggle_tool_button_new_from_stock(item->args.stockid); // TODO: gtk3 stock |
177 } |
| 184 #endif |
178 if(item->args.icon) { |
| 185 } else { |
179 set_toolbutton_icon(button, item->args.icon); |
| 186 button = gtk_toggle_tool_button_new(); |
180 } |
| 187 gtk_tool_item_set_homogeneous(button, FALSE); |
181 if(item->args.tooltip) { |
| 188 if(item->args.label) { |
182 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(button), item->args.tooltip); |
| 189 gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), item->args.label); |
|
| 190 } |
|
| 191 if(item->args.icon) { |
|
| 192 set_toolbutton_icon(button, item->args.icon); |
|
| 193 } |
|
| 194 } |
183 } |
| 195 ui_set_widget_ngroups(obj->ctx, GTK_WIDGET(button), item->args.groups, item->ngroups); |
184 ui_set_widget_ngroups(obj->ctx, GTK_WIDGET(button), item->args.groups, item->ngroups); |
| 196 |
185 |
| 197 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, NULL, item->args.varname, UI_VAR_INTEGER); |
186 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, NULL, item->args.varname, UI_VAR_INTEGER); |
| 198 if(var) { |
187 if(var) { |
| 280 free(menu); |
269 free(menu); |
| 281 } |
270 } |
| 282 |
271 |
| 283 void add_toolitem_menu_widget(GtkToolbar *tb, UiToolbarMenuItem *item, UiObject *obj) { |
272 void add_toolitem_menu_widget(GtkToolbar *tb, UiToolbarMenuItem *item, UiObject *obj) { |
| 284 GtkToolItem *button; |
273 GtkToolItem *button; |
| 285 if(item->args.stockid) { |
274 button = gtk_tool_button_new(NULL, item->args.label); |
| 286 #ifdef UI_GTK2 |
|
| 287 button = gtk_tool_button_new_from_stock(item->args.stockid); |
|
| 288 #else |
|
| 289 // TODO: gtk3 stock |
|
| 290 button = gtk_tool_button_new(NULL, item->args.label); |
|
| 291 #endif |
|
| 292 } else { |
|
| 293 button = gtk_tool_button_new(NULL, item->args.label); |
|
| 294 } |
|
| 295 |
275 |
| 296 gtk_tool_item_set_homogeneous(button, FALSE); |
276 gtk_tool_item_set_homogeneous(button, FALSE); |
| 297 if(item->args.icon) { |
277 if(item->args.icon) { |
| 298 set_toolbutton_icon(button, item->args.icon); |
278 set_toolbutton_icon(button, item->args.icon); |
| |
279 } |
| |
280 if(item->args.tooltip) { |
| |
281 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(button), item->args.tooltip); |
| 299 } |
282 } |
| 300 gtk_tool_item_set_is_important(button, TRUE); |
283 gtk_tool_item_set_is_important(button, TRUE); |
| 301 |
284 |
| 302 gtk_toolbar_insert(tb, button, -1); |
285 gtk_toolbar_insert(tb, button, -1); |
| 303 |
286 |