Skip to content

Commit

Permalink
UI filebrowser saving mode, separate from pugl/DGL/Window (#349)
Browse files Browse the repository at this point in the history
* Add UI::openFileBrowser that matches Window::openFileBrowser

* Add empty implementation so it builds

* Move file browser dialog implementation into its own file

Signed-off-by: falkTX <[email protected]>

* Fix warnings

Signed-off-by: falkTX <[email protected]>

* Fix tests; Add non-implemented saving flag

Signed-off-by: falkTX <[email protected]>

* Initial DBus/freedesktop file browser implementation

Signed-off-by: falkTX <[email protected]>

* Build fixes

Signed-off-by: falkTX <[email protected]>

* Fix window id

Signed-off-by: falkTX <[email protected]>

* More build fixes

Signed-off-by: falkTX <[email protected]>

* More file dialog tweaks

Signed-off-by: falkTX <[email protected]>

* Attempted fixes

Signed-off-by: falkTX <[email protected]>

* Fix C++98 build

Signed-off-by: falkTX <[email protected]>

* Fix windows build

Signed-off-by: falkTX <[email protected]>

* Really fix windows builds

Signed-off-by: falkTX <[email protected]>

* Fix for MSVC

Signed-off-by: falkTX <[email protected]>

* Yet another fix attempt

Signed-off-by: falkTX <[email protected]>

* Also fix macOS side

Signed-off-by: falkTX <[email protected]>

* More attempted fixes, this is getting annoying...

Signed-off-by: falkTX <[email protected]>

* FileBrowserDialog: Implement saving in Windows

Signed-off-by: falkTX <[email protected]>

* FileBrowserDialog: Implement saving on macOS

Signed-off-by: falkTX <[email protected]>

* Rework last commit

Signed-off-by: falkTX <[email protected]>

* One more macOS fix needed

Signed-off-by: falkTX <[email protected]>

* unref dbus connection on close

Signed-off-by: falkTX <[email protected]>

* More build fixes

Signed-off-by: falkTX <[email protected]>

* Hopefully final macOS fix

Signed-off-by: falkTX <[email protected]>

* Add libdbus-1-dev to CI

Signed-off-by: falkTX <[email protected]>

* Check that org.freedesktop.portal.Desktop exists before connecting

Signed-off-by: falkTX <[email protected]>

* Less indentation

Signed-off-by: falkTX <[email protected]>

* Fix macOS build
  • Loading branch information
falkTX authored Nov 12, 2021
1 parent fbbfe11 commit 29709cb
Show file tree
Hide file tree
Showing 19 changed files with 856 additions and 569 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
liblo-dev \
libgl-dev \
libcairo2-dev \
libdbus-1-dev \
libx11-dev
- name: Create Build Environment
shell: bash
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/example-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-arm64.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports bionic-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-arm64.list
sudo apt-get update -qq
sudo apt-get install -yq g++-aarch64-linux-gnu libasound2-dev:arm64 libcairo2-dev:arm64 libgl1-mesa-dev:arm64 liblo-dev:arm64 libpulse-dev:arm64 libx11-dev:arm64 libxcursor-dev:arm64 libxext-dev:arm64 libxrandr-dev:arm64 qemu-user-static
sudo apt-get install -yq g++-aarch64-linux-gnu libasound2-dev:arm64 libcairo2-dev:arm64 libdbus-1-dev:arm64 libgl1-mesa-dev:arm64 liblo-dev:arm64 libpulse-dev:arm64 libx11-dev:arm64 libxcursor-dev:arm64 libxext-dev:arm64 libxrandr-dev:arm64 qemu-user-static
# fix broken Ubuntu packages missing pkg-config file in multi-arch package
sudo apt-get install -yq libasound2-dev libgl1-mesa-dev liblo-dev libpulse-dev libxcursor-dev libxrandr-dev
sudo ln -s /usr/lib/aarch64-linux-gnu/liblo.so.7 /usr/lib/aarch64-linux-gnu/liblo.so
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-armhf.list
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ports-armhf.list
sudo apt-get update -qq
sudo apt-get install -yq g++-arm-linux-gnueabihf libasound2-dev:armhf libcairo2-dev:armhf libgl1-mesa-dev:armhf liblo-dev:armhf libpulse-dev:armhf libx11-dev:armhf libxcursor-dev:armhf libxext-dev:armhf libxrandr-dev:armhf qemu-user-static
sudo apt-get install -yq g++-arm-linux-gnueabihf libasound2-dev:armhf libcairo2-dev:armhf libdbus-1-dev:armhf libgl1-mesa-dev:armhf liblo-dev:armhf libpulse-dev:armhf libx11-dev:armhf libxcursor-dev:armhf libxext-dev:armhf libxrandr-dev:armhf qemu-user-static
# fix broken Ubuntu packages missing pkg-config file in multi-arch package
sudo apt-get install -yq libasound2-dev libgl1-mesa-dev liblo-dev libpulse-dev libxcursor-dev libxrandr-dev
sudo ln -s /usr/lib/arm-linux-gnueabihf/liblo.so.7 /usr/lib/arm-linux-gnueabihf/liblo.so
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -qq
sudo apt-get install -yq g++-multilib libasound2-dev:i386 libcairo2-dev:i386 libgl1-mesa-dev:i386 liblo-dev:i386 libpulse-dev:i386 libx11-dev:i386 libxcursor-dev:i386 libxext-dev:i386 libxrandr-dev:i386
sudo apt-get install -yq g++-multilib libasound2-dev:i386 libcairo2-dev:i386 libdbus-1-dev:i386 libgl1-mesa-dev:i386 liblo-dev:i386 libpulse-dev:i386 libx11-dev:i386 libxcursor-dev:i386 libxext-dev:i386 libxrandr-dev:i386
- name: Build linux x86
env:
CFLAGS: -m32
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- name: Set up dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yq libasound2-dev libcairo2-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
sudo apt-get install -yq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
- name: Build linux x86_64
env:
LDFLAGS: -static-libgcc -static-libstdc++
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
sudo dpkg -i kxstudio-repos_10.0.3_all.deb
sudo apt-get update -qq
# build-deps
sudo apt-get install -yq libasound2-dev libcairo2-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
sudo apt-get install -yq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev
# runtime testing
sudo apt-get install -yq carla-git lilv-utils lv2-dev lv2lint valgrind
- name: Build plugins
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -yq libasound2-dev libcairo2-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev xvfb
sudo apt-get install -yq libasound2-dev libcairo2-dev libdbus-1-dev libgl1-mesa-dev liblo-dev libpulse-dev libx11-dev libxcursor-dev libxext-dev libxrandr-dev xvfb
- name: Without any warnings
env:
CFLAGS: -Werror
Expand Down
6 changes: 6 additions & 0 deletions Makefile.base.mk
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ HAVE_OPENGL = true
else
HAVE_OPENGL = $(shell $(PKG_CONFIG) --exists gl && echo true)
ifneq ($(HAIKU),true)
HAVE_DBUS = $(shell $(PKG_CONFIG) --exists dbus-1 && echo true)
HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
HAVE_XCURSOR = $(shell $(PKG_CONFIG) --exists xcursor && echo true)
HAVE_XEXT = $(shell $(PKG_CONFIG) --exists xext && echo true)
Expand Down Expand Up @@ -284,6 +285,10 @@ DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
endif

ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_DBUS),true)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1) -DHAVE_DBUS
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs dbus-1)
endif
ifeq ($(HAVE_X11),true)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11) -DHAVE_X11
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
Expand Down Expand Up @@ -476,6 +481,7 @@ features:
$(call print_available,UNIX)
@echo === Detected features
$(call print_available,HAVE_ALSA)
$(call print_available,HAVE_DBUS)
$(call print_available,HAVE_CAIRO)
$(call print_available,HAVE_DGL)
$(call print_available,HAVE_LIBLO)
Expand Down
57 changes: 9 additions & 48 deletions dgl/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

#include "Geometry.hpp"

#ifndef DGL_FILE_BROWSER_DISABLED
# include "../distrho/extra/FileBrowserDialog.hpp"
#endif

START_NAMESPACE_DGL

class Application;
class PluginWindow;
class TopLevelWidget;

// -----------------------------------------------------------------------
Expand Down Expand Up @@ -53,53 +58,9 @@ class Window

public:
#ifndef DGL_FILE_BROWSER_DISABLED
/**
File browser options.
@see Window::openFileBrowser
*/
struct FileBrowserOptions {
/**
File browser button state.
This allows to customize the behaviour of the file browse dialog buttons.
Note these are merely hints, not all systems support them.
*/
enum ButtonState {
kButtonInvisible,
kButtonVisibleUnchecked,
kButtonVisibleChecked,
};

/** Start directory, uses current working directory if null */
const char* startDir;
/** File browser dialog window title, uses "FileBrowser" if null */
const char* title;
// TODO file filter

/**
File browser buttons.
*/
struct Buttons {
/** Whether to list all files vs only those with matching file extension */
ButtonState listAllFiles;
/** Whether to show hidden files */
ButtonState showHidden;
/** Whether to show list of places (bookmarks) */
ButtonState showPlaces;

/** Constructor for default values */
Buttons()
: listAllFiles(kButtonVisibleChecked),
showHidden(kButtonVisibleUnchecked),
showPlaces(kButtonVisibleChecked) {}
} buttons;

/** Constructor for default values */
FileBrowserOptions()
: startDir(nullptr),
title(nullptr),
buttons() {}
};
#endif // DGL_FILE_BROWSER_DISABLED
typedef DISTRHO_NAMESPACE::FileBrowserHandle FileBrowserHandle;
typedef DISTRHO_NAMESPACE::FileBrowserOptions FileBrowserOptions;
#endif

/**
Window graphics context as a scoped struct.
Expand Down Expand Up @@ -361,7 +322,7 @@ class Window

#ifndef DGL_FILE_BROWSER_DISABLED
/**
Open a file browser dialog with this window as parent.
Open a file browser dialog with this window as transient parent.
A few options can be specified to setup the dialog.
If a path is selected, onFileSelected() will be called with the user chosen path.
Expand Down
Loading

0 comments on commit 29709cb

Please sign in to comment.