[Commits] [SCM] claws branch, gtk3tree, updated. 3.99.0-132-g8b03aa8b5

thorsten at claws-mail.org thorsten at claws-mail.org
Thu Apr 22 16:27:04 CEST 2021


The branch, gtk3tree has been updated
       via  8b03aa8b57624699212d444ddbc2a9947befed6e (commit)
      from  bc091d748443aeec67524b7bd6e606dc499d9bb5 (commit)

Summary of changes:
 TODO             |  4 ----
 src/folderview.c | 39 +++++++++++++++++++++++++++++++++++++++
 src/folderview.h |  2 ++
 3 files changed, 41 insertions(+), 4 deletions(-)


- Log -----------------------------------------------------------------
commit 8b03aa8b57624699212d444ddbc2a9947befed6e
Author: Thorsten Maerz <info at netztorte.de>
Date:   Thu Apr 22 16:24:20 2021 +0200

    Remember column widths

diff --git a/TODO b/TODO
index d19e9b151..2b73565b5 100644
--- a/TODO
+++ b/TODO
@@ -23,9 +23,5 @@ GtkTreeView based folderview
 
 * File-not-found messages after moving folders (drag&drop)
 
-* Resizing the column headers needs to be detected (to updated
-  prefs_common.folder_col_size).
-  (The "resize_column" signal doesn't exist any longer)
-
 * The column headers will always steal the focus. Once they are set clickable,
   gtk_widget_set_can_focus() has no effect.
diff --git a/src/folderview.c b/src/folderview.c
index f2632d074..907731eba 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -308,6 +308,7 @@ static gboolean button_press_cb(GtkWidget *widget, GdkEventButton *event,
 		return FALSE;
 	}
 
+	folderview->data_row_clicked = TRUE; /* don't save column-widths on button-release */
 	is_expander = gtkut_tree_is_expander_clicked(GTK_TREE_VIEW(widget),
 			path, column, event->x, event->y);
 
@@ -342,6 +343,40 @@ static gboolean button_press_cb(GtkWidget *widget, GdkEventButton *event,
 	return FALSE;
 }
 
+static gboolean button_release_cb(GtkWidget *widget, GdkEventButton *event,
+				  gpointer user_data)
+{
+	FolderView *folderview = (FolderView *)user_data;
+	gboolean data_row_clicked = folderview->data_row_clicked;
+	GtkTreePath *path;
+	GtkTreeViewColumn *column;
+	gint i;
+
+	/* TM: Workaround for missing "resize_column" signal
+	 * Opposed to button-press, the button-release signal is fired for
+	 * headers as well, but event->y gets the SAME values, when clicked on
+	 * the headers, as if clicked on the first data row. To distiguish
+	 * them, data_row_clicked is set in the button-press handler.
+	 */
+	folderview->data_row_clicked = FALSE;
+	/* ignore clicks on and below data rows */
+	if (data_row_clicked || !gtk_tree_view_get_path_at_pos
+			(GTK_TREE_VIEW(widget),
+			 event->x, event->y, &path, NULL, NULL, NULL))
+		return FALSE;
+
+	/* button released on header row: save column widths */
+	for (i = F_COL_FOLDER; i <= F_COL_TOTAL; i++) {
+		column = (GtkTreeViewColumn*)g_list_nth_data
+				(treeview_default_columns_ordered,
+				 i - F_COL_FOLDER);
+		prefs_common.folder_col_size[i] =
+			 gtk_tree_view_column_get_width(column);
+	}
+	return FALSE;
+}
+
+
 static void folderview_toggle_expansion(GtkTreeView *treeview)
 {
 	GtkTreePath *path;
@@ -753,6 +788,8 @@ FolderView *folderview_create(MainWindow *mainwin)
 	folderview->menu_item = NULL;
 	folderview->open_path = gtk_tree_path_new_from_string("0");
 
+	folderview->data_row_clicked = FALSE;
+
 	folderview->popups = g_hash_table_new(g_str_hash, g_str_equal);
 	g_hash_table_foreach(folderview_popups, create_action_groups, folderview);
 
@@ -786,6 +823,8 @@ FolderView *folderview_create(MainWindow *mainwin)
 			 G_CALLBACK(folderview_key_pressed), folderview);
 	g_signal_connect(G_OBJECT(folderview->treeview), "button-press-event",
 			G_CALLBACK(button_press_cb), folderview);
+	g_signal_connect(G_OBJECT(folderview->treeview), "button-release-event",
+			G_CALLBACK(button_release_cb), folderview);
 	g_signal_connect(G_OBJECT(folderview->treeview), "cursor-changed",
 			G_CALLBACK(cursor_changed_cb), folderview);
 	g_signal_connect(G_OBJECT(folderview->treeview), "row-activated",
diff --git a/src/folderview.h b/src/folderview.h
index c5ffbee59..4223ea74a 100644
--- a/src/folderview.h
+++ b/src/folderview.h
@@ -60,6 +60,8 @@ struct _FolderView
 	FolderItem *menu_item; /* Pointer to item the popup menu is open for */
 	GtkTreePath *open_path; /* Pointer to currently open item */
 
+	gboolean data_row_clicked; /* helper for saving column-widths */
+
 	GHashTable *popups;
 
 	/* DND states */

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list