[recipes] Add a plain text shopping list formatter
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Add a plain text shopping list formatter
- Date: Sat, 11 Feb 2017 02:07:15 +0000 (UTC)
commit f209d45a374b8d9ec6765f61e64b7dcfd6b4aef5
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Feb 10 19:35:02 2017 -0500
Add a plain text shopping list formatter
src/Makefile.am | 2 +
src/gr-shopping-list-formatter.c | 58 ++++++++++++++++++++++++++++++++++++++
src/gr-shopping-list-formatter.h | 32 +++++++++++++++++++++
3 files changed, 92 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 5977867..f7c8cdf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -108,6 +108,8 @@ recipes_SOURCES = \
gr-search-page.c \
gr-season.h \
gr-season.c \
+ gr-shopping-list-formatter.h \
+ gr-shopping-list-formatter.c \
gr-shopping-list-printer.h \
gr-shopping-list-printer.c \
gr-shopping-page.h \
diff --git a/src/gr-shopping-list-formatter.c b/src/gr-shopping-list-formatter.c
new file mode 100644
index 0000000..d845c23
--- /dev/null
+++ b/src/gr-shopping-list-formatter.c
@@ -0,0 +1,58 @@
+/* gr-shopping-list-formatter.c:
+ *
+ * Copyright (C) 2017 Matthias Clasen <mclasen redhat com>
+ *
+ * Licensed under the GNU General Public License Version 3
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <glib/gi18n.h>
+
+#include "gr-shopping-list-formatter.h"
+#include "gr-ingredients-list.h"
+#include "gr-images.h"
+#include "gr-chef.h"
+#include "gr-recipe-store.h"
+#include "gr-app.h"
+#include "gr-utils.h"
+
+char *
+gr_shopping_list_format (GList *recipes,
+ GList *items)
+{
+ GString *s;
+ GList *l;
+
+ s = g_string_new ("");
+
+ g_string_append_printf (s, "*** %s ***\n", _("Shopping List"));
+ g_string_append (s, "\n");
+ g_string_append_printf (s, "%s\n", _("For the following recipes:"));
+ for (l = recipes; l; l = l->next) {
+ GrRecipe *recipe = l->data;
+ g_string_append_printf (s, "%s\n", gr_recipe_get_translated_name (recipe));
+ }
+
+ for (l = items; l; l = l->next) {
+ ShoppingListItem *item = l->data;
+ g_string_append (s, "\n");
+ g_string_append_printf (s, "%s %s", item->amount, item->name);
+ }
+
+ return g_string_free (s, FALSE);
+}
diff --git a/src/gr-shopping-list-formatter.h b/src/gr-shopping-list-formatter.h
new file mode 100644
index 0000000..29d7d38
--- /dev/null
+++ b/src/gr-shopping-list-formatter.h
@@ -0,0 +1,32 @@
+/* gr-shopping-list-formatter.h:
+ *
+ * Copyright (C) 2017 Matthias Clasen <mclasen redhat com>
+ *
+ * Licensed under the GNU General Public License Version 3
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+#include "gr-recipe.h"
+#include "gr-shopping-list-printer.h"
+
+G_BEGIN_DECLS
+
+char *gr_shopping_list_format (GList *recipes,
+ GList *items);
+
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]