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.NamedAction; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import glib.c.functions; 30 private import gobject.ObjectG; 31 private import gtk.ShortcutAction; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 35 36 /** 37 * A `GtkShortcutAction` that activates an action by name. 38 */ 39 public class NamedAction : ShortcutAction 40 { 41 /** the main Gtk struct */ 42 protected GtkNamedAction* gtkNamedAction; 43 44 /** Get the main Gtk struct */ 45 public GtkNamedAction* getNamedActionStruct(bool transferOwnership = false) 46 { 47 if (transferOwnership) 48 ownedRef = false; 49 return gtkNamedAction; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected override void* getStruct() 54 { 55 return cast(void*)gtkNamedAction; 56 } 57 58 /** 59 * Sets our main struct and passes it to the parent class. 60 */ 61 public this (GtkNamedAction* gtkNamedAction, bool ownedRef = false) 62 { 63 this.gtkNamedAction = gtkNamedAction; 64 super(cast(GtkShortcutAction*)gtkNamedAction, ownedRef); 65 } 66 67 68 /** */ 69 public static GType getType() 70 { 71 return gtk_named_action_get_type(); 72 } 73 74 /** 75 * Creates an action that when activated, activates 76 * the named action on the widget. 77 * 78 * It also passes the given arguments to it. 79 * 80 * See [method@Gtk.Widget.insert_action_group] for 81 * how to add actions to widgets. 82 * 83 * Params: 84 * name = the detailed name of the action 85 * 86 * Returns: a new `GtkShortcutAction` 87 * 88 * Throws: ConstructionException GTK+ fails to create the object. 89 */ 90 public this(string name) 91 { 92 auto __p = gtk_named_action_new(Str.toStringz(name)); 93 94 if(__p is null) 95 { 96 throw new ConstructionException("null returned by new"); 97 } 98 99 this(cast(GtkNamedAction*) __p, true); 100 } 101 102 /** 103 * Returns the name of the action that will be activated. 104 * 105 * Returns: the name of the action to activate 106 */ 107 public string getActionName() 108 { 109 return Str.toString(gtk_named_action_get_action_name(gtkNamedAction)); 110 } 111 }