[balsa/wip/gtk4: 249/351] mailbox mbox: Declare it final



commit bf7c8cd507f49e307b3dd751bb7fdce3423c45ee
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Mar 26 10:28:45 2018 -0400

    mailbox mbox: Declare it final
    
    Use G_DECLARE_FINAL_TYPE for LibBalsaMailboxMbox. It was already
    private.

 libbalsa/mailbox_mbox.c |   42 ++++++++----------------------------------
 libbalsa/mailbox_mbox.h |   22 +++++++---------------
 2 files changed, 15 insertions(+), 49 deletions(-)
---
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index f81e26c..9d9efc9 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -61,8 +61,6 @@ struct message_info {
 #define FLAGS_REALLY_DIFFER(orig_flags, flags) \
     ((((orig_flags) ^ (flags)) & LIBBALSA_MESSAGE_FLAGS_REAL) != 0)
 
-static LibBalsaMailboxLocalClass *parent_class = NULL;
-
 static void libbalsa_mailbox_mbox_class_init(LibBalsaMailboxMboxClass *klass);
 static void libbalsa_mailbox_mbox_init(LibBalsaMailboxMbox * mailbox);
 static void libbalsa_mailbox_mbox_dispose(GObject * object);
@@ -109,31 +107,9 @@ struct _LibBalsaMailboxMbox {
     gboolean messages_info_changed;
 };
 
-GType libbalsa_mailbox_mbox_get_type(void)
-{
-    static GType mailbox_type = 0;
-
-    if (!mailbox_type) {
-       static const GTypeInfo mailbox_info = {
-           sizeof(LibBalsaMailboxMboxClass),
-            NULL,               /* base_init */
-            NULL,               /* base_finalize */
-           (GClassInitFunc) libbalsa_mailbox_mbox_class_init,
-            NULL,               /* class_finalize */
-            NULL,               /* class_data */
-           sizeof(LibBalsaMailboxMbox),
-            0,                  /* n_preallocs */
-           (GInstanceInitFunc) libbalsa_mailbox_mbox_init
-       };
-
-       mailbox_type =
-           g_type_register_static(LIBBALSA_TYPE_MAILBOX_LOCAL,
-                                  "LibBalsaMailboxMbox",
-                                   &mailbox_info, 0);
-    }
-
-    return mailbox_type;
-}
+G_DEFINE_TYPE(LibBalsaMailboxMbox,
+              libbalsa_mailbox_mbox,
+              LIBBALSA_TYPE_MAILBOX_LOCAL)
 
 static void
 libbalsa_mailbox_mbox_class_init(LibBalsaMailboxMboxClass * klass)
@@ -146,8 +122,6 @@ libbalsa_mailbox_mbox_class_init(LibBalsaMailboxMboxClass * klass)
     libbalsa_mailbox_class = LIBBALSA_MAILBOX_CLASS(klass);
     libbalsa_mailbox_local_class = LIBBALSA_MAILBOX_LOCAL_CLASS(klass);
 
-    parent_class = g_type_class_peek_parent(klass);
-
     libbalsa_mailbox_class->get_message_stream =
        libbalsa_mailbox_mbox_get_message_stream;
 
@@ -185,7 +159,7 @@ libbalsa_mailbox_mbox_dispose(GObject * object)
     if(MAILBOX_OPEN(LIBBALSA_MAILBOX(object)))
        libbalsa_mailbox_mbox_close_mailbox(LIBBALSA_MAILBOX(object), FALSE);
 
-    G_OBJECT_CLASS(parent_class)->dispose(object);
+    G_OBJECT_CLASS(libbalsa_mailbox_mbox_parent_class)->dispose(object);
 }
 
 static gint
@@ -316,7 +290,7 @@ libbalsa_mailbox_mbox_remove_files(LibBalsaMailboxLocal *mailbox)
                             _("Could not remove %s:\n%s"), 
                             libbalsa_mailbox_local_get_path(mailbox), 
                             strerror(errno));
-    LIBBALSA_MAILBOX_LOCAL_CLASS(parent_class)->remove_files(mailbox);
+    LIBBALSA_MAILBOX_LOCAL_CLASS(libbalsa_mailbox_mbox_parent_class)->remove_files(mailbox);
 }
 
 static int mbox_lock(LibBalsaMailbox * mailbox, GMimeStream *stream)
@@ -1138,8 +1112,8 @@ libbalsa_mailbox_mbox_close_mailbox(LibBalsaMailbox * mailbox,
     if (mbox->msgno_2_msg_info->len != len)
         libbalsa_mailbox_changed(mailbox);
 
-    if (LIBBALSA_MAILBOX_CLASS(parent_class)->close_mailbox)
-        LIBBALSA_MAILBOX_CLASS(parent_class)->close_mailbox(mailbox,
+    if (LIBBALSA_MAILBOX_CLASS(libbalsa_mailbox_mbox_parent_class)->close_mailbox)
+        LIBBALSA_MAILBOX_CLASS(libbalsa_mailbox_mbox_parent_class)->close_mailbox(mailbox,
                                                             expunge);
 
     /* Now it's safe to close the stream and free the message info. */
@@ -1781,7 +1755,7 @@ libbalsa_mailbox_mbox_fetch_message_structure(LibBalsaMailbox * mailbox,
     if (!message->mime_msg)
        message->mime_msg = lbm_mbox_get_mime_message(mailbox, message->msgno);
 
-    return LIBBALSA_MAILBOX_CLASS(parent_class)->
+    return LIBBALSA_MAILBOX_CLASS(libbalsa_mailbox_mbox_parent_class)->
         fetch_message_structure(mailbox, message, flags);
 }
 
diff --git a/libbalsa/mailbox_mbox.h b/libbalsa/mailbox_mbox.h
index 1aaaaa0..a7bf098 100644
--- a/libbalsa/mailbox_mbox.h
+++ b/libbalsa/mailbox_mbox.h
@@ -21,23 +21,15 @@
 #ifndef __LIBBALSA_MAILBOX_MBOX_H__
 #define __LIBBALSA_MAILBOX_MBOX_H__
 
-#define LIBBALSA_TYPE_MAILBOX_MBOX \
-    (libbalsa_mailbox_mbox_get_type())
-#define LIBBALSA_MAILBOX_MBOX(obj) \
-    (G_TYPE_CHECK_INSTANCE_CAST ((obj), LIBBALSA_TYPE_MAILBOX_MBOX, \
-                                 LibBalsaMailboxMbox))
-#define LIBBALSA_MAILBOX_MBOX_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_CAST ((klass), LIBBALSA_TYPE_MAILBOX_MBOX, \
-                              LibBalsaMailboxMboxClass))
-#define LIBBALSA_IS_MAILBOX_MBOX(obj) \
-    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LIBBALSA_TYPE_MAILBOX_MBOX))
-#define LIBBALSA_IS_MAILBOX_MBOX_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_TYPE ((klass), LIBBALSA_TYPE_MAILBOX_MBOX))
+#define LIBBALSA_TYPE_MAILBOX_MBOX libbalsa_mailbox_mbox_get_type()
 
-typedef struct _LibBalsaMailboxMbox LibBalsaMailboxMbox;
-typedef struct _LibBalsaMailboxMboxClass LibBalsaMailboxMboxClass;
+G_DECLARE_FINAL_TYPE(LibBalsaMailboxMbox,
+                     libbalsa_mailbox_mbox,
+                     LIBBALSA,
+                     MAILBOX_MBOX,
+                     LibBalsaMailboxLocal)
 
-GType libbalsa_mailbox_mbox_get_type(void);
 LibBalsaMailbox *libbalsa_mailbox_mbox_new(const gchar * path,
                                            gboolean      create);
+
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]