[devhelp/wip/tintou/more-gobject: 2/2] Register DhLanguage as Boxed
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/wip/tintou/more-gobject: 2/2] Register DhLanguage as Boxed
- Date: Mon, 31 Oct 2016 19:55:48 +0000 (UTC)
commit 02670e4439e5bb9cc3f4e754cc5e0ca641ce8494
Author: Corentin Noël <corentin elementary io>
Date: Mon Oct 31 20:54:15 2016 +0100
Register DhLanguage as Boxed
Created a copy function.
Registered the new functions in the documentation.
docs/reference/devhelp-sections.txt | 3 +++
src/dh-language.c | 23 +++++++++++++++++++++++
src/dh-language.h | 2 ++
3 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/devhelp-sections.txt b/docs/reference/devhelp-sections.txt
index 48b8613..6ad16bd 100644
--- a/docs/reference/devhelp-sections.txt
+++ b/docs/reference/devhelp-sections.txt
@@ -174,6 +174,7 @@ dh_keyword_model_get_type
<TITLE>DhLanguage</TITLE>
DhLanguage
dh_language_new
+dh_language_copy
dh_language_free
dh_language_get_name
dh_language_compare
@@ -181,6 +182,8 @@ dh_language_compare_by_name
dh_language_get_n_books_enabled
dh_language_inc_n_books_enabled
dh_language_dec_n_books_enabled
+<SUBSECTION Private>
+dh_language_get_type
</SECTION>
<SECTION>
diff --git a/src/dh-language.c b/src/dh-language.c
index b2e0f8d..a8a956d 100644
--- a/src/dh-language.c
+++ b/src/dh-language.c
@@ -27,6 +27,11 @@ struct _DhLanguage {
gint n_books_enabled;
};
+G_DEFINE_BOXED_TYPE (DhLanguage,
+ dh_language,
+ dh_language_copy,
+ dh_language_free)
+
/**
* dh_language_free:
* @language: a #DhLanguage object
@@ -41,6 +46,24 @@ dh_language_free (DhLanguage *language)
}
/**
+ * dh_language_copy:
+ * @language: a #DhLanguage object
+ *
+ * Copy @language into a new #DhLanguage object.
+ *
+ * Returns: (transfer full): The copy of the #DhLanguage object
+ */
+DhLanguage *
+dh_language_copy (const DhLanguage *language)
+{
+ DhLanguage *new_language;
+ g_return_val_if_fail (language != NULL, -1);
+ new_language = dh_language_new (language->name);
+ new_language->n_books_enabled = language->n_books_enabled;
+ return new_language;
+}
+
+/**
* dh_language_new:
* @name: the name of the language
*
diff --git a/src/dh-language.h b/src/dh-language.h
index 2c65400..e9920f2 100644
--- a/src/dh-language.h
+++ b/src/dh-language.h
@@ -23,8 +23,10 @@
typedef struct _DhLanguage DhLanguage;
+GType dh_language_get_type (void) G_GNUC_CONST;
DhLanguage *dh_language_new (const gchar *name);
void dh_language_free (DhLanguage *language);
+DhLanguage *dh_language_copy (const DhLanguage *language);
const gchar *dh_language_get_name (DhLanguage *language);
gint dh_language_compare (const DhLanguage *language_a,
const DhLanguage *language_b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]