[gnome-software] Allow private userdata to be saved on a GsApp
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Allow private userdata to be saved on a GsApp
- Date: Fri, 6 Sep 2013 15:10:34 +0000 (UTC)
commit 006038f164ffcd513f66734b4df5c87bf54d7111
Author: Richard Hughes <richard hughsie com>
Date: Fri Sep 6 16:09:30 2013 +0100
Allow private userdata to be saved on a GsApp
We don't want to duplicate every string if it's possibly the same on 2000 applications.
src/plugins/appstream-app.c | 25 +++++++++++++++++++++++++
src/plugins/appstream-app.h | 5 +++++
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/appstream-app.c b/src/plugins/appstream-app.c
index 932f8ab..bef5db9 100644
--- a/src/plugins/appstream-app.c
+++ b/src/plugins/appstream-app.c
@@ -34,6 +34,8 @@ struct AppstreamApp
gchar *icon;
AppstreamAppIconKind icon_kind;
GPtrArray *appcategories;
+ gpointer userdata;
+ GDestroyNotify userdata_destroy_func;
};
/**
@@ -50,10 +52,33 @@ appstream_app_free (AppstreamApp *app)
g_free (app->description);
g_free (app->icon);
g_ptr_array_unref (app->appcategories);
+ if (app->userdata_destroy_func != NULL)
+ app->userdata_destroy_func (app->userdata);
g_slice_free (AppstreamApp, app);
}
/**
+ * appstream_app_get_userdata:
+ */
+gpointer
+appstream_app_get_userdata (AppstreamApp *app)
+{
+ return app->userdata;
+}
+
+/**
+ * appstream_app_set_userdata:
+ */
+void
+appstream_app_set_userdata (AppstreamApp *app,
+ gpointer userdata,
+ GDestroyNotify userdata_destroy_func)
+{
+ app->userdata = userdata;
+ app->userdata_destroy_func = userdata_destroy_func;
+}
+
+/**
* appstream_app_new:
*/
AppstreamApp *
diff --git a/src/plugins/appstream-app.h b/src/plugins/appstream-app.h
index fcd4d29..f37a6a4 100644
--- a/src/plugins/appstream-app.h
+++ b/src/plugins/appstream-app.h
@@ -76,6 +76,11 @@ void appstream_app_add_category (AppstreamApp *app,
void appstream_app_set_icon_kind (AppstreamApp *app,
AppstreamAppIconKind icon_kind);
+gpointer appstream_app_get_userdata (AppstreamApp *app);
+void appstream_app_set_userdata (AppstreamApp *app,
+ gpointer userdata,
+ GDestroyNotify userdata_destroy_func);
+
G_END_DECLS
#endif /* __APPSTREAM_APP_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]