69 case UI_TOOLBAR_TOGGLEITEM: { |
70 case UI_TOOLBAR_TOGGLEITEM: { |
70 ui_add_headerbar_toggleitem(headerbar, box, (UiToolbarToggleItem*)i, obj, pos); |
71 ui_add_headerbar_toggleitem(headerbar, box, (UiToolbarToggleItem*)i, obj, pos); |
71 break; |
72 break; |
72 } |
73 } |
73 case UI_TOOLBAR_MENU: { |
74 case UI_TOOLBAR_MENU: { |
74 //add_toolitem_menu_widget(tb, (UiToolbarMenuItem*)i, obj); |
75 ui_add_headerbar_menu(headerbar, box, (UiToolbarMenuItem*)i, obj, pos); |
75 break; |
76 break; |
76 } |
77 } |
77 default: fprintf(stderr, "toolbar item type unimplemented: %d\n", (int)i->type); |
78 default: fprintf(stderr, "toolbar item type unimplemented: %d\n", (int)i->type); |
78 } |
79 } |
79 } |
80 } |
117 } |
118 } |
118 create_item(obj, headerbar, box, item, pos); |
119 create_item(obj, headerbar, box, item, pos); |
119 } |
120 } |
120 } |
121 } |
121 |
122 |
122 void ui_add_headerbar_item(GtkWidget *headerbar, GtkWidget *box, UiToolbarItem *item, UiObject *obj, enum UiToolbarPos pos) { |
123 void ui_add_headerbar_item( |
|
124 GtkWidget *headerbar, |
|
125 GtkWidget *box, |
|
126 UiToolbarItem *item, |
|
127 UiObject *obj, |
|
128 enum UiToolbarPos pos) |
|
129 { |
123 GtkWidget *button = ui_create_button(obj, item->args.label, item->args.icon, item->args.onclick, item->args.onclickdata); |
130 GtkWidget *button = ui_create_button(obj, item->args.label, item->args.icon, item->args.onclick, item->args.onclickdata); |
124 WIDGET_ADD_CSS_CLASS(button, "flat"); |
131 WIDGET_ADD_CSS_CLASS(button, "flat"); |
125 headerbar_add(headerbar, box, button, pos); |
132 headerbar_add(headerbar, box, button, pos); |
126 } |
133 } |
127 |
134 |
128 void ui_add_headerbar_toggleitem(GtkWidget *headerbar, GtkWidget *box, UiToolbarToggleItem *item, UiObject *obj, enum UiToolbarPos pos) { |
135 void ui_add_headerbar_toggleitem( |
|
136 GtkWidget *headerbar, |
|
137 GtkWidget *box, |
|
138 UiToolbarToggleItem *item, |
|
139 UiObject *obj, |
|
140 enum UiToolbarPos pos) |
|
141 { |
129 GtkWidget *button = gtk_toggle_button_new(); |
142 GtkWidget *button = gtk_toggle_button_new(); |
130 WIDGET_ADD_CSS_CLASS(button, "flat"); |
143 WIDGET_ADD_CSS_CLASS(button, "flat"); |
131 ui_setup_togglebutton(obj, button, item->args.label, item->args.icon, item->args.varname, NULL, item->args.onchange, item->args.onchangedata); |
144 ui_setup_togglebutton(obj, button, item->args.label, item->args.icon, item->args.varname, NULL, item->args.onchange, item->args.onchangedata); |
132 headerbar_add(headerbar, box, button, pos); |
145 headerbar_add(headerbar, box, button, pos); |
133 } |
146 } |
|
147 |
|
148 void ui_add_headerbar_menu( |
|
149 GtkWidget *headerbar, |
|
150 GtkWidget *box, |
|
151 UiToolbarMenuItem *item, |
|
152 UiObject *obj, |
|
153 enum UiToolbarPos pos) |
|
154 { |
|
155 GtkWidget *menubutton = gtk_menu_button_new(); |
|
156 |
|
157 if(item->args.label) { |
|
158 gtk_menu_button_set_label(GTK_MENU_BUTTON(menubutton), item->args.label); |
|
159 } |
|
160 if(item->args.icon) { |
|
161 gtk_menu_button_set_icon_name(GTK_MENU_BUTTON(menubutton), item->args.icon); |
|
162 } |
|
163 |
|
164 GMenu *menu = g_menu_new(); |
|
165 ui_gmenu_add_menu_items(menu, 0, &item->menu, obj); |
|
166 |
|
167 gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(menubutton), G_MENU_MODEL(menu)); |
|
168 |
|
169 headerbar_add(headerbar, box, menubutton, pos); |
|
170 } |
134 |
171 |
135 #endif |
172 #endif |