[Commits] [SCM] claws branch, master, updated. 3.16.0-63-g138cc2c
ticho at claws-mail.org
ticho at claws-mail.org
Sat Feb 17 18:24:26 CET 2018
The branch, master has been updated
via 138cc2c7b9fb47a1d5ed3264a734e1e4fdcdbae8 (commit)
from 65a59394f842799c1d09811b61413789ac58a0ec (commit)
Summary of changes:
src/addrgather.c | 85 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 55 insertions(+), 30 deletions(-)
- Log -----------------------------------------------------------------
commit 138cc2c7b9fb47a1d5ed3264a734e1e4fdcdbae8
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Sat Feb 17 18:23:48 2018 +0100
Replace GtkCMCList in addrgather dialog with GtkTreeView.
diff --git a/src/addrgather.c b/src/addrgather.c
index abacec1..2fded27 100644
--- a/src/addrgather.c
+++ b/src/addrgather.c
@@ -89,7 +89,7 @@ static struct _AddrHarvest {
gboolean cancelled;
gboolean done;
gchar *folderPath;
- GtkWidget *clistCount;
+ GtkWidget *viewCount;
} addrgather_dlg;
#ifndef USE_ALT_ADDRBOOK
@@ -106,6 +106,12 @@ static gchar *_harv_headerNames_[] = {
};
static GList *_harv_messageList_;
+enum {
+ ADDRGATHER_COL_HEADER,
+ ADDRGATHER_COL_COUNT,
+ N_ADDRGATHER_COLS
+};
+
static void addrgather_dlg_status_show( gchar *msg ) {
if( addrgather_dlg.statusbar != NULL ) {
gtk_statusbar_pop( GTK_STATUSBAR(addrgather_dlg.statusbar),
@@ -148,8 +154,9 @@ static void addrgather_size_allocate(
#define FMT_BUFSIZE 32
static gboolean addrgather_dlg_harvest() {
- GtkCMCList *clist;
- gchar *text[ FIELDS_N_COLS ];
+ GtkWidget *view;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
AddressHarvester *harvester;
gchar *name;
#ifndef USE_ALT_ADDRBOOK
@@ -255,19 +262,22 @@ static gboolean addrgather_dlg_harvest() {
#endif
/* Update summary count */
- clist = GTK_CMCLIST(addrgather_dlg.clistCount);
- gtk_cmclist_clear( clist );
+ view = addrgather_dlg.viewCount;
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
+ gtk_list_store_clear( GTK_LIST_STORE(model) );
for( i = 0; i < NUM_FIELDS; i++ ) {
cnt = addrharvest_get_count( harvester, _harv_headerNames_[i] );
if( cnt < 1 ) {
strcpy( str, "-" );
}
else {
- sprintf( str, "%d", cnt );
+ snprintf( str, FMT_BUFSIZE, "%d", cnt );
}
- text[ FIELD_COL_HEADER ] = _harv_headerNames_[i];
- text[ FIELD_COL_COUNT ] = str;
- gtk_cmclist_append( clist, text );
+ gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter,
+ ADDRGATHER_COL_HEADER, _harv_headerNames_[i],
+ ADDRGATHER_COL_COUNT, str,
+ -1);
}
addrharvest_free( harvester );
@@ -441,12 +451,12 @@ static void addrgather_page_fields(gint pageNum, gchar *pageLbl)
static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) {
GtkWidget *label;
GtkWidget *vbox;
- GtkWidget *clistSWin;
- GtkWidget *clistCount;
- gchar *titles[ FIELDS_N_COLS ];
- gint i;
- titles[ FIELD_COL_HEADER ] = _("Header Name");
- titles[ FIELD_COL_COUNT ] = _("Address Count");
+ GtkWidget *scrollwin;
+ GtkWidget *viewCount;
+ GtkTreeViewColumn *col;
+ GtkCellRenderer *rdr;
+ GtkTreeSelection *sel;
+ GtkTreeModel *model;
vbox = gtk_vbox_new(FALSE, 8);
gtk_container_add( GTK_CONTAINER( addrgather_dlg.notebook ), vbox );
@@ -460,24 +470,39 @@ static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) {
label );
/* Summary count */
- clistSWin = gtk_scrolled_window_new( NULL, NULL );
- gtk_container_add( GTK_CONTAINER(vbox), clistSWin );
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(clistSWin),
+ scrollwin = gtk_scrolled_window_new( NULL, NULL );
+ gtk_container_add( GTK_CONTAINER(vbox), scrollwin );
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- clistCount = gtk_cmclist_new_with_titles( FIELDS_N_COLS, titles );
- gtk_container_add( GTK_CONTAINER(clistSWin), clistCount );
- gtk_cmclist_set_selection_mode( GTK_CMCLIST(clistCount), GTK_SELECTION_BROWSE );
- gtk_cmclist_set_column_width(
- GTK_CMCLIST(clistCount), FIELD_COL_HEADER, FIELDS_COL_WIDTH_HEADER );
- gtk_cmclist_set_column_width(
- GTK_CMCLIST(clistCount), FIELD_COL_COUNT, FIELDS_COL_WIDTH_COUNT );
-
- for( i = 0; i < FIELDS_N_COLS; i++ )
- gtk_widget_set_can_focus(GTK_CMCLIST(clistCount)->column[i].button, FALSE);
-
- addrgather_dlg.clistCount = clistCount;
+ /* Treeview */
+ model = GTK_TREE_MODEL(gtk_list_store_new(N_ADDRGATHER_COLS,
+ G_TYPE_STRING, G_TYPE_STRING, -1));
+
+ viewCount = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(viewCount), TRUE);
+ gtk_tree_view_set_reorderable(GTK_TREE_VIEW(viewCount), FALSE);
+ sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(viewCount));
+ gtk_tree_selection_set_mode(sel, GTK_SELECTION_NONE);
+
+ /* Columns for the treeview */
+ rdr = gtk_cell_renderer_text_new();
+ col = gtk_tree_view_column_new_with_attributes(_("Header Name"), rdr,
+ "markup", ADDRGATHER_COL_HEADER,
+ NULL);
+ gtk_tree_view_column_set_min_width(col, FIELDS_COL_WIDTH_HEADER);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(viewCount), col);
+
+ col = gtk_tree_view_column_new_with_attributes(_("Address Count"), rdr,
+ "text", ADDRGATHER_COL_COUNT,
+ NULL);
+ gtk_tree_view_column_set_min_width(col, FIELDS_COL_WIDTH_COUNT);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(viewCount), col);
+
+ gtk_container_add( GTK_CONTAINER(scrollwin), viewCount );
+
+ addrgather_dlg.viewCount = viewCount;
}
/*
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list