[nostalgia/studio] Fix file dialog to close properly
This commit is contained in:
parent
8a6f08ae73
commit
4a4f380a11
@ -12,18 +12,16 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <ox/std/defer.hpp>
|
||||
#include <ox/std/memory.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
#include <ox/std/trace.hpp>
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
ox::Result<ox::String> chooseDirectory() noexcept {
|
||||
ox::Result<ox::String> out;
|
||||
const auto action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||
gtk_init(0, nullptr);
|
||||
auto dialog = gtk_file_chooser_dialog_new("Open File", nullptr, action,
|
||||
("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
const auto action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
|
||||
gtk_init(nullptr, nullptr);
|
||||
auto dialog = gtk_file_chooser_dialog_new("Open Project Directory", nullptr, action,
|
||||
("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
("_Open"), GTK_RESPONSE_ACCEPT,
|
||||
nullptr);
|
||||
const auto res = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
@ -36,6 +34,10 @@ ox::Result<ox::String> chooseDirectory() noexcept {
|
||||
out = OxError(1);
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
// for some reason we need to 4 iterations through the main loop to destroy the dialog
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
gtk_main_iteration_do(false);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user