Wed, 13 Jul 2016 15:35:59 +0200
implemented simple toolbar items (Cocoa)
3 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2014 Olaf Wintermann. All rights reserved. | |
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" |
3 | 37 | #include "../../ucx/mempool.h" |
38 | #include "../common/context.h" | |
39 | ||
40 | static UcxMap *toolbar_items; | |
41 | static UcxList *defaults; | |
42 | ||
43 | void ui_toolbar_init() { | |
44 | toolbar_items = ucx_map_new(16); | |
45 | } | |
46 | ||
47 | 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
|
48 | ui_toolitem_img(name, label, NULL, f, udata); |
3 | 49 | } |
50 | ||
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
51 | 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
|
52 | 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
|
53 | } |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
54 | |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
55 | 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
|
56 | 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
|
57 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
58 | |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
59 | 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
|
60 | va_list ap; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
61 | va_start(ap, userdata); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
62 | 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
|
63 | va_end(ap); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
64 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
65 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
66 | 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
|
67 | va_list ap; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
68 | va_start(ap, userdata); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
69 | 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
|
70 | va_end(ap); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
71 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
72 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
73 | 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
|
74 | UiToolItem *item = malloc(sizeof(UiToolItem)); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
75 | 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
|
76 | item->label = label; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
77 | item->image = img; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
78 | item->callback = f; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
79 | item->userdata = udata; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
80 | item->isimportant = 0; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
81 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
82 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
83 | ucx_map_cstr_put(toolbar_items, name, item); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
84 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
85 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
86 | void ui_toolitem_vstgr( |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
87 | char *name, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
88 | char *stockid, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
89 | int isimportant, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
90 | ui_callback f, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
91 | void *userdata, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
92 | va_list ap) |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
93 | { |
3 | 94 | UiStToolItem *item = malloc(sizeof(UiStToolItem)); |
95 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_widget; | |
96 | item->stockid = stockid; | |
97 | 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
|
98 | item->userdata = userdata; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
99 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
100 | item->isimportant = isimportant; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
101 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
102 | // add groups |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
103 | int group; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
104 | while((group = va_arg(ap, int)) != -1) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
105 | item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
106 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
107 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
108 | ucx_map_cstr_put(toolbar_items, name, item); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
109 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
110 | |
49
a80ba8741be6
added toolbar toggle button (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
42
diff
changeset
|
111 | void ui_toolitem_toggle_st(char *name, char *stockid, 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
|
112 | ui_toolitem_toggle_stgr(name, stockid, f, udata, -1); |
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 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
115 | void ui_toolitem_toggle_stgr(char *name, char *stockid, ui_callback f, void *udata, ...) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
116 | UiStToolItem *item = malloc(sizeof(UiStToolItem)); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
117 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_toggle_st_widget; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
118 | item->stockid = stockid; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
119 | item->callback = f; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
120 | item->userdata = udata; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
121 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
122 | item->isimportant = 0; |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
123 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
124 | // add groups |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
125 | va_list ap; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
126 | va_start(ap, udata); |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
127 | int group; |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
128 | while((group = va_arg(ap, int)) != -1) { |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
129 | item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group); |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
130 | } |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
131 | va_end(ap); |
3 | 132 | |
133 | ucx_map_cstr_put(toolbar_items, name, item); | |
134 | } | |
135 | ||
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
136 | void ui_toolitem_toggle_imggr(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
|
137 | UiToolItem *item = malloc(sizeof(UiToolItem)); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
138 | 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
|
139 | item->label = label; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
140 | item->image = img; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
141 | item->callback = f; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
142 | item->userdata = udata; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
143 | item->groups = NULL; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
144 | item->isimportant = 0; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
145 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
146 | // add groups |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
147 | va_list ap; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
148 | va_start(ap, udata); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
149 | int group; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
150 | while((group = va_arg(ap, int)) != -1) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
151 | item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
152 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
153 | va_end(ap); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
154 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
155 | ucx_map_cstr_put(toolbar_items, name, item); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
156 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
157 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
158 | |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
159 | void ui_toolbar_combobox( |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
160 | char *name, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
161 | UiList *list, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
162 | ui_model_getvalue_f getvalue, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
163 | ui_callback f, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
164 | void *udata) |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
165 | { |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
166 | UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox)); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
167 | cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
168 | cb->list = list; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
169 | cb->getvalue = getvalue; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
170 | cb->callback = f; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
171 | cb->userdata = udata; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
172 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
173 | ucx_map_cstr_put(toolbar_items, name, cb); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
174 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
175 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
176 | void ui_toolbar_combobox_str( |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
177 | char *name, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
178 | UiList *list, |
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 | 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
|
183 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
184 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
185 | void ui_toolbar_combobox_nv( |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
186 | char *name, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
187 | char *listname, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
188 | ui_model_getvalue_f getvalue, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
189 | ui_callback f, |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
190 | void *udata) |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
191 | { |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
192 | UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV)); |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
193 | 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
|
194 | cb->listname = listname; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
195 | cb->getvalue = getvalue; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
196 | cb->callback = f; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
197 | cb->userdata = udata; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
198 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
199 | ucx_map_cstr_put(toolbar_items, name, cb); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
200 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
201 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
202 | |
3 | 203 | void ui_toolbar_add_default(char *name) { |
204 | char *s = strdup(name); | |
205 | defaults = ucx_list_append(defaults, s); | |
206 | } | |
207 | ||
208 | GtkWidget* ui_create_toolbar(UiObject *obj) { | |
209 | if(!defaults) { | |
210 | return NULL; | |
211 | } | |
212 | ||
213 | GtkWidget *toolbar = gtk_toolbar_new(); | |
214 | #ifdef UI_GTK3 | |
215 | gtk_style_context_add_class( | |
216 | gtk_widget_get_style_context(toolbar), | |
217 | GTK_STYLE_CLASS_PRIMARY_TOOLBAR); | |
218 | #endif | |
219 | ||
220 | GtkToolbar *tb = GTK_TOOLBAR(toolbar); | |
221 | UCX_FOREACH(elm, defaults) { | |
222 | UiToolItemI *item = ucx_map_cstr_get(toolbar_items, elm->data); | |
223 | if(item) { | |
224 | item->add_to(tb, item, obj); | |
225 | } else if(!strcmp(elm->data, "@separator")) { | |
226 | gtk_toolbar_insert(tb, gtk_separator_tool_item_new(), -1); | |
227 | } else { | |
228 | fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", elm->data); | |
229 | } | |
230 | } | |
231 | ||
232 | return toolbar; | |
233 | } | |
234 | ||
235 | void add_toolitem_widget(GtkToolbar *tb, UiToolItem *item, UiObject *obj) { | |
236 | GtkToolItem *button = gtk_tool_button_new(NULL, item->label); | |
237 | 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
|
238 | if(item->image) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
239 | 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
|
240 | 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
|
241 | 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
|
242 | } else { |
2019fdbaadfd
persistent textarea cursor position
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
243 | 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
|
244 | } |
3 | 245 | |
246 | if(item->callback) { | |
247 | UiEventData *event = ucx_mempool_malloc( | |
248 | obj->ctx->mempool, | |
249 | sizeof(UiEventData)); | |
250 | event->obj = obj; | |
42
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
251 | event->userdata = item->userdata; |
3 | 252 | event->callback = item->callback; |
253 | ||
254 | g_signal_connect( | |
255 | button, | |
256 | "clicked", | |
257 | G_CALLBACK(ui_button_clicked), | |
258 | event); | |
259 | } | |
260 | ||
261 | 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
|
262 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
263 | if(item->groups) { |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
264 | uic_add_group_widget(obj->ctx, button, item->groups); |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
265 | } |
3 | 266 | } |
267 | ||
268 | void add_toolitem_st_widget(GtkToolbar *tb, UiStToolItem *item, UiObject *obj) { | |
269 | GtkToolItem *button = gtk_tool_button_new_from_stock(item->stockid); | |
270 | 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
|
271 | if(item->isimportant) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
272 | 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
|
273 | } |
3 | 274 | |
275 | if(item->callback) { | |
276 | UiEventData *event = ucx_mempool_malloc( | |
277 | obj->ctx->mempool, | |
278 | sizeof(UiEventData)); | |
279 | event->obj = obj; | |
42
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
280 | event->userdata = item->userdata; |
3 | 281 | event->callback = item->callback; |
282 | ||
283 | g_signal_connect( | |
284 | button, | |
285 | "clicked", | |
286 | G_CALLBACK(ui_button_clicked), | |
287 | event); | |
288 | } | |
289 | ||
290 | 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
|
291 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
292 | if(item->groups) { |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
293 | uic_add_group_widget(obj->ctx, button, item->groups); |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
294 | } |
3 | 295 | } |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
296 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
297 | void add_toolitem_toggle_widget(GtkToolbar *tb, UiToolItem *item, UiObject *obj) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
298 | GtkToolItem *button = gtk_toggle_tool_button_new(); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
299 | gtk_tool_item_set_homogeneous(button, FALSE); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
300 | if(item->label) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
301 | gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), item->label); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
302 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
303 | if(item->image) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
304 | 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
|
305 | 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
|
306 | gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), image); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
307 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
308 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
309 | if(item->callback) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
310 | UiEventData *event = ucx_mempool_malloc( |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
311 | obj->ctx->mempool, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
312 | sizeof(UiEventData)); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
313 | event->obj = obj; |
42
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
314 | event->userdata = item->userdata; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
315 | event->callback = item->callback; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
316 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
317 | g_signal_connect( |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
318 | button, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
319 | "toggled", |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
320 | G_CALLBACK(ui_button_toggled), |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
321 | event); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
322 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
323 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
324 | 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
|
325 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
326 | if(item->groups) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
327 | uic_add_group_widget(obj->ctx, button, item->groups); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
328 | } |
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 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
331 | void add_toolitem_toggle_st_widget(GtkToolbar *tb, UiStToolItem *item, UiObject *obj) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
332 | GtkToolItem *button = gtk_toggle_tool_button_new_from_stock(item->stockid); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
333 | gtk_tool_item_set_homogeneous(button, FALSE); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
334 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
335 | if(item->callback) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
336 | UiEventData *event = ucx_mempool_malloc( |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
337 | obj->ctx->mempool, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
338 | sizeof(UiEventData)); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
339 | event->obj = obj; |
42
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
33
diff
changeset
|
340 | event->userdata = item->userdata; |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
341 | event->callback = item->callback; |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
342 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
343 | g_signal_connect( |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
344 | button, |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
345 | "toggled", |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
346 | G_CALLBACK(ui_button_toggled), |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
347 | event); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
348 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
349 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
350 | 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
|
351 | |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
352 | if(item->groups) { |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
353 | uic_add_group_widget(obj->ctx, button, item->groups); |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
354 | } |
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
355 | } |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
356 | |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
357 | void add_toolbar_combobox(GtkToolbar *tb, UiToolbarComboBox *cb, UiObject *obj) { |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
358 | UiModelInfo *modelinfo = ui_model_info(obj->ctx, UI_STRING, "", -1); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
359 | modelinfo->getvalue = cb->getvalue; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
360 | UiListPtr *listptr = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiListPtr)); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
361 | listptr->list = cb->list; |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
362 | UiListModel *model = ui_list_model_new(listptr, modelinfo); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
363 | |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
364 | 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
|
365 | GtkToolItem *item = gtk_tool_item_new(); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
366 | gtk_container_add(GTK_CONTAINER(item), combobox); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
367 | gtk_toolbar_insert(tb, item, -1); |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
368 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
369 | |
116
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
370 | void add_toolbar_combobox_nv(GtkToolbar *tb, UiToolbarComboBoxNV *cb, UiObject *obj) { |
480354705c2f
added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
90
diff
changeset
|
371 | // TODO |
86
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
372 | } |
3c63f57a8f77
added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
373 |