Also fixes iterating docs for *Close other Documents* in notebook tab order. I'd like to add a folder item for *Open in New Window* too.
Screenshot: ![image](https://user-images.githubusercontent.com/1107820/66410821-ab798e00-e9ea-11e...)
You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/2346
-- Commit Summary --
* Use gtk_widget_show_all in show_tab_bar_popup_menu * Add *Documents in _Folder* notebook menu * Remove unnecessary casts * Iterate in tab order for *Close Other Documents* and close folder items
-- File Changes --
M src/callbacks.c (11) M src/notebook.c (75) M src/sidebar.c (1)
-- Patch Links --
https://github.com/geany/geany/pull/2346.patch https://github.com/geany/geany/pull/2346.diff
ntrel commented on this pull request.
- if (cur_doc == NULL)
+ cur_doc = document_get_current(); + if (!cur_doc->real_path) + return; + + gchar *dir = g_dirname(cur_doc->real_path); + + for (gint i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)); i++) + { + GeanyDocument *doc = document_get_from_page(i); + + if (!doc->real_path) + continue; + if (other_folders && g_str_has_prefix(doc->real_path, dir)) + continue; + if (!other_folders && !g_str_has_prefix(doc->real_path, dir))
Checking for a prefix means subdirectories will also be matched, not sure whether that's good or bad.
@ntrel pushed 1 commit.
e2a098a4e15a93c744b228fdd4a2eb3a25ea3a3a Iterate in tab order for close folder items
elextr commented on this pull request.
- if (cur_doc == NULL)
+ cur_doc = document_get_current(); + if (!cur_doc->real_path) + return; + + gchar *dir = g_dirname(cur_doc->real_path); + + for (gint i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)); i++) + { + GeanyDocument *doc = document_get_from_page(i); + + if (!doc->real_path) + continue; + if (other_folders && g_str_has_prefix(doc->real_path, dir)) + continue; + if (!other_folders && !g_str_has_prefix(doc->real_path, dir))
If you mean closing in the whole tree subtree, that probably would be better on the documents sidebar where the specific root directory can be selected, you may not have files in that specific directory open, only subdirectories.
Could be useful at times, quick looks ok, havn't tested.
codebrainz commented on this pull request.
@@ -455,60 +456,104 @@ static void on_close_documents_right_activate(GtkMenuItem *menuitem, GeanyDocume
}
+// simple implementation (vs. close all which doesn't close documents if cancelled) +static void close_folder_action(GeanyDocument *cur_doc, gboolean other_folders) +{ + if (cur_doc == NULL) + cur_doc = document_get_current(); + if (!cur_doc->real_path) + return; + + gchar *dir = g_dirname(cur_doc->real_path);
Should probably use `g_path_get_dirname()` since `g_dirname()` is deprecated.
codebrainz commented on this pull request.
@@ -857,7 +857,6 @@ static void on_openfiles_document_action(GtkMenuItem *menuitem, gpointer user_da
while (i >= 0 && gtk_tree_model_iter_nth_child(model, &child, &iter, i)) { gtk_tree_model_get(model, &child, DOCUMENTS_DOCUMENT, &doc, -1); -
Unrelated whitespace change in otherwise untouched file.
sidebar tree #1813 implements the "in folder part" through the side bar, i.e. when you close a folder (via popup menu or middle mouse click) then all files below that folder will be closed. The other use case could probably also be implemented there. Do you think it makes this PR obsolete?
I never use the notebook popup menu, mainly because I always have many files open so I always have to scroll.
I never use the notebook popup menu, mainly because I always have many files open so I always have to scroll.
ditto because I have the tabs turned off
@ntrel pushed 1 commit.
b33d7a81e1e4e6f9b0dfd4cc894400f8142a2907 g_dirname is deprecated
@ntrel pushed 1 commit.
07bdb07af839a3f93426fc1a08fb22e55391a469 Revert whitespace change
ntrel commented on this pull request.
@@ -455,60 +456,104 @@ static void on_close_documents_right_activate(GtkMenuItem *menuitem, GeanyDocume
}
+// simple implementation (vs. close all which doesn't close documents if cancelled) +static void close_folder_action(GeanyDocument *cur_doc, gboolean other_folders) +{ + if (cur_doc == NULL) + cur_doc = document_get_current(); + if (!cur_doc->real_path) + return; + + gchar *dir = g_dirname(cur_doc->real_path);
Thanks, fixed.
#1813 implements the "in folder part" through the side bar
Actually the sidebar 'Show Paths' option already supports closing all docs in a folder.
The other use case could probably also be implemented there. Do you think it makes this PR obsolete?
I think this pull makes the feature more discoverable, a user might not think to try right clicking on a folder in the sidebar documents. This pull also closes docs in notebook tab order instead of filename order.
Also, the notebook popup already has Close All, Close other documents and Close tabs to the right. I think this fits in with those commands.
Okay, your call.
Actually the sidebar 'Show Paths' option already supports closing all docs in a folder.
It doesn't do it recursively because each sub-(sub-) directory gets a top-level node just below the root.
ntrel commented on this pull request.
- if (cur_doc == NULL)
+ cur_doc = document_get_current(); + if (!cur_doc->real_path) + return; + + gchar *dir = g_dirname(cur_doc->real_path); + + for (gint i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)); i++) + { + GeanyDocument *doc = document_get_from_page(i); + + if (!doc->real_path) + continue; + if (other_folders && g_str_has_prefix(doc->real_path, dir)) + continue; + if (!other_folders && !g_str_has_prefix(doc->real_path, dir))
you may not have files in that specific directory open, only subdirectories.
Sorry, I'm not following this part of your comment.
ntrel commented on this pull request.
- if (cur_doc == NULL)
+ cur_doc = document_get_current(); + if (!cur_doc->real_path) + return; + + gchar *dir = g_dirname(cur_doc->real_path); + + for (gint i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)); i++) + { + GeanyDocument *doc = document_get_from_page(i); + + if (!doc->real_path) + continue; + if (other_folders && g_str_has_prefix(doc->real_path, dir)) + continue; + if (!other_folders && !g_str_has_prefix(doc->real_path, dir))
There has to be at least one file with that full directory because there wouldn't be a notebook tab otherwise.
It doesn't do it recursively
True, I'm not sure whether this pull should or not. (Recursive closing does make sense for your sidebar tree PR).
I do use the tab menu a lot, but I'm not a big fan of the UI of this PR. Even before, I thought there were too many "close" options in the menu, and this adds another. My inclination would be too put them all in a submenu, but while it de-clutters the menu, it makes them more annoying to use. Also I don't like how the new item is grouped with Open in New Window rather than at the bottom of the existing "close" related items, in the same section/group as them.
I suppose I'm biased though since I have never had a need for this feature and it will only add more stuff into an already (usually) massive menu, negatively affecting my personal usage.
For example, with maybe around half of Geany's C files open, I already have to scroll to access the menu items I do use:
![geany_tab_menu](https://user-images.githubusercontent.com/181177/66528752-e8f71d80-eab5-11e9...)
This pull also closes docs in notebook tab order instead of filename order.
Isn't that what #2347 is for?
Ah, I'm reading my emails in chronological order, hadn't seen the UI issues are already being discussed/addressed in a separate PR #2348.
I thought there were too many "close" options in the menu, and this adds another. My inclination would be too put them all in a submenu, but while it de-clutters the menu, it makes them more annoying to use
I think putting the multiple document close icons in a submenu would be good UI design, so people don't accidentally click them. They should be harder to use.
Isn't that what #2347 is for?
That pull is for the existing close other documents command. I was pointing out the close order difference of this pull vs the sidebar documents close folder. Perhaps the latter should close in tab order too rather than alphabetic order?
I have never had a need for this feature
Maybe you keep all files in a project open always. But as you mention, this makes it harder to switch to the document you need. It is also impractical for slower systems as it slows down opening a project and uses more memory.
I would use this e.g. when I've finished looking at files in the ctags subfolder. It's also useful when I've opened a folder in a current project and would rather it was in a separate project. Currently I save the project and copy the project file. Once I implement Open in New Instance for this pulls Documents in Folder menu, it will make splitting a project a bit easier.
it will only add more stuff into an already (usually) massive menu,
it will only add more stuff into an already (usually) massive menu
It only adds one menu item, (and the multiple document close items should be put in a submenu as I mentioned).
Once I implement Open in New Instance
See #2352.
I think putting the multiple document close icons in a submenu would be good UI design, so people don't accidentally click them. They should be harder to use.
I think the opposite, when possible/not too big, IMO it's better to keep a flat menu structure so it's easier to use and requires less clicks (and less mnemonics if you use accelerators). It's not like closing documents is dangerous and presumably it's rare even with a lousy trackpad or muscle control.
A nice thing about #2348 is that it alleviates my main concern that the menu was too crowded and allows stuff like this PR to get rid of the submenu and also adding items like "close to the left" or "open in split window" or whatever stuff we want.
I was pointing out the close order difference of this pull vs the sidebar documents close folder. Perhaps the latter should close in tab order too rather than alphabetic order?
IMO, the reasoning in #2347 is sound and should apply to any operation on multiple tabs (closing, searching, etc.) no matter which feature triggers the action.
Maybe you keep all files in a project open always.
My usual workflow is to keep maybe 1-15 tabs open, and close them when I don't need them for the time being (often using one of the multi-close menu items in the tab menu). I usually open documents using the ProjectOrganizer treeview, with one or two folders expanded, so there's no reason for me to keep loads of files open, every file in the project is a double-click away. It helps that I have a 4k monitor without scaling, so I can see lots of files at a glance in the sidebar.
It only adds one menu item, (and the multiple document close items should be put in a submenu as I mentioned).
If #2348 gets merged, I have no objections to this PR whatsoever, and even without, I don't feel strongly against this PR, I just most likely won't use it.
github-comments@lists.geany.org