1 /*
2  * This file is part of d-dazzle.
3  *
4  * d-dazzle 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  * d-dazzle 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 d-dazzle; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 module dazzle.ShortcutTooltip;
20 
21 private import dazzle.c.functions;
22 public  import dazzle.c.types;
23 private import glib.ConstructionException;
24 private import glib.Str;
25 private import gobject.ObjectG;
26 private import gtk.Widget;
27 
28 
29 /** */
30 public class ShortcutTooltip : ObjectG
31 {
32 	/** the main Gtk struct */
33 	protected DzlShortcutTooltip* dzlShortcutTooltip;
34 
35 	/** Get the main Gtk struct */
36 	public DzlShortcutTooltip* getShortcutTooltipStruct(bool transferOwnership = false)
37 	{
38 		if (transferOwnership)
39 			ownedRef = false;
40 		return dzlShortcutTooltip;
41 	}
42 
43 	/** the main Gtk struct as a void* */
44 	protected override void* getStruct()
45 	{
46 		return cast(void*)dzlShortcutTooltip;
47 	}
48 
49 	/**
50 	 * Sets our main struct and passes it to the parent class.
51 	 */
52 	public this (DzlShortcutTooltip* dzlShortcutTooltip, bool ownedRef = false)
53 	{
54 		this.dzlShortcutTooltip = dzlShortcutTooltip;
55 		super(cast(GObject*)dzlShortcutTooltip, ownedRef);
56 	}
57 
58 
59 	/** */
60 	public static GType getType()
61 	{
62 		return dzl_shortcut_tooltip_get_type();
63 	}
64 
65 	/**
66 	 * Create a new #DzlShortcutTooltip.
67 	 *
68 	 * Returns: a newly created #DzlShortcutTooltip
69 	 *
70 	 * Since: 3.32
71 	 *
72 	 * Throws: ConstructionException GTK+ fails to create the object.
73 	 */
74 	public this()
75 	{
76 		auto p = dzl_shortcut_tooltip_new();
77 
78 		if(p is null)
79 		{
80 			throw new ConstructionException("null returned by new");
81 		}
82 
83 		this(cast(DzlShortcutTooltip*) p, true);
84 	}
85 
86 	/**
87 	 * Gets the #DzlShortcutTooltip:accel property, which can be used to override
88 	 * the commands accel.
89 	 *
90 	 * Returns: an override accel, or %NULL
91 	 *
92 	 * Since: 3.32
93 	 */
94 	public string getAccel()
95 	{
96 		return Str.toString(dzl_shortcut_tooltip_get_accel(dzlShortcutTooltip));
97 	}
98 
99 	/**
100 	 * Gets the #DzlShortcutTooltip:command-id property.
101 	 *
102 	 * Returns: a string containing the command id
103 	 *
104 	 * Since: 3.32
105 	 */
106 	public string getCommandId()
107 	{
108 		return Str.toString(dzl_shortcut_tooltip_get_command_id(dzlShortcutTooltip));
109 	}
110 
111 	/**
112 	 * Gets the #DzlShortcutTooltip:title property, if set.
113 	 *
114 	 * Returns: a string containing the title, or %NULL
115 	 *
116 	 * Since: 3.32
117 	 */
118 	public string getTitle()
119 	{
120 		return Str.toString(dzl_shortcut_tooltip_get_title(dzlShortcutTooltip));
121 	}
122 
123 	/**
124 	 * Gets the #GtkWidget that the shortcut-tooltip is wrapping.
125 	 *
126 	 * Returns: a #GtkWidget or %NULL if unset
127 	 *
128 	 * Since: 3.32
129 	 */
130 	public Widget getWidget()
131 	{
132 		auto p = dzl_shortcut_tooltip_get_widget(dzlShortcutTooltip);
133 
134 		if(p is null)
135 		{
136 			return null;
137 		}
138 
139 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
140 	}
141 
142 	/**
143 	 * Allows overriding the accel that is used.
144 	 *
145 	 * Params:
146 	 *     accel = Sets the accelerator to use, or %NULL to unset
147 	 *         and use the default
148 	 *
149 	 * Since: 3.32
150 	 */
151 	public void setAccel(string accel)
152 	{
153 		dzl_shortcut_tooltip_set_accel(dzlShortcutTooltip, Str.toStringz(accel));
154 	}
155 
156 	/**
157 	 * This sets the #DzlShortcutTooltip:command-id property which denotes which
158 	 * shortcut registered with libdazzle to display when a tooltip request is
159 	 * received.
160 	 *
161 	 * Params:
162 	 *     commandId = the command-id of the shortcut registered
163 	 *
164 	 * Since: 3.32
165 	 */
166 	public void setCommandId(string commandId)
167 	{
168 		dzl_shortcut_tooltip_set_command_id(dzlShortcutTooltip, Str.toStringz(commandId));
169 	}
170 
171 	/**
172 	 * Sets the #DzlShortcutTooltip:title property, which can be used to
173 	 * override the default title for the tooltip as discovered from the
174 	 * shortcut manager.
175 	 *
176 	 * Params:
177 	 *     title = a title for the tooltip, or %NULL
178 	 *
179 	 * Since: 3.32
180 	 */
181 	public void setTitle(string title)
182 	{
183 		dzl_shortcut_tooltip_set_title(dzlShortcutTooltip, Str.toStringz(title));
184 	}
185 
186 	/**
187 	 * Sets the widget to connect to the #GtkWidget::query-tooltip signal.
188 	 *
189 	 * If configured, the widget will be displayed with an appropriate tooltip
190 	 * message matching the shortcut from #DzlShortcutTooltip:command-id.
191 	 *
192 	 * Params:
193 	 *     widget = a #GtkWidget or %NULL
194 	 *
195 	 * Since: 3.32
196 	 */
197 	public void setWidget(Widget widget)
198 	{
199 		dzl_shortcut_tooltip_set_widget(dzlShortcutTooltip, (widget is null) ? null : widget.getWidgetStruct());
200 	}
201 }