Hi, I'd like to propose the addition of two items in the right click menu, to open a terminal or file manager in the same directory as the current file. I often utilize these in my workflow versus the integrated terminal and tree browser, when I require something a bit more complex or something that's not one-off. But please do let me know if you also find them useful; suggestions for adjustments are welcome.
The right-click menu:
<img src="https://github.com/geany/geany/assets/31203804/ecacd2b2-7b96-49fa-b91e-118e0...; width=20%>
For the file manager command to use, I took the initiative of adding a new entry in Preferences/Tools. For the terminal, I utilized the Terminal command that's already present.
<img src="https://github.com/geany/geany/assets/31203804/2a649b9a-a6c5-4316-99f9-23195...; width=50%>
You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3813
-- Commit Summary --
* Add 'Open Terminal' and 'Open Directory' to right click menu
-- File Changes --
M data/geany.glade (513) M doc/geany.txt (6) M src/callbacks.c (74) M src/callbacks.h (4) M src/keyfile.c (51) M src/prefs.c (12) M src/prefs.h (3)
-- Patch Links --
https://github.com/geany/geany/pull/3813.patch https://github.com/geany/geany/pull/3813.diff
@elextr requested changes on this pull request.
In principle the right click menu should be context related, like the `Open Selected File` entry[^1]. So it might be better to add these new items to a normal menu, and then they can be given a keyboard accelerator and even a shortcut as well.
I suggest that adding a separate command for terminal would be better than using the existing command and substituting nothing for `%c`. There is no guarantee that will produce a valid command. There is plenty of space in the Tools Preferences page.
Which version of glade did you use? there seems to be a lot of unrelated change noise.
I have only had a quick look review so far.
[^1]: Yes yes I know it has accumulated non-context related things over the years, but thats no excuse to continue the trend.
in the command are substituted with the run script name, see
`Terminal emulators`_.
+File Manager + The command to use to open a file manager. Occurences of %d + are substituted with a directory in which to open it. +
Say _what_ is substituted for %d directory of current file or home dir if no files open, its up to the command to determine what to do with that.
@@ -73,37 +73,40 @@
/* some default settings which are used at the very first start of Geany to fill * the configuration file */ -#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 -#define GEANY_MIN_SYMBOLLIST_CHARS 4 -#define GEANY_MSGWIN_HEIGHT 208 -#define GEANY_DISK_CHECK_TIMEOUT 30 -#define GEANY_DEFAULT_TOOLS_MAKE "make" +#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 +#define GEANY_MIN_SYMBOLLIST_CHARS 4 +#define GEANY_MSGWIN_HEIGHT 208 +#define GEANY_DISK_CHECK_TIMEOUT 30 +#define GEANY_DEFAULT_TOOLS_MAKE "make"
Why all these noise changes?
gchar *term_cmd; /**< terminal emulator command */
+ gchar *file_manager_cmd; /**< file manager command */
This struct is in the plugin API, so add new fields at the end to avoid breaking the ABI, increment the API, see HACKING.
Thanks for the comments. Alright yeah I totally get not cluttering the right click menu, shall I place the entries in say the 'Tools' menu? Will also add shortcuts, and a new command in Preferences for opening the Terminal.
Indeed Glade did a bunch of changes on its own. I'm on version 3.40.0(+r14+g1fbca367) (Arch's package). Is there a specific version I should use? I saw in HACKING the recommendation for 3.8.5, but that seemed to be for GTK+ 2 purposes, which is now out of the picture, and some comments on here hinted that a higher versions may be used now (?).
@gkatev commented on this pull request.
gchar *term_cmd; /**< terminal emulator command */
+ gchar *file_manager_cmd; /**< file manager command */
My bad, will fix
@gkatev commented on this pull request.
@@ -73,37 +73,40 @@
/* some default settings which are used at the very first start of Geany to fill * the configuration file */ -#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 -#define GEANY_MIN_SYMBOLLIST_CHARS 4 -#define GEANY_MSGWIN_HEIGHT 208 -#define GEANY_DISK_CHECK_TIMEOUT 30 -#define GEANY_DEFAULT_TOOLS_MAKE "make" +#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 +#define GEANY_MIN_SYMBOLLIST_CHARS 4 +#define GEANY_MSGWIN_HEIGHT 208 +#define GEANY_DISK_CHECK_TIMEOUT 30 +#define GEANY_DEFAULT_TOOLS_MAKE "make"
These are to realign all the columns after adding `GEANY_DEFAULT_TOOLS_FILE_MANAGER` which is longer than the previous items.
@ntrel commented on this pull request.
@@ -73,37 +73,40 @@
/* some default settings which are used at the very first start of Geany to fill * the configuration file */ -#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 -#define GEANY_MIN_SYMBOLLIST_CHARS 4 -#define GEANY_MSGWIN_HEIGHT 208 -#define GEANY_DISK_CHECK_TIMEOUT 30 -#define GEANY_DEFAULT_TOOLS_MAKE "make" +#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 +#define GEANY_MIN_SYMBOLLIST_CHARS 4 +#define GEANY_MSGWIN_HEIGHT 208 +#define GEANY_DISK_CHECK_TIMEOUT 30 +#define GEANY_DEFAULT_TOOLS_MAKE "make"
Just to mention, we prefer not to realign lines when we add fields. From HACKING: ```c typedef struct Foo { gint foo; /* names are somewhat aligned visually */ gint bar; /* fields don't share the same line */ SomeLongTypeName baz; /* alignment is not strict */ ```
shall I place the entries in say the 'Tools' menu?
Well thats a short menu so a good candidate, although plugins add stuff to it too. Which raises the question, did you check that none of the plugins already does either of these? Especially Add Ons which has become a bit of a catch all :-)
Also personally I can't see the purpose for the Open terminal if its just going to open the same as if its from the desktop. Geany isn't trying to become a whole OS unlike Emacs ;-P
As for Glade, yeah, the 3.8.5 isn't relevant any more, this sort of change noise used to be a problem and 3.8.5 did fix it, thats why it was mentioned, but as to current versions, somebody else will have to advise, I havn't used Glade for years and am not sure what the minimum and maximum version is or if it has settings for a target file version.
@gkatev commented on this pull request.
@@ -73,37 +73,40 @@
/* some default settings which are used at the very first start of Geany to fill * the configuration file */ -#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 -#define GEANY_MIN_SYMBOLLIST_CHARS 4 -#define GEANY_MSGWIN_HEIGHT 208 -#define GEANY_DISK_CHECK_TIMEOUT 30 -#define GEANY_DEFAULT_TOOLS_MAKE "make" +#define GEANY_MAX_SYMBOLLIST_HEIGHT 10 +#define GEANY_MIN_SYMBOLLIST_CHARS 4 +#define GEANY_MSGWIN_HEIGHT 208 +#define GEANY_DISK_CHECK_TIMEOUT 30 +#define GEANY_DEFAULT_TOOLS_MAKE "make"
Hmm I see, well I can leave them unaligned, it's not too bad. They will no longer all be aligned, like they were before, but if that's not an issue with you it's not one with me!
So the Tree Browser plugin offers both of these choices, though it's only in the right click menu inside the tree browser sidebar. I'd definitely lean towards something with less steps; one option could be to add shortctus in Tree Browser for these two actions. But it doesn't really feel like the optimal fit? What do you think? Should this be part of an existing plugin, or even a new one?
The difference with opening a terminal or file manager from the desktop, is that this opens it inside the same directory as the file, saving a whole lot of time compared to manually navigating to the same directory.
Opening a terminal in the same directory as the file I find useful for all sorts of things (and do actually use it heavily!). Simple examples are git stuff, grepping, building/running. And while all this can theoretically be achieved from the integrated terminal and the tree browser, I find the external tools more convenient especially for more complex tasks. And I do tend to generally keep them open at the side rather than close immediately close them.
I'm leaning towards creating a new plugin for this, one I'd also be willing to contribute to geany-plugins. Would you say that this indeed sounds like the best option?
The difference with opening a terminal or file manager from the desktop, is that this opens it inside the same directory as the file, saving a whole lot of time compared to manually navigating to the same directory.
I knew that the file manager opened in the current file directory, but I didn't think terminal did, which is why I asked.
I'm leaning towards creating a new plugin for this, one I'd also be willing to contribute to geany-plugins. Would you say that this indeed sounds like the best option?
Yes, especially if it is fairly general to "Run Commands".
ATM Geany can run commands:
1. custom commands that get the buffer/selection in their stdin and the buffer/selection is replaced by their stdout, can have 10 IIRC, or 2. run a grep compatible command and show results in the message window, or 3. build commands where the stdout is scanned for errors and shown in the compiler tab, or 4. execute comands that are run in a script in a terminal so their stdout is shown to the user.
All of these wait for completion, AFAIR there is no way to just run commands and forget about them.
So a plugin that allowed commands to be configured that would just be run and forgotten would be useful. If it had a fixed number like custom commands it should be possible to have a keybinding section for the plugin so you could have shortcuts for the commands, fixed because the keybinding GUI doesn't handle variable numbers of entries after loading which is why extra build commands can't have keybindings, only the fixed minimum entries. A single "Run Commands" menu item could be added to tools with the actual commands as a submenu.
Gold star for configuration GUI to define the commands.
Extra points for %c %d type substitutions in commands like build commands do.
Closed #3813.
Closing in favor of https://github.com/geany/geany-plugins/pull/1325
github-comments@lists.geany.org