1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GtkUIManager.html 27 * outPack = gtk 28 * outFile = UIManager 29 * strct = GtkUIManager 30 * realStrct= 31 * ctorStrct= 32 * clss = UIManager 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - BuildableIF 40 * prefixes: 41 * - gtk_ui_manager_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - gtk_ui_manager_get_widget 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - glib.ErrorG 50 * - glib.GException 51 * - glib.ListG 52 * - glib.ListSG 53 * - gobject.Type 54 * - gtk.AccelGroup 55 * - gtk.Action 56 * - gtk.ActionGroup 57 * - gtk.CheckMenuItem 58 * - gtk.ImageMenuItem 59 * - gtk.Menu 60 * - gtk.MenuBar 61 * - gtk.MenuItem 62 * - gtk.MenuToolButton 63 * - gtk.RadioMenuItem 64 * - gtk.RadioToolButton 65 * - gtk.SeparatorMenuItem 66 * - gtk.SeparatorToolItem 67 * - gtk.TearoffMenuItem 68 * - gtk.ToggleToolButton 69 * - gtk.Toolbar 70 * - gtk.ToolButton 71 * - gtk.ToolItem 72 * - gtk.Widget 73 * - gtk.BuildableIF 74 * - gtk.BuildableT 75 * structWrap: 76 * - GList* -> ListG 77 * - GSList* -> ListSG 78 * - GtkAccelGroup* -> AccelGroup 79 * - GtkAction* -> Action 80 * - GtkActionGroup* -> ActionGroup 81 * - GtkWidget* -> Widget 82 * module aliases: 83 * local aliases: 84 * overrides: 85 */ 86 87 module gtk.UIManager; 88 89 public import gtkc.gtktypes; 90 91 private import gtkc.gtk; 92 private import glib.ConstructionException; 93 private import gobject.ObjectG; 94 95 private import gobject.Signals; 96 public import gtkc.gdktypes; 97 private import glib.Str; 98 private import glib.ErrorG; 99 private import glib.GException; 100 private import glib.ListG; 101 private import glib.ListSG; 102 private import gobject.Type; 103 private import gtk.AccelGroup; 104 private import gtk.Action; 105 private import gtk.ActionGroup; 106 private import gtk.CheckMenuItem; 107 private import gtk.ImageMenuItem; 108 private import gtk.Menu; 109 private import gtk.MenuBar; 110 private import gtk.MenuItem; 111 private import gtk.MenuToolButton; 112 private import gtk.RadioMenuItem; 113 private import gtk.RadioToolButton; 114 private import gtk.SeparatorMenuItem; 115 private import gtk.SeparatorToolItem; 116 private import gtk.TearoffMenuItem; 117 private import gtk.ToggleToolButton; 118 private import gtk.Toolbar; 119 private import gtk.ToolButton; 120 private import gtk.ToolItem; 121 private import gtk.Widget; 122 private import gtk.BuildableIF; 123 private import gtk.BuildableT; 124 125 126 private import gobject.ObjectG; 127 128 /** 129 * A GtkUIManager constructs a user interface (menus and toolbars) from 130 * one or more UI definitions, which reference actions from one or more 131 * action groups. 132 * 133 * UI Definitions 134 * 135 * The UI definitions are specified in an XML format which can be 136 * roughly described by the following DTD. 137 * 138 * Note 139 * 140 * Do not confuse the GtkUIManager UI Definitions described here with 141 * the similarly named GtkBuilder UI 142 * Definitions. 143 * 144 * <!ELEMENT ui (menubar|toolbar|popup|accelerator)* > 145 * <!ELEMENT menubar (menuitem|separator|placeholder|menu)* > 146 * <!ELEMENT menu (menuitem|separator|placeholder|menu)* > 147 * <!ELEMENT popup (menuitem|separator|placeholder|menu)* > 148 * <!ELEMENT toolbar (toolitem|separator|placeholder)* > 149 * <!ELEMENT placeholder (menuitem|toolitem|separator|placeholder|menu)* > 150 * <!ELEMENT menuitem EMPTY > 151 * <!ELEMENT toolitem (menu?) > 152 * <!ELEMENT separator EMPTY > 153 * <!ELEMENT accelerator EMPTY > 154 * <!ATTLIST menubar name #IMPLIED 155 * action #IMPLIED > 156 * <!ATTLIST toolbar name #IMPLIED 157 * action #IMPLIED > 158 * <!ATTLIST popup name #IMPLIED 159 * action #IMPLIED 160 * accelerators (true|false) #IMPLIED > 161 * <!ATTLIST placeholder name #IMPLIED 162 * action #IMPLIED > 163 * <!ATTLIST separator name #IMPLIED 164 * action #IMPLIED 165 * expand (true|false) #IMPLIED > 166 * <!ATTLIST menu name #IMPLIED 167 * action #REQUIRED 168 * position (top|bot) #IMPLIED > 169 * <!ATTLIST menuitem name #IMPLIED 170 * action #REQUIRED 171 * position (top|bot) #IMPLIED 172 * always-show-image (true|false) #IMPLIED > 173 * <!ATTLIST toolitem name #IMPLIED 174 * action #REQUIRED 175 * position (top|bot) #IMPLIED > 176 * <!ATTLIST accelerator name #IMPLIED 177 * action #REQUIRED > 178 * 179 * There are some additional restrictions beyond those specified in the 180 * DTD, e.g. every toolitem must have a toolbar in its anchestry and 181 * every menuitem must have a menubar or popup in its anchestry. Since 182 * a GMarkup parser is used to parse the UI description, it must not only 183 * be valid XML, but valid GMarkup. 184 * 185 * If a name is not specified, it defaults to the action. If an action is 186 * not specified either, the element name is used. The name and action 187 * attributes must not contain '/' characters after parsing (since that 188 * would mess up path lookup) and must be usable as XML attributes when 189 * enclosed in doublequotes, thus they must not '"' characters or references 190 * to the " entity. 191 * 192 * $(DDOC_COMMENT example) 193 * 194 * The constructed widget hierarchy is very similar to the element tree 195 * of the XML, with the exception that placeholders are merged into their 196 * parents. The correspondence of XML elements to widgets should be 197 * almost obvious: 198 * 199 * menubar 200 * 201 * a GtkMenuBar 202 * 203 * toolbar 204 * 205 * a GtkToolbar 206 * 207 * popup 208 * 209 * a toplevel GtkMenu 210 * 211 * menu 212 * 213 * a GtkMenu attached to a menuitem 214 * 215 * menuitem 216 * 217 * a GtkMenuItem subclass, the exact type depends on the 218 * action 219 * 220 * toolitem 221 * 222 * a GtkToolItem subclass, the exact type depends on the 223 * action. Note that toolitem elements may contain a menu element, but only 224 * if their associated action specifies a GtkMenuToolButton as proxy. 225 * 226 * separator 227 * 228 * a GtkSeparatorMenuItem or 229 * GtkSeparatorToolItem 230 * 231 * accelerator 232 * 233 * a keyboard accelerator 234 * 235 * The "position" attribute determines where a constructed widget is positioned 236 * wrt. to its siblings in the partially constructed tree. If it is 237 * "top", the widget is prepended, otherwise it is appended. 238 * 239 * <hr> 240 * 241 * UI Merging 242 * 243 * The most remarkable feature of GtkUIManager is that it can overlay a set 244 * of menuitems and toolitems over another one, and demerge them later. 245 * 246 * Merging is done based on the names of the XML elements. Each element is 247 * identified by a path which consists of the names of its anchestors, separated 248 * by slashes. For example, the menuitem named "Left" in the example above 249 * has the path /ui/menubar/JustifyMenu/Left and the 250 * toolitem with the same name has path 251 * /ui/toolbar1/JustifyToolItems/Left. 252 * 253 * <hr> 254 * 255 * Accelerators 256 * 257 * Every action has an accelerator path. Accelerators are installed together with 258 * menuitem proxies, but they can also be explicitly added with <accelerator> 259 * elements in the UI definition. This makes it possible to have accelerators for 260 * actions even if they have no visible proxies. 261 * 262 * <hr> 263 * 264 * Smart Separators 265 * 266 * The separators created by GtkUIManager are "smart", i.e. they do not show up 267 * in the UI unless they end up between two visible menu or tool items. Separators 268 * which are located at the very beginning or end of the menu or toolbar 269 * containing them, or multiple separators next to each other, are hidden. This 270 * is a useful feature, since the merging of UI elements from multiple sources 271 * can make it hard or impossible to determine in advance whether a separator 272 * will end up in such an unfortunate position. 273 * 274 * For separators in toolbars, you can set expand="true" to 275 * turn them from a small, visible separator to an expanding, invisible one. 276 * Toolitems following an expanding separator are effectively right-aligned. 277 * 278 * <hr> 279 * 280 * Empty Menus 281 * 282 * Submenus pose similar problems to separators inconnection with merging. It is 283 * impossible to know in advance whether they will end up empty after merging. 284 * GtkUIManager offers two ways to treat empty submenus: 285 * 286 * make them disappear by hiding the menu item they're attached to 287 * 288 * add an insensitive "Empty" item 289 * 290 * The behaviour is chosen based on the "hide_if_empty" property of the action 291 * to which the submenu is associated. 292 * 293 * <hr> 294 * 295 * GtkUIManager as GtkBuildable 296 * 297 * The GtkUIManager implementation of the GtkBuildable interface accepts 298 * GtkActionGroup objects as <child> elements in UI definitions. 299 * 300 * A GtkUIManager UI definition as described above can be embedded in 301 * an GtkUIManager <object> element in a GtkBuilder UI definition. 302 * 303 * The widgets that are constructed by a GtkUIManager can be embedded in 304 * other parts of the constructed user interface with the help of the 305 * "constructor" attribute. See the example below. 306 * 307 * $(DDOC_COMMENT example) 308 */ 309 public class UIManager : ObjectG, BuildableIF 310 { 311 312 /** the main Gtk struct */ 313 protected GtkUIManager* gtkUIManager; 314 315 316 /** Get the main Gtk struct */ 317 public GtkUIManager* getUIManagerStruct() 318 { 319 return gtkUIManager; 320 } 321 322 323 /** the main Gtk struct as a void* */ 324 protected override void* getStruct() 325 { 326 return cast(void*)gtkUIManager; 327 } 328 329 /** 330 * Sets our main struct and passes it to the parent class 331 */ 332 public this (GtkUIManager* gtkUIManager) 333 { 334 super(cast(GObject*)gtkUIManager); 335 this.gtkUIManager = gtkUIManager; 336 } 337 338 protected override void setStruct(GObject* obj) 339 { 340 super.setStruct(obj); 341 gtkUIManager = cast(GtkUIManager*)obj; 342 } 343 344 // add the Buildable capabilities 345 mixin BuildableT!(GtkUIManager); 346 347 /** 348 * Warning: getWidget is deprecated and should not be used in newly-written code. 3.10 349 * 350 * Looks up a widget by following a path. 351 * The path consists of the names specified in the XML description of the UI. 352 * separated by '/'. Elements which don't have a name or action attribute in 353 * the XML (e.g. <popup>) can be addressed by their XML element name 354 * (e.g. "popup"). The root element ("/ui") can be omitted in the path. 355 * 356 * Note that the widget found by following a path that ends in a <menu> 357 * element is the menuitem to which the menu is attached, not the menu itself. 358 * 359 * Also note that the widgets constructed by a ui manager are not tied to 360 * the lifecycle of the ui manager. If you add the widgets returned by this 361 * function to some container or explicitly ref them, they will survive the 362 * destruction of the ui manager. 363 * 364 * Since 2.4 365 * 366 * Params: 367 * path = a path 368 * 369 * Returns: the widget found by following the path, or null if no widget was found. 370 */ 371 public Widget getWidget(string path) 372 { 373 // GtkWidget * gtk_ui_manager_get_widget (GtkUIManager *manager, const gchar *path); 374 auto p = gtk_ui_manager_get_widget(gtkUIManager, Str.toStringz(path)); 375 376 if(p is null) 377 { 378 return null; 379 } 380 381 string typeName = Type.name((cast(GTypeInstance*)p).gClass.gType); 382 383 switch(typeName) 384 { 385 case "GtkCheckMenuItem": 386 return ObjectG.getDObject!(CheckMenuItem)(cast(GtkCheckMenuItem*) p); 387 case "GtkImageMenuItem": 388 return ObjectG.getDObject!(ImageMenuItem)(cast(GtkImageMenuItem*) p); 389 case "GtkMenu": 390 return ObjectG.getDObject!(Menu)(cast(GtkMenu*) p); 391 case "GtkMenuBar": 392 return ObjectG.getDObject!(MenuBar)(cast(GtkMenuBar*) p); 393 case "GtkMenuItem": 394 return ObjectG.getDObject!(MenuItem)(cast(GtkMenuItem*) p); 395 case "GtkMenuToolButton": 396 return ObjectG.getDObject!(MenuToolButton)(cast(GtkMenuToolButton*) p); 397 case "GtkRadioMenuItem": 398 return ObjectG.getDObject!(RadioMenuItem)(cast(GtkRadioMenuItem*) p); 399 case "GtkRadioToolButton": 400 return ObjectG.getDObject!(RadioToolButton)(cast(GtkRadioToolButton*) p); 401 case "GtkSeparatorMenuItem": 402 return ObjectG.getDObject!(SeparatorMenuItem)(cast(GtkSeparatorMenuItem*) p); 403 case "GtkSeparatorToolItem": 404 return ObjectG.getDObject!(SeparatorToolItem)(cast(GtkSeparatorToolItem*) p); 405 case "GtkTearoffMenuItem": 406 return ObjectG.getDObject!(TearoffMenuItem)(cast(GtkTearoffMenuItem*) p); 407 case "GtkToggleToolButton": 408 return ObjectG.getDObject!(ToggleToolButton)(cast(GtkToggleToolButton*) p); 409 case "GtkToolbar": 410 return ObjectG.getDObject!(Toolbar)(cast(GtkToolbar*) p); 411 case "GtkToolButton": 412 return ObjectG.getDObject!(ToolButton)(cast(GtkToolButton*) p); 413 case "GtkToolItem": 414 return ObjectG.getDObject!(ToolItem)(cast(GtkToolItem*) p); 415 default: 416 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 417 } 418 } 419 420 /** 421 */ 422 int[string] connectedSignals; 423 424 void delegate(UIManager)[] onActionsChangedListeners; 425 /** 426 * Warning 427 * GtkUIManager::actions-changed is deprecated and should not be used in newly-written code. 3.10 428 * The ::actions-changed signal is emitted whenever the set of actions 429 * changes. 430 * Since 2.4 431 */ 432 void addOnActionsChanged(void delegate(UIManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 433 { 434 if ( !("actions-changed" in connectedSignals) ) 435 { 436 Signals.connectData( 437 getStruct(), 438 "actions-changed", 439 cast(GCallback)&callBackActionsChanged, 440 cast(void*)this, 441 null, 442 connectFlags); 443 connectedSignals["actions-changed"] = 1; 444 } 445 onActionsChangedListeners ~= dlg; 446 } 447 extern(C) static void callBackActionsChanged(GtkUIManager* managerStruct, UIManager _uIManager) 448 { 449 foreach ( void delegate(UIManager) dlg ; _uIManager.onActionsChangedListeners ) 450 { 451 dlg(_uIManager); 452 } 453 } 454 455 void delegate(Widget, UIManager)[] onAddWidgetListeners; 456 /** 457 * Warning 458 * GtkUIManager::add-widget is deprecated and should not be used in newly-written code. 3.10 459 * The ::add-widget signal is emitted for each generated menubar and toolbar. 460 * It is not emitted for generated popup menus, which can be obtained by 461 * gtk_ui_manager_get_widget(). 462 * Since 2.4 463 */ 464 void addOnAddWidget(void delegate(Widget, UIManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 465 { 466 if ( !("add-widget" in connectedSignals) ) 467 { 468 Signals.connectData( 469 getStruct(), 470 "add-widget", 471 cast(GCallback)&callBackAddWidget, 472 cast(void*)this, 473 null, 474 connectFlags); 475 connectedSignals["add-widget"] = 1; 476 } 477 onAddWidgetListeners ~= dlg; 478 } 479 extern(C) static void callBackAddWidget(GtkUIManager* managerStruct, GtkWidget* widget, UIManager _uIManager) 480 { 481 foreach ( void delegate(Widget, UIManager) dlg ; _uIManager.onAddWidgetListeners ) 482 { 483 dlg(ObjectG.getDObject!(Widget)(widget), _uIManager); 484 } 485 } 486 487 void delegate(Action, Widget, UIManager)[] onConnectProxyListeners; 488 /** 489 * Warning 490 * GtkUIManager::connect-proxy is deprecated and should not be used in newly-written code. 3.10 491 * The ::connect-proxy signal is emitted after connecting a proxy to 492 * an action in the group. 493 * This is intended for simple customizations for which a custom action 494 * class would be too clumsy, e.g. showing tooltips for menuitems in the 495 * statusbar. 496 * Since 2.4 497 */ 498 void addOnConnectProxy(void delegate(Action, Widget, UIManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 499 { 500 if ( !("connect-proxy" in connectedSignals) ) 501 { 502 Signals.connectData( 503 getStruct(), 504 "connect-proxy", 505 cast(GCallback)&callBackConnectProxy, 506 cast(void*)this, 507 null, 508 connectFlags); 509 connectedSignals["connect-proxy"] = 1; 510 } 511 onConnectProxyListeners ~= dlg; 512 } 513 extern(C) static void callBackConnectProxy(GtkUIManager* managerStruct, GtkAction* action, GtkWidget* proxy, UIManager _uIManager) 514 { 515 foreach ( void delegate(Action, Widget, UIManager) dlg ; _uIManager.onConnectProxyListeners ) 516 { 517 dlg(ObjectG.getDObject!(Action)(action), ObjectG.getDObject!(Widget)(proxy), _uIManager); 518 } 519 } 520 521 void delegate(Action, Widget, UIManager)[] onDisconnectProxyListeners; 522 /** 523 * Warning 524 * GtkUIManager::disconnect-proxy is deprecated and should not be used in newly-written code. 3.10 525 * The ::disconnect-proxy signal is emitted after disconnecting a proxy 526 * from an action in the group. 527 * Since 2.4 528 */ 529 void addOnDisconnectProxy(void delegate(Action, Widget, UIManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 530 { 531 if ( !("disconnect-proxy" in connectedSignals) ) 532 { 533 Signals.connectData( 534 getStruct(), 535 "disconnect-proxy", 536 cast(GCallback)&callBackDisconnectProxy, 537 cast(void*)this, 538 null, 539 connectFlags); 540 connectedSignals["disconnect-proxy"] = 1; 541 } 542 onDisconnectProxyListeners ~= dlg; 543 } 544 extern(C) static void callBackDisconnectProxy(GtkUIManager* managerStruct, GtkAction* action, GtkWidget* proxy, UIManager _uIManager) 545 { 546 foreach ( void delegate(Action, Widget, UIManager) dlg ; _uIManager.onDisconnectProxyListeners ) 547 { 548 dlg(ObjectG.getDObject!(Action)(action), ObjectG.getDObject!(Widget)(proxy), _uIManager); 549 } 550 } 551 552 void delegate(Action, UIManager)[] onPostActivateListeners; 553 /** 554 * Warning 555 * GtkUIManager::post-activate is deprecated and should not be used in newly-written code. 3.10 556 * The ::post-activate signal is emitted just after the action 557 * is activated. 558 * This is intended for applications to get notification 559 * just after any action is activated. 560 * Since 2.4 561 */ 562 void addOnPostActivate(void delegate(Action, UIManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 563 { 564 if ( !("post-activate" in connectedSignals) ) 565 { 566 Signals.connectData( 567 getStruct(), 568 "post-activate", 569 cast(GCallback)&callBackPostActivate, 570 cast(void*)this, 571 null, 572 connectFlags); 573 connectedSignals["post-activate"] = 1; 574 } 575 onPostActivateListeners ~= dlg; 576 } 577 extern(C) static void callBackPostActivate(GtkUIManager* managerStruct, GtkAction* action, UIManager _uIManager) 578 { 579 foreach ( void delegate(Action, UIManager) dlg ; _uIManager.onPostActivateListeners ) 580 { 581 dlg(ObjectG.getDObject!(Action)(action), _uIManager); 582 } 583 } 584 585 void delegate(Action, UIManager)[] onPreActivateListeners; 586 /** 587 * Warning 588 * GtkUIManager::pre-activate is deprecated and should not be used in newly-written code. 3.10 589 * The ::pre-activate signal is emitted just before the action 590 * is activated. 591 * This is intended for applications to get notification 592 * just before any action is activated. 593 * Since 2.4 594 * See Also 595 * GtkBuilder 596 */ 597 void addOnPreActivate(void delegate(Action, UIManager) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 598 { 599 if ( !("pre-activate" in connectedSignals) ) 600 { 601 Signals.connectData( 602 getStruct(), 603 "pre-activate", 604 cast(GCallback)&callBackPreActivate, 605 cast(void*)this, 606 null, 607 connectFlags); 608 connectedSignals["pre-activate"] = 1; 609 } 610 onPreActivateListeners ~= dlg; 611 } 612 extern(C) static void callBackPreActivate(GtkUIManager* managerStruct, GtkAction* action, UIManager _uIManager) 613 { 614 foreach ( void delegate(Action, UIManager) dlg ; _uIManager.onPreActivateListeners ) 615 { 616 dlg(ObjectG.getDObject!(Action)(action), _uIManager); 617 } 618 } 619 620 621 /** 622 * Warning 623 * gtk_ui_manager_new is deprecated and should not be used in newly-written code. 3.10 624 * Creates a new ui manager object. 625 * Since 2.4 626 * Throws: ConstructionException GTK+ fails to create the object. 627 */ 628 public this () 629 { 630 // GtkUIManager * gtk_ui_manager_new (void); 631 auto p = gtk_ui_manager_new(); 632 if(p is null) 633 { 634 throw new ConstructionException("null returned by gtk_ui_manager_new()"); 635 } 636 this(cast(GtkUIManager*) p); 637 } 638 639 /** 640 * Warning 641 * gtk_ui_manager_set_add_tearoffs has been deprecated since version 3.4 and should not be used in newly-written code. Tearoff menus are deprecated and should not 642 * be used in newly written code. 643 * Sets the "add_tearoffs" property, which controls whether menus 644 * generated by this GtkUIManager will have tearoff menu items. 645 * Note that this only affects regular menus. Generated popup 646 * menus never have tearoff menu items. 647 * Since 2.4 648 * Params: 649 * addTearoffs = whether tearoff menu items are added 650 */ 651 public void setAddTearoffs(int addTearoffs) 652 { 653 // void gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager, gboolean add_tearoffs); 654 gtk_ui_manager_set_add_tearoffs(gtkUIManager, addTearoffs); 655 } 656 657 /** 658 * Warning 659 * gtk_ui_manager_get_add_tearoffs has been deprecated since version 3.4 and should not be used in newly-written code. Tearoff menus are deprecated and should not 660 * be used in newly written code. 661 * Returns whether menus generated by this GtkUIManager 662 * will have tearoff menu items. 663 * Since 2.4 664 * Returns: whether tearoff menu items are added 665 */ 666 public int getAddTearoffs() 667 { 668 // gboolean gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager); 669 return gtk_ui_manager_get_add_tearoffs(gtkUIManager); 670 } 671 672 /** 673 * Warning 674 * gtk_ui_manager_insert_action_group is deprecated and should not be used in newly-written code. 3.10 675 * Inserts an action group into the list of action groups associated 676 * with manager. Actions in earlier groups hide actions with the same 677 * name in later groups. 678 * If pos is larger than the number of action groups in manager, or 679 * negative, action_group will be inserted at the end of the internal 680 * list. 681 * Since 2.4 682 * Params: 683 * actionGroup = the action group to be inserted 684 * pos = the position at which the group will be inserted. 685 */ 686 public void insertActionGroup(ActionGroup actionGroup, int pos) 687 { 688 // void gtk_ui_manager_insert_action_group (GtkUIManager *manager, GtkActionGroup *action_group, gint pos); 689 gtk_ui_manager_insert_action_group(gtkUIManager, (actionGroup is null) ? null : actionGroup.getActionGroupStruct(), pos); 690 } 691 692 /** 693 * Warning 694 * gtk_ui_manager_remove_action_group is deprecated and should not be used in newly-written code. 3.10 695 * Removes an action group from the list of action groups associated 696 * with manager. 697 * Since 2.4 698 * Params: 699 * actionGroup = the action group to be removed 700 */ 701 public void removeActionGroup(ActionGroup actionGroup) 702 { 703 // void gtk_ui_manager_remove_action_group (GtkUIManager *manager, GtkActionGroup *action_group); 704 gtk_ui_manager_remove_action_group(gtkUIManager, (actionGroup is null) ? null : actionGroup.getActionGroupStruct()); 705 } 706 707 /** 708 * Warning 709 * gtk_ui_manager_get_action_groups is deprecated and should not be used in newly-written code. 3.10 710 * Returns the list of action groups associated with manager. 711 * Since 2.4 712 * Returns: a GList of action groups. The list is owned by GTK+ and should not be modified. [element-type GtkActionGroup][transfer none] 713 */ 714 public ListG getActionGroups() 715 { 716 // GList * gtk_ui_manager_get_action_groups (GtkUIManager *manager); 717 auto p = gtk_ui_manager_get_action_groups(gtkUIManager); 718 719 if(p is null) 720 { 721 return null; 722 } 723 724 return ObjectG.getDObject!(ListG)(cast(GList*) p); 725 } 726 727 /** 728 * Warning 729 * gtk_ui_manager_get_accel_group is deprecated and should not be used in newly-written code. 3.10 730 * Returns the GtkAccelGroup associated with manager. 731 * Since 2.4 732 * Returns: the GtkAccelGroup. [transfer none] 733 */ 734 public AccelGroup getAccelGroup() 735 { 736 // GtkAccelGroup * gtk_ui_manager_get_accel_group (GtkUIManager *manager); 737 auto p = gtk_ui_manager_get_accel_group(gtkUIManager); 738 739 if(p is null) 740 { 741 return null; 742 } 743 744 return ObjectG.getDObject!(AccelGroup)(cast(GtkAccelGroup*) p); 745 } 746 747 /** 748 * Warning 749 * gtk_ui_manager_get_toplevels is deprecated and should not be used in newly-written code. 3.10 750 * Obtains a list of all toplevel widgets of the requested types. 751 * Since 2.4 752 * Params: 753 * types = specifies the types of toplevel widgets to include. Allowed 754 * types are GTK_UI_MANAGER_MENUBAR, GTK_UI_MANAGER_TOOLBAR and 755 * GTK_UI_MANAGER_POPUP. 756 * Returns: a newly-allocated GSList of all toplevel widgets of the requested types. Free the returned list with g_slist_free(). [element-type GtkWidget][transfer container] 757 */ 758 public ListSG getToplevels(GtkUIManagerItemType types) 759 { 760 // GSList * gtk_ui_manager_get_toplevels (GtkUIManager *manager, GtkUIManagerItemType types); 761 auto p = gtk_ui_manager_get_toplevels(gtkUIManager, types); 762 763 if(p is null) 764 { 765 return null; 766 } 767 768 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 769 } 770 771 /** 772 * Warning 773 * gtk_ui_manager_get_action is deprecated and should not be used in newly-written code. 3.10 774 * Looks up an action by following a path. See gtk_ui_manager_get_widget() 775 * for more information about paths. 776 * Since 2.4 777 * Params: 778 * path = a path 779 * Returns: the action whose proxy widget is found by following the path, or NULL if no widget was found. [transfer none] 780 */ 781 public Action getAction(string path) 782 { 783 // GtkAction * gtk_ui_manager_get_action (GtkUIManager *manager, const gchar *path); 784 auto p = gtk_ui_manager_get_action(gtkUIManager, Str.toStringz(path)); 785 786 if(p is null) 787 { 788 return null; 789 } 790 791 return ObjectG.getDObject!(Action)(cast(GtkAction*) p); 792 } 793 794 /** 795 * Warning 796 * gtk_ui_manager_add_ui_from_resource is deprecated and should not be used in newly-written code. 3.10 797 * Parses a resource file containing a UI definition and 798 * merges it with the current contents of manager. 799 * Params: 800 * resourcePath = the resource path of the file to parse 801 * Returns: The merge id for the merged UI. The merge id can be used to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, the return value is 0. Since 3.4 802 * Throws: GException on failure. 803 */ 804 public uint addUiFromResource(string resourcePath) 805 { 806 // guint gtk_ui_manager_add_ui_from_resource (GtkUIManager *manager, const gchar *resource_path, GError **error); 807 GError* err = null; 808 809 auto p = gtk_ui_manager_add_ui_from_resource(gtkUIManager, Str.toStringz(resourcePath), &err); 810 811 if (err !is null) 812 { 813 throw new GException( new ErrorG(err) ); 814 } 815 816 return p; 817 } 818 819 /** 820 * Warning 821 * gtk_ui_manager_add_ui_from_string is deprecated and should not be used in newly-written code. 3.10 822 * Parses a string containing a UI definition and 823 * merges it with the current contents of manager. An enclosing <ui> 824 * element is added if it is missing. 825 * Since 2.4 826 * Params: 827 * buffer = the string to parse 828 * Returns: The merge id for the merged UI. The merge id can be used to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, the return value is 0. 829 * Throws: GException on failure. 830 */ 831 public uint addUiFromString(string buffer) 832 { 833 // guint gtk_ui_manager_add_ui_from_string (GtkUIManager *manager, const gchar *buffer, gssize length, GError **error); 834 GError* err = null; 835 836 auto p = gtk_ui_manager_add_ui_from_string(gtkUIManager, cast(char*)buffer.ptr, cast(int) buffer.length, &err); 837 838 if (err !is null) 839 { 840 throw new GException( new ErrorG(err) ); 841 } 842 843 return p; 844 } 845 846 /** 847 * Warning 848 * gtk_ui_manager_add_ui_from_file is deprecated and should not be used in newly-written code. 3.10 849 * Parses a file containing a UI definition and 850 * merges it with the current contents of manager. 851 * Since 2.4 852 * Params: 853 * filename = the name of the file to parse. [type filename] 854 * Returns: The merge id for the merged UI. The merge id can be used to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred, the return value is 0. 855 * Throws: GException on failure. 856 */ 857 public uint addUiFromFile(string filename) 858 { 859 // guint gtk_ui_manager_add_ui_from_file (GtkUIManager *manager, const gchar *filename, GError **error); 860 GError* err = null; 861 862 auto p = gtk_ui_manager_add_ui_from_file(gtkUIManager, Str.toStringz(filename), &err); 863 864 if (err !is null) 865 { 866 throw new GException( new ErrorG(err) ); 867 } 868 869 return p; 870 } 871 872 /** 873 * Warning 874 * gtk_ui_manager_new_merge_id is deprecated and should not be used in newly-written code. 3.10 875 * Returns an unused merge id, suitable for use with 876 * gtk_ui_manager_add_ui(). 877 * Since 2.4 878 * Returns: an unused merge id. 879 */ 880 public uint newMergeId() 881 { 882 // guint gtk_ui_manager_new_merge_id (GtkUIManager *manager); 883 return gtk_ui_manager_new_merge_id(gtkUIManager); 884 } 885 886 /** 887 * Warning 888 * gtk_ui_manager_add_ui is deprecated and should not be used in newly-written code. 3.10 889 * Adds a UI element to the current contents of manager. 890 * If type is GTK_UI_MANAGER_AUTO, GTK+ inserts a menuitem, toolitem or 891 * separator if such an element can be inserted at the place determined by 892 * path. Otherwise type must indicate an element that can be inserted at 893 * the place determined by path. 894 * If path points to a menuitem or toolitem, the new element will be inserted 895 * before or after this item, depending on top. 896 * Since 2.4 897 * Params: 898 * mergeId = the merge id for the merged UI, see gtk_ui_manager_new_merge_id() 899 * path = a path 900 * name = the name for the added UI element 901 * action = the name of the action to be proxied, or NULL to add a separator. [allow-none] 902 * type = the type of UI element to add. 903 * top = if TRUE, the UI element is added before its siblings, otherwise it 904 * is added after its siblings. 905 */ 906 public void addUi(uint mergeId, string path, string name, string action, GtkUIManagerItemType type, int top) 907 { 908 // void gtk_ui_manager_add_ui (GtkUIManager *manager, guint merge_id, const gchar *path, const gchar *name, const gchar *action, GtkUIManagerItemType type, gboolean top); 909 gtk_ui_manager_add_ui(gtkUIManager, mergeId, Str.toStringz(path), Str.toStringz(name), Str.toStringz(action), type, top); 910 } 911 912 /** 913 * Warning 914 * gtk_ui_manager_remove_ui is deprecated and should not be used in newly-written code. 3.10 915 * Unmerges the part of managers content identified by merge_id. 916 * Since 2.4 917 * Params: 918 * mergeId = a merge id as returned by gtk_ui_manager_add_ui_from_string() 919 */ 920 public void removeUi(uint mergeId) 921 { 922 // void gtk_ui_manager_remove_ui (GtkUIManager *manager, guint merge_id); 923 gtk_ui_manager_remove_ui(gtkUIManager, mergeId); 924 } 925 926 /** 927 * Warning 928 * gtk_ui_manager_get_ui is deprecated and should not be used in newly-written code. 3.10 929 * Creates a UI definition of the merged UI. 930 * Since 2.4 931 * Returns: A newly allocated string containing an XML representation of the merged UI. 932 */ 933 public string getUi() 934 { 935 // gchar * gtk_ui_manager_get_ui (GtkUIManager *manager); 936 return Str.toString(gtk_ui_manager_get_ui(gtkUIManager)); 937 } 938 939 /** 940 * Warning 941 * gtk_ui_manager_ensure_update is deprecated and should not be used in newly-written code. 3.10 942 * Makes sure that all pending updates to the UI have been completed. 943 * This may occasionally be necessary, since GtkUIManager updates the 944 * UI in an idle function. A typical example where this function is 945 * useful is to enforce that the menubar and toolbar have been added to 946 * Since 2.4 947 */ 948 public void ensureUpdate() 949 { 950 // void gtk_ui_manager_ensure_update (GtkUIManager *manager); 951 gtk_ui_manager_ensure_update(gtkUIManager); 952 } 953 }