[Commits] [SCM] claws branch, gtk3tree, updated. 3.99.0-78-g75c02db8e

thorsten at claws-mail.org thorsten at claws-mail.org
Fri Apr 2 11:10:36 CEST 2021


The branch, gtk3tree has been updated
       via  75c02db8e56e9d90d91719a5731581a95c3d989b (commit)
       via  51f4c8abd6a873e1679bc4efaff0c67ee878b44d (commit)
       via  114d96ca363869be1d36ecd995f53b52b1ce588c (commit)
      from  01e915aaaf65a17f0cc27dd748ff4970da2cc239 (commit)

Summary of changes:
 TODO               |   9 +++++
 src/folderview.c   | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/gtk/gtkutils.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/gtk/gtkutils.h |   9 +++++
 4 files changed, 236 insertions(+), 1 deletion(-)


- Log -----------------------------------------------------------------
commit 75c02db8e56e9d90d91719a5731581a95c3d989b
Author: Thorsten Maerz <info at netztorte.de>
Date:   Fri Apr 2 11:07:28 2021 +0200

    Reimplement folderview_select_next_with_flag()
    
    Jump to next folder with flagged message (space key)

diff --git a/src/folderview.c b/src/folderview.c
index 71638e6da..1598b026f 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -1236,10 +1236,123 @@ void folderview_unselect(FolderView *folderview)
 	folderview->open_item = NULL;
 }
 
+static GtkTreePath *folderview_find_next_with_flag(GtkTreeView *treeview,
+						   GtkTreePath *path,
+						   MsgPermFlags flag)
+{
+	FolderItem *item;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	GtkTreePath *path_old = NULL;
+
+	model = gtk_tree_view_get_model(treeview);
+	if (!model)
+		return NULL;
+
+	if (path)
+		path = gtkut_tree_path_next(treeview, path);
+	else
+		path = gtk_tree_path_new_from_string("0"); /* top node */
+
+	for (; path && gtk_tree_model_get_iter(model, &iter, path);
+	       path = gtkut_tree_path_next(treeview, path)) {
+		if (path_old) {
+			gtk_tree_path_free(path_old);
+			path_old = NULL;
+		}
+		gtk_tree_model_get(model, &iter, F_COL_FOLDERITEM, &item, -1);
+		if (!item)
+			continue;
+		if (item->stype == F_TRASH || item->stype == F_DRAFT)
+			continue;
+		switch (flag) {
+		case MSG_UNREAD:
+			if(item->unread_msgs > 0)
+				goto out;
+			break;
+		case MSG_NEW:
+			if(item->new_msgs > 0)
+				goto out;
+			break;
+		case MSG_MARKED:
+			if(item->marked_msgs > 0)
+				goto out;
+			break;
+		default:
+			if(item->total_msgs > 0)
+				goto out;
+			break;
+		}
+		path_old = path;
+	}
+
+	if (path_old)
+		gtk_tree_path_free(path_old);
+	return NULL;
+
+out:
+	if (path_old)
+		gtk_tree_path_free(path_old);
+	return path;
+}
+
 void folderview_select_next_with_flag(FolderView *folderview,
 				      MsgPermFlags flag)
 {
-	debug_print("========STUB======== folderview_select_next_with_flag\n");
+	GtkTreeView *treeview = GTK_TREE_VIEW(folderview->treeview);
+	GtkTreePath *path = NULL, *startpath = NULL;
+	EntryAction last_summary_select_prio = prefs_common.summary_select_prio[0];
+	gboolean update_cursor = FALSE;
+
+	switch (flag) {
+	case MSG_UNREAD:
+		prefs_common.summary_select_prio[0] = ACTION_OLDEST_UNREAD;
+		break;
+	case MSG_NEW:
+		prefs_common.summary_select_prio[0] = ACTION_OLDEST_NEW;
+		break;
+	case MSG_MARKED:
+		prefs_common.summary_select_prio[0] = ACTION_OLDEST_MARKED;
+		break;
+	default:
+		prefs_common.summary_select_prio[0] = ACTION_OLDEST_LIST;
+		break;
+	}
+
+	gtk_tree_view_get_cursor(treeview, &startpath, NULL);
+	if (!startpath)
+		return;
+
+	path = folderview_find_next_with_flag(treeview, startpath, flag);
+	if (path != NULL) {
+		update_cursor = TRUE;
+		goto out;
+	}
+
+/* TM: - this inhibits search from top - what was this used for?
+	if (!folderview->open_item ||
+	    folderview->open_item == folderview_get_selected_item(folderview)) {
+		goto out;
+	}
+*/
+
+	/* search again from the first node */
+	path = folderview_find_next_with_flag(treeview, NULL, flag);
+	update_cursor = (path != NULL);
+
+out:
+	if (update_cursor) {
+		gtk_tree_view_set_cursor(treeview, path, NULL, FALSE);
+		/* TM: Workaround "row-activated" not fired on single click */
+		row_activated_cb(treeview, path,
+				 gtk_tree_view_get_column(treeview,0),
+				 folderview);
+	}
+	if (startpath)
+		gtk_tree_path_free(startpath);
+	if (path)
+		gtk_tree_path_free(path);
+	prefs_common.summary_select_prio[0] = last_summary_select_prio;
 }
 
 FolderItem *folderview_get_selected_item(FolderView *folderview)

commit 51f4c8abd6a873e1679bc4efaff0c67ee878b44d
Author: Thorsten Maerz <info at netztorte.de>
Date:   Fri Apr 2 11:06:06 2021 +0200

    Utility functions for treeview
    
    Used by folderview_select_next_with_flag()

diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 012b90841..cd9a0bc28 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -403,6 +403,110 @@ void gtkut_clist_set_focus_row(GtkCMCList *clist, gint row)
 	GTKUT_CTREE_REFRESH(clist);
 }
 
+/* children: one level below
+ * returns newly allocated path (or NULL), needs gtk_tree_path_free() */
+GtkTreePath *gtkut_tree_path_get_children(GtkTreeView *treeview,
+					  GtkTreePath *path)
+{
+	GtkTreeModel *model = gtk_tree_view_get_model(treeview);
+	if (!model)
+		return NULL;
+
+	GtkTreeIter parent;
+	if (!(gtk_tree_model_get_iter(model, &parent, path)))
+		return NULL;
+
+	GtkTreeIter iter;
+	if (!(gtk_tree_model_iter_children(model, &iter, &parent)))
+		return NULL;
+	else {
+		path = gtk_tree_model_get_path(model, &iter);
+		return path;
+	}
+}
+
+/* sibling: on same level
+ * returns newly allocated path (or NULL), needs gtk_tree_path_free() */
+GtkTreePath *gtkut_tree_path_get_sibling(GtkTreeView *treeview,
+					 GtkTreePath *path)
+{
+	GtkTreeModel *model = gtk_tree_view_get_model(treeview);
+	if (!model)
+		return NULL;
+
+	GtkTreeIter iter;
+	if (!(gtk_tree_model_get_iter(model, &iter, path)))
+		return NULL;
+
+	if (!(gtk_tree_model_iter_next(model, &iter)))
+		return NULL;
+	else {
+		path = gtk_tree_model_get_path(model, &iter);
+		return path;
+	}
+}
+
+/* parent: one level above
+ * returns newly allocated path (or NULL), needs gtk_tree_path_free() */
+GtkTreePath *gtkut_tree_path_get_parent(GtkTreeView *treeview,
+					GtkTreePath *path)
+{
+	GtkTreeModel *model = gtk_tree_view_get_model(treeview);
+	if (!model)
+		return NULL;
+
+	GtkTreeIter child;
+	if (!(gtk_tree_model_get_iter(model, &child, path)))
+		return NULL;
+
+	GtkTreeIter iter;
+	if (!(gtk_tree_model_iter_parent(model, &iter, &child)))
+		return NULL;
+	else {
+		path = gtk_tree_model_get_path(model, &iter);
+		return path;
+	}
+}
+
+/* selects the next visible row below
+ * returns newly allocated path (or NULL), needs gtk_tree_path_free() */
+GtkTreePath *gtkut_tree_path_next(GtkTreeView *treeview, GtkTreePath *path)
+{
+	GtkTreePath *parent;
+	GtkTreePath *parent_old = NULL;
+	GtkTreePath *tmp;
+
+	if (!path) return NULL;
+
+	tmp = gtkut_tree_path_get_children(treeview, path);
+	if (tmp)
+		return tmp;
+
+	tmp = gtkut_tree_path_get_sibling(treeview, path);
+	if (tmp)
+		return tmp;
+
+	for (parent = gtkut_tree_path_get_parent(treeview, path); parent != NULL;
+	     parent = gtkut_tree_path_get_parent(treeview, parent)) {
+		if (parent_old) {
+			gtk_tree_path_free(parent_old);
+			parent_old = NULL;
+		}
+
+		tmp = gtkut_tree_path_get_sibling(treeview, parent);
+		if (tmp) {
+			gtk_tree_path_free(parent);
+			return tmp;
+		}
+
+		parent_old = parent;
+	}
+
+	if (parent_old)
+		gtk_tree_path_free(parent_old);
+	return NULL;
+}
+
 static gboolean gtkut_text_buffer_match_string(GtkTextBuffer *textbuf,
 					const GtkTextIter *iter,
 					gunichar *wcs, gint len,
diff --git a/src/gtk/gtkutils.h b/src/gtk/gtkutils.h
index 6ff0db7e4..1b5fcc6ad 100644
--- a/src/gtk/gtkutils.h
+++ b/src/gtk/gtkutils.h
@@ -132,6 +132,15 @@ void gtkut_ctree_set_focus_row		(GtkCMCTree	*ctree,
 void gtkut_clist_set_focus_row		(GtkCMCList	*clist,
 					 gint		 row);
 
+GtkTreePath *gtkut_tree_path_get_children	(GtkTreeView *treeview,
+						 GtkTreePath *path);
+GtkTreePath *gtkut_tree_path_get_sibling	(GtkTreeView *treeview,
+						 GtkTreePath *path);
+GtkTreePath *gtkut_tree_path_get_parent		(GtkTreeView *treeview,
+						 GtkTreePath *path);
+GtkTreePath *gtkut_tree_path_next		(GtkTreeView *treeview,
+						 GtkTreePath *path);
+
 gchar *gtkut_text_view_get_selection	(GtkTextView	*textview);
 void gtkut_text_view_set_position		(GtkTextView *text, gint pos);
 gboolean gtkut_text_view_search_string	(GtkTextView *text, const gchar *str,

commit 114d96ca363869be1d36ecd995f53b52b1ce588c
Author: Thorsten Maerz <info at netztorte.de>
Date:   Fri Apr 2 11:02:21 2021 +0200

    Update TODO

diff --git a/TODO b/TODO
index 36a06a1fe..295fd469e 100644
--- a/TODO
+++ b/TODO
@@ -21,10 +21,16 @@ GtkTreeView based folderview
 * The drag&drop events could need some documentation, which are called (and
   in which order) for different dragged objects, on aborted drop, etc.
 
+* File-not-found messages after moving folders (drag&drop)
+
 * The "row-activated" signal is not emitted on single-clicks, even though
   gtk_tree_view_set_activate_on_single_click() was called.
   (worked around by a direct call in button_press_cb())
 
+* gtk_tree_view_set_cursor() doesn't open the summaryview
+  workaround: call row_activated_cb() (in folderview_select_next_with_flag())
+  Maybe same effect as missing "row-activated" signal
+
 * Resizing the column headers needs to be detected (to updated
   prefs_common.folder_col_size).
   (The "resize_column" signal doesn't exist any longer)
@@ -32,3 +38,6 @@ GtkTreeView based folderview
 * The column headers will always steal the focus. Once they are set clickable,
   gtk_widget_set_can_focus() has no effect.
 
+* Sort-order in summaryview sometimes flips (folderview_select_next_with_flag()
+  might be a cause)
+

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list