[balsa] balsa-mblist: Use modern macros



commit 648faa08a7326b6eaee6a995a4d9c62490f1aa0a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jul 22 16:23:23 2019 -0400

    balsa-mblist: Use modern macros
    
    Use modern macros to declare and define.
    Make BalsaMBList opaque; no accessors needed.
    
    * src/balsa-mblist.c (balsa_mblist_class_init), (bmbl_drag_motion),
      (balsa_mblist_init):
    * src/balsa-mblist.h:

 ChangeLog          | 10 ++++++++++
 src/balsa-mblist.c | 54 ++++++++++++++++--------------------------------------
 src/balsa-mblist.h | 30 ++----------------------------
 3 files changed, 28 insertions(+), 66 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c3207990f..0594c0d05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-07-22  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       balsa-mblist: Use modern macros to declare and define.
+
+       Make BalsaMBList opaque; no accessors needed.
+
+       * src/balsa-mblist.c (balsa_mblist_class_init), (bmbl_drag_motion),
+       (balsa_mblist_init):
+       * src/balsa-mblist.h:
+
 2019-07-22  Peter Bloomfield  <pbloomfield bellsouth net>
 
        balsa-index: Another convenience function
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index 3c645d2ac..4ac3c25fe 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -79,10 +79,7 @@ static GtkTargetEntry bmbl_drop_types[] = {
     {"x-application/x-message-list", GTK_TARGET_SAME_APP, TARGET_MESSAGES}
 };
 
-static GtkTreeViewClass *parent_class = NULL;
-
 /* class methods */
-static void bmbl_class_init(BalsaMBListClass * klass);
 static void bmbl_set_property(GObject * object, guint prop_id,
                               const GValue * value, GParamSpec * pspec);
 static void bmbl_get_property(GObject * object, guint prop_id,
@@ -93,7 +90,6 @@ static gboolean bmbl_drag_motion(GtkWidget * mblist,
 static gboolean bmbl_popup_menu(GtkWidget * widget);
 static void bmbl_select_mailbox(GtkTreeSelection * selection,
                                 gpointer data);
-static void bmbl_init(BalsaMBList * mblist);
 static gboolean bmbl_selection_func(GtkTreeSelection * selection,
                                     GtkTreeModel * model,
                                     GtkTreePath * path,
@@ -141,42 +137,27 @@ static void bmbl_expand_to_row(BalsaMBList * mblist, GtkTreePath * path);
 
 /* class methods */
 
-GType
-balsa_mblist_get_type(void)
-{
-    static GType mblist_type = 0;
-
-    if (!mblist_type) {
-       static const GTypeInfo mblist_info = {
-           sizeof(BalsaMBListClass),
-            NULL,               /* base_init */
-            NULL,               /* base_finalize */
-           (GClassInitFunc) bmbl_class_init,
-            NULL,               /* class_finalize */
-            NULL,               /* class_data */
-           sizeof(BalsaMBList),
-            0,                  /* n_preallocs */
-           (GInstanceInitFunc) bmbl_init
-       };
-
-       mblist_type =
-            g_type_register_static(GTK_TYPE_TREE_VIEW,
-                                  "BalsaMBList",
-                                   &mblist_info, 0);
-    }
+struct _BalsaMBList {
+    GtkTreeView tree_view;
 
-    return mblist_type;
-}
+    /* shall the number of messages be displayed ? */
+    gboolean display_info;
+    /* signal handler id */
+    gulong toggled_handler_id;
 
+    /* to set sort order in an idle callback */
+    gint  sort_column_id;
+    guint sort_idle_id;
+};
+
+G_DEFINE_TYPE(BalsaMBList, balsa_mblist, GTK_TYPE_TREE_VIEW)
 
 static void
-bmbl_class_init(BalsaMBListClass * klass)
+balsa_mblist_class_init(BalsaMBListClass * klass)
 {
     GObjectClass *object_class;
     GtkWidgetClass *widget_class;
 
-    parent_class = g_type_class_peek_parent(klass);
-
     object_class = (GObjectClass *) klass;
     widget_class = (GtkWidgetClass *) klass;
 
@@ -186,7 +167,7 @@ bmbl_class_init(BalsaMBListClass * klass)
         g_signal_new("has-unread-mailbox",
                      G_TYPE_FROM_CLASS(object_class),
                      G_SIGNAL_RUN_FIRST,
-                     G_STRUCT_OFFSET(BalsaMBListClass, has_unread_mailbox),
+                     0,
                      NULL, NULL,
                      NULL,
                      G_TYPE_NONE,
@@ -200,9 +181,6 @@ bmbl_class_init(BalsaMBListClass * klass)
     widget_class->drag_motion = bmbl_drag_motion;
     widget_class->popup_menu = bmbl_popup_menu;
 
-    /* Signals */
-    klass->has_unread_mailbox = NULL;
-
     /* Properties */
     g_object_class_install_property(object_class, PROP_SHOW_CONTENT_INFO,
                                     g_param_spec_boolean
@@ -310,7 +288,7 @@ bmbl_drag_motion(GtkWidget * mblist, GdkDragContext * context, gint x,
     gboolean can_drop;
 
     ret_val =
-        GTK_WIDGET_CLASS(parent_class)->drag_motion(mblist, context, x, y,
+        GTK_WIDGET_CLASS(balsa_mblist_parent_class)->drag_motion(mblist, context, x, y,
                                                     time);
 
     gtk_tree_view_get_drag_dest_row(tree_view, &path, NULL);
@@ -335,7 +313,7 @@ bmbl_drag_motion(GtkWidget * mblist, GdkDragContext * context, gint x,
  * callbacks
  */
 static void
-bmbl_init(BalsaMBList * mblist)
+balsa_mblist_init(BalsaMBList * mblist)
 {
     GtkTreeStore *store = balsa_mblist_get_store();
     GtkTreeView *tree_view = GTK_TREE_VIEW(mblist);
diff --git a/src/balsa-mblist.h b/src/balsa-mblist.h
index 79d94d005..e355e21db 100644
--- a/src/balsa-mblist.h
+++ b/src/balsa-mblist.h
@@ -23,35 +23,9 @@
 #include <gtk/gtk.h>
 #include "mailbox-node.h"
 
-#define BALSA_TYPE_MBLIST          (balsa_mblist_get_type ())
-#define BALSA_MBLIST(obj)          G_TYPE_CHECK_INSTANCE_CAST (obj, BALSA_TYPE_MBLIST, BalsaMBList)
-#define BALSA_MBLIST_CLASS(klass)  G_TYPE_CHECK_CLASS_CAST (klass, BALSA_TYPE_MBLIST, BalsaMBListClass)
-#define BALSA_IS_MBLIST(obj)       G_TYPE_CHECK_INSTANCE_TYPE (obj, BALSA_TYPE_MBLIST)
+#define BALSA_TYPE_MBLIST (balsa_mblist_get_type ())
 
-typedef struct _BalsaMBList BalsaMBList;
-typedef struct _BalsaMBListClass BalsaMBListClass;
-
-struct _BalsaMBList {
-    GtkTreeView tree_view;
-
-    /* shall the number of messages be displayed ? */
-    gboolean display_info;
-    /* signal handler id */
-    gulong toggled_handler_id;
-
-    /* to set sort order in an idle callback */
-    gint  sort_column_id;
-    guint sort_idle_id;
-};
-
-struct _BalsaMBListClass {
-    GtkTreeViewClass parent_class;
-
-    void (*has_unread_mailbox)(BalsaMBList * mblist,
-                               gboolean has_unread_mailbox);
-};
-
-GType balsa_mblist_get_type(void);
+G_DECLARE_FINAL_TYPE(BalsaMBList, balsa_mblist, BALSA, MBLIST, GtkTreeView)
 
 GtkWidget *balsa_mblist_new(void);
 


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