Thu, 12 Dec 2024 20:01:43 +0100
update toolkit
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2023 Olaf Wintermann. All rights reserved. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "menu.h" |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include <stdarg.h> |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include <string.h> |
100 | 33 | #include <stdio.h> |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | #include <cx/linked_list.h> |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include <cx/array_list.h> |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | |
77
5de33c2d94c6
fix text/image preview loading
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
70
diff
changeset
|
38 | |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
39 | static UiMenuBuilder *current_builder; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
40 | static UiMenuBuilder global_builder; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
42 | static int menu_item_counter = 0; |
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
43 | |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
44 | void uic_menu_init(void) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
45 | global_builder.current = cxLinkedListCreate(cxDefaultAllocator, NULL, CX_STORE_POINTERS); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
46 | current_builder = &global_builder; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
47 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
48 | |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | static void add_menu(UiMenu *menu) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | cx_linked_list_add( |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
51 | (void**)¤t_builder->menus_begin, |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
52 | (void**)¤t_builder->menus_end, |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | offsetof(UiMenu, item.prev), |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | offsetof(UiMenu, item.next), |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | menu); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | static void add_item(UiMenuItemI *item) { |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
59 | UiMenu *menu = cxListAt(current_builder->current, 0); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | cx_linked_list_add( |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | (void**)&menu->items_begin, |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | (void**)&menu->items_end, |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | offsetof(UiMenu, item.prev), |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | offsetof(UiMenu, item.next), |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
68 | static void mitem_set_id(UiMenuItemI *item) { |
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
69 | snprintf(item->id, 8, "%x", menu_item_counter++); |
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
70 | } |
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
71 | |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | static char* nl_strdup(const char* s) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | return s ? strdup(s) : NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | |
70
94144a948aff
fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
76 | int* uic_copy_groups(const int* groups, size_t *ngroups) { |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | *ngroups = 0; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | if (!groups) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | return NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | size_t n; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | for (n = 0; groups[n] > -1; n++) { } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | if (ngroups > 0) { |
90
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
86 | int* newarray = calloc(n+1, sizeof(int)); |
68 | 87 | memcpy(newarray, groups, n * sizeof(int)); |
90
f501f0efc9a8
implement gtk dnd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
88 | newarray[n] = -1; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | *ngroups = n; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | return newarray; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | return NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
95 | void ui_menu_create(const char *label) { |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | // create menu |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | UiMenu *menu = malloc(sizeof(UiMenu)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
98 | mitem_set_id(&menu->item); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | menu->item.prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | menu->item.next = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | menu->item.type = UI_MENU; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | menu->label = label; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | menu->items_begin = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | menu->items_end = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | menu->parent = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | menu->end = 0; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
110 | if (cxListSize(current_builder->current) == 0) { |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | add_menu(menu); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | else { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | add_item((UiMenuItemI*)menu); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | uic_add_menu_to_stack(menu); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | UIEXPORT void ui_menu_end(void) { |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
120 | cxListRemove(current_builder->current, 0); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
121 | if(cxListSize(current_builder->current) == 0) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
122 | current_builder = &global_builder; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
123 | } |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | void ui_menuitem_create(UiMenuItemArgs args) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | UiMenuItem* item = malloc(sizeof(UiMenuItem)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
130 | mitem_set_id(&item->item); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | item->item.prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | item->item.next = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | item->item.type = UI_MENU_ITEM; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | item->label = nl_strdup(args.label); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | item->stockid = nl_strdup(args.stockid); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | item->icon = nl_strdup(args.icon); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | item->userdata = args.onclickdata; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | item->callback = args.onclick; |
70
94144a948aff
fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
140 | item->groups = uic_copy_groups(args.groups, &item->ngroups); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | add_item((UiMenuItemI*)item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | void ui_menuseparator() { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | UiMenuItemI *item = malloc(sizeof(UiMenuItemI)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
147 | item->id[0] = 0; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | item->prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | item->next = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | item->type = UI_MENU_SEPARATOR; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | add_item((UiMenuItemI*)item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | void ui_menu_toggleitem_create(UiMenuToggleItemArgs args) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | UiMenuCheckItem *item = malloc(sizeof(UiMenuCheckItem)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
157 | mitem_set_id(&item->item); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | item->item.prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | item->item.next = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | item->item.type = UI_MENU_CHECK_ITEM; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | item->label = nl_strdup(args.label); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | item->stockid = nl_strdup(args.stockid); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | item->icon = nl_strdup(args.icon); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | item->varname = nl_strdup(args.varname); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | item->userdata = args.onchangedata; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | item->callback = args.onchange; |
70
94144a948aff
fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
168 | item->groups = uic_copy_groups(args.groups, &item->ngroups); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | add_item((UiMenuItemI*)item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
173 | void ui_menu_radioitem_create(UiMenuToggleItemArgs args) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | UiMenuCheckItem* item = malloc(sizeof(UiMenuCheckItem)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
175 | mitem_set_id(&item->item); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | item->item.prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | item->item.next = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | item->item.type = UI_MENU_CHECK_ITEM; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | item->label = nl_strdup(args.label); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | item->stockid = nl_strdup(args.stockid); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
182 | item->icon = nl_strdup(args.icon); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | item->varname = nl_strdup(args.varname); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | item->userdata = args.onchangedata; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | item->callback = args.onchange; |
70
94144a948aff
fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
68
diff
changeset
|
186 | item->groups = uic_copy_groups(args.groups, &item->ngroups); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | add_item((UiMenuItemI*)item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | void ui_menu_itemlist_create(UiMenuItemListArgs args) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | UiMenuItemList*item = malloc(sizeof(UiMenuItemList)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
193 | mitem_set_id(&item->item); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | item->item.prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | item->item.next = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | item->item.type = UI_MENU_ITEM_LIST; |
8
726b24766437
implement connecting to repositories
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
197 | item->getvalue = args.getvalue; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | item->callback = args.onselect; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | item->userdata = args.onselectdata; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | item->varname = nl_strdup(args.varname); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | add_item((UiMenuItemI*)item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | void ui_menu_checkitemlist_create(UiMenuItemListArgs args) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | UiMenuItemList* item = malloc(sizeof(UiMenuItemList)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
207 | mitem_set_id(&item->item); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | item->item.prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | item->item.next = NULL; |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
210 | item->item.type = UI_MENU_CHECKITEM_LIST; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | item->callback = args.onselect; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | item->userdata = args.onselectdata; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | item->varname = nl_strdup(args.varname); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | add_item((UiMenuItemI*)item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | void ui_menu_radioitemlist_create(UiMenuItemListArgs args) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | UiMenuItemList* item = malloc(sizeof(UiMenuItemList)); |
44
473954dc6b74
update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
220 | mitem_set_id(&item->item); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | item->item.prev = NULL; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
222 | item->item.next = NULL; |
3
f154867f54dc
add nav buttons, update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
223 | item->item.type = UI_MENU_RADIOITEM_LIST; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | item->callback = args.onselect; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | item->userdata = args.onselectdata; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | item->varname = nl_strdup(args.varname); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | add_item((UiMenuItemI*)item); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
229 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
231 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
232 | void uic_add_menu_to_stack(UiMenu* menu) { |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
233 | cxListInsert(current_builder->current, 0, menu); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
234 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
235 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
236 | UiMenu* uic_get_menu_list(void) { |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
237 | return current_builder->menus_begin; |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
238 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
239 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
240 | UIEXPORT void ui_menu_close(void) { |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
241 | UiMenu* menu = cxListAt(current_builder->current, 0); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
242 | menu->end = 1; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
243 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
244 | |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
245 | UIEXPORT int ui_menu_is_open(void) { |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
246 | UiMenu* menu = cxListAt(current_builder->current, 0); |
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
247 | if (menu->end) { |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
248 | ui_menu_end(); |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
249 | return 0; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
250 | } |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
251 | return 1; |
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
252 | } |
88
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
253 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
254 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
255 | void ui_contextmenu_builder(UiMenuBuilder **out_builder) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
256 | UiMenuBuilder *builder = malloc(sizeof(UiMenuBuilder)); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
257 | builder->menus_begin = NULL; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
258 | builder->menus_end = NULL; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
259 | builder->current = cxLinkedListCreate(cxDefaultAllocator, NULL, CX_STORE_POINTERS); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
260 | current_builder = builder; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
261 | *out_builder = builder; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
262 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
263 | ui_menu_create(NULL); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
264 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
265 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
266 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
267 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
268 | static void free_menuitem(UiMenuItemI *item) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
269 | switch(item->type) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
270 | default: break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
271 | case UI_MENU: { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
272 | UiMenu *menu = (UiMenu*)item; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
273 | UiMenuItemI *m = menu->items_begin; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
274 | while(m) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
275 | UiMenuItemI *next = m->next; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
276 | free_menuitem(m); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
277 | m = next; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
278 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
279 | break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
280 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
281 | case UI_MENU_ITEM: { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
282 | UiMenuItem *i = (UiMenuItem*)item; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
283 | free(i->groups); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
284 | free(i->label); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
285 | free(i->stockid); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
286 | free(i->icon); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
287 | break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
288 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
289 | case UI_MENU_CHECK_ITEM: { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
290 | UiMenuCheckItem *i = (UiMenuCheckItem*)item; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
291 | free(i->groups); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
292 | free(i->label); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
293 | free(i->stockid); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
294 | free(i->icon); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
295 | free(i->varname); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
296 | break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
297 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
298 | case UI_MENU_RADIO_ITEM: { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
299 | UiMenuRadioItem *i = (UiMenuRadioItem*)item; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
300 | free(i->groups); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
301 | free(i->label); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
302 | free(i->stockid); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
303 | free(i->icon); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
304 | //free(i->varname); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
305 | break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
306 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
307 | case UI_MENU_ITEM_LIST: { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
308 | break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
309 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
310 | case UI_MENU_CHECKITEM_LIST: { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
311 | break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
312 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
313 | case UI_MENU_RADIOITEM_LIST: { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
314 | break; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
315 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
316 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
317 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
318 | free(item); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
319 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
320 | |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
321 | void ui_menubuilder_free(UiMenuBuilder *builder) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
322 | UiMenuItemI *m = &builder->menus_begin->item; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
323 | while(m) { |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
324 | UiMenuItemI *next = m->next; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
325 | free_menuitem(m); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
326 | m = next; |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
327 | } |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
328 | cxListDestroy(builder->current); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
329 | free(builder); |
e27526429d85
add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
330 | } |