[balsa] Declare LibBalsaAddressBookLdif final
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Declare LibBalsaAddressBookLdif final
- Date: Thu, 16 May 2019 00:01:23 +0000 (UTC)
commit e24c00be982c06335d588d5f2890361b2f1c7669
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Wed May 15 19:35:10 2019 -0400
Declare LibBalsaAddressBookLdif final
Use G_DECLARE_FINAL_TYPE to declare LibBalsaAddressBookLdif.
Make the structure private; no need for getters and setters.
* libbalsa/address-book-ldif.c (libbalsa_address_book_ldif_init),
(libbalsa_address_book_ldif_new):
* libbalsa/address-book-ldif.h:
ChangeLog | 10 +++++++++
libbalsa/address-book-ldif.c | 52 +++++++++++++++-----------------------------
libbalsa/address-book-ldif.h | 22 +++----------------
3 files changed, 30 insertions(+), 54 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 164dce433..858b333b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-05-15 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Use G_DECLARE_FINAL_TYPE to declare LibBalsaAddressBookLdif
+
+ Make the structure private; no need for getters and setters.
+
+ * libbalsa/address-book-ldif.c (libbalsa_address_book_ldif_init),
+ (libbalsa_address_book_ldif_new):
+ * libbalsa/address-book-ldif.h:
+
2019-05-15 Peter Bloomfield <pbloomfield bellsouth net>
Use G_DECLARE_FINAL_TYPE to declare LibBalsaAddressBookLdap
diff --git a/libbalsa/address-book-ldif.c b/libbalsa/address-book-ldif.c
index e5e147b0f..78ead0c14 100644
--- a/libbalsa/address-book-ldif.c
+++ b/libbalsa/address-book-ldif.c
@@ -32,10 +32,6 @@
#include <glib/gi18n.h>
-static void
-libbalsa_address_book_ldif_class_init(LibBalsaAddressBookLdifClass *
- klass);
-
static LibBalsaABErr
libbalsa_address_book_ldif_parse_address(FILE * stream_in,
LibBalsaAddress * address_in,
@@ -45,31 +41,20 @@ static LibBalsaABErr
libbalsa_address_book_ldif_save_address(FILE * stream,
LibBalsaAddress * address);
+struct _LibBalsaAddressBookLdif {
+ LibBalsaAddressBookText parent;
+};
-GType libbalsa_address_book_ldif_get_type(void)
-{
- static GType address_book_ldif_type = 0;
-
- if (!address_book_ldif_type) {
- static const GTypeInfo address_book_ldif_info = {
- sizeof(LibBalsaAddressBookLdifClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) libbalsa_address_book_ldif_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(LibBalsaAddressBookLdif),
- 0, /* n_preallocs */
- NULL
- };
-
- address_book_ldif_type =
- g_type_register_static(LIBBALSA_TYPE_ADDRESS_BOOK_TEXT,
- "LibBalsaAddressBookLdif",
- &address_book_ldif_info, 0);
- }
+struct _LibBalsaAddressBookLdifClass {
+ LibBalsaAddressBookTextClass parent_class;
+};
- return address_book_ldif_type;
+G_DEFINE_TYPE(LibBalsaAddressBookLdif, libbalsa_address_book_ldif,
+ LIBBALSA_TYPE_ADDRESS_BOOK_TEXT)
+
+static void
+libbalsa_address_book_ldif_init(LibBalsaAddressBookLdif * ab_ldif)
+{
}
static void
@@ -89,18 +74,15 @@ LibBalsaAddressBook *
libbalsa_address_book_ldif_new(const gchar * name, const gchar * path)
{
LibBalsaAddressBookLdif *ab_ldif;
- LibBalsaAddressBook *ab;
ab_ldif =
- LIBBALSA_ADDRESS_BOOK_LDIF(g_object_new
- (LIBBALSA_TYPE_ADDRESS_BOOK_LDIF,
- NULL));
- ab = LIBBALSA_ADDRESS_BOOK(ab_ldif);
+ (LibBalsaAddressBookLdif *)
+ g_object_new(LIBBALSA_TYPE_ADDRESS_BOOK_LDIF, NULL);
- libbalsa_address_book_set_name(ab, name);
- libbalsa_address_book_text_set_path(LIBBALSA_ADDRESS_BOOK_TEXT(ab), path);
+ libbalsa_address_book_set_name((LibBalsaAddressBook *) ab_ldif, name);
+ libbalsa_address_book_text_set_path((LibBalsaAddressBookText *) ab_ldif, path);
- return ab;
+ return (LibBalsaAddressBook *) ab_ldif;
}
/* Helpers */
diff --git a/libbalsa/address-book-ldif.h b/libbalsa/address-book-ldif.h
index db1a85cdf..15209d58e 100644
--- a/libbalsa/address-book-ldif.h
+++ b/libbalsa/address-book-ldif.h
@@ -27,25 +27,9 @@
#include "address-book-text.h"
-#define LIBBALSA_TYPE_ADDRESS_BOOK_LDIF (libbalsa_address_book_ldif_get_type())
-#define LIBBALSA_ADDRESS_BOOK_LDIF(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj,
LIBBALSA_TYPE_ADDRESS_BOOK_LDIF, LibBalsaAddressBookLdif))
-#define LIBBALSA_ADDRESS_BOOK_LDIF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass,
LIBBALSA_TYPE_ADDRESS_BOOK_LDIF, LibBalsaAddressBookLdifClass))
-#define LIBBALSA_IS_ADDRESS_BOOK_LDIF(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj,
LIBBALSA_TYPE_ADDRESS_BOOK_LDIF))
-#define LIBBALSA_IS_ADDRESS_BOOK_LDIF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass,
LIBBALSA_TYPE_ADDRESS_BOOK_LDIF))
-
-typedef struct _LibBalsaAddressBookLdif LibBalsaAddressBookLdif;
-typedef struct _LibBalsaAddressBookLdifClass
- LibBalsaAddressBookLdifClass;
-
-struct _LibBalsaAddressBookLdif {
- LibBalsaAddressBookText parent;
-};
-
-struct _LibBalsaAddressBookLdifClass {
- LibBalsaAddressBookTextClass parent_class;
-};
-
-GType libbalsa_address_book_ldif_get_type(void);
+#define LIBBALSA_TYPE_ADDRESS_BOOK_LDIF (libbalsa_address_book_ldif_get_type())
+G_DECLARE_FINAL_TYPE(LibBalsaAddressBookLdif, libbalsa_address_book_ldif,
+ LIBBALSA, ADDRESS_BOOK_LDIF, LibBalsaAddressBookText)
LibBalsaAddressBook *libbalsa_address_book_ldif_new(const gchar * name,
const gchar * path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]