ui/gtk/toolbar.c

Sun, 24 Jan 2016 11:59:58 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 24 Jan 2016 11:59:58 +0100
changeset 108
fcf6d5fac8f5
parent 90
2019fdbaadfd
child 116
480354705c2f
permissions
-rw-r--r--

radio buttons bind to UiInteger now

3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "toolbar.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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"
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "../../ucx/mempool.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include "../common/context.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 static UcxMap *toolbar_items;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 static UcxList *defaults;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 void ui_toolbar_init() {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 toolbar_items = ucx_map_new(16);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 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
47 ui_toolitem_img(name, label, NULL, f, udata);
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
50 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
51 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
52 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
53
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
54 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
55 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
56 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
57
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
58 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
59 va_list ap;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
60 va_start(ap, userdata);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
61 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
62 va_end(ap);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
63 }
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 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
66 va_list ap;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
67 va_start(ap, userdata);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
68 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
69 va_end(ap);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
70 }
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 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
73 UiToolItem *item = malloc(sizeof(UiToolItem));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
74 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
75 item->label = label;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
76 item->image = img;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
77 item->callback = f;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
78 item->userdata = udata;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
79 item->isimportant = 0;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
80 item->groups = NULL;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
81
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
82 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
83 }
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 void ui_toolitem_vstgr(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
86 char *name,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
87 char *stockid,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
88 int isimportant,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
89 ui_callback f,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
90 void *userdata,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
91 va_list ap)
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
92 {
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 UiStToolItem *item = malloc(sizeof(UiStToolItem));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_widget;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 item->stockid = stockid;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 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
97 item->userdata = userdata;
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
98 item->groups = NULL;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
99 item->isimportant = isimportant;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
100
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
101 // add groups
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
102 int group;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
103 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
104 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
105 }
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 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
108 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
109
49
a80ba8741be6 added toolbar toggle button (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
110 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
111 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
112 }
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 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
115 UiStToolItem *item = malloc(sizeof(UiStToolItem));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
116 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
117 item->stockid = stockid;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
118 item->callback = f;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
119 item->userdata = udata;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
120 item->groups = NULL;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
121 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
122
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
123 // add groups
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
124 va_list ap;
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
125 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
126 int group;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
127 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
128 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
129 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
130 va_end(ap);
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 ucx_map_cstr_put(toolbar_items, name, item);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
135 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
136 UiToolItem *item = malloc(sizeof(UiToolItem));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
137 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
138 item->label = label;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
139 item->image = img;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
140 item->callback = f;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
141 item->userdata = udata;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
142 item->groups = NULL;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
143 item->isimportant = 0;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
144
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
145 // add groups
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
146 va_list ap;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
147 va_start(ap, udata);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
148 int group;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
149 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
150 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
151 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
152 va_end(ap);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
153
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
154 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
155 }
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
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
158 void ui_toolbar_combobox(
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
159 char *name,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
160 UiList *list,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
161 ui_model_getvalue_f getvalue,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
162 ui_callback f,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
163 void *udata)
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
164 {
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
165 UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox));
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
166 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
167 cb->list = list;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
168 cb->getvalue = getvalue;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
169 cb->callback = f;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
170 cb->userdata = udata;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
171
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
172 ucx_map_cstr_put(toolbar_items, name, cb);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
173 }
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 void ui_toolbar_combobox_str(
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
176 char *name,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
177 UiList *list,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
178 ui_callback f,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
179 void *udata)
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
180 {
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
181 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
182 }
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 void ui_toolbar_combobox_nv(
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
185 char *name,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
186 char *listname,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
187 ui_model_getvalue_f getvalue,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
188 ui_callback f,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
189 void *udata)
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
190 {
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
191 UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV));
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
192 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
193 cb->listname = listname;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
194 cb->getvalue = getvalue;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
195 cb->callback = f;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
196 cb->userdata = udata;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
197
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
198 ucx_map_cstr_put(toolbar_items, name, cb);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
199 }
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
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 void ui_toolbar_add_default(char *name) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 char *s = strdup(name);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 defaults = ucx_list_append(defaults, s);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 GtkWidget* ui_create_toolbar(UiObject *obj) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 if(!defaults) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 return NULL;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 GtkWidget *toolbar = gtk_toolbar_new();
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 #ifdef UI_GTK3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 gtk_style_context_add_class(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 gtk_widget_get_style_context(toolbar),
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 #endif
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 GtkToolbar *tb = GTK_TOOLBAR(toolbar);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 UCX_FOREACH(elm, defaults) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 UiToolItemI *item = ucx_map_cstr_get(toolbar_items, elm->data);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 if(item) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 item->add_to(tb, item, obj);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 } else if(!strcmp(elm->data, "@separator")) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 gtk_toolbar_insert(tb, gtk_separator_tool_item_new(), -1);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 } else {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", elm->data);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 return toolbar;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 void add_toolitem_widget(GtkToolbar *tb, UiToolItem *item, UiObject *obj) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 GtkToolItem *button = gtk_tool_button_new(NULL, item->label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 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
237 if(item->image) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
238 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
239 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
240 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
241 } else {
2019fdbaadfd persistent textarea cursor position
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
242 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
243 }
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 if(item->callback) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 UiEventData *event = ucx_mempool_malloc(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 obj->ctx->mempool,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 sizeof(UiEventData));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 event->obj = obj;
42
29b2821d1262 added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
250 event->userdata = item->userdata;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 event->callback = item->callback;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 g_signal_connect(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 button,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 "clicked",
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 G_CALLBACK(ui_button_clicked),
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 event);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 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
261
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
262 if(item->groups) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
263 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
264 }
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 void add_toolitem_st_widget(GtkToolbar *tb, UiStToolItem *item, UiObject *obj) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 GtkToolItem *button = gtk_tool_button_new_from_stock(item->stockid);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 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
270 if(item->isimportant) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
271 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
272 }
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 if(item->callback) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 UiEventData *event = ucx_mempool_malloc(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 obj->ctx->mempool,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 sizeof(UiEventData));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 event->obj = obj;
42
29b2821d1262 added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
279 event->userdata = item->userdata;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 event->callback = item->callback;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 g_signal_connect(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 button,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 "clicked",
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 G_CALLBACK(ui_button_clicked),
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 event);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 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
290
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
291 if(item->groups) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
292 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
293 }
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
295
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
296 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
297 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
298 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
299 if(item->label) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
300 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
301 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
302 if(item->image) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
303 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
304 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
305 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
306 }
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 if(item->callback) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
309 UiEventData *event = ucx_mempool_malloc(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
310 obj->ctx->mempool,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
311 sizeof(UiEventData));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
312 event->obj = obj;
42
29b2821d1262 added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
313 event->userdata = item->userdata;
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
314 event->callback = item->callback;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
315
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
316 g_signal_connect(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
317 button,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
318 "toggled",
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
319 G_CALLBACK(ui_button_toggled),
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
320 event);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
321 }
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 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
324
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
325 if(item->groups) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
326 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
327 }
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 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
331 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
332 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
333
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
334 if(item->callback) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
335 UiEventData *event = ucx_mempool_malloc(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
336 obj->ctx->mempool,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
337 sizeof(UiEventData));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
338 event->obj = obj;
42
29b2821d1262 added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
339 event->userdata = item->userdata;
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
340 event->callback = item->callback;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
341
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
342 g_signal_connect(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
343 button,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
344 "toggled",
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
345 G_CALLBACK(ui_button_toggled),
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
346 event);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
347 }
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 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
350
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
351 if(item->groups) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
352 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
353 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
354 }
86
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
355
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
356 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
357 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
358 modelinfo->getvalue = cb->getvalue;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
359 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
360 listptr->list = cb->list;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
361 UiListModel *model = ui_list_model_new(listptr, modelinfo);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
362
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
363 GtkWidget *combobox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model));
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
364 cb->list->observers = ui_add_observer(
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
365 cb->list->observers,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
366 (ui_callback)ui_listview_update,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
367 combobox);
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 GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
370 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), renderer, TRUE);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
371 gtk_cell_layout_set_attributes(
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
372 GTK_CELL_LAYOUT(combobox),
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
373 renderer,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
374 "text",
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
375 0,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
376 NULL);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
377 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
378
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
379 // add callback
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
380 if(cb->callback) {
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
381 UiEventData *event = ui_malloc(obj->ctx, sizeof(UiEventData));
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
382 event->obj = obj;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
383 event->userdata = cb->userdata;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
384 event->callback = cb->callback;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
385 event->value = 0;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
386
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
387 g_signal_connect(
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
388 combobox,
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
389 "changed",
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
390 G_CALLBACK(ui_combobox_change_event),
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
391 event);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
392 }
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
393
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
394 GtkToolItem *item = gtk_tool_item_new();
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
395 gtk_container_add(GTK_CONTAINER(item), combobox);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
396 gtk_toolbar_insert(tb, item, -1);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
397 }
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
398
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
399 void add_toolbara_combobox_nv(GtkToolbar *tb, UiToolbarComboBoxNV *cb, UiObject *obj) {
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
400
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
401 }
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
402
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
403 void ui_combobox_change_event(GtkComboBox *widget, UiEventData *e) {
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
404 UiEvent event;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
405 event.obj = e->obj;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
406 event.window = event.obj->window;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
407 event.document = event.obj->ctx->document;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
408 event.eventdata = NULL;
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
409 event.intval = gtk_combo_box_get_active(widget);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
410 e->callback(&event, e->userdata);
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
411 }
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
412
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
413 void ui_combobox_update(UiEvent *event, void *combobox) {
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
414 printf("ui_combobox_update\n");
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
415 printf("TODO: implement\n");
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
416 }
3c63f57a8f77 added toolbar combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 49
diff changeset
417

mercurial