![]() Registered Member ![]()
|
First of all, a tip to fellow Kate users-- even though the UI doesn't let you edit the menus, you can edit $HOME/.kde/share/apps/kate/kateui.rc and $HOME/.kde/share/apps/katepart/katepartui.rc. They are XML files and it seems that they define menus, and plugins can then add to those menus by specifying the same names. You can, for instance, force the enormous Tools menu to get broken up into sub-menus by nesting additional blocks inside it that enclose commands you don't want to be at the top level.
...surprising that I couldn't find the above documented anyplace. And now, here's my question. I figured out how to bury stuff in the Tools menu, but now I want to *un*bury a script I made via the External Tools plugin. Instead of having it be in "Tools"->"External Tools" I want it to be linked either to a button on the toolbar or at the top of the "Sessions" menu (because this script happens to be a workaround for Kate forgetting its session settings). Does anybody have any idea how I could do that? Either that, or perhaps someone knows a better workaround that doesn't involve scripting for Kate sometimes overwriting a .katesession file with default values without being asked to do so? |
![]() Registered Member ![]()
|
Got it! Kate gave up its secret when I assigned a keyboard shortcut to the script I created. Apparently the internal name for the script is:
"externaltool_ScriptNameWithoutSpaces" ...and it only gets explicitly added to the ui.rc if it's somehow different from all the other scripts, such as having a keyboard shortcut. So going with the dummy code conventions I posted before, if you want to add this script to the menu "original_name" in kateui.rc, you edit $HOME/.kde/share/apps/kate/plugins/kateexternaltools/ui.rc You will see some menu declarations enclosed in top-level <Menu> </Menu> tags which are in turn enclosed in <MenuBar> </MenuBar> tags. Copy and paste the declaration for "original_name" inside those menu tags (being careful not to nest them inside on of the menu declarations of course) and delete all the tags inside "original_name" except the <text></text> tag. It should look like this...
Now inside the "original_name" tags, insert the following:
So in the end, your kateexternaltools/ui.rc files looks like this:
You can add stuff to the toolbar by copying the outer set of the tags for the toolbar you want from kateui.rc, pasting those inside the <gui></gui> tags (but outside the <MenuBar></MenuBar> tags), and then again pasting the Action just like you did for the menu. It will probably look something like this...
In other words, it looks like whatever is enclosed in the same hierarchy of tags as defined in kateui.rc and katepart.rc will get added to the corresponding menu or toolbar. One last thing, at the end of my ui.rc file, just before </gui>, there are these lines:
I'm sure it's necessary to define the keyboard shortcut, but if you don't want a keyboard shortcut, I think you don't have to include it, but I'm not sure. Anyway, hope this is useful to someone, and saves them a lot of trial-and-error that went into figuring it out. Have fun! |
![]() Administrator ![]()
|
The above is known as KDE's XMLGUI framework, and is documented on KDE Techbase ( apart from the Kate specific components )
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: Bing [Bot], Evergrowing, Google [Bot]