0
votes

I am using GTKADA, for a small application, and wish to right justify the help menu on the menu bar.

The old way was to call Set_Right_justified on the new menu, but that is now obsolescent.

Apparantly I should be able to use Set_Hexpand, and Set_Halign to do this.

The code I am currently using is :-

with GTK.WIDGET;
procedure Add_Menu_To_Menu_Bar
 ( Menu_Bar        : in GTK.MENU_BAR.Gtk_Menu_Bar;
   Menu            : in GTK.MENU.Gtk_Menu;
   Label           : in string;
   Right_Justified : in boolean := False )
is
  New_Item : GTK.MENU_ITEM.Gtk_Menu_Item;
begin
  GTK.MENU_ITEM.Gtk_New( Menu_Item => New_Item,
                         Label     => Label );

  New_Item.Set_Right_Justified( Right_Justified => Right_Justified );

--  if Right_Justified then
--      -- Below is the recommended alternative to above
--      -- but dosn't work
--           New_Item.Set_Hexpand( Expand => true );
--           New_Item.Set_Hexpand_Set(Set => true );
--           New_Item.Set_Halign( Align  => GTK.WIDGET.Align_End );
--      -- Below does work, but only sets a fixed margin
--           New_Item.Set_Margin_Start(Margin => 40 );
--           New_Item.Set_Margin_End(Margin => 40 );
--     -- Below effects the entire menu bar
--           Menu_Bar.Set_Hexpand(Expand => true);
--           Menu_Bar.Set_Halign(Align => GTK.WIDGET.Align_End);
--  end if;


  GTK.MENU_ITEM.Show( New_Item );

  GTK.MENU_ITEM.Set_Submenu( New_Item, Menu );

  GTK.MENU_BAR.Append( Menu_Shell => Menu_Bar,
                       Child      => New_Item );

end Add_Menu_To_Menu_Bar;

N.B. 1. I know that this is now considered bad practice. 2. I am not using glade 3. This is on windows 10, with the GPL 2017 versions of GTK & GPS

1
Why does the recommended alternative not work? What is the actual result?flyx

1 Answers

0
votes

I have now solved this by having two menu bars, putting them in opposite sides of a Hbox, and adding the right justifed menu's to the righthand side menu bar.

However I still think this is a bit of a cludge.

N.B. The results of my attempts are shown in as comments in the code sample, basicly the obvious solution dosn't do anything...