[recipes] Try the file chooser portal again
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Try the file chooser portal again
- Date: Wed, 18 Jan 2017 10:42:46 +0000 (UTC)
commit 1281197512f5f9ac334c4731c278db6b229fe816
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 17 17:07:32 2017 -0500
Try the file chooser portal again
Some further debugging has shown that the problem is with
nonatomically writing to the save location, so work around
that.
src/gr-recipe-exporter.c | 55 +++++++++++++++++++++++++++------------------
1 files changed, 33 insertions(+), 22 deletions(-)
---
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index c443907..0a54c00 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -423,42 +423,53 @@ start_export (GrRecipeExporter *exporter)
}
static void
+file_chooser_response (GtkNativeDialog *dialog,
+ int response_id,
+ GrRecipeExporter *exporter)
+{
+ if (response_id == GTK_RESPONSE_ACCEPT) {
+ g_message ("exporting %d recipes now", g_list_length (exporter->recipes));
+
+ exporter->output = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+
+ start_export (exporter);
+ }
+ else {
+ g_message ("not exporting now");
+ }
+
+ gtk_native_dialog_destroy (dialog);
+}
+
+static void
export_dialog_response (GtkWidget *dialog,
int response_id,
GrRecipeExporter *exporter)
{
+ gtk_widget_destroy (dialog);
+ exporter->dialog_heading = NULL;
+
if (response_id == GTK_RESPONSE_CANCEL) {
g_message ("not exporting now");
}
else if (response_id == GTK_RESPONSE_OK) {
- g_autofree char *path = NULL;
- int i;
-
- g_message ("exporting %d recipes now", g_list_length (exporter->recipes));
+ GtkFileChooserNative *chooser;
- for (i = 0; i < 1000; i++) {
- g_autofree char *tmp;
- tmp = g_strdup_printf ("%s/.var/app/org.gnome.Recipes/recipes%d.tar.gz",
g_get_home_dir (), i);
- if (!g_file_test (tmp, G_FILE_TEST_EXISTS)) {
- path = g_strdup (tmp);
- break;
- }
- }
+ chooser = gtk_file_chooser_native_new (_("Select the location"),
+ GTK_WINDOW (exporter->window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ _("_Save"),
+ _("_Cancel"));
- if (!path) {
- g_autofree char *dir = NULL;
+ gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (chooser), TRUE);
- dir = g_dir_make_tmp ("recipesXXXXXX", NULL);
- path = g_build_filename (dir, "recipes.tar.gz", NULL);
- }
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (chooser), TRUE);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), "recipes.tar.gz");
- exporter->output = g_file_new_for_path (path);
+ g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), exporter);
- start_export (exporter);
+ gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
}
-
- gtk_widget_destroy (dialog);
- exporter->dialog_heading = NULL;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]