void testOpenFilePanel(WMScreen * scr) { WMOpenPanel *panel; /* windowCount++; */ /* get the shared Open File panel */ panel = WMGetOpenPanel(scr); WMRunModalFilePanelForDirectory(panel, NULL, "/usr/local", NULL, NULL); /* free the panel to save some memory. Not needed otherwise. */ WMFreeFilePanel(WMGetOpenPanel(scr)); }
static void browseForFile(WMWidget * self, void *clientData) { _Panel *panel = (_Panel *) clientData; WMFilePanel *filePanel; char *text, *oldprog, *newprog; filePanel = WMGetOpenPanel(WMWidgetScreen(self)); text = WMGetTextFieldText(panel->commandT); oldprog = wtrimspace(text); wfree(text); if (oldprog[0] == 0 || oldprog[0] != '/') { wfree(oldprog); oldprog = wstrdup("/"); } else { char *ptr = oldprog; while (*ptr && !isspace(*ptr)) ptr++; *ptr = 0; } WMSetFilePanelCanChooseDirectories(filePanel, False); if (WMRunModalFilePanelForDirectory(filePanel, panel->parent, oldprog, _("Select Program"), NULL) == True) { newprog = WMGetFilePanelFileName(filePanel); WMSetTextFieldText(panel->commandT, newprog); updateMenuItem(panel, panel->currentItem, panel->commandT); wfree(newprog); } wfree(oldprog); }
static void browseForFile(WMWidget *w, void *data) { _Panel *panel = (_Panel*)data; WMFilePanel *filePanel; filePanel = WMGetOpenPanel(WMWidgetScreen(w)); WMSetFilePanelCanChooseFiles(filePanel, False); if (WMRunModalFilePanelForDirectory(filePanel, panel->parent, "/", _("Select directory"), NULL) == True) { char *str = WMGetFilePanelFileName(filePanel); if (str) { int len = strlen(str); /* Remove the trailing '/' except if the path is exactly / */ if (len > 1 && str[len-1] == '/') { str[len-1] = '\0'; len--; } if (len > 0) { WMList *lPtr; int i; if (w == panel->icoaB) lPtr = panel->icoL; else if (w == panel->pixaB) lPtr = panel->pixL; i = WMGetListSelectedItemRow(lPtr); if (i >= 0) i++; addPathToList(lPtr, i, str); WMSetListBottomPosition(lPtr, WMGetListNumberOfRows(lPtr)); wfree(str); } } } }