2 * Copyright (C) 2007 Openismus GmbH
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
22 #include "gtktoolshell.h"
23 #include "gtkwidget.h"
28 * SECTION:gtktoolshell
29 * @Short_description: Interface for containers containing GtkToolItem widgets
30 * @Title: GtkToolShell
31 * @see_also: #GtkToolbar, #GtkToolItem
33 * The #GtkToolShell interface allows container widgets to provide additional
34 * information when embedding #GtkToolItem widgets.
40 * Dummy structure for accessing instances of #GtkToolShellIface.
44 typedef GtkToolShellIface GtkToolShellInterface;
45 G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET);
47 static GtkReliefStyle gtk_tool_shell_real_get_relief_style (GtkToolShell *shell);
48 static GtkOrientation gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell);
49 static gfloat gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell);
50 static PangoEllipsizeMode gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell);
53 gtk_tool_shell_default_init (GtkToolShellInterface *iface)
55 iface->get_relief_style = gtk_tool_shell_real_get_relief_style;
56 iface->get_text_orientation = gtk_tool_shell_real_get_text_orientation;
57 iface->get_text_alignment = gtk_tool_shell_real_get_text_alignment;
58 iface->get_ellipsize_mode = gtk_tool_shell_real_get_ellipsize_mode;
62 gtk_tool_shell_real_get_relief_style (GtkToolShell *shell)
64 return GTK_RELIEF_NONE;
68 gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell)
70 return GTK_ORIENTATION_HORIZONTAL;
74 gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell)
79 static PangoEllipsizeMode
80 gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell)
82 return PANGO_ELLIPSIZE_NONE;
87 * gtk_tool_shell_get_icon_size:
88 * @shell: a #GtkToolShell
90 * Retrieves the icon size for the tool shell. Tool items must not call this
91 * function directly, but rely on gtk_tool_item_get_icon_size() instead.
93 * Return value: (type int): the current size for icons of @shell
98 gtk_tool_shell_get_icon_size (GtkToolShell *shell)
100 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_icon_size (shell);
104 * gtk_tool_shell_get_orientation:
105 * @shell: a #GtkToolShell
107 * Retrieves the current orientation for the tool shell. Tool items must not
108 * call this function directly, but rely on gtk_tool_item_get_orientation()
111 * Return value: the current orientation of @shell
116 gtk_tool_shell_get_orientation (GtkToolShell *shell)
118 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_orientation (shell);
122 * gtk_tool_shell_get_style:
123 * @shell: a #GtkToolShell
125 * Retrieves whether the tool shell has text, icons, or both. Tool items must
126 * not call this function directly, but rely on gtk_tool_item_get_toolbar_style()
129 * Return value: the current style of @shell
134 gtk_tool_shell_get_style (GtkToolShell *shell)
136 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_style (shell);
140 * gtk_tool_shell_get_relief_style:
141 * @shell: a #GtkToolShell
143 * Returns the relief style of buttons on @shell. Tool items must not call this
144 * function directly, but rely on gtk_tool_item_get_relief_style() instead.
146 * Return value: The relief style of buttons on @shell.
151 gtk_tool_shell_get_relief_style (GtkToolShell *shell)
153 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
155 return iface->get_relief_style (shell);
159 * gtk_tool_shell_rebuild_menu:
160 * @shell: a #GtkToolShell
162 * Calling this function signals the tool shell that the overflow menu item for
163 * tool items have changed. If there is an overflow menu and if it is visible
164 * when this function it called, the menu will be rebuilt.
166 * Tool items must not call this function directly, but rely on
167 * gtk_tool_item_rebuild_menu() instead.
172 gtk_tool_shell_rebuild_menu (GtkToolShell *shell)
174 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
176 if (iface->rebuild_menu)
177 iface->rebuild_menu (shell);
181 * gtk_tool_shell_get_text_orientation:
182 * @shell: a #GtkToolShell
184 * Retrieves the current text orientation for the tool shell. Tool items must not
185 * call this function directly, but rely on gtk_tool_item_get_text_orientation()
188 * Return value: the current text orientation of @shell
193 gtk_tool_shell_get_text_orientation (GtkToolShell *shell)
195 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
197 return iface->get_text_orientation (shell);
201 * gtk_tool_shell_get_text_alignment:
202 * @shell: a #GtkToolShell
204 * Retrieves the current text alignment for the tool shell. Tool items must not
205 * call this function directly, but rely on gtk_tool_item_get_text_alignment()
208 * Return value: the current text alignment of @shell
213 gtk_tool_shell_get_text_alignment (GtkToolShell *shell)
215 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
217 return iface->get_text_alignment (shell);
221 * gtk_tool_shell_get_ellipsize_mode:
222 * @shell: a #GtkToolShell
224 * Retrieves the current ellipsize mode for the tool shell. Tool items must not
225 * call this function directly, but rely on gtk_tool_item_get_ellipsize_mode()
228 * Return value: the current ellipsize mode of @shell
233 gtk_tool_shell_get_ellipsize_mode (GtkToolShell *shell)
235 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
237 return iface->get_ellipsize_mode (shell);
241 * gtk_tool_shell_get_text_size_group:
242 * @shell: a #GtkToolShell
244 * Retrieves the current text size group for the tool shell. Tool items must not
245 * call this function directly, but rely on gtk_tool_item_get_text_size_group()
248 * Return value: (transfer none): the current text size group of @shell
253 gtk_tool_shell_get_text_size_group (GtkToolShell *shell)
255 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
257 if (iface->get_text_size_group)
258 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_size_group (shell);