[balsa] mailbox: Use more precise types



commit 38ffd69cb1490474321008886735d59b10caa527
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Apr 3 20:35:59 2019 -0400

    mailbox: Use more precise types
    
    Balsa has been using G_TYPE_UINT for properties that are retrieved as
    G_TYPE_INT and G_TYPE_ENUM, which seems to work, but may lead to some
    obscure problems. Oddly, gtk_cell_renderer_text_set_property()
    recognizes PANGO_TYPE_STYLE as an enum, but not PANGO_TYPE_WEIGHT, which
    it retrieves using g_value_get_int().
    
    * libbalsa/mailbox.c (mbox_model_init), (mbox_model_get_value):
      Use the GTypes that are expected in gtk_cell_renderer_text_set_property().

 ChangeLog          |  8 ++++++++
 libbalsa/mailbox.c | 16 ++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 47d58bba6..ee36b3e1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-04-03  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Use more precise types
+
+       * libbalsa/mailbox.c (mbox_model_init), (mbox_model_get_value):
+       Use the GTypes that are expected in
+       gtk_cell_renderer_text_set_property().
+
 2019-04-01  Albrecht Dreß  <albrecht dress arcor de>
 
        Improve IMAP folder parent selection, subscription management
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index c0ca8e68d..10f177cb7 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -2766,12 +2766,12 @@ mbox_model_init(GtkTreeModelIface *iface)
     mbox_model_col_type[LB_MBOX_SUBJECT_COL] = G_TYPE_STRING;
     mbox_model_col_type[LB_MBOX_DATE_COL]    = G_TYPE_STRING;
     mbox_model_col_type[LB_MBOX_SIZE_COL]    = G_TYPE_STRING;
-    mbox_model_col_type[LB_MBOX_WEIGHT_COL]  = G_TYPE_UINT;
-    mbox_model_col_type[LB_MBOX_STYLE_COL]   = G_TYPE_UINT;
+    mbox_model_col_type[LB_MBOX_WEIGHT_COL]  = G_TYPE_INT;
+    mbox_model_col_type[LB_MBOX_STYLE_COL]   = PANGO_TYPE_STYLE;
     mbox_model_col_type[LB_MBOX_FOREGROUND_COL]     = G_TYPE_STRING;
-    mbox_model_col_type[LB_MBOX_FOREGROUND_SET_COL] = G_TYPE_UINT;
+    mbox_model_col_type[LB_MBOX_FOREGROUND_SET_COL] = G_TYPE_BOOLEAN;
     mbox_model_col_type[LB_MBOX_BACKGROUND_COL]     = G_TYPE_STRING;
-    mbox_model_col_type[LB_MBOX_BACKGROUND_SET_COL] = G_TYPE_UINT;
+    mbox_model_col_type[LB_MBOX_BACKGROUND_SET_COL] = G_TYPE_BOOLEAN;
 
 
     libbalsa_mbox_model_signals[ROW_CHANGED] =
@@ -3044,11 +3044,11 @@ mbox_model_get_value(GtkTreeModel *tree_model,
         else g_value_set_static_string(value, "          ");
         break;
     case LB_MBOX_WEIGHT_COL:
-        g_value_set_uint(value, msg && msg->unseen
+        g_value_set_int(value, msg != NULL && msg->unseen
                          ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
         break;
     case LB_MBOX_STYLE_COL:
-        g_value_set_uint(value, msg &&
+        g_value_set_enum(value, msg != NULL &&
                         lbm_node_has_unseen_child(lmm,
                                                   (GNode *) iter->user_data)
                          ? PANGO_STYLE_OBLIQUE : PANGO_STYLE_NORMAL);
@@ -3060,7 +3060,7 @@ mbox_model_get_value(GtkTreeModel *tree_model,
         }
         break;
     case LB_MBOX_FOREGROUND_SET_COL:
-        g_value_set_uint(value, msg && msg->foreground_set);
+        g_value_set_boolean(value, msg != NULL && msg->foreground_set);
         break;
     case LB_MBOX_BACKGROUND_COL:
         if(msg) {
@@ -3069,7 +3069,7 @@ mbox_model_get_value(GtkTreeModel *tree_model,
         }
         break;
     case LB_MBOX_BACKGROUND_SET_COL:
-        g_value_set_uint(value, msg && msg->background_set);
+        g_value_set_boolean(value, msg != NULL && msg->background_set);
         break;
     }
 }


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