[Commits] [SCM] claws branch, gtk3tree, updated. 3.99.0-88-gf90c10802

thorsten at claws-mail.org thorsten at claws-mail.org
Sat Apr 3 15:07:22 CEST 2021


The branch, gtk3tree has been updated
       via  f90c10802dbe42f07bfa994d024ac96a1a93579c (commit)
       via  f19263ef5acdda283e2c45cda1a64daf25a31a38 (commit)
       via  b07a743665236c5083ca1fc9a93cb6c073d84b16 (commit)
       via  1fcbd6317c9986d4dd9ab1bae7ad2b643b4f7cd7 (commit)
       via  17eec306d46ed41731773e13fc419725ea710f3b (commit)
      from  2dd0287c4d0d654101b454519916e2499576acc3 (commit)

Summary of changes:
 src/folderview.c | 58 ++++++++++++++++++++++++++++++++++----------------------
 src/folderview.h |  2 +-
 src/news_gtk.c   |  2 +-
 3 files changed, 37 insertions(+), 25 deletions(-)


- Log -----------------------------------------------------------------
commit f90c10802dbe42f07bfa994d024ac96a1a93579c
Author: Thorsten Maerz <info at netztorte.de>
Date:   Sat Apr 3 15:02:50 2021 +0200

    Jump back to prev. selection after popup menu
    
    Remember selection in folderview->open_path for popup and drag&drop,
    remove folderview->drag_src_path.

diff --git a/src/folderview.c b/src/folderview.c
index 59b7a7188..c4d5d81c6 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -309,6 +309,7 @@ static gboolean button_press_cb(GtkWidget *widget, GdkEventButton *event,
 	} else if (event->button == 3) { /* Right click */
 		debug_print("will show popup menu\n");
 
+		gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), path, NULL, FALSE);
 		/* Find out which item the click was on */
 		GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
 		gtk_tree_model_get_iter(model, &iter, path);
@@ -452,6 +453,9 @@ static void row_activated_cb(GtkTreeView *treeview, GtkTreePath *path,
 
 	debug_print("row-activated\n");
 
+	if (folderview->open_path)
+		gtk_tree_path_free(folderview->open_path);
+	folderview->open_path = gtk_tree_path_copy(path);
 	gtk_tree_model_get_iter(model, &iter, path);
 	gtk_tree_model_get(model, &iter,
 			F_COL_FOLDERITEM, &item, -1);
@@ -722,6 +726,7 @@ FolderView *folderview_create(MainWindow *mainwin)
 	folderview->will_open_selected = FALSE;
 	folderview->open_item = NULL;
 	folderview->menu_item = NULL;
+	folderview->open_path = gtk_tree_path_new_from_string("0");
 
 	folderview->popups = g_hash_table_new(g_str_hash, g_str_equal);
 	g_hash_table_foreach(folderview_popups, create_action_groups, folderview);
@@ -2230,8 +2235,6 @@ static void drag_state_start(FolderView *folderview, GtkTreePath *path, FolderIt
 static void folderview_drag_begin(GtkWidget *widget, GdkDragContext *context,
 			          FolderView *folderview)
 {
-	gtk_tree_view_get_cursor(GTK_TREE_VIEW(folderview->treeview),
-				 &folderview->drag_src_path, NULL);
 	free_paths_to_recollapse(folderview->paths_to_recollapse);
 	if (folderview->paths_to_recollapse)
 		g_slist_free(folderview->paths_to_recollapse);
@@ -2252,14 +2255,14 @@ static void folderview_drag_data_get(GtkWidget        *widget,
 	FolderItem *item;
 	gchar *source = NULL;
 	if (info == TARGET_DUMMY) {
-		if (!folderview->drag_src_path)
+		if (!folderview->open_path)
 			return;
 
 		model = gtk_tree_view_get_model(GTK_TREE_VIEW(folderview->treeview));
 		if (!model)
 			return;
 
-		gtk_tree_model_get_iter(model, &iter, folderview->drag_src_path);
+		gtk_tree_model_get_iter(model, &iter, folderview->open_path);
 		gtk_tree_model_get(model, &iter, F_COL_FOLDERITEM, &item, -1);
 		if (item) {
 			source = g_strdup_printf ("FROM_OTHER_FOLDER%s", folder_item_get_identifier(item));
@@ -2351,11 +2354,6 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
 			    src_item != item && FOLDER_CLASS(item->folder)->copy_msg != NULL &&
 			    FOLDER_TYPE(item->folder) != F_UNKNOWN)
 				acceptable = TRUE;
-			/* TM: remember current selection, to restore it afterwards */
-			if (!folderview->drag_src_path) {
-				gtk_tree_view_get_cursor(GTK_TREE_VIEW(folderview->treeview),
-						   &folderview->drag_src_path, NULL);
-			}
 		} else if (srcwidget == folderview->treeview) {
 			/* comes from folderview */
 			/* we are moving folder items, only accept folders that are not
@@ -2526,12 +2524,10 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
 			/* TM: drop done - cleanup */
 			drag_state_stop(folderview);
 			folderview->scroll_value = 0;
-			if (folderview->drag_src_path) {
+			if (folderview->open_path) {
 				gtk_tree_view_set_cursor
 					(GTK_TREE_VIEW(folderview->treeview),
-					 folderview->drag_src_path, NULL, FALSE);
-				gtk_tree_path_free(folderview->drag_src_path);
-				folderview->drag_src_path = NULL;
+					 folderview->open_path, NULL, FALSE);
 				summary_grab_focus(folderview->summaryview);
 			}
 		} else {
@@ -2587,10 +2583,6 @@ static void folderview_drag_end_cb(GtkWidget	    *widget,
 		g_slist_free(folderview->paths_to_recollapse);
 		folderview->paths_to_recollapse = NULL;
 	}
-	if (folderview->drag_src_path) {
-		gtk_tree_path_free(folderview->drag_src_path);
-		folderview->drag_src_path = NULL;
-	}
 }
 
 
@@ -2954,6 +2946,8 @@ static void folderview_popup_close(GtkMenuShell *menu_shell,
 {
 	debug_print("folderview_popup_close\n");
 	folderview->menu_item = NULL;
+	if (folderview->open_path)
+		gtk_tree_view_set_cursor(GTK_TREE_VIEW(folderview->treeview), folderview->open_path, NULL, FALSE);
 }
 
 static void set_sens_and_popup_menu(FolderView *folderview, FolderItem *item,
diff --git a/src/folderview.h b/src/folderview.h
index 49ab644ae..596d1ec02 100644
--- a/src/folderview.h
+++ b/src/folderview.h
@@ -60,6 +60,7 @@ struct _FolderView
 	gboolean will_toggle_expand_selected;
 	FolderItem *open_item; /* Pointer to currently open item */
 	FolderItem *menu_item; /* Pointer to item the popup menu is open for */
+	GtkTreePath *open_path; /* Pointer to currently open item */
 
 	GHashTable *popups;
 
@@ -68,7 +69,6 @@ struct _FolderView
 	guint   drag_timer_id;		/* timer id */
 	FolderItem *drag_dst_item;	/* dragged item (destination) */
 	GtkTreePath *drag_dst_path;	/* drag path (destination) */
-	GtkTreePath *drag_src_path;	/* drag path (source: either dragged folder, or folder, that contained the dragged message) */
 
 	gint scroll_value;
 	guint scroll_timeout_id;

commit f19263ef5acdda283e2c45cda1a64daf25a31a38
Author: Thorsten Maerz <info at netztorte.de>
Date:   Sat Apr 3 13:11:47 2021 +0200

    Remove unused variables

diff --git a/src/folderview.c b/src/folderview.c
index b90d00f51..59b7a7188 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -2008,7 +2008,6 @@ static gboolean update_prefs_func(GtkTreeModel *model, GtkTreePath *path,
 void folderview_reflect_prefs(FolderView *folderview)
 {
 	gboolean update_font = FALSE;
-	gboolean update_color = FALSE;
 
 	debug_print("folderview_reflect_prefs\n");
 
@@ -2475,12 +2474,10 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
 					guint             time,
 					FolderView       *folderview)
 {
-	gint row, column;
 	FolderItem *item = NULL, *src_item;
 	GtkTreePath *path;
 	GtkTreeModel *model;
 	GtkTreeIter iter;
-	int offset = prefs_common.show_col_headers ? 24:0;
 
 	folderview->scroll_value = 0;
 
@@ -2603,7 +2600,6 @@ void folderview_update_search_icon(FolderItem *item, gboolean matches)
 	FolderView *folderview;
 	GtkTreeView *treeview;
 	GtkTreeModel *model;
-	GtkTreeIter iter;
 
 	struct finditer_ctx *ctx = g_new0(struct finditer_ctx, 1);
 	ctx->item = item;

commit b07a743665236c5083ca1fc9a93cb6c073d84b16
Author: Thorsten Maerz <info at netztorte.de>
Date:   Sat Apr 3 08:12:43 2021 +0200

    Remove STUB message for unnecessary function

diff --git a/src/folderview.c b/src/folderview.c
index c82b9d3be..b90d00f51 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -2411,7 +2411,9 @@ static void folderview_drag_leave_cb(GtkWidget      *widget,
 				     guint           time,
 				     FolderView     *folderview)
 {
+/* TM: unnecessary
 	debug_print("========STUB======== folderview_drag_leave_cb\n");
+*/
 }
 
 static void free_info (gpointer stuff, gpointer data)

commit 1fcbd6317c9986d4dd9ab1bae7ad2b643b4f7cd7
Author: Thorsten Maerz <info at netztorte.de>
Date:   Sat Apr 3 08:07:00 2021 +0200

    Fix updating fonts
    
    Bugfix: Bold font used instead of normal font (after prefs dialog).
    Remove STUB message for unnecessary function.

diff --git a/src/folderview.c b/src/folderview.c
index 7002cb6ff..c82b9d3be 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -1985,7 +1985,9 @@ void folderview_set_target_folder_color(GdkRGBA color_op)
 
 void folderview_reinit_fonts(FolderView *folderview)
 {
+/* TM: not necessary (and useless, unless folderview_reflect_prefs() is called)
 	debug_print("========STUB======== folderview_reinit_fonts\n");
+*/
 }
 
 /* TODO: this function will eventually set normal or bold fonts,
@@ -2038,7 +2040,7 @@ void folderview_reflect_prefs(FolderView *folderview)
 		pango_font_description_free(folderview->normal_font);
 		pango_font_description_free(folderview->bold_font);
 		folderview->normal_font = pango_font_description_from_string(NORMAL_FONT);
-		folderview->normal_font = pango_font_description_from_string(BOLD_FONT);
+		folderview->bold_font = pango_font_description_from_string(BOLD_FONT);
 	}
 
 // 	if (update_color) {

commit 17eec306d46ed41731773e13fc419725ea710f3b
Author: Thorsten Maerz <info at netztorte.de>
Date:   Sat Apr 3 07:42:04 2021 +0200

    Reimplement folderview_remove_item()

diff --git a/src/folderview.c b/src/folderview.c
index 5b661d91a..7002cb6ff 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -2683,7 +2683,25 @@ void folderview_close_opened(FolderView *folderview, gboolean dirty)
 
 void folderview_remove_item(FolderView *folderview, FolderItem *item)
 {
-	debug_print("========STUB======== folderview_remove_item\n");
+	struct finditer_ctx *ctx = g_new0(struct finditer_ctx, 1);
+	ctx->item = item;
+	ctx->iter = NULL;
+	GtkTreeModel *model =
+		gtk_tree_view_get_model(GTK_TREE_VIEW(folderview->treeview));
+
+	if (!model)
+		return;
+
+	gtk_tree_model_foreach(model, folderview_find_iter_foreach_func, ctx);
+
+	if (ctx->iter == NULL) {
+		g_free(ctx);
+		return;
+	}
+
+	gtk_tree_store_remove(GTK_TREE_STORE(model), ctx->iter);
+	gtk_tree_iter_free(ctx->iter);
+	g_free(ctx);
 }
 
 /* TM: There is no freeze/thaw. Detaching the model can be a workaround,
diff --git a/src/news_gtk.c b/src/news_gtk.c
index 729877207..59baa554d 100644
--- a/src/news_gtk.c
+++ b/src/news_gtk.c
@@ -232,7 +232,7 @@ static void unsubscribe_newsgroup_cb(GtkAction *action, gpointer data)
 	AlertValue avalue;
 	MainWindow *mainwin = mainwindow_get_mainwindow();
 	
-	if ((item = folderview_get_selected_item(folderview)) != NULL)
+	if ((item = folderview_get_selected_item(folderview)) == NULL)
 		return;
 
 	if (mainwin->lock_count || news_folder_locked(item->folder))

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list