ui/motif/toolkit.c

Tue, 17 Oct 2023 21:00:48 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 17 Oct 2023 21:00:48 +0200
branch
newapi
changeset 219
527a66c0afb2
parent 176
bc63cb601f6d
permissions
-rw-r--r--

add label (WinUI3)

0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1f419bd32da1 added files
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
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
31 #include <unistd.h>
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
32 #include <pthread.h>
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "toolkit.h"
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1
diff changeset
35 #include "toolbar.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1
diff changeset
36 #include "stock.h"
1
eb5269000bc8 added some document functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
37 #include "../common/document.h"
24
06bceda81a03 added application properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 21
diff changeset
38 #include "../common/properties.h"
176
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 160
diff changeset
39 #include <cx/buffer.h>
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 static XtAppContext app;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 static Display *display;
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
43 static Widget active_window;
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 static char *application_name;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
134
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
46 static ui_callback startup_func;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
47 static void *startup_data;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
48 static ui_callback open_func;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
49 void *open_data;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
50 static ui_callback exit_func;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
51 void *exit_data;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
52
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 static ui_callback appclose_fnc;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 static void *appclose_udata;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 static int is_toplevel_realized = 0;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
58 int event_pipe[2];
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
59
160
b3f36bfe1b41 Motif: enable xft text rendering by default
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
60
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
61 static String fallback[] = {
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
62 //"*fontList: -dt-interface system-medium-r-normal-s*utf*:",
64
6ef2c7f73a30 added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
63 "*text_area*renderTable: f1",
6ef2c7f73a30 added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
64 "*f1*fontType: FONT_IS_XFT",
6ef2c7f73a30 added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
65 "*f1*fontName: Monospace",
6ef2c7f73a30 added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 59
diff changeset
66 "*f1*fontSize: 11",
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
67 "*renderTable: rt",
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
68 "*rt*fontType: FONT_IS_XFT",
160
b3f36bfe1b41 Motif: enable xft text rendering by default
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
69 "*rt*fontName: Sans",
59
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
70 "*rt*fontSize: 11",
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
71 NULL
eb6611be50c7 added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
72 };
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
74 void input_proc(XtPointer data, int *source, XtInputId *iid) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
75 void *ptr;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
76 read(event_pipe[0], &ptr, sizeof(void*));
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
77 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
78
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 void ui_init(char *appname, int argc, char **argv) {
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
80 application_name = appname;
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 XtToolkitInitialize();
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 XtSetLanguageProc(NULL, NULL, NULL);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 app = XtCreateApplicationContext();
46
4a5e0b9b6992 fixed fonts (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 36
diff changeset
85 XtAppSetFallbackResources(app, fallback);
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 display = XtOpenDisplay(app, NULL, appname, appname, NULL, 0, &argc, argv);
30
34513f76d5a8 added locale support (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
88 char **missing = NULL;
34513f76d5a8 added locale support (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
89 int nm = 0;
34513f76d5a8 added locale support (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
90 char *def = NULL;
34513f76d5a8 added locale support (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
91 XCreateFontSet(display, "-dt-interface system-medium-r-normal-s*utf*", &missing, &nm, &def);
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 uic_docmgr_init();
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1
diff changeset
94 ui_toolbar_init();
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1
diff changeset
95 ui_stock_init();
24
06bceda81a03 added application properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 21
diff changeset
96
06bceda81a03 added application properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 21
diff changeset
97 uic_load_app_properties();
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
98
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
99 if(pipe(event_pipe)) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
100 fprintf(stderr, "UiError: Cannot create event pipe\n");
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
101 exit(-1);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
102 }
36
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
103 XtAppAddInput(
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
104 app,
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
105 event_pipe[0],
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
106 (XtPointer)XtInputReadMask,
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
107 input_proc,
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
108 NULL);
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
111 char* ui_appname() {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
112 return application_name;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
113 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
114
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 Display* ui_get_display() {
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 return display;
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118
134
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
119 void ui_onstartup(ui_callback f, void *userdata) {
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
120 startup_func = f;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
121 startup_data = userdata;
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123
134
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
124 void ui_onopen(ui_callback f, void *userdata) {
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
125 open_func = f;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
126 open_data = userdata;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
127 }
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
128
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
129 void ui_onexit(ui_callback f, void *userdata) {
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
130 exit_func = f;
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
131 exit_data = userdata;
29
c96169444d88 added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
132 }
c96169444d88 added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
133
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 void ui_main() {
134
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
135 if(startup_func) {
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
136 startup_func(NULL, startup_data);
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
137 }
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 XtAppMainLoop(app);
134
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
139 if(exit_func) {
69e8e0936858 adds new app callbacks (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 122
diff changeset
140 exit_func(NULL, exit_data);
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 }
24
06bceda81a03 added application properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 21
diff changeset
142 uic_store_app_properties();
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 }
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144
36
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
145 void ui_exit_mainloop() {
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
146 XtAppSetExitFlag(app);
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
147 }
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
148
28
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
149 void ui_secondary_event_loop(int *loop) {
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
150 while(*loop && !XtAppGetExitFlag(app)) {
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
151 XEvent event;
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
152 XtAppNextEvent(app, &event);
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
153 XtDispatchEvent(&event);
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
154 }
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
155 }
794a5c91c479 added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
156
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 void ui_show(UiObject *obj) {
21
012418e7dc90 added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
158 uic_check_group_widgets(obj->ctx);
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 XtRealizeWidget(obj->widget);
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
160 ui_window_dark_theme(XtDisplay(obj->widget), XtWindow(obj->widget)); // TODO: if
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 }
21
012418e7dc90 added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
162
36
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
163 // implemented in window.c
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
164 //void ui_close(UiObject *obj)
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
165
21
012418e7dc90 added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
166 void ui_set_enabled(UIWIDGET widget, int enabled) {
012418e7dc90 added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
167 XtSetSensitive(widget, enabled);
012418e7dc90 added groups for menu items (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
168 }
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
169
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
170 void ui_set_show_all(UIWIDGET widget, int value) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
171 if(!value) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
172 XtUnmanageChild(widget);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
173 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
174 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
175
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
176 void ui_set_visible(UIWIDGET widget, int visible) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
177 if(visible) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
178 XtManageChild(widget);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
179 } else {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
180 XtUnmanageChild(widget);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
181 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
182 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
183
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
184 static Boolean ui_job_finished(void *data) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
185 printf("WorkProc\n");
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
186 UiJob *job = data;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
187
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
188 UiEvent event;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
189 event.obj = job->obj;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
190 event.window = job->obj->window;
52
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
191 event.document = job->obj->ctx->document;
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
192 event.intval = 0;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
193 event.eventdata = NULL;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
194
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
195 job->finish_callback(&event, job->finish_data);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
196 free(job);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
197 return TRUE;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
198 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
199
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
200 static void* ui_jobthread(void *data) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
201 UiJob *job = data;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
202 int result = job->job_func(job->job_data);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
203 if(!result) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
204 printf("XtAppAddWorkProc\n");
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
205 write(event_pipe[1], &job, sizeof(void*)); // hack
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
206 XtAppAddWorkProc(app, ui_job_finished, job);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
207
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
208 }
176
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 160
diff changeset
209 return NULL;
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
210 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
211
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
212 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
213 UiJob *job = malloc(sizeof(UiJob));
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
214 job->obj = obj;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
215 job->job_func = tf;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
216 job->job_data = td;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
217 job->finish_callback = f;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
218 job->finish_data = fd;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
219 pthread_t pid;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
220 pthread_create(&pid, NULL, ui_jobthread, job);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
221 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
222
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
223 void ui_clipboard_set(char *str) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
224 printf("copy: {%s}\n", str);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
225 int length = strlen(str) + 1;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
226
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
227 Display *dp = XtDisplayOfObject(active_window);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
228 Window window = XtWindowOfObject(active_window);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
229
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
230 XmString label = XmStringCreateLocalized("toolkit_clipboard");
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
231 long id = 0;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
232
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
233 while(XmClipboardStartCopy(
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
234 dp,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
235 window,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
236 label,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
237 CurrentTime,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
238 NULL,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
239 NULL,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
240 &id) == ClipboardLocked);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
241 XmStringFree(label);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
242
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
243 while(XmClipboardCopy(
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
244 dp,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
245 window,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
246 id,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
247 "STRING",
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
248 str,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
249 length,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
250 1,
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
251 NULL) == ClipboardLocked);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
252
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
253 while(XmClipboardEndCopy(dp, window, id) == ClipboardLocked);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
254 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
255
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
256 char* ui_clipboard_get() {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
257 Display *dp = XtDisplayOfObject(active_window);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
258 Window window = XtWindowOfObject(active_window);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
259
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
260 long id;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
261 size_t size = 128;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
262 char *buf = malloc(size);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
263
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
264 int r;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
265 for(;;) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
266 r = XmClipboardRetrieve(dp, window, "STRING", buf, size, NULL, &id);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
267 if(r == ClipboardSuccess) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
268 break;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
269 } else if(r == ClipboardTruncate) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
270 size *= 2;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
271 buf = realloc(buf, size);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
272 } else if(r == ClipboardNoData) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
273 free(buf);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
274 buf = NULL;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
275 break;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
276 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
277 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
278
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
279 return buf;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
280 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
281
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
282 void ui_set_active_window(Widget w) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
283 active_window = w;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
284 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
285
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
286 Widget ui_get_active_window() {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
287 return active_window;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 24
diff changeset
288 }
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
289
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
290 void ui_window_dark_theme(Display *dp, Window window) {
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
291 Atom atom = XInternAtom(dp, "_GTK_THEME_VARIANT", False);
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
292 Atom type = XInternAtom(dp, "UTF8_STRING", False);
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
293 XChangeProperty(
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
294 dp,
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
295 window,
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
296 atom,
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
297 type,
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
298 8,
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
299 PropModeReplace,
122
e82b01d17a78 added some special textfields (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 99
diff changeset
300 (const unsigned char*)"dark",
99
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
301 4);
ea1a2d5de765 improved grid container (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
302 }

mercurial