[devhelp] Profile: add a DhBookList
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Profile: add a DhBookList
- Date: Sat, 28 Apr 2018 10:49:30 +0000 (UTC)
commit dfd4f6570a664ac755abcfaba3fcf918dec3b92e
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Apr 28 12:22:12 2018 +0200
Profile: add a DhBookList
devhelp/dh-profile-builder.c | 30 +++++++++++++++++++++++++++++-
devhelp/dh-profile-builder.h | 4 ++++
devhelp/dh-profile.c | 28 ++++++++++++++++++++++++++--
devhelp/dh-profile.h | 6 +++++-
docs/reference/devhelp-sections.txt | 2 ++
5 files changed, 66 insertions(+), 4 deletions(-)
---
diff --git a/devhelp/dh-profile-builder.c b/devhelp/dh-profile-builder.c
index 12e7b88..16ec6f3 100644
--- a/devhelp/dh-profile-builder.c
+++ b/devhelp/dh-profile-builder.c
@@ -37,6 +37,7 @@
struct _DhProfileBuilderPrivate {
DhSettings *settings;
+ DhBookList *book_list;
};
G_DEFINE_TYPE_WITH_PRIVATE (DhProfileBuilder, dh_profile_builder, G_TYPE_OBJECT)
@@ -47,6 +48,7 @@ dh_profile_builder_dispose (GObject *object)
DhProfileBuilder *builder = DH_PROFILE_BUILDER (object);
g_clear_object (&builder->priv->settings);
+ g_clear_object (&builder->priv->book_list);
G_OBJECT_CLASS (dh_profile_builder_parent_class)->dispose (object);
}
@@ -100,6 +102,28 @@ dh_profile_builder_set_settings (DhProfileBuilder *builder,
}
/**
+ * dh_profile_builder_set_book_list:
+ * @builder: a #DhProfileBuilder.
+ * @book_list: a #DhBookList.
+ *
+ * Sets the #DhBookList object.
+ *
+ * If you don't call this function, the default #DhBookList object as returned
+ * by dh_book_list_get_default() will be used.
+ *
+ * Since: 3.30
+ */
+void
+dh_profile_builder_set_book_list (DhProfileBuilder *builder,
+ DhBookList *book_list)
+{
+ g_return_if_fail (DH_IS_PROFILE_BUILDER (builder));
+ g_return_if_fail (DH_IS_BOOK_LIST (book_list));
+
+ g_set_object (&builder->priv->book_list, book_list);
+}
+
+/**
* dh_profile_builder_create_object:
* @builder: a #DhProfileBuilder.
*
@@ -118,5 +142,9 @@ dh_profile_builder_create_object (DhProfileBuilder *builder)
if (builder->priv->settings == NULL)
dh_profile_builder_set_settings (builder, dh_settings_get_default ());
- return _dh_profile_new (builder->priv->settings);
+ if (builder->priv->book_list == NULL)
+ dh_profile_builder_set_book_list (builder, dh_book_list_get_default ());
+
+ return _dh_profile_new (builder->priv->settings,
+ builder->priv->book_list);
}
diff --git a/devhelp/dh-profile-builder.h b/devhelp/dh-profile-builder.h
index 6623275..25e409c 100644
--- a/devhelp/dh-profile-builder.h
+++ b/devhelp/dh-profile-builder.h
@@ -22,6 +22,7 @@
#define DH_PROFILE_BUILDER_H
#include <glib-object.h>
+#include <devhelp/dh-book-list.h>
#include <devhelp/dh-profile.h>
#include <devhelp/dh-settings.h>
@@ -58,6 +59,9 @@ DhProfileBuilder * dh_profile_builder_new (void);
void dh_profile_builder_set_settings (DhProfileBuilder *builder,
DhSettings *settings);
+void dh_profile_builder_set_book_list (DhProfileBuilder *builder,
+ DhBookList *book_list);
+
DhProfile * dh_profile_builder_create_object (DhProfileBuilder *builder);
G_END_DECLS
diff --git a/devhelp/dh-profile.c b/devhelp/dh-profile.c
index edae365..c8ee8bc 100644
--- a/devhelp/dh-profile.c
+++ b/devhelp/dh-profile.c
@@ -47,6 +47,7 @@
struct _DhProfilePrivate {
DhSettings *settings;
+ DhBookList *book_list;
};
static DhProfile *default_instance = NULL;
@@ -59,6 +60,7 @@ dh_profile_dispose (GObject *object)
DhProfile *profile = DH_PROFILE (object);
g_clear_object (&profile->priv->settings);
+ g_clear_object (&profile->priv->book_list);
G_OBJECT_CLASS (dh_profile_parent_class)->dispose (object);
}
@@ -88,14 +90,17 @@ dh_profile_init (DhProfile *profile)
}
DhProfile *
-_dh_profile_new (DhSettings *settings)
+_dh_profile_new (DhSettings *settings,
+ DhBookList *book_list)
{
DhProfile *profile;
g_return_val_if_fail (DH_IS_SETTINGS (settings), NULL);
+ g_return_val_if_fail (DH_IS_BOOK_LIST (book_list), NULL);
profile = g_object_new (DH_TYPE_PROFILE, NULL);
profile->priv->settings = g_object_ref (settings);
+ profile->priv->book_list = g_object_ref (book_list);
return profile;
}
@@ -104,7 +109,8 @@ _dh_profile_new (DhSettings *settings)
* dh_profile_get_default:
*
* Gets the default #DhProfile object. It has the default #DhSettings object as
- * returned by dh_settings_get_default().
+ * returned by dh_settings_get_default(), and the default #DhBookList object as
+ * returned by dh_book_list_get_default().
*
* Returns: (transfer none): the default #DhProfile object.
* Since: 3.30
@@ -152,3 +158,21 @@ dh_profile_get_settings (DhProfile *profile)
return profile->priv->settings;
}
+
+/**
+ * dh_profile_get_book_list:
+ * @profile: a #DhProfile.
+ *
+ * Gets the #DhBookList object of @profile. The returned object is guaranteed to
+ * be the same for the lifetime of @profile.
+ *
+ * Returns: (transfer none): the #DhBookList of @profile.
+ * Since: 3.30
+ */
+DhBookList *
+dh_profile_get_book_list (DhProfile *profile)
+{
+ g_return_val_if_fail (DH_IS_PROFILE (profile), NULL);
+
+ return profile->priv->book_list;
+}
diff --git a/devhelp/dh-profile.h b/devhelp/dh-profile.h
index 26bf308..5af1bfc 100644
--- a/devhelp/dh-profile.h
+++ b/devhelp/dh-profile.h
@@ -22,6 +22,7 @@
#define DH_PROFILE_H
#include <glib-object.h>
+#include <devhelp/dh-book-list.h>
#include <devhelp/dh-settings.h>
G_BEGIN_DECLS
@@ -53,7 +54,8 @@ struct _DhProfileClass {
GType dh_profile_get_type (void);
G_GNUC_INTERNAL
-DhProfile * _dh_profile_new (DhSettings *settings);
+DhProfile * _dh_profile_new (DhSettings *settings,
+ DhBookList *book_list);
DhProfile * dh_profile_get_default (void);
@@ -62,6 +64,8 @@ void _dh_profile_unref_default (void);
DhSettings * dh_profile_get_settings (DhProfile *profile);
+DhBookList * dh_profile_get_book_list (DhProfile *profile);
+
G_END_DECLS
#endif /* DH_PROFILE_H */
diff --git a/docs/reference/devhelp-sections.txt b/docs/reference/devhelp-sections.txt
index fd1b360..d744bb1 100644
--- a/docs/reference/devhelp-sections.txt
+++ b/docs/reference/devhelp-sections.txt
@@ -212,6 +212,7 @@ dh_link_type_get_type
DhProfile
dh_profile_get_default
dh_profile_get_settings
+dh_profile_get_book_list
<SUBSECTION Standard>
DH_IS_PROFILE
DH_IS_PROFILE_CLASS
@@ -229,6 +230,7 @@ dh_profile_get_type
DhProfileBuilder
dh_profile_builder_new
dh_profile_builder_set_settings
+dh_profile_builder_set_book_list
dh_profile_builder_create_object
<SUBSECTION Standard>
DH_IS_PROFILE_BUILDER
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]