[recipes] exporter: Add a method to contribute a recipe directly
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] exporter: Add a method to contribute a recipe directly
- Date: Sun, 19 Feb 2017 16:52:39 +0000 (UTC)
commit b1d93d6d6bb43b0999fb504973e894c126bc6b76
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 19 11:47:33 2017 -0500
exporter: Add a method to contribute a recipe directly
This method avoids the dialog with the list of recipes and directly
opens the mail window.
src/gr-recipe-exporter.c | 63 ++++++++++++++++++++++++++++++----------------
src/gr-recipe-exporter.h | 3 ++
2 files changed, 44 insertions(+), 22 deletions(-)
---
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index f4258cb..a8e19f4 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -451,6 +451,33 @@ start_export (GrRecipeExporter *exporter)
}
static void
+do_export (GrRecipeExporter *exporter)
+{
+ int i;
+ g_autofree char *path = NULL;
+
+ for (i = 0; i < 1000; i++) {
+ g_autofree char *tmp;
+ tmp = g_strdup_printf ("%s/.var/app/org.gnome.Recipes/recipes%d.gnome-recipes-export",
g_get_home_dir (), i);
+ if (!g_file_test (tmp, G_FILE_TEST_EXISTS)) {
+ path = g_strdup (tmp);
+ break;
+ }
+ }
+
+ if (!path) {
+ g_autofree char *dir = NULL;
+
+ dir = g_dir_make_tmp ("recipesXXXXXX", NULL);
+ path = g_build_filename (dir, "recipes.gnome-recipes-export", NULL);
+ }
+
+ exporter->output = g_file_new_for_path (path);
+
+ start_export (exporter);
+}
+
+static void
export_dialog_response (GtkWidget *dialog,
int response_id,
GrRecipeExporter *exporter)
@@ -459,32 +486,11 @@ export_dialog_response (GtkWidget *dialog,
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));
exporter->contribute = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(exporter->contribute_button));
- for (i = 0; i < 1000; i++) {
- g_autofree char *tmp;
- tmp = g_strdup_printf
("%s/.var/app/org.gnome.Recipes/recipes%d.gnome-recipes-export", g_get_home_dir (), i);
- if (!g_file_test (tmp, G_FILE_TEST_EXISTS)) {
- path = g_strdup (tmp);
- break;
- }
- }
-
- if (!path) {
- g_autofree char *dir = NULL;
-
- dir = g_dir_make_tmp ("recipesXXXXXX", NULL);
- path = g_build_filename (dir, "recipes.gnome-recipes-export", NULL);
- }
-
- exporter->output = g_file_new_for_path (path);
-
- start_export (exporter);
+ do_export (exporter);
}
gtk_widget_destroy (dialog);
@@ -675,3 +681,16 @@ gr_recipe_exporter_export (GrRecipeExporter *exporter,
dialog:
show_export_dialog (exporter);
}
+
+void
+gr_recipe_exporter_contribute (GrRecipeExporter *exporter,
+ GrRecipe *recipe)
+{
+ g_list_free_full (exporter->recipes, g_object_unref);
+
+ exporter->recipes = g_list_append (NULL, g_object_ref (recipe));
+
+ exporter->contribute = TRUE;
+
+ do_export (exporter);
+}
diff --git a/src/gr-recipe-exporter.h b/src/gr-recipe-exporter.h
index e6bb1d5..e458891 100644
--- a/src/gr-recipe-exporter.h
+++ b/src/gr-recipe-exporter.h
@@ -34,4 +34,7 @@ GrRecipeExporter *gr_recipe_exporter_new (GtkWindow *window);
void gr_recipe_exporter_export (GrRecipeExporter *exporter,
GrRecipe *recipe);
+void gr_recipe_exporter_contribute (GrRecipeExporter *exporter,
+ GrRecipe *recipe);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]