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
32 * The #GtkToolShell interface allows container widgets to provide additional
33 * information when embedding #GtkToolItem widgets.
35 * @see_also: #GtkToolbar, #GtkToolItem
41 * Dummy structure for accessing instances of #GtkToolShellIface.
45 typedef GtkToolShellIface GtkToolShellInterface;
46 G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET);
48 static GtkReliefStyle gtk_tool_shell_real_get_relief_style (GtkToolShell *shell);
49 static GtkOrientation gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell);
50 static gfloat gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell);
51 static PangoEllipsizeMode gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell);
54 gtk_tool_shell_default_init (GtkToolShellInterface *iface)
56 iface->get_relief_style = gtk_tool_shell_real_get_relief_style;
57 iface->get_text_orientation = gtk_tool_shell_real_get_text_orientation;
58 iface->get_text_alignment = gtk_tool_shell_real_get_text_alignment;
59 iface->get_ellipsize_mode = gtk_tool_shell_real_get_ellipsize_mode;
63 gtk_tool_shell_real_get_relief_style (GtkToolShell *shell)
65 return GTK_RELIEF_NONE;
69 gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell)
71 return GTK_ORIENTATION_HORIZONTAL;
75 gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell)
80 static PangoEllipsizeMode
81 gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell)
83 return PANGO_ELLIPSIZE_NONE;
88 * gtk_tool_shell_get_icon_size:
89 * @shell: a #GtkToolShell
91 * Retrieves the icon size for the tool shell. Tool items must not call this
92 * function directly, but rely on gtk_tool_item_get_icon_size() instead.
94 * Return value: (type int): the current size for icons of @shell
99 gtk_tool_shell_get_icon_size (GtkToolShell *shell)
101 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_icon_size (shell);
105 * gtk_tool_shell_get_orientation:
106 * @shell: a #GtkToolShell
108 * Retrieves the current orientation for the tool shell. Tool items must not
109 * call this function directly, but rely on gtk_tool_item_get_orientation()
112 * Return value: the current orientation of @shell
117 gtk_tool_shell_get_orientation (GtkToolShell *shell)
119 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_orientation (shell);
123 * gtk_tool_shell_get_style:
124 * @shell: a #GtkToolShell
126 * Retrieves whether the tool shell has text, icons, or both. Tool items must
127 * not call this function directly, but rely on gtk_tool_item_get_toolbar_style()
130 * Return value: the current style of @shell
135 gtk_tool_shell_get_style (GtkToolShell *shell)
137 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_style (shell);
141 * gtk_tool_shell_get_relief_style:
142 * @shell: a #GtkToolShell
144 * Returns the relief style of buttons on @shell. Tool items must not call this
145 * function directly, but rely on gtk_tool_item_get_relief_style() instead.
147 * Return value: The relief style of buttons on @shell.
152 gtk_tool_shell_get_relief_style (GtkToolShell *shell)
154 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
156 return iface->get_relief_style (shell);
160 * gtk_tool_shell_rebuild_menu:
161 * @shell: a #GtkToolShell
163 * Calling this function signals the tool shell that the overflow menu item for
164 * tool items have changed. If there is an overflow menu and if it is visible
165 * when this function it called, the menu will be rebuilt.
167 * Tool items must not call this function directly, but rely on
168 * gtk_tool_item_rebuild_menu() instead.
173 gtk_tool_shell_rebuild_menu (GtkToolShell *shell)
175 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
177 if (iface->rebuild_menu)
178 iface->rebuild_menu (shell);
182 * gtk_tool_shell_get_text_orientation:
183 * @shell: a #GtkToolShell
185 * Retrieves the current text orientation for the tool shell. Tool items must not
186 * call this function directly, but rely on gtk_tool_item_get_text_orientation()
189 * Return value: the current text orientation of @shell
194 gtk_tool_shell_get_text_orientation (GtkToolShell *shell)
196 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
198 return iface->get_text_orientation (shell);
202 * gtk_tool_shell_get_text_alignment:
203 * @shell: a #GtkToolShell
205 * Retrieves the current text alignment for the tool shell. Tool items must not
206 * call this function directly, but rely on gtk_tool_item_get_text_alignment()
209 * Return value: the current text alignment of @shell
214 gtk_tool_shell_get_text_alignment (GtkToolShell *shell)
216 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
218 return iface->get_text_alignment (shell);
222 * gtk_tool_shell_get_ellipsize_mode
223 * @shell: a #GtkToolShell
225 * Retrieves the current ellipsize mode for the tool shell. Tool items must not
226 * call this function directly, but rely on gtk_tool_item_get_ellipsize_mode()
229 * Return value: the current ellipsize mode of @shell
234 gtk_tool_shell_get_ellipsize_mode (GtkToolShell *shell)
236 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
238 return iface->get_ellipsize_mode (shell);
242 * gtk_tool_shell_get_text_size_group:
243 * @shell: a #GtkToolShell
245 * Retrieves the current text size group for the tool shell. Tool items must not
246 * call this function directly, but rely on gtk_tool_item_get_text_size_group()
249 * Return value: (transfer none): the current text size group of @shell
254 gtk_tool_shell_get_text_size_group (GtkToolShell *shell)
256 GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
258 if (iface->get_text_size_group)
259 return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_size_group (shell);