[recipes] Make it possible to export all recipes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Make it possible to export all recipes
- Date: Fri, 3 Mar 2017 22:52:15 +0000 (UTC)
commit c3b0223ccf7fe701edc0026a68ac94df42edaeda
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Mar 3 17:48:40 2017 -0500
Make it possible to export all recipes
Add an exporter API that exports all 'your' recipes
to a file.
src/gr-recipe-exporter.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
src/gr-recipe-exporter.h | 2 +
2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index 2061fb3..2f0082c 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -54,6 +54,7 @@ struct _GrRecipeExporter
GList *sources;
char *dir;
+ gboolean just_export;
gboolean contribute;
GtkWidget *dialog_heading;
@@ -77,12 +78,22 @@ gr_recipe_exporter_finalize (GObject *object)
G_OBJECT_CLASS (gr_recipe_exporter_parent_class)->finalize (object);
}
+static guint done_signal;
+
static void
gr_recipe_exporter_class_init (GrRecipeExporterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gr_recipe_exporter_finalize;
+
+ done_signal = g_signal_new ("done",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 1, G_TYPE_FILE);
}
static void
@@ -176,6 +187,12 @@ completed_cb (AutoarCompressor *compressor,
g_autofree char *body = NULL;
const char *attachments[2];
+ if (exporter->just_export) {
+ g_signal_emit (exporter, done_signal, 0, exporter->output);
+ cleanup_export (exporter);
+ return;
+ }
+
if (exporter->contribute) {
address = "recipes-list gnome org";
subject = _("Recipe contribution");
@@ -738,3 +755,38 @@ gr_recipe_exporter_contribute (GrRecipeExporter *exporter,
do_export (exporter);
}
+
+static void
+collect_all_recipes (GrRecipeExporter *exporter)
+{
+ GrRecipeStore *store;
+ g_autofree char **keys = NULL;
+ guint length;
+ int i;
+
+ store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
+ keys = gr_recipe_store_get_recipe_keys (store, &length);
+ for (i = 0; keys[i]; i++) {
+ g_autoptr(GrRecipe) recipe = gr_recipe_store_get_recipe (store, keys[i]);
+ if (!gr_recipe_is_readonly (recipe))
+ exporter->recipes = g_list_append (exporter->recipes, recipe);
+ }
+}
+
+void
+gr_recipe_exporter_export_all (GrRecipeExporter *exporter,
+ GFile *file)
+{
+ collect_all_recipes (exporter);
+
+ g_message ("Exporting %d recipes", g_list_length (exporter->recipes));
+
+ if (exporter->recipes == NULL)
+ return;
+
+ exporter->output = file;
+
+ exporter->just_export = TRUE;
+
+ start_export (exporter);
+}
diff --git a/src/gr-recipe-exporter.h b/src/gr-recipe-exporter.h
index e458891..cd9e9b9 100644
--- a/src/gr-recipe-exporter.h
+++ b/src/gr-recipe-exporter.h
@@ -36,5 +36,7 @@ void gr_recipe_exporter_export (GrRecipeExporter *exporter,
void gr_recipe_exporter_contribute (GrRecipeExporter *exporter,
GrRecipe *recipe);
+void gr_recipe_exporter_export_all (GrRecipeExporter *exporter,
+ GFile *file);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]