Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: GitHub noreply@github.com Date: Sun, 13 Nov 2022 12:50:50 UTC Commit: 38def100f9c8cf214101d716f977ff8b2d1e44a1 https://github.com/geany/geany-plugins/commit/38def100f9c8cf214101d716f977ff...
Log Message: ----------- Merge pull request #1195 from eht16/issue1194_treebrowser_refresh
TreeBrowser: Fix refresh from popup menu with a selected file
Modified Paths: -------------- treebrowser/src/treebrowser.c
Modified: treebrowser/src/treebrowser.c 23 lines changed, 21 insertions(+), 2 deletions(-) =================================================================== @@ -1148,15 +1148,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).