1 /* Copyright (C) 1992-1998 The Geometry Center
2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3 *
4 * This file is part of Geomview.
5 *
6 * Geomview is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Geomview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Geomview; see the file COPYING. If not, write
18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA, or visit http://www.gnu.org.
20 */
21
22 #if HAVE_CONFIG_H
23 # include "config.h"
24 #endif
25
26 #if 0
27 static char copyright[] = "Copyright (C) 1992-1998 The Geometry Center\n\
28 Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips";
29 #endif
30
31 #include "mibload.h"
32 #include <Xm/DialogS.h>
33 #include "../common/drawer.h"
34 #include "gvui.h"
35 #include "interface/LoadPaths.mib"
36
37 extern Display *dpy;
38 extern Widget TopLevel;
39
40 /* private methods and variables */
41 /*****************************************************************************/
42
43 static void load_selection(Widget, XtPointer,
44 XmFileSelectionBoxCallbackStruct *);
45 static void select_path(Widget, XtPointer, XmListCallbackStruct *);
46 /*static void ui_update_filespanel();*/
47 static Widget shell, pathlist, filesform;
48 static char **dirp;
49
50 /*****************************************************************************/
51
ui_load_filespanel()52 void ui_load_filespanel()
53 {
54 Widget pathform,
55 temp;
56
57 mib_Widget *pathload;
58 XmString xname;
59 static char Files[] = "Files";
60
61 /*****************************************************************************/
62
63 shell = ui_make_panel_and_form(Files, Root, True, False, NULL);
64
65 filesform = XmCreateFileSelectionBox(shell, Files, NULL, 0);
66
67 XtManageChild(filesform);
68 XtSetMappedWhenManaged(filesform, True);
69
70 /*****************************************************************************/
71
72 temp = XmFileSelectionBoxGetChild(filesform, XmDIALOG_HELP_BUTTON);
73 XtUnmanageChild(temp);
74
75 XtAddCallback(filesform, XmNokCallback, (XtCallbackProc) load_selection,
76 (XtPointer) NULL);
77
78 temp = XmFileSelectionBoxGetChild(filesform, XmDIALOG_CANCEL_BUTTON);
79
80 xname = XmStringCreateSimple("Hide");
81 XtVaSetValues(temp, XmNlabelString, xname, NULL);
82 XmStringFree(xname);
83
84 XtAddCallback(temp, XmNactivateCallback, (XtCallbackProc) ui_hide,
85 (XtPointer) Files);
86
87 /*****************************************************************************/
88
89 /*pathload = mib_load_interface(filesform, "interface/LoadPaths.mib",
90 MI_FROMFILE);*/
91 pathload = mib_load_interface(filesform, Root,
92 MI_FROMSTRING);
93 pathform = pathload->me;
94
95 pathlist = mib_find_name(pathload, "PathList")->me;
96 XtAddCallback(pathlist, XmNbrowseSelectionCallback,
97 (XtCallbackProc) select_path, (XtPointer) NULL);
98 XtManageChild(pathform);
99 XtManageChild(pathlist);
100 }
101
102
103 /*****************************************************************************/
104
ui_show_filespanel()105 void ui_show_filespanel()
106 {
107 int i;
108 XmString str;
109
110 XmListDeleteAllItems(pathlist);
111 dirp = getfiledirs();
112 for (i=0; dirp[i] != NULL; i++)
113 {
114 str = XmStringCreateSimple(dirp[i]);
115 XmListAddItemUnselected(pathlist, str, 0);
116 XmStringFree(str);
117 }
118 }
119
120 /*****************************************************************************/
121
select_path(Widget w,XtPointer data,XmListCallbackStruct * cbs)122 static void select_path(Widget w, XtPointer data, XmListCallbackStruct *cbs)
123 {
124 char *temp, dirmask[200];
125 XmString dmask;
126
127 if (!XmStringGetLtoR(cbs->item, XmSTRING_DEFAULT_CHARSET, &temp))
128 return;
129
130 if (!*temp)
131 return;
132
133 sprintf(dirmask,"%s/*", temp);
134 XtFree(temp);
135 dmask = XmStringCreate(dirmask, XmSTRING_DEFAULT_CHARSET);
136
137 XmFileSelectionDoSearch(filesform, dmask);
138
139 XmStringFree(dmask);
140 }
141
142 /*****************************************************************************/
143
load_selection(Widget w,XtPointer data,XmFileSelectionBoxCallbackStruct * cbs)144 static void load_selection(Widget w, XtPointer data,
145 XmFileSelectionBoxCallbackStruct *cbs)
146 {
147
148 char *object;
149
150 if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &object))
151 return;
152
153 if (!*object)
154 return;
155
156 gv_load(object, NULL);
157 XtFree(object);
158 }
159
160 /*****************************************************************************/
161