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.Shortcut; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import glib.Variant; 30 private import gobject.ObjectG; 31 private import gtk.ShortcutAction; 32 private import gtk.ShortcutTrigger; 33 private import gtk.c.functions; 34 public import gtk.c.types; 35 36 37 /** 38 * A `GtkShortcut` describes a keyboard shortcut. 39 * 40 * It contains a description of how to trigger the shortcut via a 41 * [class@Gtk.ShortcutTrigger] and a way to activate the shortcut 42 * on a widget via a [class@Gtk.ShortcutAction]. 43 * 44 * The actual work is usually done via [class@Gtk.ShortcutController], 45 * which decides if and when to activate a shortcut. Using that controller 46 * directly however is rarely necessary as various higher level 47 * convenience APIs exist on #GtkWidgets that make it easier to use 48 * shortcuts in GTK. 49 * 50 * `GtkShortcut` does provide functionality to make it easy for users 51 * to work with shortcuts, either by providing informational strings 52 * for display purposes or by allowing shortcuts to be configured. 53 */ 54 public class Shortcut : ObjectG 55 { 56 /** the main Gtk struct */ 57 protected GtkShortcut* gtkShortcut; 58 59 /** Get the main Gtk struct */ 60 public GtkShortcut* getShortcutStruct(bool transferOwnership = false) 61 { 62 if (transferOwnership) 63 ownedRef = false; 64 return gtkShortcut; 65 } 66 67 /** the main Gtk struct as a void* */ 68 protected override void* getStruct() 69 { 70 return cast(void*)gtkShortcut; 71 } 72 73 /** 74 * Sets our main struct and passes it to the parent class. 75 */ 76 public this (GtkShortcut* gtkShortcut, bool ownedRef = false) 77 { 78 this.gtkShortcut = gtkShortcut; 79 super(cast(GObject*)gtkShortcut, ownedRef); 80 } 81 82 83 /** */ 84 public static GType getType() 85 { 86 return gtk_shortcut_get_type(); 87 } 88 89 /** 90 * Creates a new `GtkShortcut` that is triggered by 91 * @trigger and then activates @action. 92 * 93 * Params: 94 * trigger = The trigger that will trigger the shortcut 95 * action = The action that will be activated upon 96 * triggering 97 * 98 * Returns: a new `GtkShortcut` 99 * 100 * Throws: ConstructionException GTK+ fails to create the object. 101 */ 102 public this(ShortcutTrigger trigger, ShortcutAction action) 103 { 104 auto __p = gtk_shortcut_new((trigger is null) ? null : trigger.getShortcutTriggerStruct(), (action is null) ? null : action.getShortcutActionStruct()); 105 106 if(__p is null) 107 { 108 throw new ConstructionException("null returned by new"); 109 } 110 111 this(cast(GtkShortcut*) __p, true); 112 } 113 114 /** 115 * Gets the action that is activated by this shortcut. 116 * 117 * Returns: the action 118 */ 119 public ShortcutAction getAction() 120 { 121 auto __p = gtk_shortcut_get_action(gtkShortcut); 122 123 if(__p is null) 124 { 125 return null; 126 } 127 128 return ObjectG.getDObject!(ShortcutAction)(cast(GtkShortcutAction*) __p); 129 } 130 131 /** 132 * Gets the arguments that are passed when activating the shortcut. 133 * 134 * Returns: the arguments 135 */ 136 public Variant getArguments() 137 { 138 auto __p = gtk_shortcut_get_arguments(gtkShortcut); 139 140 if(__p is null) 141 { 142 return null; 143 } 144 145 return new Variant(cast(GVariant*) __p); 146 } 147 148 /** 149 * Gets the trigger used to trigger @self. 150 * 151 * Returns: the trigger used 152 */ 153 public ShortcutTrigger getTrigger() 154 { 155 auto __p = gtk_shortcut_get_trigger(gtkShortcut); 156 157 if(__p is null) 158 { 159 return null; 160 } 161 162 return ObjectG.getDObject!(ShortcutTrigger)(cast(GtkShortcutTrigger*) __p); 163 } 164 165 /** 166 * Sets the new action for @self to be @action. 167 * 168 * Params: 169 * action = The new action. 170 * If the @action is %NULL, the nothing action will be used. 171 */ 172 public void setAction(ShortcutAction action) 173 { 174 gtk_shortcut_set_action(gtkShortcut, (action is null) ? null : action.getShortcutActionStruct()); 175 } 176 177 /** 178 * Sets the arguments to pass when activating the shortcut. 179 * 180 * Params: 181 * args = arguments to pass when activating @self 182 */ 183 public void setArguments(Variant args) 184 { 185 gtk_shortcut_set_arguments(gtkShortcut, (args is null) ? null : args.getVariantStruct()); 186 } 187 188 /** 189 * Sets the new trigger for @self to be @trigger. 190 * 191 * Params: 192 * trigger = The new trigger. 193 * If the @trigger is %NULL, the never trigger will be used. 194 */ 195 public void setTrigger(ShortcutTrigger trigger) 196 { 197 gtk_shortcut_set_trigger(gtkShortcut, (trigger is null) ? null : trigger.getShortcutTriggerStruct()); 198 } 199 }