summaryrefslogtreecommitdiff
path: root/src/gui_gtk.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui_gtk.cc')
-rw-r--r--src/gui_gtk.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/gui_gtk.cc b/src/gui_gtk.cc
index 2af33e2..0c251a9 100644
--- a/src/gui_gtk.cc
+++ b/src/gui_gtk.cc
@@ -715,26 +715,26 @@ public:
std::string file_dialog(std::string const& title, std::string const& file,
uint8_t flags,
std::vector<GuiFile::Filter> const& filter) override {
- auto chooser = gtk_file_chooser_native_new(
+ shared_gobject<GtkFileChooserNative> chooser(gtk_file_chooser_native_new(
title.c_str(),
reinterpret_cast<GtkWindow*>(impl()),
flags & GuiFile::FILE_SAVE ? GTK_FILE_CHOOSER_ACTION_SAVE
: GTK_FILE_CHOOSER_ACTION_OPEN,
- nullptr, nullptr);
+ nullptr, nullptr));
if (flags & GuiFile::FILE_SAVE) {
gtk_file_chooser_set_do_overwrite_confirmation(
- GTK_FILE_CHOOSER(chooser), true);
+ GTK_FILE_CHOOSER(chooser.get()), true);
}
if (file.empty()) {
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser), file.c_str());
+ gtk_file_chooser_set_filename(
+ GTK_FILE_CHOOSER(chooser.get()), file.c_str());
}
- set_filter(GTK_FILE_CHOOSER(chooser), filter);
+ set_filter(GTK_FILE_CHOOSER(chooser.get()), filter);
std::string ret_file;
- auto ret = gtk_native_dialog_run(GTK_NATIVE_DIALOG(chooser));
+ auto ret = gtk_native_dialog_run(GTK_NATIVE_DIALOG(chooser.get()));
if (ret == GTK_RESPONSE_ACCEPT) {
- ret_file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
+ ret_file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser.get()));
}
- gtk_widget_destroy(GTK_WIDGET(chooser));
return ret_file;
}