mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Incomplete file dialog implementation for Haiku
This commit is contained in:
parent
945db73ec6
commit
dc3823c491
70
nfd/nfd_haiku.cpp
Normal file
70
nfd/nfd_haiku.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include "nfd.h"
|
||||||
|
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
nfdresult_t NFD_Init(void) {
|
||||||
|
return NFD_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NFD_Quit(void) {}
|
||||||
|
|
||||||
|
static nfdresult_t dialog(BFilePanel &p, nfdnchar_t **outPath,
|
||||||
|
const nfdnfilteritem_t *filterList,
|
||||||
|
nfdfiltersize_t filterCount) {
|
||||||
|
p.Show();
|
||||||
|
while (p.IsShowing())
|
||||||
|
usleep(100000);
|
||||||
|
entry_ref sel;
|
||||||
|
if (p.GetNextSelectedRef(&sel) == B_OK) {
|
||||||
|
BEntry e(&sel);
|
||||||
|
BPath path;
|
||||||
|
if (e.GetPath(&path) == B_OK) {
|
||||||
|
outPath[0] = strdup(path.Path());
|
||||||
|
return NFD_OKAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NFD_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
class NFDFilter : public BRefFilter {
|
||||||
|
public:
|
||||||
|
NFDFilter(const nfdnfilteritem_t *filterList, nfdfiltersize_t filterCount) {}
|
||||||
|
|
||||||
|
bool Filter(const entry_ref *ref, BNode *node, struct stat_beos *stat,
|
||||||
|
const char *mimeType) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
nfdresult_t
|
||||||
|
NFD_OpenDialogN(nfdnchar_t **outPath, const nfdnfilteritem_t *filterList,
|
||||||
|
nfdfiltersize_t filterCount, const nfdnchar_t *defaultPath) {
|
||||||
|
NFDFilter f(filterList, filterCount);
|
||||||
|
BFilePanel p(B_OPEN_PANEL, NULL, NULL, 0, false, NULL, &f, true, true);
|
||||||
|
p.Window()->SetTitle(filterList[0].name);
|
||||||
|
if (defaultPath)
|
||||||
|
p.SetPanelDirectory(defaultPath);
|
||||||
|
return dialog(p, outPath, filterList, filterCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
nfdresult_t NFD_SaveDialogN(nfdnchar_t** outPath,
|
||||||
|
const nfdnfilteritem_t* filterList,
|
||||||
|
nfdfiltersize_t filterCount,
|
||||||
|
const nfdnchar_t* defaultPath,
|
||||||
|
const nfdnchar_t* defaultName) {
|
||||||
|
NFDFilter f(filterList, filterCount);
|
||||||
|
BFilePanel p(B_SAVE_PANEL, NULL, NULL, 0, false, NULL, &f, true, true);
|
||||||
|
p.Window()->SetTitle(filterList[0].name);
|
||||||
|
if (defaultPath)
|
||||||
|
p.SetPanelDirectory(defaultPath);
|
||||||
|
if (defaultName)
|
||||||
|
p.SetSaveText(defaultName);
|
||||||
|
return dialog(p, outPath, filterList, filterCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NFD_FreePathN(nfdnchar_t* filePath) {
|
||||||
|
free(filePath);
|
||||||
|
}
|
||||||
@ -20,11 +20,16 @@ else
|
|||||||
SRC += ../../../nfd/nfd_gtk.cpp
|
SRC += ../../../nfd/nfd_gtk.cpp
|
||||||
INCLUDES += $(shell pkg-config --cflags gtk+-3.0)
|
INCLUDES += $(shell pkg-config --cflags gtk+-3.0)
|
||||||
LIBS += $(shell pkg-config --libs gtk+-3.0)
|
LIBS += $(shell pkg-config --libs gtk+-3.0)
|
||||||
|
else
|
||||||
|
ifeq ($(shell uname -o),Haiku)
|
||||||
|
SRC += ../../../nfd/nfd_haiku.cpp
|
||||||
|
LIBS += -lbe -ltracker
|
||||||
else
|
else
|
||||||
SRC += ../../../nfd/nfd_portal.cpp
|
SRC += ../../../nfd/nfd_portal.cpp
|
||||||
INCLUDES += $(shell pkg-config --cflags dbus-1)
|
INCLUDES += $(shell pkg-config --cflags dbus-1)
|
||||||
LIBS += $(shell pkg-config --libs dbus-1)
|
LIBS += $(shell pkg-config --libs dbus-1)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
include ../../../common/unix.mk
|
include ../../../common/unix.mk
|
||||||
|
|||||||
@ -1,10 +1,5 @@
|
|||||||
ifeq ($(shell uname -o),Haiku)
|
|
||||||
CFLAGS := -gdwarf-3 -Wall
|
|
||||||
LDFLAGS := -gdwarf-3
|
|
||||||
else
|
|
||||||
CFLAGS := -g3 -Wall
|
CFLAGS := -g3 -Wall
|
||||||
LDFLAGS := -g3
|
LDFLAGS := -g3
|
||||||
endif
|
|
||||||
DEFINES := -DDEBUG
|
DEFINES := -DDEBUG
|
||||||
BUILD := debug
|
BUILD := debug
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,10 @@ else
|
|||||||
SRC += ../../../nfd/nfd_gtk.cpp
|
SRC += ../../../nfd/nfd_gtk.cpp
|
||||||
INCLUDES += $(shell pkg-config --cflags gtk+-3.0)
|
INCLUDES += $(shell pkg-config --cflags gtk+-3.0)
|
||||||
LIBS += $(shell pkg-config --libs gtk+-3.0)
|
LIBS += $(shell pkg-config --libs gtk+-3.0)
|
||||||
|
else
|
||||||
|
ifeq ($(shell uname -o),Haiku)
|
||||||
|
SRC += ../../../nfd/nfd_haiku.cpp
|
||||||
|
LIBS += -lbe -ltracker
|
||||||
else
|
else
|
||||||
SRC += ../../../nfd/nfd_portal.cpp
|
SRC += ../../../nfd/nfd_portal.cpp
|
||||||
INCLUDES += $(shell pkg-config --cflags dbus-1)
|
INCLUDES += $(shell pkg-config --cflags dbus-1)
|
||||||
@ -29,5 +33,6 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
include ../../../common/unix.mk
|
include ../../../common/unix.mk
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user