ui/gtk/toolbar.c

Sun, 29 Sep 2024 11:29:37 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 29 Sep 2024 11:29:37 +0200
branch
newapi
changeset 311
450a813dc2a5
parent 310
4918f9132552
child 321
8d63b7cd3d98
permissions
-rw-r--r--

implement GTK4 gmenu item and item list

3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "toolbar.h"
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
34 #include "menu.h"
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #include "button.h"
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
36 #include "image.h"
116
480354705c2f added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 90
diff changeset
37 #include "tree.h"
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
38 #include <cx/mempool.h>
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
39 #include <cx/hash_map.h>
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
40 #include <cx/linked_list.h>
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
41 #include <cx/array_list.h>
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #include "../common/context.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
44
293
736c962f1011 initial gtk4 porting, incomplete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
45 #if UI_GTK2 || UI_GTK3
736c962f1011 initial gtk4 porting, incomplete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
46
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 GtkWidget* ui_create_toolbar(UiObject *obj) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 GtkWidget *toolbar = gtk_toolbar_new();
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 #ifdef UI_GTK3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 gtk_style_context_add_class(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 gtk_widget_get_style_context(toolbar),
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 #endif
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
55 CxMap *items = uic_get_toolbar_items();
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
56 CxList *left_defaults = uic_get_toolbar_defaults(UI_TOOLBAR_LEFT);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
57 CxList *center_defaults = uic_get_toolbar_defaults(UI_TOOLBAR_CENTER);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
58 CxList *right_defaults = uic_get_toolbar_defaults(UI_TOOLBAR_RIGHT);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
59
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
60 ui_toolbar_add_items(obj, toolbar, items, left_defaults);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
61 ui_toolbar_add_items(obj, toolbar, items, center_defaults);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
62 ui_toolbar_add_items(obj, toolbar, items, right_defaults);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
63
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
64 /*
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 GtkToolbar *tb = GTK_TOOLBAR(toolbar);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
66 CxIterator i = cxListIterator(defaults);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
67 cx_foreach(char *, def, i) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
68 UiToolItemI *item = cxMapGet(toolbar_items, def);
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 if(item) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 item->add_to(tb, item, obj);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
71 } else if(!strcmp(def, "@separator")) {
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 gtk_toolbar_insert(tb, gtk_separator_tool_item_new(), -1);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 } else {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
74 fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", def);
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 }
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
77 */
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 return toolbar;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
82 static void create_item(UiObject *obj, GtkWidget *toolbar, UiToolbarItemI *i) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
83 GtkToolbar *tb = GTK_TOOLBAR(toolbar);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
84 switch(i->type) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
85 case UI_TOOLBAR_ITEM: {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
86 add_toolitem_widget(tb, (UiToolbarItem*)i, obj);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
87 break;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
88 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
89 case UI_TOOLBAR_TOGGLEITEM: {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
90 add_toolitem_toggle_widget(tb, (UiToolbarToggleItem*)i, obj);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
91 break;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
92 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
93 case UI_TOOLBAR_MENU: {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
94 add_toolitem_menu_widget(tb, (UiToolbarMenuItem*)i, obj);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
95 break;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
96 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
97 default: fprintf(stderr, "toolbar item type unimplemented: %d\n", (int)i->type);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
98 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
99 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
100
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
101 void ui_toolbar_add_items(UiObject *obj, GtkWidget *toolbar, CxMap *items, CxList *defaults) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
102 // add pre-configured items
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
103 CxIterator i = cxListIterator(defaults);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
104 cx_foreach(char*, def, i) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
105 UiToolbarItemI* item = uic_toolbar_get_item(def);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
106 if (!item) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
107 fprintf(stderr, "unknown toolbar item: %s\n", def);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
108 continue;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
109 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
110 create_item(obj, toolbar, item);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
111 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
112 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
113
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
114 static void set_toolbutton_icon(GtkToolItem *item, const char *icon_name) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
115 #if GTK_MAJOR_VERSION >= 3
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
116 gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item), icon_name);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
117 #else
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
118 UiIcon *icon = ui_icon(icon_name, 24);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
119 if(icon) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
120 GdkPixbuf *pixbuf = ui_icon_pixbuf(icon);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
121 if(pixbuf) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
122 GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
123 gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), image);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
124 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
125 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
126 #endif
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
127 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
128
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
129 void add_toolitem_widget(GtkToolbar *tb, UiToolbarItem *item, UiObject *obj) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
130 GtkToolItem *button;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
131 if(item->args.stockid) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
132 #ifdef UI_GTK2
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
133 button = gtk_tool_button_new_from_stock(item->args.stockid);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
134 #else
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
135 // TODO: gtk3 stock
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
136 button = gtk_tool_button_new(NULL, item->args.label);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
137 #endif
90
2019fdbaadfd persistent textarea cursor position
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
138 } else {
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
139 button = gtk_tool_button_new(NULL, item->args.label);
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
140 }
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
142 gtk_tool_item_set_homogeneous(button, FALSE);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
143 if(item->args.icon) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
144 set_toolbutton_icon(button, item->args.icon);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
145 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
146 gtk_tool_item_set_is_important(button, TRUE);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
147
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
148 if(item->args.onclick) {
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
149 UiEventData *event = cxMalloc(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
150 obj->ctx->allocator,
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 sizeof(UiEventData));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 event->obj = obj;
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
153 event->callback = item->args.onclick;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
154 event->userdata = item->args.onclickdata;
278
a8faf8757450 implement ui_dialog_create (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 276
diff changeset
155 event->customdata = NULL;
a8faf8757450 implement ui_dialog_create (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 276
diff changeset
156 event->value = 0;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 g_signal_connect(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 button,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 "clicked",
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 G_CALLBACK(ui_button_clicked),
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 event);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 gtk_toolbar_insert(tb, button, -1);
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
166
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
167 /*
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
168 if(item->groups) {
168
1b99acacc5bb refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 167
diff changeset
169 uic_add_group_widget(obj->ctx, button, (ui_enablefunc)ui_set_enabled, item->groups);
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
170 }
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
171 */
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
173
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
174 void add_toolitem_toggle_widget(GtkToolbar *tb, UiToolbarToggleItem *item, UiObject *obj) {
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
175 GtkToolItem *button;
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
176 if(item->args.stockid) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
177 #ifdef UI_GTK2
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
178 button = gtk_toggle_tool_button_new_from_stock(item->args.stockid);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
179 #else
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
180 button = gtk_toggle_tool_button_new_from_stock(item->args.stockid); // TODO: gtk3 stock
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
181 #endif
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
182 } else {
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
183 button = gtk_toggle_tool_button_new();
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
184 gtk_tool_item_set_homogeneous(button, FALSE);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
185 if(item->args.label) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
186 gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), item->args.label);
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
187 }
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
188 if(item->args.icon) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
189 set_toolbutton_icon(button, item->args.icon);
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
190 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
191 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
192
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
193 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, NULL, item->args.varname, UI_VAR_INTEGER);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
194 if(var) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
195 UiInteger *i = (UiInteger*)var->value;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
196 if(i) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
197 i->get = ui_tool_toggle_button_get;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
198 i->set = ui_tool_toggle_button_set;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
199 i->obj = button;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
200
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
201 if(i->value != 0) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
202 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(button), TRUE);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
203 }
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
204 }
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
205 }
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
206
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
207 UiVarEventData *event = cxMalloc(
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
208 obj->ctx->allocator,
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
209 sizeof(UiVarEventData));
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
210 event->obj = obj;
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
211 event->callback = item->args.onchange;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
212 event->userdata = item->args.onchangedata;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
213 event->var = var;
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
214
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
215 g_signal_connect(
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
216 button,
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
217 "toggled",
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
218 G_CALLBACK(ui_tool_button_toggled),
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
219 event);
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
220
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
221 // add item to toolbar
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
222 gtk_toolbar_insert(tb, button, -1);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
223
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
224 /*
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
225 if(item->groups) {
168
1b99acacc5bb refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 167
diff changeset
226 uic_add_group_widget(obj->ctx, button, (ui_enablefunc)ui_set_enabled, item->groups);
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
227 }
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
228 */
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
229 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
230
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
231 void ui_tool_button_toggled(GtkToggleToolButton *widget, UiVarEventData *event) {
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
232 UiEvent e;
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
233 e.obj = event->obj;
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
234 e.window = event->obj->window;
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
235 e.document = event->obj->ctx->document;
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
236 e.eventdata = NULL;
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
237 e.intval = gtk_toggle_tool_button_get_active(widget);
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
238
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
239 if(event->callback) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
240 event->callback(&e, event->userdata);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
241 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
242
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
243 UiVar *var = event->var;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
244 UiInteger *i = var ? var->value : NULL;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
245
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
246 if(i) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
247 ui_notify_evt(i->observers, &e);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
248 }
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
249 }
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
250
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
251 int64_t ui_tool_toggle_button_get(UiInteger *integer) {
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
252 integer->value = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(integer->obj));
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
253 return integer->value;
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
254 }
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
255
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
256 void ui_tool_toggle_button_set(UiInteger *integer, int64_t value) {
168
1b99acacc5bb refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 167
diff changeset
257 gboolean s = value != 0 ? TRUE : FALSE;
167
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
258 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(integer->obj), s);
161511838ea6 add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 163
diff changeset
259 integer->value = s;
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
260 }
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
261
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
262
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
263
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
264 typedef struct UiToolbarMenuWidget {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
265 GtkWidget *button;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
266 GtkMenu *menu;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
267 } UiToolbarMenuWidget;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
268
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
269 static void ui_toolbar_menubutton_clicked(GtkWidget *widget, UiToolbarMenuWidget *menu) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
270 int x;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
271 gtk_menu_popup_at_widget(menu->menu, menu->button, GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
272 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
273
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
274 static void ui_toolbar_menubutton_destroy(GtkWidget *widget, UiToolbarMenuWidget *menu) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
275 free(menu);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
276 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
277
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
278 void add_toolitem_menu_widget(GtkToolbar *tb, UiToolbarMenuItem *item, UiObject *obj) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
279 GtkToolItem *button;
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
280 if(item->args.stockid) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
281 #ifdef UI_GTK2
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
282 button = gtk_tool_button_new_from_stock(item->args.stockid);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
283 #else
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
284 // TODO: gtk3 stock
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
285 button = gtk_tool_button_new(NULL, item->args.label);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
286 #endif
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
287 } else {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
288 button = gtk_tool_button_new(NULL, item->args.label);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
289 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
290
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
291 gtk_tool_item_set_homogeneous(button, FALSE);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
292 if(item->args.icon) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
293 set_toolbutton_icon(button, item->args.icon);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
294 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
295 gtk_tool_item_set_is_important(button, TRUE);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
296
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
297 gtk_toolbar_insert(tb, button, -1);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
298
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
299 // menu
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
300 GtkWidget *menu_widget = gtk_menu_new();
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
301 ui_add_menu_items(menu_widget, 0, &item->menu, obj);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
302 gtk_widget_show_all(menu_widget);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
303
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
304 UiToolbarMenuWidget *tbmenu = malloc(sizeof(UiToolbarMenuWidget));
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
305 tbmenu->button = GTK_WIDGET(button);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
306 tbmenu->menu = GTK_MENU(menu_widget);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
307
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
308 g_signal_connect(
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
309 button,
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
310 "clicked",
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
311 G_CALLBACK(ui_toolbar_menubutton_clicked),
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
312 tbmenu);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
313
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
314 g_signal_connect(
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
315 button,
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
316 "destroy",
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
317 G_CALLBACK(ui_toolbar_menubutton_destroy),
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
318 tbmenu);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
319 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
320
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
321
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
322
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
323
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
324 // deprecated / unsupported
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
325 /*
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
326 void add_toolbar_combobox(GtkToolbar *tb, UiToolbarComboBox *cb, UiObject *obj) {
146
dd0ae1c62a72 new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 142
diff changeset
327 UiModel *modelinfo = ui_model(obj->ctx, UI_STRING, "", -1);
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
328 modelinfo->getvalue = cb->getvalue;
147
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 146
diff changeset
329 UiListModel *model = ui_list_model_new(obj, cb->var, modelinfo);
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
330
116
480354705c2f added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 90
diff changeset
331 GtkWidget *combobox = ui_create_combobox(obj, model, cb->callback, cb->userdata);
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
332 GtkToolItem *item = gtk_tool_item_new();
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
333 gtk_container_add(GTK_CONTAINER(item), combobox);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
334 gtk_toolbar_insert(tb, item, -1);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
335 }
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
336
116
480354705c2f added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 90
diff changeset
337 void add_toolbar_combobox_nv(GtkToolbar *tb, UiToolbarComboBoxNV *cb, UiObject *obj) {
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
338 UiVar *var = uic_create_var(obj->ctx, cb->listname, UI_VAR_LIST);
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
339 if(var) {
146
dd0ae1c62a72 new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 142
diff changeset
340 UiModel *modelinfo = ui_model(obj->ctx, UI_STRING, "", -1);
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
341 modelinfo->getvalue = cb->getvalue;
147
2e384acc89a6 adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 146
diff changeset
342 UiListModel *model = ui_list_model_new(obj, var, modelinfo);
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
343
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
344 GtkWidget *combobox = ui_create_combobox(obj, model, cb->callback, cb->userdata);
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
345 GtkToolItem *item = gtk_tool_item_new();
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
346 gtk_container_add(GTK_CONTAINER(item), combobox);
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
347 gtk_toolbar_insert(tb, item, -1);
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
348 }
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
349 }
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 254
diff changeset
350 */
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
351
276
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
352
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
353
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
354 #ifdef UI_GTK3
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
355
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
356 GtkWidget* ui_create_headerbar(UiObject *obj) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
357 GtkWidget *headerbar = gtk_header_bar_new();
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
358
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
359 CxMap *items = uic_get_toolbar_items();
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
360 CxList *left_defaults = uic_get_toolbar_defaults(UI_TOOLBAR_LEFT);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
361 CxList *center_defaults = uic_get_toolbar_defaults(UI_TOOLBAR_CENTER);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
362 CxList *right_defaults = uic_get_toolbar_defaults(UI_TOOLBAR_RIGHT);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
363
310
4918f9132552 add gtk4 pathbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
364 ui_toolbar_headerbar_add_items(obj, headerbar, items, left_defaults);
4918f9132552 add gtk4 pathbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
365 ui_toolbar_headerbar_add_items(obj, headerbar, items, center_defaults);
4918f9132552 add gtk4 pathbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
366 ui_toolbar_headerbar_add_items(obj, headerbar, items, right_defaults);
276
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
367
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
368 return headerbar;
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
369 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
370
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
371 static void hb_create_item(UiObject *obj, GtkWidget *toolbar, UiToolbarItemI *i) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
372 GtkHeaderBar *tb = GTK_HEADER_BAR(toolbar);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
373 switch(i->type) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
374 case UI_TOOLBAR_ITEM: {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
375 add_headerbar_item_widget(tb, (UiToolbarItem*)i, obj);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
376 break;
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
377 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
378 case UI_TOOLBAR_TOGGLEITEM: {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
379 add_headerbar_item_toggle_widget(tb, (UiToolbarToggleItem*)i, obj);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
380 break;
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
381 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
382 case UI_TOOLBAR_MENU: {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
383 add_headerbar_item_menu_widget(tb, (UiToolbarMenuItem*)i, obj);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
384 break;
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
385 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
386 default: fprintf(stderr, "toolbar item type unimplemented: %d\n", (int)i->type);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
387 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
388 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
389
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
390
310
4918f9132552 add gtk4 pathbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
391 void ui_toolbar_headerbar_add_items(UiObject *obj, GtkWidget *headerbar, CxMap *items, CxList *defaults) {
276
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
392 // add pre-configured items
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
393 CxIterator i = cxListIterator(defaults);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
394 cx_foreach(char*, def, i) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
395 UiToolbarItemI* item = uic_toolbar_get_item(def);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
396 if (!item) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
397 fprintf(stderr, "unknown toolbar item: %s\n", def);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
398 continue;
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
399 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
400 hb_create_item(obj, headerbar, item);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
401 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
402 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
403
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
404 void add_headerbar_item_widget(GtkHeaderBar *hb, UiToolbarItem *item, UiObject *obj) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
405 GtkWidget *button = gtk_button_new_with_label(item->args.label);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
406 if(item->args.icon) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
407 ui_button_set_icon_name(button, item->args.icon);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
408 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
409
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
410 gtk_header_bar_pack_start(hb, button);
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
411
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
412 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
413
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
414 void add_headerbar_item_toggle_widget(GtkHeaderBar *hb, UiToolbarToggleItem *item, UiObject *obj) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
415
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
416 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
417
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
418 void add_headerbar_item_menu_widget(GtkHeaderBar *hb, UiToolbarMenuItem *item, UiObject *obj) {
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
419
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
420 }
376921880a7f add initial support for headerbars (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 275
diff changeset
421
293
736c962f1011 initial gtk4 porting, incomplete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
422 #endif /* UI_GTK3 */
736c962f1011 initial gtk4 porting, incomplete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
423
736c962f1011 initial gtk4 porting, incomplete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
424 #endif /* UI_GTK2 || UI_GTK3 */

mercurial