[Commits] [SCM] claws branch, gtk3tree, updated. 3.99.0-99-gc9bf22d4e

thorsten at claws-mail.org thorsten at claws-mail.org
Wed Apr 7 13:06:51 CEST 2021


The branch, gtk3tree has been updated
       via  c9bf22d4e9644f9bd202d2620195a2bfb10f6a24 (commit)
      from  f1b181f31d1090c5b69aa65551efa43639782474 (commit)

Summary of changes:
 src/folderview.c   | 19 ++++++++++++++++---
 src/gtk/gtkutils.c | 32 ++++++++++++++++++++++++++++++++
 src/gtk/gtkutils.h |  5 +++++
 3 files changed, 53 insertions(+), 3 deletions(-)


- Log -----------------------------------------------------------------
commit c9bf22d4e9644f9bd202d2620195a2bfb10f6a24
Author: Thorsten Maerz <info at netztorte.de>
Date:   Wed Apr 7 13:04:02 2021 +0200

    Fix clicks on expander arrow
    
    Clicks on expander arrows should
    - not move the selection
    - not expand the selected row (a different row may be selected)

diff --git a/src/folderview.c b/src/folderview.c
index c1bb2ab59..70ca91093 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -284,9 +284,11 @@ static gboolean button_press_cb(GtkWidget *widget, GdkEventButton *event,
 {
 	FolderView *folderview = (FolderView *)user_data;
 	GtkTreePath *path;
+	GtkTreeViewColumn *column;
 	GtkTreeIter iter;
 	gboolean ret;
 	FolderItem *item;
+	gboolean is_expander;
 
 	debug_print("button-press: button %d\n", event->button);
 
@@ -297,17 +299,28 @@ static gboolean button_press_cb(GtkWidget *widget, GdkEventButton *event,
 
 	ret = gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
 			event->x, event->y,
-			&path, NULL, NULL, NULL);
-
+			&path, &column, NULL, NULL);
 	if (!ret) {
 		debug_print("clicked empty space, ignoring\n");
 		gtk_tree_path_free(path);
 		return FALSE;
 	}
 
+	is_expander = gtkut_tree_is_expander_clicked(GTK_TREE_VIEW(widget),
+			path, column, event->x, event->y);
+
 	if (event->button == 1) { /* Left click */
-	        if (event->type == GDK_2BUTTON_PRESS)
+		if (is_expander) {
+			gtk_tree_path_free(path);
+			return FALSE;
+		}
+
+		if (event->type == GDK_2BUTTON_PRESS) {
 			folderview->will_toggle_expand_selected = TRUE;
+			gtk_tree_path_free(path);
+			return FALSE;
+		}
+
 		/* Indicate to cursor-changed handler that it should open the
 		 * folder on selected row. */
 		debug_print("will open selected\n");
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index cd9a0bc28..b07334715 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -507,6 +507,38 @@ GtkTreePath *gtkut_tree_path_next(GtkTreeView *treeview, GtkTreePath *path)
 	return NULL;
 }
 
+gboolean gtkut_tree_is_expander_clicked(GtkTreeView *treeview,
+		GtkTreePath *path, GtkTreeViewColumn *column,
+		gdouble event_x, gdouble event_y)
+{
+	GtkTreeModel *model = gtk_tree_view_get_model(treeview);
+	GtkTreeIter iter;
+	GdkRectangle inner_rect;
+	gint x, x_start;
+
+	/* no expander shown */
+	if (!gtk_tree_view_get_show_expanders(treeview))
+		return FALSE;
+	/* no child? no expander! */
+	if (!model)
+		return FALSE;
+	if (!gtk_tree_model_get_iter(model, &iter, path))
+		return FALSE;
+	if (!gtk_tree_model_iter_has_child(model, &iter))
+		return FALSE;
+
+	/* excluding surrounding borders and the tree expander area */
+	gtk_tree_view_get_cell_area(treeview, path, column, &inner_rect);
+	x = (gint)(event_x + 0.5);
+	/* TM:TODO:
+	 * - add inner_rect.width to x_start, if detected right-to-left
+	 * - eliminate constants (probably line-width)
+	 */
+	x_start = inner_rect.x;
+	return (x >= x_start - inner_rect.height - 1)
+	    && (x <= x_start - 3);
+}
+
 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 1b5fcc6ad..e21bc7121 100644
--- a/src/gtk/gtkutils.h
+++ b/src/gtk/gtkutils.h
@@ -141,6 +141,11 @@ GtkTreePath *gtkut_tree_path_get_parent		(GtkTreeView *treeview,
 GtkTreePath *gtkut_tree_path_next		(GtkTreeView *treeview,
 						 GtkTreePath *path);
 
+gboolean gtkut_tree_is_expander_clicked	(GtkTreeView *treeview,
+					 GtkTreePath *path,
+					 GtkTreeViewColumn *column,
+					 gdouble event_x, gdouble event_y);
+
 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,

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list