Sun, 23 Nov 2025 08:35:40 +0100
implement ui_openfiledialog (Motif)
| 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> | |
| 31 | ||
| 32 | #include "toolkit.h" | |
| 33 | #include "menu.h" | |
| 3 | 34 | #include "toolbar.h" |
|
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
35 | #include "container.h" |
| 0 | 36 | #include "../ui/window.h" |
| 37 | #include "../common/context.h" | |
| 38 | ||
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
39 | #include "Grid.h" |
|
925
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
40 | #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
|
41 | |
|
253
087cc9216f28
initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
42 | #include <cx/mempool.h> |
|
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
43 | |
| 0 | 44 | static int nwindows = 0; |
| 45 | ||
|
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
46 | static int window_default_width = 600; |
|
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
47 | static int window_default_height = 500; |
| 0 | 48 | |
|
479
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
49 | void ui_window_widget_destroy(UiObject *obj) { |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
50 | 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
|
51 | uic_object_destroy(obj); |
| 0 | 52 | nwindows--; |
| 53 | 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
|
54 | ui_app_quit(); |
| 0 | 55 | } |
| 56 | } | |
| 57 | ||
|
479
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
58 | 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
|
59 | UiObject *obj = udata; |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
60 | |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
61 | uic_context_prepare_close(obj->ctx); |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
62 | obj->ref--; |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
63 | if(obj->ref > 0) { |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
64 | XtUnmapWidget(obj->widget); |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
65 | } else { |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
66 | ui_window_widget_destroy(obj); |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
67 | } |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
68 | } |
|
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
69 | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
70 | |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
71 | static UiObject* create_window(const char *title, void *window_data, 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
|
72 | CxMempool *mp = cxMempoolCreateSimple(256); |
|
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
73 | 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
|
74 | UiObject *obj = uic_object_new_toplevel(); |
|
128
c284c15509a8
fixes var binding and motif tableview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
75 | obj->window = window_data; |
|
479
d9b58dd1c30b
implement window reference counting (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
471
diff
changeset
|
76 | obj->destroy = ui_window_widget_destroy; |
| 0 | 77 | |
| 78 | Arg args[16]; | |
| 79 | 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
|
80 | 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
|
81 | 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
|
82 | XtSetArg(args[n], XmNminHeight, 50); n++; |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
83 | XtSetArg(args[n], XmNwidth, window_default_width); n++; |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
84 | XtSetArg(args[n], XmNheight, window_default_height); n++; |
| 0 | 85 | |
| 86 | 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
|
87 | ui_appname(), |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
88 | "mainwindow", |
| 0 | 89 | //applicationShellWidgetClass, |
| 90 | vendorShellWidgetClass, | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
91 | ui_motif_get_display(), |
| 0 | 92 | args, |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
93 | n); |
| 0 | 94 | |
| 95 | Atom wm_delete_window; | |
| 96 | wm_delete_window = XmInternAtom( | |
| 97 | XtDisplay(toplevel), | |
| 98 | "WM_DELETE_WINDOW", | |
| 99 | 0); | |
| 100 | XmAddWMProtocolCallback( | |
| 101 | toplevel, | |
| 102 | wm_delete_window, | |
| 103 | window_close_handler, | |
| 104 | obj); | |
| 105 | ||
| 106 | Widget window = XtVaCreateManagedWidget( | |
| 107 | title, | |
| 108 | xmMainWindowWidgetClass, | |
| 109 | toplevel, | |
| 110 | NULL); | |
| 3 | 111 | |
|
416
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
112 | // menu |
|
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
113 | if(!simple) { |
|
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
114 | ui_create_menubar(obj, window); |
|
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
115 | } |
|
89ad8467c39f
implement motif menu/menu item
Olaf Winermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
116 | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
117 | // content frame |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
118 | n = 0; |
|
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
119 | Widget frame = XmCreateFrame(window, "window_frame", args, n); |
|
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
120 | XtManageChild(frame); |
|
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
121 | |
|
424
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
122 | 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
|
123 | XtManageChild(form); |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
124 | |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
125 | n = 0; |
|
51e856688fba
add form widget to a window to fix layout problems (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
416
diff
changeset
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | uic_object_push_container(obj, container); |
| 3 | 133 | |
| 0 | 134 | obj->widget = toplevel; |
| 135 | nwindows++; | |
| 136 | return obj; | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
137 | } |
|
28
794a5c91c479
added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
138 | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
139 | UiObject* ui_window(const char *title, void *window_data) { |
|
106
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
140 | return create_window(title, window_data, FALSE); |
|
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
141 | } |
|
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
142 | |
|
406
0ebf9d7b23e8
add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
253
diff
changeset
|
143 | UiObject* ui_simple_window(const char *title, void *window_data) { |
|
106
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
144 | return create_window(title, window_data, TRUE); |
|
a4f4123ca12a
added simple window and open/save file dialogs for Qt
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
62
diff
changeset
|
145 | } |
|
925
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
146 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
147 | 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
|
148 | UiEvent evt; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
149 | evt.obj = event->obj; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
150 | evt.document = evt.obj->ctx->document; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
151 | evt.window = evt.obj->window; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
152 | evt.intval = result; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
153 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
154 | evt.eventdata = &flist; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
155 | evt.eventdatatype = UI_EVENT_DATA_FILE_LIST; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
156 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
157 | if(event->callback) { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
158 | event->callback(&evt, event->userdata); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
159 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
160 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
161 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
162 | static void filedialog_select( |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
163 | Widget widget, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
164 | UiEventData *data, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
165 | XmFileSelectionBoxCallbackStruct *selection) |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
166 | { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
167 | UiFileList flist; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
168 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
169 | char *value = NULL; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
170 | XmStringGetLtoR(selection->value, XmSTRING_DEFAULT_CHARSET, &value); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
171 | flist.files = &value; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
172 | flist.nfiles = 1; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
173 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
174 | filedialog_event(data, 1, flist); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
175 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
176 | XtFree(value); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
177 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
178 | XtUnmanageChild(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
179 | XtDestroyWidget(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
180 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
181 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
182 | static void filedialog_cancel( |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
183 | Widget widget, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
184 | UiEventData *data, |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
185 | XmFileSelectionBoxCallbackStruct *selection) |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
186 | { |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
187 | UiFileList flist; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
188 | flist.files = NULL; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
189 | flist.nfiles = 0; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
190 | filedialog_event(data, 0, flist); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
191 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
192 | XtUnmanageChild(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
193 | XtDestroyWidget(widget); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
194 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
195 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
196 | 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
|
197 | Widget dialog = XnCreateFileSelectionDialog(obj->widget, "dialog", NULL, 0); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
198 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
199 | UiEventData *data = malloc(sizeof(UiEventData)); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
200 | memset(data, 0, sizeof(UiEventData)); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
201 | data->obj = obj; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
202 | data->callback = file_selected_callback; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
203 | data->userdata = cbdata; |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
204 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
205 | XtAddCallback(dialog, XmNokCallback, (XtCallbackProc)filedialog_select, data); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
206 | XtAddCallback(dialog, XmNcancelCallback, (XtCallbackProc)filedialog_cancel, data); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
207 | //XtAddCallback(dialog, XmNhelpCallback, (XtCallbackProc)filedialog_help, wd); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
208 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
209 | XtManageChild(dialog); |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
210 | } |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
211 | |
|
df27741d02b5
implement ui_openfiledialog (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
924
diff
changeset
|
212 | void ui_savefiledialog(UiObject *obj, const char *name, ui_callback file_selected_callback, void *cbdata) { |
|
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 | } |