Hi Peter! Am 27.03.19 16:16 schrieb(en) Peter Bloomfield:
I have only one question: you use a series of defined constants to label the columns of the GtkTreeStore, where elsewhere Balsa (mostly?) uses an enumeration; the enumeration can be extended with a final *_N_COLS member which avoids hard-coding the column count. Any particular reason to prefer defined constants?
You're of course right, and to be honest, I have to admit that I just forgot to fix the consts when cleaning up the patch for submission… Attached is a small patch, on top of the first one, fixing this. Thanks a lot for pointing me to that! Cheers, Albrecht.
diff --git a/libbalsa/folder-scanners.c b/libbalsa/folder-scanners.c index c20d21af0..1788ac6c0 100644 --- a/libbalsa/folder-scanners.c +++ b/libbalsa/folder-scanners.c @@ -499,7 +499,8 @@ libbalsa_scanner_imap_tree(LibBalsaServer *server, libbalsa_imap_server_release_handle(LIBBALSA_IMAP_SERVER(server), scan_data.handle); /* create the resulting tree store */ - imap_store.store = gtk_tree_store_new(5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, PANGO_TYPE_STYLE); + imap_store.store = gtk_tree_store_new(LB_SCANNER_IMAP_N_COLS, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, PANGO_TYPE_STYLE); g_hash_table_foreach(folders, (GHFunc) imap_tree_to_store, &imap_store); g_hash_table_unref(folders); } else { diff --git a/libbalsa/folder-scanners.h b/libbalsa/folder-scanners.h index b501d147e..857b55bfb 100644 --- a/libbalsa/folder-scanners.h +++ b/libbalsa/folder-scanners.h @@ -66,13 +66,16 @@ void libbalsa_scanner_imap_dir(gpointer rnode, LibBalsaServer * server, GtkTreeStore *libbalsa_scanner_imap_tree(LibBalsaServer *server, gboolean subscriptions, GError **error) -G_GNUC_WARN_UNUSED_RESULT; + G_GNUC_WARN_UNUSED_RESULT; -#define LB_SCANNER_IMAP_FOLDER 0 -#define LB_SCANNER_IMAP_PATH 1 -#define LB_SCANNER_IMAP_SUBS_NEW 2 -#define LB_SCANNER_IMAP_SUBS_OLD 3 -#define LB_SCANNER_IMAP_STYLE 4 +typedef enum { + LB_SCANNER_IMAP_FOLDER = 0, + LB_SCANNER_IMAP_PATH, + LB_SCANNER_IMAP_SUBS_NEW, + LB_SCANNER_IMAP_SUBS_OLD, + LB_SCANNER_IMAP_STYLE, + LB_SCANNER_IMAP_N_COLS +} lb_scanner_imap_tree_cols_t; #endif /* __FOLDER_SCANNERS_H__ */
Attachment:
pgpEhSAVC4nAq.pgp
Description: PGP signature