How do I create a tearoff menu using GTKAda?
If you've added the code that you have to your question, it will be more descriptive.
I wrote some code to demonstrate using a tear-off menu with GTKAda, it's not that hard, but it can be tricky to find documentation about it:
function CreateFileMenu(tearOff : boolean) return Gtk_Menu is fileMenu : Gtk_Menu; newFile, loadFile, saveFile, saveAs, close : Gtk_Menu_Item; begin -- Create the menu: Gtk_New(fileMenu); -- Add the tear off item to the menu if required: if tearOff then declare tear : Gtk_Tearoff_Menu_Item; begin Gtk_New(tear); Append fileMenu, tear); Show(tear); end; end if; -- Create the rest of the menu items: Gtk_New_With_Mnemonic(newFile, "_New"); Gtk_New_With_Mnemonic(loadFile, "_Load"); Gtk_New_With_Mnemonic(saveFile, "_Save"); Gtk_New_With_Mnemonic(saveAs, "Save _as..."); Gtk_New_With_Mnemonic(close, "_Close"); -- Add the items to the menu: Add(fileMenu, newFile); Add(fileMenu, loadFile); Add(fileMenu, saveFile); Add(fileMenu, saveAs); Add(fileMenu, close); return fileMenu; end CreateFileMenu;
The structure declare/begin/end
allows you to declare variables at runtime.
The parameter boolean
lets you decide if you want it to be a tear-off menu when you create it. The function just creates the menu, so you'll have to add it to the menu bar (for example) later.
source to share
Not sure if this is what you are looking for, but the GtkAda reference manual says :
All menus in GtkAda can be Undo menus, that is, you can detach them from their parent (either in the menu bar or in another menu) so that they are always displayed on the screen).
It sounds like you don't have to do anything.