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 change21 // find conversion definition on APILookup.txt22 // implement new conversion functionalities on the wrap.utils pakage23 24 25 modulegtk.Shortcut;
26 27 privateimportglib.ConstructionException;
28 privateimportglib.Str;
29 privateimportglib.Variant;
30 privateimportgobject.ObjectG;
31 privateimportgtk.ShortcutAction;
32 privateimportgtk.ShortcutTrigger;
33 privateimportgtk.c.functions;
34 publicimportgtk.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 publicclassShortcut : ObjectG55 {
56 /** the main Gtk struct */57 protectedGtkShortcut* gtkShortcut;
58 59 /** Get the main Gtk struct */60 publicGtkShortcut* getShortcutStruct(booltransferOwnership = false)
61 {
62 if (transferOwnership)
63 ownedRef = false;
64 returngtkShortcut;
65 }
66 67 /** the main Gtk struct as a void* */68 protectedoverridevoid* getStruct()
69 {
70 returncast(void*)gtkShortcut;
71 }
72 73 /**
74 * Sets our main struct and passes it to the parent class.
75 */76 publicthis (GtkShortcut* gtkShortcut, boolownedRef = false)
77 {
78 this.gtkShortcut = gtkShortcut;
79 super(cast(GObject*)gtkShortcut, ownedRef);
80 }
81 82 83 /** */84 publicstaticGTypegetType()
85 {
86 returngtk_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 publicthis(ShortcutTriggertrigger, ShortcutActionaction)
103 {
104 auto__p = gtk_shortcut_new((triggerisnull) ? null : trigger.getShortcutTriggerStruct(), (actionisnull) ? null : action.getShortcutActionStruct());
105 106 if(__pisnull)
107 {
108 thrownewConstructionException("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 publicShortcutActiongetAction()
120 {
121 auto__p = gtk_shortcut_get_action(gtkShortcut);
122 123 if(__pisnull)
124 {
125 returnnull;
126 }
127 128 returnObjectG.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 publicVariantgetArguments()
137 {
138 auto__p = gtk_shortcut_get_arguments(gtkShortcut);
139 140 if(__pisnull)
141 {
142 returnnull;
143 }
144 145 returnnewVariant(cast(GVariant*) __p);
146 }
147 148 /**
149 * Gets the trigger used to trigger @self.
150 *
151 * Returns: the trigger used
152 */153 publicShortcutTriggergetTrigger()
154 {
155 auto__p = gtk_shortcut_get_trigger(gtkShortcut);
156 157 if(__pisnull)
158 {
159 returnnull;
160 }
161 162 returnObjectG.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 publicvoidsetAction(ShortcutActionaction)
173 {
174 gtk_shortcut_set_action(gtkShortcut, (actionisnull) ? 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 publicvoidsetArguments(Variantargs)
184 {
185 gtk_shortcut_set_arguments(gtkShortcut, (argsisnull) ? 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 publicvoidsetTrigger(ShortcutTriggertrigger)
196 {
197 gtk_shortcut_set_trigger(gtkShortcut, (triggerisnull) ? null : trigger.getShortcutTriggerStruct());
198 }
199 }