Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Sun, 11 Sep 2022 15:26:17 UTC Commit: fd42f7e1b8eaf1c0d12ae86cfd91025c0e77b1f4 https://github.com/geany/geany-plugins/commit/fd42f7e1b8eaf1c0d12ae86cfd9102...
Log Message: ----------- TreeBrowser: Fix refresh from popup menu with a selected file
Closes #1194.
Modified Paths: -------------- treebrowser/src/treebrowser.c
Modified: treebrowser/src/treebrowser.c 23 lines changed, 21 insertions(+), 2 deletions(-) =================================================================== @@ -1163,15 +1163,34 @@ static void on_menu_refresh(GtkMenuItem *menuitem, gpointer *user_data) { GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); - GtkTreeIter iter; + GtkTreeIter iter, parent_iter; + GtkTreeIter *target_iter = NULL; GtkTreeModel *model; gchar *uri;
if (gtk_tree_selection_get_selected(selection, &model, &iter)) { gtk_tree_model_get(model, &iter, TREEBROWSER_COLUMN_URI, &uri, -1); + /* if a directory is selected, use it directly for treebrowser_browse() + * if a file within a directory is selected, use its parent for treebrowser_browse() + * if a file on the top level is selected, use *no* parent for treebrowser_browse() */ if (g_file_test(uri, G_FILE_TEST_IS_DIR)) - treebrowser_browse(uri, &iter); + target_iter = &iter; + else + { + if (gtk_tree_model_iter_parent(model, &parent_iter, &iter)) + { + g_free(uri); + gtk_tree_model_get(model, &iter, TREEBROWSER_COLUMN_URI, &uri, -1); + target_iter = &parent_iter; + } + else + { + SETPTR(uri, g_path_get_dirname(uri)); + target_iter = NULL; + } + } + treebrowser_browse(uri, target_iter); g_free(uri); } else
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org