6 #include <X11/keysym.h>
11 #define INITIALIZED_PANEL (1<<0)
13 #define FSI_HEIGHT 418
16 #define NUM_PANEL 5/* 6 */
29 typedef struct _FSInspector
{
34 WMPopUpButton
*popupMenu
;
45 Panel
*panel
[NUM_PANEL
];
51 typedef struct _FSInspector FSInspector
;
52 static FSInspector
*fsInspector
;
55 FSEnableInspectorPanels(FSInspector
*fsInspector
)
60 st
= (struct stat
*) wmalloc(sizeof(struct stat
));
62 pathname
= (char *) wmalloc(strlen(fsInspector
->fileInfo
->path
)+
63 strlen(fsInspector
->fileInfo
->name
)+1);
64 strcpy(pathname
, fsInspector
->fileInfo
->path
);
65 if (fsInspector
->fileInfo
->fileType
!= ROOT
)
66 strcat(pathname
, fsInspector
->fileInfo
->name
);
68 /* get information of a file represented by pathname */
69 if (stat(pathname
, st
) == -1)
70 wwarning(_("%s %d: Stat Error"), __FILE__
, __LINE__
);
72 if (S_ISDIR(st
->st_mode
))
74 WMSetPopUpButtonItemEnabled(fsInspector
->popupMenu
, EditPanel
, False
);
75 WMSetPopUpButtonItemEnabled(fsInspector
->popupMenu
, ViewPanel
, False
);
76 WMSetPopUpButtonItemEnabled(fsInspector
->popupMenu
, ExePanel
, False
);
77 /* WMSetPopUpButtonItemEnabled(fsInspector->popupMenu, ExtnPanel, False); */
81 WMSetPopUpButtonItemEnabled(fsInspector
->popupMenu
, EditPanel
, True
);
82 WMSetPopUpButtonItemEnabled(fsInspector
->popupMenu
, ViewPanel
, True
);
83 if (st
->st_mode
& (S_IXUSR
| S_IXGRP
| S_IXOTH
))
85 WMSetPopUpButtonItemEnabled(fsInspector
->popupMenu
,
87 /* WMSetPopUpButtonItemEnabled(fsInspector->popupMenu, */
88 /* ExtnPanel, True); */
92 WMSetPopUpButtonItemEnabled(fsInspector
->popupMenu
,
94 /* WMSetPopUpButtonItemEnabled(fsInspector->popupMenu, */
95 /* ExtnPanel, False); */
110 FSUpdateInspectorFileInfoDisplay(FSInspector
*fsInspector
)
117 color
.green
= 0xaa; /* aa ?*/
121 if (fsInspector
->fileInfo
->fileType
!= ROOT
)
122 WMSetLabelText(fsInspector
->nameLabel
, fsInspector
->fileInfo
->name
);
128 WMSetLabelText(fsInspector
->nameLabel
, tmp
);
131 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(fsInspector
->win
),
132 fsInspector
->fileInfo
->imgName
,
134 WMSetLabelImage(fsInspector
->nameLabel
, pixmap
);
136 buf
= (char *) wmalloc(strlen(_("Path: ")) +
137 strlen(fsInspector
->fileInfo
->path
)+1);
138 sprintf(buf
, _("Path: %s"), fsInspector
->fileInfo
->path
);
139 WMSetLabelText(fsInspector
->pathLabel
, buf
);
147 FSCopyInspectorFileInfo(FileInfo
*fileInfo
)
149 fsInspector
->fileInfo
->name
=
150 (char *) wrealloc(fsInspector
->fileInfo
->name
,
151 strlen(fileInfo
->name
)+1);
152 strcpy(fsInspector
->fileInfo
->name
, fileInfo
->name
);
154 fsInspector
->fileInfo
->path
=
155 (char *) wrealloc(fsInspector
->fileInfo
->path
,
156 strlen(fileInfo
->path
)+1);
157 strcpy(fsInspector
->fileInfo
->path
, fileInfo
->path
);
159 fsInspector
->fileInfo
->extn
=
160 (char *) wrealloc(fsInspector
->fileInfo
->extn
,
161 strlen(fileInfo
->extn
)+1);
162 strcpy(fsInspector
->fileInfo
->extn
, fileInfo
->extn
);
164 fsInspector
->fileInfo
->abbrev
=
165 (char *) wrealloc(fsInspector
->fileInfo
->abbrev
,
166 strlen(fileInfo
->abbrev
)+1);
167 strcpy(fsInspector
->fileInfo
->abbrev
, fileInfo
->abbrev
);
169 fsInspector
->fileInfo
->imgName
=
170 (char *) wrealloc(fsInspector
->fileInfo
->imgName
,
171 strlen(fileInfo
->imgName
)+1);
172 strcpy(fsInspector
->fileInfo
->imgName
, fileInfo
->imgName
);
174 fsInspector
->fileInfo
->fileType
= fileInfo
->fileType
;
178 FSHideInspectorPanel(Panel
*panel
)
180 PanelRec
*rec
= (PanelRec
*)panel
;
182 WMUnmapWidget(rec
->frame
);
186 FSShowInspectorPanel(Panel
*panel
)
188 PanelRec
*rec
= (PanelRec
*)panel
;
190 if (!(rec
->callbacks
.flags
& INITIALIZED_PANEL
)) {
191 (*rec
->callbacks
.createWidgets
)(panel
);
192 rec
->callbacks
.flags
|= INITIALIZED_PANEL
;
195 WMSetWindowTitle(fsInspector
->win
, rec
->sectionName
);
197 (*rec
->callbacks
.updateDisplay
)(panel
);
198 WMMapWidget(rec
->frame
);
202 FSCloseInspectorWindow(WMWidget
*w
, void *data
)
204 fsInspector
->isOpen
= False
;
205 WMUnmapWidget((WMWindow
*) w
);
209 FSUpdateInspectorWindow(FileInfo
*fileInfo
)
211 if (fsInspector
->isOpen
)
213 fsInspector
->currentPanel
= fsInspector
->panel
[AttribPanel
];
214 WMSetPopUpButtonSelectedItem(fsInspector
->popupMenu
, AttribPanel
);
215 /* WMMapWidget(fsInspector->win); */
216 FSCopyInspectorFileInfo(fileInfo
);
217 FSUpdateInspectorFileInfoDisplay(fsInspector
);
218 FSEnableInspectorPanels(fsInspector
);
219 FSShowInspectorPanel(fsInspector
->currentPanel
);
220 fsInspector
->isOpen
= True
;
225 FSShowInspectorWindow(WMScreen
*scr
, FileInfo
*fileInfo
)
227 fsInspector
->currentPanel
= fsInspector
->panel
[AttribPanel
];
228 WMSetPopUpButtonSelectedItem(fsInspector
->popupMenu
, AttribPanel
);
229 WMMapWidget(fsInspector
->win
);
230 FSCopyInspectorFileInfo(fileInfo
);
231 FSUpdateInspectorFileInfoDisplay(fsInspector
);
232 FSEnableInspectorPanels(fsInspector
);
233 FSShowInspectorPanel(fsInspector
->currentPanel
);
234 fsInspector
->isOpen
= True
;
238 FSHideInspectorWindow(WMScreen
*scr
)
240 FSCloseInspectorWindow(fsInspector
->win
, NULL
);
244 FSInspectorPopupAction(WMWidget
*self
, void *data
)
246 int i
= WMGetPopUpButtonSelectedItem((WMPopUpButton
*)self
);
248 if (fsInspector
->currentPanel
!= fsInspector
->panel
[i
])
250 FSHideInspectorPanel(fsInspector
->currentPanel
);
251 fsInspector
->currentPanel
= fsInspector
->panel
[i
];
252 FSShowInspectorPanel(fsInspector
->panel
[i
]);
257 FSCreateInspectorWindow()
259 WMScreen
*scr
= FSGetFSViewerScreen(fsInspector
->fsViewer
);
262 fsInspector
->win
= WMCreateWindow(scr
, "FSViewer Inspector");
263 WMResizeWidget(fsInspector
->win
, FSI_WIDTH
, FSI_HEIGHT
);
264 WMSetWindowTitle(fsInspector
->win
, _("FSViewer Inspector"));
265 WMSetWindowCloseAction(fsInspector
->win
, FSCloseInspectorWindow
, NULL
);
266 WMSetWindowMaxSize(fsInspector
->win
, FSI_WIDTH
, FSI_HEIGHT
);
267 WMSetWindowMinSize(fsInspector
->win
, FSI_WIDTH
, FSI_HEIGHT
);
270 fsInspector
->mainF
= WMCreateFrame(fsInspector
->win
);
271 WMResizeWidget(fsInspector
->mainF
, FSI_WIDTH
+10, FSI_HEIGHT
+10);
272 WMMoveWidget(fsInspector
->mainF
, -MF_X
, -MF_Y
);
273 WMSetFrameRelief(fsInspector
->mainF
, WRFlat
);
275 font
= WMCreateFont(WMWidgetScreen(fsInspector
->win
),
276 "-*-helvetica-medium-r-*-*-18-*-*-*-*-*-*-*");
278 font
= WMBoldSystemFontOfSize(WMWidgetScreen(fsInspector
->win
), 18);
280 fsInspector
->popupMenu
= WMCreatePopUpButton(fsInspector
->mainF
);
281 WMResizeWidget(fsInspector
->popupMenu
, 112, 20);
282 WMMoveWidget(fsInspector
->popupMenu
, ((FSI_WIDTH
-112)/2)+MF_X
, 8+MF_Y
);
283 WMSetPopUpButtonText(fsInspector
->popupMenu
, _("Select"));
284 WMAddPopUpButtonItem(fsInspector
->popupMenu
, _("Attributes"));
285 WMAddPopUpButtonItem(fsInspector
->popupMenu
, _("Icon"));
286 WMAddPopUpButtonItem(fsInspector
->popupMenu
, _("Viewer"));
287 WMAddPopUpButtonItem(fsInspector
->popupMenu
, _("Editor"));
288 WMAddPopUpButtonItem(fsInspector
->popupMenu
, _("Executable"));
289 /* WMAddPopUpButtonItem(fsInspector->popupMenu, "File Extensions"); */
290 WMSetPopUpButtonAction(fsInspector
->popupMenu
, FSInspectorPopupAction
,
292 WMSetPopUpButtonSelectedItem(fsInspector
->popupMenu
, INIT_PANEL
);
294 fsInspector
->infoF
= WMCreateFrame(fsInspector
->mainF
);
295 WMResizeWidget(fsInspector
->infoF
, FSI_WIDTH
+10, 93);
296 WMMoveWidget(fsInspector
->infoF
, 0, 36+MF_Y
);
297 WMSetFrameRelief(fsInspector
->infoF
, WRGroove
);
299 fsInspector
->nameLabel
= WMCreateLabel(fsInspector
->infoF
);
300 WMResizeWidget(fsInspector
->nameLabel
, FSI_WIDTH
-10, 55);
301 WMMoveWidget(fsInspector
->nameLabel
, 8+MF_X
, 8);
302 WMSetLabelFont(fsInspector
->nameLabel
, font
);
303 WMSetLabelImagePosition(fsInspector
->nameLabel
, WIPLeft
);
304 WMSetLabelTextAlignment(fsInspector
->nameLabel
, WALeft
);
307 fsInspector
->pathLabel
= WMCreateLabel(fsInspector
->infoF
);
308 WMResizeWidget(fsInspector
->pathLabel
, FSI_WIDTH
-10, 30);
309 WMMoveWidget(fsInspector
->pathLabel
, 8, 60);
311 WMMapSubwidgets(fsInspector
->win
);
313 fsInspector
->panel
[AttribPanel
] = InitAttribs(fsInspector
->win
,
314 fsInspector
->fileInfo
);
315 fsInspector
->panel
[IconPanel
] = InitIcon(fsInspector
->win
,
316 fsInspector
->fsViewer
,
317 fsInspector
->fileInfo
,
319 fsInspector
->panel
[ViewPanel
] = InitViewer(fsInspector
->win
,
320 fsInspector
->fileInfo
);
321 fsInspector
->panel
[EditPanel
] = InitEditor(fsInspector
->win
,
322 fsInspector
->fileInfo
);
323 fsInspector
->panel
[ExePanel
] = InitExecutable(fsInspector
->win
,
324 fsInspector
->fileInfo
);
325 /* fsInspector->panel[ExtnPanel] = InitExtn(fsInspector->win, */
326 /* fsInspector->fsViewer, */
327 /* fsInspector->fileInfo); */
332 FSInitInspector(FSViewer
*fsViewer
)
336 GNUstepWMAttributes attributes
;
338 if (!(fsInspector
= (FSInspector
*) malloc(sizeof(FSInspector
))))
340 wfatal(_("Unable to allocate memory for FSInspector %s %d\n"),
343 memset(fsInspector
, 0, sizeof(FSInspector
));
345 fsInspector
->fileInfo
= FSCreateFileInfo();
346 fsInspector
->fsViewer
= fsViewer
;
347 FSCreateInspectorWindow();
349 WMRealizeWidget(fsInspector
->win
);
350 FSAddWindow(fsInspector
->fsViewer
, WMWidgetXID(fsInspector
->win
));
351 fsInspector
->isOpen
= False
;