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