Thu, 15 Feb 2024 21:12:54 +0100
implement grid colspan/rowspan (GTK)
3 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
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 | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include <stdio.h> | |
30 | #include <stdlib.h> | |
31 | #include <string.h> | |
32 | ||
33 | #include "toolbar.h" | |
34 | #include "button.h" | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
35 | #include "image.h" |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
36 | #include "tree.h" |
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
37 | #include <cx/mempool.h> |
174 | 38 | #include <cx/hash_map.h> |
39 | #include <cx/linked_list.h> | |
40 | #include <cx/array_list.h> | |
3 | 41 | #include "../common/context.h" |
42 | ||
174 | 43 | static CxMap *toolbar_items; |
44 | static CxList *defaults; | |
3 | 45 | |
46 | void ui_toolbar_init() { | |
174 | 47 | toolbar_items = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16); |
48 | defaults = cxLinkedListCreateSimple(CX_STORE_POINTERS); | |
3 | 49 | } |
50 | ||
51 | void ui_toolitem(char *name, char *label, ui_callback f, void *udata) { | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
52 | ui_toolitem_img(name, label, NULL, f, udata); |
3 | 53 | } |
54 | ||
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
55 | void ui_toolitem_st(char *name, char *stockid, ui_callback f, void *userdata) { |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
56 | ui_toolitem_stgr(name, stockid, f, userdata, -1); |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
57 | } |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
58 | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
59 | void ui_toolitem_sti(char *name, char *stockid, ui_callback f, void *userdata) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
60 | ui_toolitem_stgri(name, stockid, f, userdata, -1); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
61 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
62 | |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
63 | void ui_toolitem_stgr(char *name, char *stockid, ui_callback f, void *userdata, ...) { |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
64 | va_list ap; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
65 | va_start(ap, userdata); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
66 | ui_toolitem_vstgr(name, stockid, 0, f, userdata, ap); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
67 | va_end(ap); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
68 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
69 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
70 | void ui_toolitem_stgri(char *name, char *stockid, ui_callback f, void *userdata, ...) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
71 | va_list ap; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
72 | va_start(ap, userdata); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
73 | ui_toolitem_vstgr(name, stockid, 1, f, userdata, ap); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
74 | va_end(ap); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
75 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
76 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
77 | void ui_toolitem_img(char *name, char *label, char *img, ui_callback f, void *udata) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
78 | UiToolItem *item = malloc(sizeof(UiToolItem)); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
79 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_widget; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
80 | item->label = label; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
81 | item->image = img; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
82 | item->callback = f; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
83 | item->userdata = udata; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
84 | item->isimportant = 0; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
85 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
86 | |
174 | 87 | cxMapPut(toolbar_items, name, item); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
88 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
89 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
90 | void ui_toolitem_vstgr( |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
91 | char *name, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
92 | char *stockid, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
93 | int isimportant, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
94 | ui_callback f, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
95 | void *userdata, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
96 | va_list ap) |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
97 | { |
3 | 98 | UiStToolItem *item = malloc(sizeof(UiStToolItem)); |
99 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_widget; | |
100 | item->stockid = stockid; | |
101 | item->callback = f; | |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
102 | item->userdata = userdata; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
103 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
104 | item->isimportant = isimportant; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
105 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
106 | // add groups |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
107 | int group; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
108 | while((group = va_arg(ap, int)) != -1) { |
174 | 109 | if(!item->groups) { |
110 | item->groups = cxArrayListCreateSimple(sizeof(int), 16); | |
111 | } | |
112 | cxListAdd(item->groups, &group); | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
113 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
114 | |
174 | 115 | cxMapPut(toolbar_items, name, item); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
116 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
117 | |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
118 | void ui_toolitem_toggle(const char *name, const char *label, const char *img, UiInteger *i) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
119 | UiToggleToolItem *item = malloc(sizeof(UiToggleToolItem)); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
120 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_toggle_widget; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
121 | item->label = label; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
122 | item->image = img; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
123 | item->stockid = NULL; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
124 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
125 | item->isimportant = 0; |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
126 | item->value = i; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
127 | item->var = NULL; |
3 | 128 | |
174 | 129 | cxMapPut(toolbar_items, name, item); |
3 | 130 | } |
131 | ||
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
132 | void ui_toolitem_toggle_st(const char *name, const char *stockid, UiInteger *i) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
133 | UiToggleToolItem *item = malloc(sizeof(UiToggleToolItem)); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
134 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_toggle_widget; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
135 | item->label = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
136 | item->image = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
137 | item->stockid = stockid; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
138 | item->groups = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
139 | item->isimportant = 0; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
140 | item->value = i; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
141 | item->var = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
142 | |
174 | 143 | cxMapPut(toolbar_items, name, item); |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
144 | } |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
145 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
146 | void ui_toolitem_toggle_nv(const char *name, const char *label, const char *img, const char *intvar) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
147 | UiToggleToolItem *item = malloc(sizeof(UiToggleToolItem)); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
148 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_toggle_widget; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
149 | item->label = label; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
150 | item->image = img; |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
151 | item->stockid = NULL; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
152 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
153 | item->isimportant = 0; |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
154 | item->value = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
155 | item->var = intvar; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
156 | |
174 | 157 | cxMapPut(toolbar_items, name, item); |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
158 | } |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
159 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
160 | void ui_toolitem_toggle_stnv(const char *name, const char *stockid, const char *intvar) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
161 | UiToggleToolItem *item = malloc(sizeof(UiToggleToolItem)); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
162 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_toggle_widget; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
163 | item->label = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
164 | item->image = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
165 | item->stockid = stockid; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
166 | item->groups = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
167 | item->isimportant = 0; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
168 | item->value = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
169 | item->var = intvar; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
170 | |
174 | 171 | cxMapPut(toolbar_items, name, item); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
172 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
173 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
174 | |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
175 | void ui_toolbar_combobox( |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
176 | char *name, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
177 | UiList *list, |
142
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
178 | ui_getvaluefunc getvalue, |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
179 | ui_callback f, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
180 | void *udata) |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
181 | { |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
182 | UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox)); |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
183 | cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
184 | UiVar *var = malloc(sizeof(UiVar)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
185 | var->value = list; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
186 | var->type = UI_VAR_SPECIAL; |
163
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
187 | var->from = NULL; |
b70e2a77dea0
refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
188 | var->from_ctx = NULL; |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
189 | cb->var = var; |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
190 | cb->getvalue = getvalue; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
191 | cb->callback = f; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
192 | cb->userdata = udata; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
193 | |
174 | 194 | cxMapPut(toolbar_items, name, cb); |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
195 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
196 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
197 | void ui_toolbar_combobox_str( |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
198 | char *name, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
199 | UiList *list, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
200 | ui_callback f, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
201 | void *udata) |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
202 | { |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
203 | ui_toolbar_combobox(name, list, ui_strmodel_getvalue, f, udata); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
204 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
205 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
206 | void ui_toolbar_combobox_nv( |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
207 | char *name, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
208 | char *listname, |
142
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
209 | ui_getvaluefunc getvalue, |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
210 | ui_callback f, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
211 | void *udata) |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
212 | { |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
213 | UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV)); |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
214 | cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox_nv; |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
215 | cb->listname = listname; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
216 | cb->getvalue = getvalue; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
217 | cb->callback = f; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
218 | cb->userdata = udata; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
219 | |
174 | 220 | cxMapPut(toolbar_items, name, cb); |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
221 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
222 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
223 | |
3 | 224 | GtkWidget* ui_create_toolbar(UiObject *obj) { |
225 | if(!defaults) { | |
226 | return NULL; | |
227 | } | |
228 | ||
229 | GtkWidget *toolbar = gtk_toolbar_new(); | |
230 | #ifdef UI_GTK3 | |
231 | gtk_style_context_add_class( | |
232 | gtk_widget_get_style_context(toolbar), | |
233 | GTK_STYLE_CLASS_PRIMARY_TOOLBAR); | |
234 | #endif | |
235 | ||
236 | GtkToolbar *tb = GTK_TOOLBAR(toolbar); | |
174 | 237 | CxIterator i = cxListIterator(defaults); |
238 | cx_foreach(char *, def, i) { | |
239 | UiToolItemI *item = cxMapGet(toolbar_items, def); | |
3 | 240 | if(item) { |
241 | item->add_to(tb, item, obj); | |
174 | 242 | } else if(!strcmp(def, "@separator")) { |
3 | 243 | gtk_toolbar_insert(tb, gtk_separator_tool_item_new(), -1); |
244 | } else { | |
174 | 245 | fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", def); |
3 | 246 | } |
247 | } | |
248 | ||
249 | return toolbar; | |
250 | } | |
251 | ||
252 | void add_toolitem_widget(GtkToolbar *tb, UiToolItem *item, UiObject *obj) { | |
253 | GtkToolItem *button = gtk_tool_button_new(NULL, item->label); | |
254 | gtk_tool_item_set_homogeneous(button, FALSE); | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
255 | if(item->image) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
256 | GdkPixbuf *pixbuf = ui_get_image(item->image); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
257 | GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
258 | gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), image); |
90
2019fdbaadfd
persistent textarea cursor position
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
259 | } else { |
2019fdbaadfd
persistent textarea cursor position
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
260 | gtk_tool_item_set_is_important(button, TRUE); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
261 | } |
3 | 262 | |
263 | if(item->callback) { | |
174 | 264 | UiEventData *event = cxMalloc( |
265 | obj->ctx->allocator, | |
3 | 266 | sizeof(UiEventData)); |
267 | event->obj = obj; | |
42
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
268 | event->userdata = item->userdata; |
3 | 269 | event->callback = item->callback; |
270 | ||
271 | g_signal_connect( | |
272 | button, | |
273 | "clicked", | |
274 | G_CALLBACK(ui_button_clicked), | |
275 | event); | |
276 | } | |
277 | ||
278 | 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
|
279 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
280 | if(item->groups) { |
168
1b99acacc5bb
refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
167
diff
changeset
|
281 | 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
|
282 | } |
3 | 283 | } |
284 | ||
285 | void add_toolitem_st_widget(GtkToolbar *tb, UiStToolItem *item, UiObject *obj) { | |
286 | GtkToolItem *button = gtk_tool_button_new_from_stock(item->stockid); | |
287 | gtk_tool_item_set_homogeneous(button, FALSE); | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
288 | if(item->isimportant) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
289 | gtk_tool_item_set_is_important(button, TRUE); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
290 | } |
3 | 291 | |
292 | if(item->callback) { | |
174 | 293 | UiEventData *event = cxMalloc( |
294 | obj->ctx->allocator, | |
3 | 295 | sizeof(UiEventData)); |
296 | event->obj = obj; | |
42
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
297 | event->userdata = item->userdata; |
3 | 298 | event->callback = item->callback; |
299 | ||
300 | g_signal_connect( | |
301 | button, | |
302 | "clicked", | |
303 | G_CALLBACK(ui_button_clicked), | |
304 | event); | |
305 | } | |
306 | ||
307 | 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
|
308 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
309 | if(item->groups) { |
168
1b99acacc5bb
refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
167
diff
changeset
|
310 | 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
|
311 | } |
3 | 312 | } |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
313 | |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
314 | void add_toolitem_toggle_widget(GtkToolbar *tb, UiToggleToolItem *item, UiObject *obj) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
315 | GtkToolItem *button; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
316 | if(item->stockid) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
317 | button = gtk_toggle_tool_button_new_from_stock(item->stockid); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
318 | } else { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
319 | button = gtk_toggle_tool_button_new(); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
320 | gtk_tool_item_set_homogeneous(button, FALSE); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
321 | if(item->label) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
322 | gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), item->label); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
323 | } |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
324 | if(item->image) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
325 | GdkPixbuf *pixbuf = ui_get_image(item->image); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
326 | GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
327 | gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), image); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
328 | } |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
329 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
330 | |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
331 | UiVar *var; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
332 | if(item->value) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
333 | var = malloc(sizeof(UiVar)); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
334 | var->value = item->value; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
335 | var->type = UI_VAR_SPECIAL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
336 | var->from = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
337 | var->from_ctx = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
338 | } else { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
339 | var = uic_create_var(obj->ctx, item->var, UI_VAR_INTEGER); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
340 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
341 | |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
342 | if(var->value) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
343 | UiInteger *i = var->value; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
344 | i->get = ui_tool_toggle_button_get; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
345 | i->set = ui_tool_toggle_button_set; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
346 | i->obj = button; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
347 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
348 | if(i->value != 0) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
349 | gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(button), TRUE); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
350 | } |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
351 | } |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
352 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
353 | // register event |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
354 | // the event func will call the UiInteger observer callbacks |
174 | 355 | UiEventData *event = cxMalloc( |
356 | obj->ctx->allocator, | |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
357 | sizeof(UiEventData)); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
358 | event->obj = obj; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
359 | event->userdata = var; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
360 | event->callback = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
361 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
362 | g_signal_connect( |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
363 | button, |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
364 | "toggled", |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
365 | G_CALLBACK(ui_tool_button_toggled), |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
366 | event); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
367 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
368 | // add item to toolbar |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
369 | 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
|
370 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
371 | if(item->groups) { |
168
1b99acacc5bb
refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
167
diff
changeset
|
372 | 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
|
373 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
374 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
375 | |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
376 | void ui_tool_button_toggled(GtkToggleToolButton *widget, UiEventData *event) { |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
377 | UiEvent e; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
378 | e.obj = event->obj; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
379 | e.window = event->obj->window; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
380 | e.document = event->obj->ctx->document; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
381 | e.eventdata = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
382 | 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
|
383 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
384 | UiVar *var = event->userdata; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
385 | UiInteger *i = var->value; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
386 | |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
387 | ui_notify_evt(i->observers, &e); |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
388 | } |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
389 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
390 | 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
|
391 | 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
|
392 | return integer->value; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
393 | } |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
394 | |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
395 | 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
|
396 | gboolean s = value != 0 ? TRUE : FALSE; |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
397 | 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
|
398 | integer->value = s; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
399 | } |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
400 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
401 | 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
|
402 | 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
|
403 | modelinfo->getvalue = cb->getvalue; |
147
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
404 | 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
|
405 | |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
406 | 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
|
407 | GtkToolItem *item = gtk_tool_item_new(); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
408 | gtk_container_add(GTK_CONTAINER(item), combobox); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
409 | gtk_toolbar_insert(tb, item, -1); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
410 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
411 | |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
412 | 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
|
413 | 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
|
414 | if(var) { |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
415 | 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
|
416 | modelinfo->getvalue = cb->getvalue; |
147
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
417 | 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
|
418 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
419 | 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
|
420 | GtkToolItem *item = gtk_tool_item_new(); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
421 | gtk_container_add(GTK_CONTAINER(item), combobox); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
422 | gtk_toolbar_insert(tb, item, -1); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
423 | } |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
424 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
425 |