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.SignalAction;
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 `GtkShortcut`Action that emits a signal.
38  * 
39  * Signals that are used in this way are referred to as keybinding signals,
40  * and they are expected to be defined with the %G_SIGNAL_ACTION flag.
41  */
42 public class SignalAction : ShortcutAction
43 {
44 	/** the main Gtk struct */
45 	protected GtkSignalAction* gtkSignalAction;
46 
47 	/** Get the main Gtk struct */
48 	public GtkSignalAction* getSignalActionStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gtkSignalAction;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)gtkSignalAction;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GtkSignalAction* gtkSignalAction, bool ownedRef = false)
65 	{
66 		this.gtkSignalAction = gtkSignalAction;
67 		super(cast(GtkShortcutAction*)gtkSignalAction, ownedRef);
68 	}
69 
70 
71 	/** */
72 	public static GType getType()
73 	{
74 		return gtk_signal_action_get_type();
75 	}
76 
77 	/**
78 	 * Creates an action that when activated, emits the given action signal
79 	 * on the provided widget.
80 	 *
81 	 * It will also unpack the args into arguments passed to the signal.
82 	 *
83 	 * Params:
84 	 *     signalName = name of the signal to emit
85 	 *
86 	 * Returns: a new `GtkShortcutAction`
87 	 *
88 	 * Throws: ConstructionException GTK+ fails to create the object.
89 	 */
90 	public this(string signalName)
91 	{
92 		auto __p = gtk_signal_action_new(Str.toStringz(signalName));
93 
94 		if(__p is null)
95 		{
96 			throw new ConstructionException("null returned by new");
97 		}
98 
99 		this(cast(GtkSignalAction*) __p, true);
100 	}
101 
102 	/**
103 	 * Returns the name of the signal that will be emitted.
104 	 *
105 	 * Returns: the name of the signal to emit
106 	 */
107 	public string getSignalName()
108 	{
109 		return Str.toString(gtk_signal_action_get_signal_name(gtkSignalAction));
110 	}
111 }