Fri, 12 Dec 2025 12:44:03 +0100
fix uic_store_app_properties
| 0 | 1 | /* |
| 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
| 3 | * | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
4 | * Copyright 2024 Olaf Wintermann. All rights reserved. |
| 0 | 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without | |
| 7 | * modification, are permitted provided that the following conditions are met: | |
| 8 | * | |
| 9 | * 1. Redistributions of source code must retain the above copyright | |
| 10 | * notice, this list of conditions and the following disclaimer. | |
| 11 | * | |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
| 13 | * notice, this list of conditions and the following disclaimer in the | |
| 14 | * documentation and/or other materials provided with the distribution. | |
| 15 | * | |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
| 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 26 | * POSSIBILITY OF SUCH DAMAGE. | |
| 27 | */ | |
| 28 | ||
| 29 | #include <stdio.h> | |
| 30 | #include <stdlib.h> | |
|
926
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
31 | #include <errno.h> |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
32 | #include <limits.h> |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
33 | #include <unistd.h> |
| 0 | 34 | |
|
930
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
35 | #include "window.h" |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
36 | |
| 0 | 37 | #include "toolkit.h" |
| 38 | #include "menu.h" | |
| 3 | 39 | #include "toolbar.h" |
|
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
40 | #include "container.h" |
|
926
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
41 | #include "pathbar.h" |
| 0 | 42 | #include "../common/context.h" |
|
930
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
43 | #include "../common/utils.h" |
| 0 | 44 | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
45 | #include "Grid.h" |
|
925
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
46 | #include "Fsb.h" |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
47 | |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
48 | #include <cx/mempool.h> |
|
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
49 | |
| 0 | 50 | static int nwindows = 0; |
| 51 | ||
|
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
52 | static int window_default_width = 600; |
|
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
53 | static int window_default_height = 500; |
| 0 | 54 | |
|
479
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
55 | void ui_window_widget_destroy(UiObject *obj) { |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
56 | XtDestroyWidget(obj->widget); |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
57 | uic_object_destroy(obj); |
| 0 | 58 | nwindows--; |
| 59 | if(nwindows == 0) { | |
|
924
6c6e97e06009
fix wrong exit func in ui_window_widget_destroy (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
627
diff
changeset
|
60 | ui_app_quit(); |
| 0 | 61 | } |
| 62 | } | |
| 63 | ||
|
479
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
64 | static void window_close_handler(Widget window, void *udata, void *cdata) { |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
65 | UiObject *obj = udata; |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
66 | |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
67 | uic_context_prepare_close(obj->ctx); |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
68 | obj->ref--; |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
69 | if(obj->ref > 0) { |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
70 | XtUnmapWidget(obj->widget); |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
71 | } else { |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
72 | ui_window_widget_destroy(obj); |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
73 | } |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
74 | } |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
75 | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
76 | |
|
986
6f7600c2b9e1
remove window data arg
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
934
diff
changeset
|
77 | static UiObject* create_window(const char *title, Boolean simple) { |
|
471
063a9f29098c
ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
424
diff
changeset
|
78 | CxMempool *mp = cxMempoolCreateSimple(256); |
|
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
79 | const CxAllocator *a = mp->allocator; |
|
627
3f0c9fe60c68
use uic_object_new_toplevel to create toplevel objects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
479
diff
changeset
|
80 | UiObject *obj = uic_object_new_toplevel(); |
|
479
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
81 | obj->destroy = ui_window_widget_destroy; |
| 0 | 82 | |
|
930
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
83 | int window_width = window_default_width; |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
84 | int window_height = window_default_height; |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
85 | if(!simple) { |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
86 | ui_get_window_default_width(&window_width, &window_height); |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
87 | } |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
88 | |
|
931
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
89 | UiMotifAppWindow *appwindow = cxZalloc(a, sizeof(UiMotifAppWindow)); |
|
933
70e14fa98ab4
use ui_object_set/get to store UiMotifAppWindow (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
931
diff
changeset
|
90 | ui_object_set(obj, "ui_motif_app_window", appwindow); |
|
931
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
91 | |
| 0 | 92 | Arg args[16]; |
| 93 | int n = 0; | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
94 | XtSetArg(args[n], XmNtitle, title); n++; |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
95 | XtSetArg(args[n], XmNminWidth, 100); n++; |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
96 | XtSetArg(args[n], XmNminHeight, 50); n++; |
|
930
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
97 | XtSetArg(args[n], XmNwidth, window_width); n++; |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
98 | XtSetArg(args[n], XmNheight, window_height); n++; |
| 0 | 99 | |
| 100 | Widget toplevel = XtAppCreateShell( | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
101 | ui_appname(), |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
102 | "mainwindow", |
| 0 | 103 | //applicationShellWidgetClass, |
| 104 | vendorShellWidgetClass, | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
105 | ui_motif_get_display(), |
| 0 | 106 | args, |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
107 | n); |
| 0 | 108 | |
| 109 | Atom wm_delete_window; | |
| 110 | wm_delete_window = XmInternAtom( | |
| 111 | XtDisplay(toplevel), | |
| 112 | "WM_DELETE_WINDOW", | |
| 113 | 0); | |
| 114 | XmAddWMProtocolCallback( | |
| 115 | toplevel, | |
| 116 | wm_delete_window, | |
| 117 | window_close_handler, | |
| 118 | obj); | |
| 119 | ||
| 120 | Widget window = XtVaCreateManagedWidget( | |
| 121 | title, | |
| 122 | xmMainWindowWidgetClass, | |
| 123 | toplevel, | |
| 124 | NULL); | |
| 3 | 125 | |
|
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
126 | // menu |
|
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
127 | if(!simple) { |
|
931
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
128 | appwindow->menubar = ui_create_menubar(obj, window); |
|
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
129 | } |
|
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
130 | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
131 | // content frame |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
132 | n = 0; |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
133 | Widget frame = XmCreateFrame(window, "window_frame", args, n); |
|
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
134 | XtManageChild(frame); |
|
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
135 | |
|
424
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
136 | Widget form = XmCreateForm(frame, "window_form", args, 0); |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
137 | XtManageChild(form); |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
138 | |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
139 | n = 0; |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
140 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
141 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
142 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
143 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
144 | Widget vbox = XtCreateManagedWidget("window_vbox", gridClass, form, args, n); |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
145 | UiContainerX *container = ui_box_container(obj, vbox, UI_BOX_VERTICAL); |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
146 | uic_object_push_container(obj, container); |
| 3 | 147 | |
| 0 | 148 | obj->widget = toplevel; |
| 149 | nwindows++; | |
| 150 | return obj; | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
151 | } |
|
28
794a5c91c479
added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
152 | |
|
986
6f7600c2b9e1
remove window data arg
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
934
diff
changeset
|
153 | UiObject* ui_window(const char *title) { |
|
6f7600c2b9e1
remove window data arg
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
934
diff
changeset
|
154 | return create_window(title, FALSE); |
|
106
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
155 | } |
|
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
156 | |
|
986
6f7600c2b9e1
remove window data arg
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
934
diff
changeset
|
157 | UiObject* ui_simple_window(const char *title) { |
|
6f7600c2b9e1
remove window data arg
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
934
diff
changeset
|
158 | return create_window(title, TRUE); |
|
106
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
159 | } |
|
925
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
160 | |
|
930
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
161 | void ui_window_size(UiObject *obj, int width, int height) { |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
162 | XtVaSetValues(obj->widget, XmNwidth, width, XmNheight, height, NULL); |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
163 | } |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
164 | |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
165 | void ui_window_default_size(int width, int height) { |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
166 | window_default_width = width; |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
167 | window_default_height = height; |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
168 | } |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
169 | |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
170 | void ui_window_menubar_set_visible(UiObject *obj, UiBool visible) { |
|
933
70e14fa98ab4
use ui_object_set/get to store UiMotifAppWindow (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
931
diff
changeset
|
171 | UiMotifAppWindow *window = ui_object_get(obj, "ui_motif_app_window"); |
|
931
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
172 | if(window) { |
|
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
173 | if(window->menubar) { |
|
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
174 | ui_set_visible(window->menubar, visible); |
|
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
175 | } |
|
933
70e14fa98ab4
use ui_object_set/get to store UiMotifAppWindow (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
931
diff
changeset
|
176 | } else { |
|
70e14fa98ab4
use ui_object_set/get to store UiMotifAppWindow (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
931
diff
changeset
|
177 | fprintf(stderr, "Error: obj is not an application window\n"); |
|
931
6ca1ef6c8107
add ui_window_menubar_set_visible (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
930
diff
changeset
|
178 | } |
|
930
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
179 | } |
|
4ce8df2311f0
implement ui_window_size/ui_window_default_size (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
926
diff
changeset
|
180 | |
|
934
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
181 | static Atom net_wm_state; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
182 | static Atom net_wm_state_fullscreen; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
183 | static int net_wm_atoms_initialized = 0; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
184 | |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
185 | void ui_window_fullscreen(UiObject *obj, UiBool fullscreen) { |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
186 | Display *dpy = XtDisplay(obj->widget); |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
187 | |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
188 | // init net_wm_state atoms |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
189 | if(!net_wm_atoms_initialized) { |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
190 | net_wm_state = XInternAtom(dpy, "_NET_WM_STATE", False); |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
191 | net_wm_state_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
192 | net_wm_atoms_initialized = 1; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
193 | } |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
194 | |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
195 | XEvent ev; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
196 | memset(&ev, 0, sizeof(XEvent)); |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
197 | ev.type = ClientMessage; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
198 | ev.xclient.window = XtWindow(obj->widget); |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
199 | ev.xclient.message_type = net_wm_state; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
200 | ev.xclient.format = 32; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
201 | ev.xclient.data.l[0] = fullscreen ? 1 : 0; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
202 | ev.xclient.data.l[1] = net_wm_state_fullscreen; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
203 | ev.xclient.data.l[2] = 0; |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
204 | XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureNotifyMask | SubstructureRedirectMask, &ev); |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
205 | } |
|
89118a9350da
add ui_window_fullscreen (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
933
diff
changeset
|
206 | |
|
925
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
207 | static void filedialog_event(UiEventData *event, int result, UiFileList flist) { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
208 | UiEvent evt; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
209 | evt.obj = event->obj; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
210 | evt.document = evt.obj->ctx->document; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
211 | evt.window = evt.obj->window; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
212 | evt.intval = result; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
213 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
214 | evt.eventdata = &flist; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
215 | evt.eventdatatype = UI_EVENT_DATA_FILE_LIST; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
216 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
217 | if(event->callback) { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
218 | event->callback(&evt, event->userdata); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
219 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
220 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
221 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
222 | static void filedialog_select( |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
223 | Widget widget, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
224 | UiEventData *data, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
225 | XmFileSelectionBoxCallbackStruct *selection) |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
226 | { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
227 | UiFileList flist; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
228 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
229 | char *value = NULL; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
230 | XmStringGetLtoR(selection->value, XmSTRING_DEFAULT_CHARSET, &value); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
231 | flist.files = &value; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
232 | flist.nfiles = 1; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
233 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
234 | filedialog_event(data, 1, flist); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
235 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
236 | XtFree(value); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
237 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
238 | XtUnmanageChild(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
239 | XtDestroyWidget(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
240 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
241 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
242 | static void filedialog_cancel( |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
243 | Widget widget, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
244 | UiEventData *data, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
245 | XmFileSelectionBoxCallbackStruct *selection) |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
246 | { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
247 | UiFileList flist; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
248 | flist.files = NULL; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
249 | flist.nfiles = 0; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
250 | filedialog_event(data, 0, flist); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
251 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
252 | XtUnmanageChild(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
253 | XtDestroyWidget(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
254 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
255 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
256 | void ui_openfiledialog(UiObject *obj, unsigned int mode, ui_callback file_selected_callback, void *cbdata) { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
257 | Widget dialog = XnCreateFileSelectionDialog(obj->widget, "dialog", NULL, 0); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
258 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
259 | UiEventData *data = malloc(sizeof(UiEventData)); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
260 | memset(data, 0, sizeof(UiEventData)); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
261 | data->obj = obj; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
262 | data->callback = file_selected_callback; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
263 | data->userdata = cbdata; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
264 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
265 | XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)filedialog_select, data); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
266 | XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)filedialog_cancel, data); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
267 | //XtAddCallback(dialog, XmNhelpCallback, (XtCallbackProc)filedialog_help, wd); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
268 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
269 | XtManageChild(dialog); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
270 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
271 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
272 | void ui_savefiledialog(UiObject *obj, const char *name, ui_callback file_selected_callback, void *cbdata) { |
|
926
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
273 | Arg args[16]; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
274 | int n = 0; |
|
925
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
275 | |
|
926
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
276 | // Save File Dialog needs this parameter |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
277 | XtSetArg(args[n], XnNfsbType, FILEDIALOG_SAVE); n++; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
278 | char *selectedpath = (char*)name; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
279 | if(name) { |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
280 | if(name[0] != '/') { |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
281 | char cwd[PATH_MAX]; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
282 | if(getcwd(cwd, PATH_MAX)) { |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
283 | pathbar_concat_path(cwd, name); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
284 | } else { |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
285 | fprintf(stderr, "Error: getcwd failed: %s\n", strerror(errno)); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
286 | selectedpath = NULL; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
287 | } |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
288 | } |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
289 | if(selectedpath) { |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
290 | XtSetArg(args[n], XnNselectedPath, selectedpath); n++; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
291 | } |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
292 | } |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
293 | Widget dialog = XnCreateFileSelectionDialog(obj->widget, "dialog", args, n); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
294 | |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
295 | UiEventData *data = malloc(sizeof(UiEventData)); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
296 | memset(data, 0, sizeof(UiEventData)); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
297 | data->obj = obj; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
298 | data->callback = file_selected_callback; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
299 | data->userdata = cbdata; |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
300 | |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
301 | XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)filedialog_select, data); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
302 | XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)filedialog_cancel, data); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
303 | //XtAddCallback(dialog, XmNhelpCallback, (XtCallbackProc)filedialog_help, wd); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
304 | |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
305 | XtManageChild(dialog); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
306 | |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
307 | if(selectedpath != name) { |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
308 | free(selectedpath); |
|
32b16cbca280
implement ui_savefiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
925
diff
changeset
|
309 | } |
|
925
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
310 | } |