[recipes] Don't pile up import file choosers
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Don't pile up import file choosers
- Date: Thu, 9 Feb 2017 23:55:28 +0000 (UTC)
commit fccc81591b86af356eacaa58048a7c65d6ade192
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Feb 9 18:07:18 2017 -0500
Don't pile up import file choosers
Only allow a single file chooser for importing to be open
at a time.
src/gr-window.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index 7e7e0c1..ef212be 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -70,6 +70,7 @@ struct _GrWindow
GtkWidget *shopping_added_revealer;
guint shopping_timeout_id;
+ GObject *file_chooser;
GrRecipeImporter *importer;
GQueue *back_entry_stack;
@@ -656,29 +657,33 @@ file_chooser_response (GtkNativeDialog *self,
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (self));
do_import (window, file);
}
+
+ gtk_native_dialog_destroy (self);
+ window->file_chooser = NULL;
}
void
gr_window_load_recipe (GrWindow *window,
GFile *file)
{
- GtkFileChooserNative *chooser;
-
if (file) {
do_import (window, file);
return;
}
- chooser = gtk_file_chooser_native_new (_("Select a recipe file"),
- GTK_WINDOW (window),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- _("Open"),
- _("Cancel"));
- gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (chooser), TRUE);
+ if (window->file_chooser)
+ return;
+
+ window->file_chooser = (GObject *)gtk_file_chooser_native_new (_("Select a recipe file"),
+ GTK_WINDOW (window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ _("Open"),
+ _("Cancel"));
+ gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (window->file_chooser), TRUE);
- g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), window);
+ g_signal_connect (window->file_chooser, "response", G_CALLBACK (file_chooser_response), window);
- gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
+ gtk_native_dialog_show (GTK_NATIVE_DIALOG (window->file_chooser));
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]