[gnome-control-center/wip/jsparber/background: 6/58] [feat] add new class for GListStore
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/jsparber/background: 6/58] [feat] add new class for GListStore
- Date: Fri, 24 Nov 2017 21:46:21 +0000 (UTC)
commit 4e0d8a2643e798de9f9a3384ab085edb9e02d0f0
Author: Julian Sparber <julian sparber net>
Date: Mon Oct 23 02:02:18 2017 +0200
[feat] add new class for GListStore
panels/background/Makefile.am | 2 +
panels/background/cc-background-store.c | 94 +++++++++++++++++++++++++++++++
panels/background/cc-background-store.h | 44 ++++++++++++++
3 files changed, 140 insertions(+), 0 deletions(-)
---
diff --git a/panels/background/Makefile.am b/panels/background/Makefile.am
index ccb8017..688b2c1 100644
--- a/panels/background/Makefile.am
+++ b/panels/background/Makefile.am
@@ -31,6 +31,8 @@ libbackground_chooser_la_SOURCES = \
cc-background-grilo-miner.h \
cc-background-item.c \
cc-background-item.h \
+ cc-background-store.c \
+ cc-background-store.h \
cc-background-xml.c \
cc-background-xml.h \
bg-source.c \
diff --git a/panels/background/cc-background-store.c b/panels/background/cc-background-store.c
new file mode 100644
index 0000000..33c1900
--- /dev/null
+++ b/panels/background/cc-background-store.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2017 jsparber
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Julian Sparber <julian sparber net>
+ *
+ */
+
+#include <gio/gio.h>
+#include "cc-background-store.h"
+#include "cc-background-item.h"
+
+struct _CcBackgroundStore
+{
+ GObject parent_instance;
+
+ /* Other members, including private data. */
+};
+
+/* Private structure definition. */
+typedef struct _CcBackgroundStorePrivate CcBackgroundStorePrivate;
+
+struct _CcBackgroundStorePrivate
+{
+ GListStore * model;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (CcBackgroundStore, cc_background_store, G_TYPE_OBJECT)
+
+
+static void
+cc_background_store_dispose (GObject *gobject)
+{
+ CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (CC_BACKGROUND_STORE (gobject));
+
+ /* In dispose(), you are supposed to free all types referenced from this
+ * object which might themselves hold a reference to self. Generally,
+ * the most simple solution is to unref all members on which you own a
+ * reference.
+ */
+
+ /* dispose() might be called multiple times, so we must guard against
+ * calling g_object_unref() on an invalid GObject by setting the member
+ * NULL; g_clear_object() does this for us.
+ */
+ g_clear_object (&priv->model);
+
+ /* Always chain up to the parent class; there is no need to check if
+ * the parent class implements the dispose() virtual function: it is
+ * always guaranteed to do so
+ */
+ G_OBJECT_CLASS (cc_background_store_parent_class)->dispose (gobject);
+}
+
+static void
+cc_background_store_finalize (GObject *gobject)
+{
+ //CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (CC_BACKGROUND_STORE
(gobject));
+
+ //g_free (priv->filename);
+
+ /* Always chain up to the parent class; as with dispose(), finalize()
+ * is guaranteed to exist on the parent's class virtual function table
+ */
+ G_OBJECT_CLASS (cc_background_store_parent_class)->finalize (gobject);
+}
+
+static void
+cc_background_store_class_init (CcBackgroundStoreClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = cc_background_store_dispose;
+ object_class->finalize = cc_background_store_finalize;
+}
+
+static void
+cc_background_store_init (CcBackgroundStore *self)
+{
+ CcBackgroundStorePrivate *priv = cc_background_store_get_instance_private (self);
+ priv->model = g_list_store_new (cc_background_item_get_type());
+}
diff --git a/panels/background/cc-background-store.h b/panels/background/cc-background-store.h
new file mode 100644
index 0000000..40da76d
--- /dev/null
+++ b/panels/background/cc-background-store.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 jsparber
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Julian Sparber <julian sparber net>
+ *
+ */
+
+#ifndef __CC_BACKGROUND_STORE_H__
+#define __CC_BACKGROUND_STORE_H__
+
+#include <glib-object.h>
+/*
+ * Potentially, include other headers on which this header depends.
+ */
+
+G_BEGIN_DECLS
+
+/*
+ * Type declaration.
+ */
+#define CC_TYPE_BACKGROUND_STORE (cc_background_store_get_type ())
+G_DECLARE_FINAL_TYPE (CcBackgroundStore, cc_background_store, CC, BACKGROUND_STORE, GObject)
+
+/*
+ * Method definitions.
+ */
+CcBackgroundStore *cc_backgroud_store_new (void);
+
+G_END_DECLS
+
+#endif /* __CC_BACKGROUND_STORE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]