1------------------------------------------------------------------------------ 2-- -- 3-- Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet -- 4-- Copyright (C) 2000-2015, AdaCore -- 5-- -- 6-- This library is free software; you can redistribute it and/or modify it -- 7-- under terms of the GNU General Public License as published by the Free -- 8-- Software Foundation; either version 3, or (at your option) any later -- 9-- version. This library is distributed in the hope that it will be useful, -- 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- 11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 12-- -- 13-- As a special exception under Section 7 of GPL version 3, you are granted -- 14-- additional permissions described in the GCC Runtime Library Exception, -- 15-- version 3.1, as published by the Free Software Foundation. -- 16-- -- 17-- You should have received a copy of the GNU General Public License and -- 18-- a copy of the GCC Runtime Library Exception along with this program; -- 19-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 20-- <http://www.gnu.org/licenses/>. -- 21-- -- 22------------------------------------------------------------------------------ 23 24-- <description> 25-- GtkApplicationWindow is a Gtk.Window.Gtk_Window subclass that offers some 26-- extra functionality for better integration with 27-- Gtk.Application.Gtk_Application features. Notably, it can handle both the 28-- application menu as well as the menubar. See Gtk.Application.Set_App_Menu 29-- and Gtk.Application.Set_Menubar. 30-- 31-- This class implements the Glib.Action_Group.Gaction_Group and 32-- Glib.Action_Map.Gaction_Map interfaces, to let you add window-specific 33-- actions that will be exported by the associated 34-- Gtk.Application.Gtk_Application, together with its application-wide 35-- actions. Window-specific actions are prefixed with the "win." prefix and 36-- application-wide actions are prefixed with the "app." prefix. Actions must 37-- be addressed with the prefixed name when referring to them from a 38-- Glib.Menu_Model.Gmenu_Model. 39-- 40-- Note that widgets that are placed inside a GtkApplicationWindow can also 41-- activate these actions, if they implement the GtkActionable interface. 42-- 43-- As with Gtk.Application.Gtk_Application, the GDK lock will be acquired 44-- when processing actions arriving from other processes and should therefore 45-- be held when activating actions locally (if GDK threads are enabled). 46-- 47-- The settings Gtk.Settings.Gtk_Settings:gtk-shell-shows-app-menu and 48-- Gtk.Settings.Gtk_Settings:gtk-shell-shows-menubar tell GTK+ whether the 49-- desktop environment is showing the application menu and menubar models 50-- outside the application as part of the desktop shell. For instance, on OS 51-- X, both menus will be displayed remotely; on Windows neither will be. 52-- gnome-shell (starting with version 3.4) will display the application menu, 53-- but not the menubar. 54-- 55-- If the desktop environment does not display the menubar, then 56-- Gtk.Application_Window.Gtk_Application_Window will automatically show a 57-- Gtk.Menu_Bar.Gtk_Menu_Bar for it. (see the Gtk.Application.Gtk_Application 58-- docs for some screenshots of how this looks on different platforms). This 59-- behaviour can be overridden with the 60-- Gtk.Application_Window.Gtk_Application_Window:show-menubar property. If the 61-- desktop environment does not display the application menu, then it will 62-- automatically be included in the menubar. It can also be shown as part of 63-- client-side window decorations, e.g. by using 64-- Gtk.Header_Bar.Set_Show_Close_Button. 65-- 66-- ## A GtkApplicationWindow with a menubar 67-- 68-- |[<!-- language="C" --> app = gtk_application_new (); 69-- 70-- builder = gtk_builder_new (); gtk_builder_add_from_string (builder, 71-- "<interface>" " <menu id='menubar'>" " <submenu label='_Edit'>" " <item 72-- label='_Copy' action='win.copy'/>" " <item label='_Paste' 73-- action='win.paste'/>" " </submenu>" " </menu>" "</interface>"); 74-- 75-- menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")); 76-- gtk_application_set_menubar (G_APPLICATION (app), menubar); g_object_unref 77-- (builder); 78-- 79-- ... 80-- 81-- window = gtk_application_window_new (app); ]| 82-- 83-- ## Handling fallback yourself 84-- 85-- [A simple 86-- example](https://git.gnome.org/browse/gtk+/tree/examples/sunny.c) 87-- 88-- The XML format understood by Gtk.Builder.Gtk_Builder for 89-- Glib.Menu_Model.Gmenu_Model consists of a toplevel `<menu>` element, which 90-- contains one or more `<item>` elements. Each `<item>` element contains 91-- `<attribute>` and `<link>` elements with a mandatory name attribute. 92-- `<link>` elements have the same content model as `<menu>`. 93-- 94-- Attribute values can be translated using gettext, like other 95-- Gtk.Builder.Gtk_Builder content. `<attribute>` elements can be marked for 96-- translation with a `translatable="yes"` attribute. It is also possible to 97-- specify message context and translator comments,using the context and 98-- comments attributes. To make use of this, the Gtk.Builder.Gtk_Builder must 99-- have been given the gettext domain to use. 100-- 101-- </description> 102pragma Ada_2005; 103 104pragma Warnings (Off, "*is already use-visible*"); 105with GNAT.Strings; use GNAT.Strings; 106with Glib; use Glib; 107with Glib.Action; use Glib.Action; 108with Glib.Action_Group; use Glib.Action_Group; 109with Glib.Action_Map; use Glib.Action_Map; 110with Glib.Properties; use Glib.Properties; 111with Glib.Types; use Glib.Types; 112with Glib.Variant; use Glib.Variant; 113with Gtk.Application; use Gtk.Application; 114with Gtk.Buildable; use Gtk.Buildable; 115with Gtk.Window; use Gtk.Window; 116 117package Gtk.Application_Window is 118 119 type Gtk_Application_Window_Record is new Gtk_Window_Record with null record; 120 type Gtk_Application_Window is access all Gtk_Application_Window_Record'Class; 121 122 ------------------ 123 -- Constructors -- 124 ------------------ 125 126 procedure Gtk_New 127 (Self : out Gtk_Application_Window; 128 Application : not null access Gtk.Application.Gtk_Application_Record'Class); 129 procedure Initialize 130 (Self : not null access Gtk_Application_Window_Record'Class; 131 Application : not null access Gtk.Application.Gtk_Application_Record'Class); 132 -- Creates a new Gtk.Application_Window.Gtk_Application_Window. 133 -- Since: gtk+ 3.4 134 -- "application": a Gtk.Application.Gtk_Application 135 136 function Gtk_Application_Window_New 137 (Application : not null access Gtk.Application.Gtk_Application_Record'Class) 138 return Gtk_Application_Window; 139 -- Creates a new Gtk.Application_Window.Gtk_Application_Window. 140 -- Since: gtk+ 3.4 141 -- "application": a Gtk.Application.Gtk_Application 142 143 function Get_Type return Glib.GType; 144 pragma Import (C, Get_Type, "gtk_application_window_get_type"); 145 146 ------------- 147 -- Methods -- 148 ------------- 149 150 function Get_Id 151 (Self : not null access Gtk_Application_Window_Record) return Guint; 152 -- Returns the unique ID of the window. If the window has not yet been 153 -- added to a Gtk.Application.Gtk_Application, returns `0`. 154 -- Since: gtk+ 3.6 155 156 function Get_Show_Menubar 157 (Self : not null access Gtk_Application_Window_Record) return Boolean; 158 -- Returns whether the window will display a menubar for the app menu and 159 -- menubar as needed. 160 -- Since: gtk+ 3.4 161 162 procedure Set_Show_Menubar 163 (Self : not null access Gtk_Application_Window_Record; 164 Show_Menubar : Boolean); 165 -- Sets whether the window will display a menubar for the app menu and 166 -- menubar as needed. 167 -- Since: gtk+ 3.4 168 -- "show_menubar": whether to show a menubar when needed 169 170 --------------------------------------------- 171 -- Inherited subprograms (from interfaces) -- 172 --------------------------------------------- 173 -- Methods inherited from the Buildable interface are not duplicated here 174 -- since they are meant to be used by tools, mostly. If you need to call 175 -- them, use an explicit cast through the "-" operator below. 176 177 procedure Action_Added 178 (Self : not null access Gtk_Application_Window_Record; 179 Action_Name : UTF8_String); 180 181 procedure Action_Enabled_Changed 182 (Self : not null access Gtk_Application_Window_Record; 183 Action_Name : UTF8_String; 184 Enabled : Boolean); 185 186 procedure Action_Removed 187 (Self : not null access Gtk_Application_Window_Record; 188 Action_Name : UTF8_String); 189 190 procedure Action_State_Changed 191 (Self : not null access Gtk_Application_Window_Record; 192 Action_Name : UTF8_String; 193 State : Glib.Variant.Gvariant); 194 195 procedure Activate_Action 196 (Self : not null access Gtk_Application_Window_Record; 197 Action_Name : UTF8_String; 198 Parameter : Glib.Variant.Gvariant); 199 200 procedure Change_Action_State 201 (Self : not null access Gtk_Application_Window_Record; 202 Action_Name : UTF8_String; 203 Value : Glib.Variant.Gvariant); 204 205 function Get_Action_Enabled 206 (Self : not null access Gtk_Application_Window_Record; 207 Action_Name : UTF8_String) return Boolean; 208 209 function Get_Action_Parameter_Type 210 (Self : not null access Gtk_Application_Window_Record; 211 Action_Name : UTF8_String) return Glib.Variant.Gvariant_Type; 212 213 function Get_Action_State 214 (Self : not null access Gtk_Application_Window_Record; 215 Action_Name : UTF8_String) return Glib.Variant.Gvariant; 216 217 function Get_Action_State_Hint 218 (Self : not null access Gtk_Application_Window_Record; 219 Action_Name : UTF8_String) return Glib.Variant.Gvariant; 220 221 function Get_Action_State_Type 222 (Self : not null access Gtk_Application_Window_Record; 223 Action_Name : UTF8_String) return Glib.Variant.Gvariant_Type; 224 225 function Has_Action 226 (Self : not null access Gtk_Application_Window_Record; 227 Action_Name : UTF8_String) return Boolean; 228 229 function List_Actions 230 (Self : not null access Gtk_Application_Window_Record) 231 return GNAT.Strings.String_List; 232 233 function Query_Action 234 (Self : not null access Gtk_Application_Window_Record; 235 Action_Name : UTF8_String; 236 Enabled : access Boolean; 237 Parameter_Type : access Glib.Variant.Gvariant_Type; 238 State_Type : access Glib.Variant.Gvariant_Type; 239 State_Hint : access Glib.Variant.Gvariant; 240 State : access Glib.Variant.Gvariant) return Boolean; 241 242 procedure Add_Action 243 (Self : not null access Gtk_Application_Window_Record; 244 Action : Glib.Action.Gaction); 245 246 procedure Add_Action_Entries 247 (Self : not null access Gtk_Application_Window_Record; 248 Entries : GAction_Entry_Array; 249 User_Data : System.Address := System.Null_Address); 250 251 function Lookup_Action 252 (Self : not null access Gtk_Application_Window_Record; 253 Action_Name : UTF8_String) return Glib.Action.Gaction; 254 255 procedure Remove_Action 256 (Self : not null access Gtk_Application_Window_Record; 257 Action_Name : UTF8_String); 258 259 ---------------- 260 -- Properties -- 261 ---------------- 262 -- The following properties are defined for this widget. See 263 -- Glib.Properties for more information on properties) 264 265 Show_Menubar_Property : constant Glib.Properties.Property_Boolean; 266 -- If this property is True, the window will display a menubar that 267 -- includes the app menu and menubar, unless these are shown by the desktop 268 -- shell. See Gtk.Application.Set_App_Menu and Gtk.Application.Set_Menubar. 269 -- 270 -- If False, the window will not display a menubar, regardless of whether 271 -- the desktop shell is showing the menus or not. 272 273 ---------------- 274 -- Interfaces -- 275 ---------------- 276 -- This class implements several interfaces. See Glib.Types 277 -- 278 -- - "Buildable" 279 -- 280 -- - "Gio.ActionGroup" 281 -- 282 -- - "Gio.ActionMap" 283 284 package Implements_Gtk_Buildable is new Glib.Types.Implements 285 (Gtk.Buildable.Gtk_Buildable, Gtk_Application_Window_Record, Gtk_Application_Window); 286 function "+" 287 (Widget : access Gtk_Application_Window_Record'Class) 288 return Gtk.Buildable.Gtk_Buildable 289 renames Implements_Gtk_Buildable.To_Interface; 290 function "-" 291 (Interf : Gtk.Buildable.Gtk_Buildable) 292 return Gtk_Application_Window 293 renames Implements_Gtk_Buildable.To_Object; 294 295 package Implements_Gaction_Group is new Glib.Types.Implements 296 (Glib.Action_Group.Gaction_Group, Gtk_Application_Window_Record, Gtk_Application_Window); 297 function "+" 298 (Widget : access Gtk_Application_Window_Record'Class) 299 return Glib.Action_Group.Gaction_Group 300 renames Implements_Gaction_Group.To_Interface; 301 function "-" 302 (Interf : Glib.Action_Group.Gaction_Group) 303 return Gtk_Application_Window 304 renames Implements_Gaction_Group.To_Object; 305 306 package Implements_Gaction_Map is new Glib.Types.Implements 307 (Glib.Action_Map.Gaction_Map, Gtk_Application_Window_Record, Gtk_Application_Window); 308 function "+" 309 (Widget : access Gtk_Application_Window_Record'Class) 310 return Glib.Action_Map.Gaction_Map 311 renames Implements_Gaction_Map.To_Interface; 312 function "-" 313 (Interf : Glib.Action_Map.Gaction_Map) 314 return Gtk_Application_Window 315 renames Implements_Gaction_Map.To_Object; 316 317private 318 Show_Menubar_Property : constant Glib.Properties.Property_Boolean := 319 Glib.Properties.Build ("show-menubar"); 320end Gtk.Application_Window; 321