Fri, 13 Dec 2024 10:59:31 +0100
finish motif path bar implementation
5 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2014 Olaf Wintermann. All rights reserved. | |
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> | |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
31 | #include <unistd.h> |
5 | 32 | |
33 | #include "text.h" | |
34 | #include "container.h" | |
35 | ||
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
36 | #include <cx/string.h> |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
37 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
38 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
39 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
40 | /* ------------------------------ Text Field ------------------------------ */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
41 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
42 | static UIWIDGET create_textfield(UiObject *obj, UiTextFieldArgs args, int frameless, int password) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
43 | Arg xargs[16]; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
44 | int n = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
45 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
46 | if(frameless) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
47 | XtSetArg(xargs[n], XmNshadowThickness, 0); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
48 | n++; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
49 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
50 | if(password) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
51 | // TODO |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
52 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
53 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
54 | UiContainerPrivate *ctn = ui_obj_container(obj); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
55 | UI_APPLY_LAYOUT(ctn->layout, args); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
56 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
57 | Widget parent = ctn->prepare(ctn, xargs, &n); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
58 | char *name = args.name ? (char*)args.name : "textfield"; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
59 | Widget textfield = XmCreateTextField(parent, name, xargs, n); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
60 | XtManageChild(textfield); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
61 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
62 | ui_set_widget_groups(obj->ctx, textfield, args.groups); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
63 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
64 | UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_STRING); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
65 | if(var) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
66 | UiString *value = (UiString*)var->value; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
67 | value->obj = textfield; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
68 | value->get = ui_textfield_get; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
69 | value->set = ui_textfield_set; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
70 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
71 | if(value->value.ptr) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
72 | ui_textfield_set(value, value->value.ptr); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
73 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
74 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
75 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
76 | return textfield; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
77 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
78 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
79 | UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
80 | return create_textfield(obj, args, FALSE, FALSE); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
81 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
82 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
83 | UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
84 | return create_textfield(obj, args, TRUE, FALSE); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
85 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
86 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
87 | UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
88 | return create_textfield(obj, args, FALSE, FALSE); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
89 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
90 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
91 | char* ui_textfield_get(UiString *str) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
92 | str->value.free(str->value.ptr); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
93 | char *value = XmTextFieldGetString(str->obj); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
94 | str->value.ptr = value; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
95 | str->value.free = (ui_freefunc)XtFree; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
96 | return value; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
97 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
98 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
99 | void ui_textfield_set(UiString *str, const char *value) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
100 | XmTextFieldSetString(str->obj, (void*)value); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
101 | str->value.ptr = NULL; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
102 | str->value.free(str->value.ptr); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
103 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
104 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
105 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
106 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
107 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
108 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
109 | /* -------------------- path bar -------------------- */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
110 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
111 | #define XNECreateText(parent,name,args,count) XmCreateTextField(parent,name,args,count) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
112 | #define XNETextSetString(widget,value) XmTextFieldSetString(widget,value) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
113 | #define XNETextGetString(widget) XmTextFieldGetString(widget) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
114 | #define XNETextGetLastPosition(widget) XmTextFieldGetLastPosition(widget) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
115 | #define XNETextSetInsertionPosition(widget, i) XmTextFieldSetInsertionPosition(widget, i) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
116 | #define XNETextSetSelection(w, f, l, t) XmTextFieldSetSelection(w, f, l, t) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
117 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
118 | typedef void(*updatedir_callback)(void*,char*,int); |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
119 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
120 | typedef struct PathBar { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
121 | Widget widget; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
122 | Widget textfield; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
123 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
124 | Widget focus_widget; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
125 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
126 | Widget left; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
127 | Widget right; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
128 | Dimension lw; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
129 | Dimension rw; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
130 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
131 | int shift; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
132 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
133 | UiPathElm *current_pathelms; |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
134 | Widget *pathSegments; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
135 | size_t numSegments; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
136 | size_t segmentAlloc; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
137 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
138 | char *path; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
139 | int selection; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
140 | Boolean input; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
141 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
142 | int focus; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
143 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
144 | updatedir_callback updateDir; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
145 | void *updateDirData; |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
146 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
147 | ui_pathelm_func getpathelm; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
148 | void *getpathelmdata; |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
149 | } PathBar; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
150 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
151 | void PathBarSetPath(PathBar *bar, const char *path); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
152 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
153 | void pathbar_resize(Widget w, PathBar *p, XtPointer d) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
154 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
155 | Dimension width, height; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
156 | XtVaGetValues(w, XmNwidth, &width, XmNheight, &height, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
157 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
158 | Dimension *segW = (void*)XtCalloc(p->numSegments, sizeof(Dimension)); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
159 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
160 | Dimension maxHeight = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
161 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
162 | /* get width/height from all widgets */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
163 | Dimension pathWidth = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
164 | for(int i=0;i<p->numSegments;i++) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
165 | Dimension segWidth; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
166 | Dimension segHeight; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
167 | XtVaGetValues(p->pathSegments[i], XmNwidth, &segWidth, XmNheight, &segHeight, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
168 | segW[i] = segWidth; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
169 | pathWidth += segWidth; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
170 | if(segHeight > maxHeight) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
171 | maxHeight = segHeight; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
172 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
173 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
174 | Dimension tfHeight; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
175 | XtVaGetValues(p->textfield, XmNheight, &tfHeight, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
176 | if(tfHeight > maxHeight) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
177 | maxHeight = tfHeight; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
178 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
179 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
180 | Boolean arrows = False; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
181 | if(pathWidth + 10 > width) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
182 | arrows = True; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
183 | pathWidth += p->lw + p->rw; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
184 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
185 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
186 | /* calc max visible widgets */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
187 | int start = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
188 | if(arrows) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
189 | Dimension vis = p->lw+p->rw; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
190 | for(int i=p->numSegments;i>0;i--) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
191 | Dimension segWidth = segW[i-1]; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
192 | if(vis + segWidth + 10 > width) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
193 | start = i; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
194 | arrows = True; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
195 | break; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
196 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
197 | vis += segWidth; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
198 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
199 | } else { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
200 | p->shift = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
201 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
202 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
203 | int leftShift = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
204 | if(p->shift < 0) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
205 | if(start + p->shift < 0) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
206 | leftShift = start; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
207 | start = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
208 | p->shift = -leftShift; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
209 | } else { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
210 | leftShift = -p->shift; /* negative shift */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
211 | start += p->shift; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
212 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
213 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
214 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
215 | int x = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
216 | if(arrows) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
217 | XtManageChild(p->left); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
218 | XtManageChild(p->right); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
219 | x = p->lw; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
220 | } else { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
221 | XtUnmanageChild(p->left); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
222 | XtUnmanageChild(p->right); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
223 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
224 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
225 | for(int i=0;i<p->numSegments;i++) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
226 | if(i >= start && i < p->numSegments - leftShift && !p->input) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
227 | XtVaSetValues(p->pathSegments[i], XmNx, x, XmNy, 0, XmNheight, maxHeight, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
228 | x += segW[i]; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
229 | XtManageChild(p->pathSegments[i]); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
230 | } else { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
231 | XtUnmanageChild(p->pathSegments[i]); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
232 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
233 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
234 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
235 | if(arrows) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
236 | XtVaSetValues(p->left, XmNx, 0, XmNy, 0, XmNheight, maxHeight, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
237 | XtVaSetValues(p->right, XmNx, x, XmNy, 0, XmNheight, maxHeight, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
238 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
239 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
240 | free(segW); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
241 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
242 | Dimension rw, rh; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
243 | XtMakeResizeRequest(w, width, maxHeight, &rw, &rh); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
244 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
245 | XtVaSetValues(p->textfield, XmNwidth, rw, XmNheight, rh, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
246 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
247 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
248 | static void pathbarActivateTF(PathBar *p) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
249 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
250 | XtUnmanageChild(p->left); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
251 | XtUnmanageChild(p->right); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
252 | XNETextSetSelection(p->textfield, 0, XNETextGetLastPosition(p->textfield), 0); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
253 | XtManageChild(p->textfield); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
254 | p->input = 1; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
255 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
256 | XmProcessTraversal(p->textfield, XmTRAVERSE_CURRENT); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
257 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
258 | pathbar_resize(p->widget, p, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
259 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
260 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
261 | void PathBarActivateTextfield(PathBar *p) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
262 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
263 | p->focus = 1; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
264 | pathbarActivateTF(p); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
265 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
266 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
267 | void pathbar_input(Widget w, PathBar *p, XtPointer c) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
268 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
269 | XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct*)c; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
270 | XEvent *xevent = cbs->event; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
271 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
272 | if (cbs->reason == XmCR_INPUT) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
273 | if (xevent->xany.type == ButtonPress) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
274 | p->focus = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
275 | pathbarActivateTF(p); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
276 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
277 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
278 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
279 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
280 | void pathbar_losingfocus(Widget w, PathBar *p, XtPointer c) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
281 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
282 | if(--p->focus < 0) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
283 | p->input = False; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
284 | XtUnmanageChild(p->textfield); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
285 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
286 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
287 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
288 | static cxmutstr concat_path_s(cxstring base, cxstring path) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
289 | if(!path.ptr) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
290 | path = CX_STR(""); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
291 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
292 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
293 | int add_separator = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
294 | if(base.length != 0 && base.ptr[base.length-1] == '/') { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
295 | if(path.ptr[0] == '/') { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
296 | base.length--; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
297 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
298 | } else { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
299 | if(path.length == 0 || path.ptr[0] != '/') { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
300 | add_separator = 1; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
301 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
302 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
303 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
304 | cxmutstr url; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
305 | if(add_separator) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
306 | url = cx_strcat(3, base, CX_STR("/"), path); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
307 | } else { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
308 | url = cx_strcat(2, base, path); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
309 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
310 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
311 | return url; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
312 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
313 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
314 | static char* ConcatPath(const char *path1, const char *path2) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
315 | return concat_path_s(cx_str(path1), cx_str(path2)).ptr; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
316 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
317 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
318 | void pathbar_pathinput(Widget w, PathBar *p, XtPointer d) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
319 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
320 | char *newpath = XNETextGetString(p->textfield); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
321 | if(newpath) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
322 | if(newpath[0] == '~') { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
323 | char *p = newpath+1; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
324 | char *home = getenv("HOME"); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
325 | char *cp = ConcatPath(home, p); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
326 | XtFree(newpath); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
327 | newpath = cp; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
328 | } else if(newpath[0] != '/') { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
329 | char curdir[2048]; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
330 | curdir[0] = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
331 | getcwd(curdir, 2048); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
332 | char *cp = ConcatPath(curdir, newpath); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
333 | XtFree(newpath); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
334 | newpath = cp; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
335 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
336 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
337 | /* update path */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
338 | PathBarSetPath(p, newpath); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
339 | if(p->updateDir) { |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
340 | p->updateDir(p->updateDirData, newpath, -1); |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
341 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
342 | XtFree(newpath); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
343 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
344 | /* hide textfield and show path as buttons */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
345 | XtUnmanageChild(p->textfield); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
346 | pathbar_resize(p->widget, p, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
347 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
348 | if(p->focus_widget) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
349 | XmProcessTraversal(p->focus_widget, XmTRAVERSE_CURRENT); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
350 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
351 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
352 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
353 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
354 | void pathbar_shift_left(Widget w, PathBar *p, XtPointer d) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
355 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
356 | p->shift--; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
357 | pathbar_resize(p->widget, p, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
358 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
359 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
360 | void pathbar_shift_right(Widget w, PathBar *p, XtPointer d) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
361 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
362 | if(p->shift < 0) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
363 | p->shift++; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
364 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
365 | pathbar_resize(p->widget, p, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
366 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
367 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
368 | static void pathTextEH(Widget widget, XtPointer data, XEvent *event, Boolean *dispatch) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
369 | PathBar *pb = data; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
370 | if(event->type == KeyReleaseMask) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
371 | if(event->xkey.keycode == 9) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
372 | XtUnmanageChild(pb->textfield); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
373 | pathbar_resize(pb->widget, pb, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
374 | *dispatch = False; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
375 | } else if(event->xkey.keycode == 36) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
376 | pathbar_pathinput(pb->textfield, pb, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
377 | *dispatch = False; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
378 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
379 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
380 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
381 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
382 | PathBar* CreatePathBar(Widget parent, ArgList args, int n) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
383 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
384 | PathBar *bar = (PathBar*)XtMalloc(sizeof(PathBar)); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
385 | bar->path = NULL; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
386 | bar->updateDir = NULL; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
387 | bar->updateDirData = NULL; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
388 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
389 | bar->focus_widget = NULL; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
390 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
391 | bar->getpathelm = NULL; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
392 | bar->getpathelmdata = NULL; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
393 | |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
394 | bar->shift = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
395 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
396 | XtSetArg(args[n], XmNmarginWidth, 0); n++; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
397 | XtSetArg(args[n], XmNmarginHeight, 0); n++; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
398 | bar->widget = XmCreateDrawingArea(parent, "pathbar", args, n); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
399 | XtAddCallback( |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
400 | bar->widget, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
401 | XmNresizeCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
402 | (XtCallbackProc)pathbar_resize, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
403 | bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
404 | XtAddCallback( |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
405 | bar->widget, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
406 | XmNinputCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
407 | (XtCallbackProc)pathbar_input, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
408 | bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
409 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
410 | Arg a[4]; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
411 | XtSetArg(a[0], XmNshadowThickness, 0); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
412 | XtSetArg(a[1], XmNx, 0); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
413 | XtSetArg(a[2], XmNy, 0); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
414 | bar->textfield = XNECreateText(bar->widget, "pbtext", a, 3); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
415 | bar->input = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
416 | XtAddCallback( |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
417 | bar->textfield, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
418 | XmNlosingFocusCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
419 | (XtCallbackProc)pathbar_losingfocus, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
420 | bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
421 | XtAddCallback(bar->textfield, XmNactivateCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
422 | (XtCallbackProc)pathbar_pathinput, bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
423 | XtAddEventHandler(bar->textfield, KeyPressMask | KeyReleaseMask, FALSE, pathTextEH, bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
424 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
425 | XtSetArg(a[0], XmNarrowDirection, XmARROW_LEFT); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
426 | bar->left = XmCreateArrowButton(bar->widget, "pbbutton", a, 1); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
427 | XtSetArg(a[0], XmNarrowDirection, XmARROW_RIGHT); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
428 | bar->right = XmCreateArrowButton(bar->widget, "pbbutton", a, 1); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
429 | XtAddCallback( |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
430 | bar->left, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
431 | XmNactivateCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
432 | (XtCallbackProc)pathbar_shift_left, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
433 | bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
434 | XtAddCallback( |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
435 | bar->right, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
436 | XmNactivateCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
437 | (XtCallbackProc)pathbar_shift_right, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
438 | bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
439 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
440 | Pixel bg; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
441 | XtVaGetValues(bar->textfield, XmNbackground, &bg, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
442 | XtVaSetValues(bar->widget, XmNbackground, bg, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
443 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
444 | XtManageChild(bar->left); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
445 | XtManageChild(bar->right); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
446 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
447 | XtVaGetValues(bar->left, XmNwidth, &bar->lw, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
448 | XtVaGetValues(bar->right, XmNwidth, &bar->rw, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
449 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
450 | bar->segmentAlloc = 16; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
451 | bar->numSegments = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
452 | bar->pathSegments = (Widget*)XtCalloc(16, sizeof(Widget)); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
453 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
454 | bar->selection = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
455 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
456 | return bar; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
457 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
458 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
459 | void PathBarChangeDir(Widget w, PathBar *bar, XtPointer c) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
460 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
461 | XmToggleButtonSetState(bar->pathSegments[bar->selection], False, False); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
462 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
463 | int i; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
464 | for(i=0;i<bar->numSegments;i++) { |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
465 | if(bar->pathSegments[i] == w) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
466 | bar->selection = i; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
467 | XmToggleButtonSetState(w, True, False); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
468 | break; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
469 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
470 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
471 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
472 | UiPathElm elm = bar->current_pathelms[i]; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
473 | cxmutstr name = cx_strdup(cx_strn(elm.name, elm.name_len)); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
474 | if(bar->updateDir) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
475 | bar->updateDir(bar->updateDirData, name.ptr, i); |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
476 | } |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
477 | free(name.ptr); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
478 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
479 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
480 | static void ui_pathelm_destroy(UiPathElm *elms, size_t nelm) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
481 | for(int i=0;i<nelm;i++) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
482 | free(elms[i].name); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
483 | free(elms[i].path); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
484 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
485 | free(elms); |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
486 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
487 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
488 | void PathBarSetPath(PathBar *bar, const char *path) |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
489 | { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
490 | if(bar->path) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
491 | free(bar->path); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
492 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
493 | bar->path = strdup(path); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
494 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
495 | for(int i=0;i<bar->numSegments;i++) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
496 | XtDestroyWidget(bar->pathSegments[i]); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
497 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
498 | XtUnmanageChild(bar->textfield); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
499 | XtManageChild(bar->left); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
500 | XtManageChild(bar->right); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
501 | bar->input = False; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
502 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
503 | Arg args[4]; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
504 | XmString str; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
505 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
506 | bar->numSegments = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
507 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
508 | ui_pathelm_destroy(bar->current_pathelms, bar->numSegments); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
509 | size_t nelm = 0; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
510 | UiPathElm* path_elm = bar->getpathelm(bar->path, strlen(bar->path), &nelm, bar->getpathelmdata); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
511 | if (!path_elm) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
512 | return; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
513 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
514 | bar->current_pathelms = path_elm; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
515 | bar->numSegments = nelm; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
516 | bar->pathSegments = realloc(bar->pathSegments, nelm * sizeof(Widget*)); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
517 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
518 | for(int i=0;i<nelm;i++) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
519 | UiPathElm elm = path_elm[i]; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
520 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
521 | cxmutstr name = cx_strdup(cx_strn(elm.name, elm.name_len)); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
522 | str = XmStringCreateLocalized(elm.name); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
523 | free(name.ptr); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
524 | |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
525 | XtSetArg(args[0], XmNlabelString, str); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
526 | XtSetArg(args[1], XmNfillOnSelect, True); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
527 | XtSetArg(args[2], XmNindicatorOn, False); |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
528 | Widget button = XmCreateToggleButton(bar->widget, "pbbutton", args, 3); |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
529 | XtAddCallback( |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
530 | button, |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
531 | XmNvalueChangedCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
532 | (XtCallbackProc)PathBarChangeDir, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
533 | bar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
534 | XmStringFree(str); |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
535 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
536 | bar->pathSegments[i] = button; |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
537 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
538 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
539 | bar->selection = bar->numSegments-1; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
540 | XmToggleButtonSetState(bar->pathSegments[bar->selection], True, False); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
541 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
542 | XNETextSetString(bar->textfield, (char*)path); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
543 | XNETextSetInsertionPosition(bar->textfield, XNETextGetLastPosition(bar->textfield)); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
544 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
545 | pathbar_resize(bar->widget, bar, NULL); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
546 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
547 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
548 | void PathBarDestroy(PathBar *pathbar) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
549 | if(pathbar->path) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
550 | XtFree(pathbar->path); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
551 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
552 | XtFree((void*)pathbar->pathSegments); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
553 | XtFree((void*)pathbar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
554 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
555 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
556 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
557 | /* ---------------------------- Path Text Field ---------------------------- */ |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
558 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
559 | static void destroy_pathbar(Widget w, XtPointer *data, XtPointer d) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
560 | PathBar *pathbar = (PathBar*)data; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
561 | // TODO: check if there is somonething missing |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
562 | XtFree((void*)pathbar->pathSegments); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
563 | XtFree((void*)pathbar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
564 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
565 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
566 | // TODO: move to common |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
567 | static UiPathElm* default_pathelm_func(const char* full_path, size_t len, size_t* ret_nelm, void* data) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
568 | cxstring *pathelms; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
569 | size_t nelm = cx_strsplit_a(cxDefaultAllocator, cx_strn(full_path, len), CX_STR("/"), 4096, &pathelms); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
570 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
571 | if (nelm == 0) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
572 | *ret_nelm = 0; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
573 | return NULL; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
574 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
575 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
576 | UiPathElm* elms = (UiPathElm*)calloc(nelm, sizeof(UiPathElm)); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
577 | size_t n = nelm; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
578 | int j = 0; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
579 | for (int i = 0; i < nelm; i++) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
580 | cxstring c = pathelms[i]; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
581 | if (c.length == 0) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
582 | if (i == 0) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
583 | c.length = 1; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
584 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
585 | else { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
586 | n--; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
587 | continue; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
588 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
589 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
590 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
591 | cxmutstr m = cx_strdup(c); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
592 | elms[j].name = m.ptr; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
593 | elms[j].name_len = m.length; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
594 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
595 | size_t elm_path_len = c.ptr + c.length - full_path; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
596 | cxmutstr elm_path = cx_strdup(cx_strn(full_path, elm_path_len)); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
597 | elms[j].path = elm_path.ptr; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
598 | elms[j].path_len = elm_path.length; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
599 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
600 | j++; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
601 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
602 | *ret_nelm = n; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
603 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
604 | return elms; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
605 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
606 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
607 | static void pathbar_activate(void *data, char *path, int index) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
608 | UiEventData *event = data; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
609 | UiEvent evt; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
610 | evt.obj = event->obj; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
611 | evt.window = evt.obj->window; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
612 | evt.document = evt.obj->ctx->document; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
613 | evt.eventdata = path; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
614 | evt.intval = index; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
615 | event->callback(&evt, event->userdata); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
616 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
617 | |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
618 | UIWIDGET ui_path_textfield_create(UiObject* obj, UiPathTextFieldArgs args) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
619 | Arg xargs[16]; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
620 | int n = 0; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
621 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
622 | UiContainerPrivate *ctn = ui_obj_container(obj); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
623 | UI_APPLY_LAYOUT(ctn->layout, args); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
624 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
625 | Widget parent = ctn->prepare(ctn, xargs, &n); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
626 | // TODO: name |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
627 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
628 | |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
629 | PathBar *pathbar = CreatePathBar(parent, xargs, n); |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
630 | if(!args.getpathelm) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
631 | pathbar->getpathelm= default_pathelm_func; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
632 | } else { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
633 | pathbar->getpathelm = args.getpathelm; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
634 | pathbar->getpathelmdata = args.getpathelmdata; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
635 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
636 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
637 | |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
638 | XtManageChild(pathbar->widget); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
639 | ctn->add(ctn, pathbar->widget); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
640 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
641 | UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_STRING); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
642 | if (var) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
643 | UiString* value = (UiString*)var->value; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
644 | value->obj = pathbar; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
645 | value->get = ui_path_textfield_get; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
646 | value->set = ui_path_textfield_set; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
647 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
648 | if(value->value.ptr) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
649 | char *str = strdup(value->value.ptr); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
650 | ui_string_set(value, str); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
651 | free(str); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
652 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
653 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
654 | |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
655 | if(args.onactivate) { |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
656 | UiEventData *eventdata = malloc(sizeof(UiEventData)); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
657 | eventdata->callback = args.onactivate; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
658 | eventdata->userdata = args.onactivatedata; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
659 | eventdata->obj = obj; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
660 | eventdata->value = 0; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
661 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
662 | pathbar->updateDir = pathbar_activate; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
663 | pathbar->updateDirData = eventdata; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
664 | |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
665 | XtAddCallback( |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
666 | pathbar->widget, |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
667 | XmNdestroyCallback, |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
668 | (XtCallbackProc)ui_destroy_eventdata, |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
669 | eventdata); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
670 | } |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
671 | |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
672 | XtAddCallback( |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
673 | pathbar->widget, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
674 | XmNdestroyCallback, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
675 | (XtCallbackProc)destroy_pathbar, |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
676 | pathbar); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
677 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
678 | return pathbar->widget; |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
679 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
680 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
681 | char* ui_path_textfield_get(UiString *str) { |
415
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
682 | PathBar *pathbar = str->obj; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
683 | str->value.free(str->value.ptr); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
684 | char *value = XmTextFieldGetString(pathbar->textfield); |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
685 | str->value.ptr = value; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
686 | str->value.free = (ui_freefunc)XtFree; |
e35cdf33998c
finish motif path bar implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
414
diff
changeset
|
687 | return value; |
414
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
688 | } |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
689 | |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
690 | void ui_path_textfield_set(UiString *str, const char *value) { |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
691 | PathBarSetPath(str->obj, value); |
ef60d527c066
add text field widgets (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
406
diff
changeset
|
692 | } |