[gnome-software] trivial: Add an object for holding an AppStream screenshot
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Add an object for holding an AppStream screenshot
- Date: Fri, 4 Oct 2013 10:48:04 +0000 (UTC)
commit 58e01b3bc81752eebf95ad945df9634dccc7449c
Author: Richard Hughes <richard hughsie com>
Date: Fri Oct 4 10:01:53 2013 +0100
trivial: Add an object for holding an AppStream screenshot
src/plugins/Makefile.am | 2 +
src/plugins/appstream-screenshot.c | 106 ++++++++++++++++++++++++++++++++++++
src/plugins/appstream-screenshot.h | 55 +++++++++++++++++++
3 files changed, 163 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 6f22273..3940b01 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -64,6 +64,8 @@ libgs_plugin_appstream_la_SOURCES = \
appstream-app.h \
appstream-image.c \
appstream-image.h \
+ appstream-screenshot.c \
+ appstream-screenshot.h \
appstream-common.c \
appstream-common.h \
appstream-cache.c \
diff --git a/src/plugins/appstream-screenshot.c b/src/plugins/appstream-screenshot.c
new file mode 100644
index 0000000..f28eef0
--- /dev/null
+++ b/src/plugins/appstream-screenshot.c
@@ -0,0 +1,106 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include "appstream-screenshot.h"
+
+struct AppstreamScreenshot
+{
+ AppstreamScreenshotKind kind;
+ GPtrArray *array;
+};
+
+/**
+ * appstream_screenshot_new:
+ */
+AppstreamScreenshot *
+appstream_screenshot_new (void)
+{
+ AppstreamScreenshot *screenshot;
+ screenshot = g_slice_new0 (AppstreamScreenshot);
+ screenshot->kind = APPSTREAM_SCREENSHOT_KIND_NORMAL;
+ screenshot->array = g_ptr_array_new_with_free_func ((GDestroyNotify) appstream_image_free);
+ return screenshot;
+}
+
+/**
+ * appstream_screenshot_free:
+ */
+void
+appstream_screenshot_free (AppstreamScreenshot *screenshot)
+{
+ g_ptr_array_unref (screenshot->array);
+ g_slice_free (AppstreamScreenshot, screenshot);
+}
+
+/**
+ * appstream_screenshot_get_kind:
+ */
+AppstreamScreenshotKind
+appstream_screenshot_get_kind (AppstreamScreenshot *screenshot)
+{
+ return screenshot->kind;
+}
+
+/**
+ * appstream_screenshot_get_images:
+ */
+GPtrArray *
+appstream_screenshot_get_images (AppstreamScreenshot *screenshot)
+{
+ return screenshot->array;
+}
+
+/**
+ * appstream_screenshot_set_kind:
+ */
+void
+appstream_screenshot_set_kind (AppstreamScreenshot *screenshot,
+ AppstreamScreenshotKind kind)
+{
+ screenshot->kind = kind;
+}
+
+/**
+ * appstream_screenshot_add_image:
+ */
+void
+appstream_screenshot_add_image (AppstreamScreenshot *screenshot,
+ AppstreamImage *image)
+{
+ g_ptr_array_add (screenshot->array, image);
+}
+
+/**
+ * appstream_screenshot_kind_from_string:
+ */
+AppstreamScreenshotKind
+appstream_screenshot_kind_from_string (const gchar *kind)
+{
+ if (g_strcmp0 (kind, "normal") == 0)
+ return APPSTREAM_SCREENSHOT_KIND_NORMAL;
+ if (g_strcmp0 (kind, "default") == 0)
+ return APPSTREAM_SCREENSHOT_KIND_DEFAULT;
+ return APPSTREAM_SCREENSHOT_KIND_UNKNOWN;
+}
+
+/* vim: set noexpandtab: */
diff --git a/src/plugins/appstream-screenshot.h b/src/plugins/appstream-screenshot.h
new file mode 100644
index 0000000..5996e47
--- /dev/null
+++ b/src/plugins/appstream-screenshot.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __APPSTREAM_SCREENSHOT_H
+#define __APPSTREAM_SCREENSHOT_H
+
+#include <glib.h>
+
+#include "appstream-image.h"
+
+G_BEGIN_DECLS
+
+typedef struct AppstreamScreenshot AppstreamScreenshot;
+
+typedef enum {
+ APPSTREAM_SCREENSHOT_KIND_NORMAL,
+ APPSTREAM_SCREENSHOT_KIND_DEFAULT,
+ APPSTREAM_SCREENSHOT_KIND_UNKNOWN,
+ APPSTREAM_SCREENSHOT_KIND_LAST
+} AppstreamScreenshotKind;
+
+AppstreamScreenshot* appstream_screenshot_new (void);
+void appstream_screenshot_free (AppstreamScreenshot *screenshot);
+
+AppstreamScreenshotKind appstream_screenshot_get_kind (AppstreamScreenshot *screenshot);
+GPtrArray *appstream_screenshot_get_images (AppstreamScreenshot *screenshot);
+
+void appstream_screenshot_set_kind (AppstreamScreenshot *screenshot,
+ AppstreamScreenshotKind kind);
+void appstream_screenshot_add_image (AppstreamScreenshot *screenshot,
+ AppstreamImage *image);
+
+AppstreamScreenshotKind appstream_screenshot_kind_from_string (const gchar *kind);
+
+G_END_DECLS
+
+#endif /* __APPSTREAM_SCREENSHOT_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]