]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolshell.c
Merge branch 'master' into broadway2
[~andy/gtk] / gtk / gtktoolshell.c
1 /* gtktoolshell.c
2  * Copyright (C) 2007  Openismus GmbH
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Author:
20  *   Mathias Hasselmann
21  */
22
23 #include "config.h"
24 #include "gtktoolshell.h"
25 #include "gtkwidget.h"
26 #include "gtkintl.h"
27
28
29 /**
30  * SECTION:gtktoolshell
31  * @Short_description: Interface for containers containing GtkToolItem widgets
32  * @Title: GtkToolShell
33  *
34  * The #GtkToolShell interface allows container widgets to provide additional
35  * information when embedding #GtkToolItem widgets.
36  *
37  * @see_also: #GtkToolbar, #GtkToolItem
38  */
39
40 /**
41  * GtkToolShell:
42  *
43  * Dummy structure for accessing instances of #GtkToolShellIface.
44  */
45
46
47 typedef GtkToolShellIface GtkToolShellInterface;
48 G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET);
49
50
51 static void
52 gtk_tool_shell_default_init (GtkToolShellInterface *iface)
53 {
54 }
55
56
57 /**
58  * gtk_tool_shell_get_icon_size:
59  * @shell: a #GtkToolShell
60  *
61  * Retrieves the icon size for the tool shell. Tool items must not call this
62  * function directly, but rely on gtk_tool_item_get_icon_size() instead.
63  *
64  * Return value: (type int): the current size for icons of @shell
65  *
66  * Since: 2.14
67  **/
68 GtkIconSize
69 gtk_tool_shell_get_icon_size (GtkToolShell *shell)
70 {
71   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_icon_size (shell);
72 }
73
74 /**
75  * gtk_tool_shell_get_orientation:
76  * @shell: a #GtkToolShell
77  *
78  * Retrieves the current orientation for the tool shell. Tool items must not
79  * call this function directly, but rely on gtk_tool_item_get_orientation()
80  * instead.
81  *
82  * Return value: the current orientation of @shell
83  *
84  * Since: 2.14
85  **/
86 GtkOrientation
87 gtk_tool_shell_get_orientation (GtkToolShell *shell)
88 {
89   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_orientation (shell);
90 }
91
92 /**
93  * gtk_tool_shell_get_style:
94  * @shell: a #GtkToolShell
95  *
96  * Retrieves whether the tool shell has text, icons, or both. Tool items must
97  * not call this function directly, but rely on gtk_tool_item_get_toolbar_style()
98  * instead.
99  *
100  * Return value: the current style of @shell
101  *
102  * Since: 2.14
103  **/
104 GtkToolbarStyle
105 gtk_tool_shell_get_style (GtkToolShell *shell)
106 {
107   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_style (shell);
108 }
109
110 /**
111  * gtk_tool_shell_get_relief_style:
112  * @shell: a #GtkToolShell
113  *
114  * Returns the relief style of buttons on @shell. Tool items must not call this
115  * function directly, but rely on gtk_tool_item_get_relief_style() instead.
116  *
117  * Return value: The relief style of buttons on @shell.
118  *
119  * Since: 2.14
120  **/
121 GtkReliefStyle
122 gtk_tool_shell_get_relief_style (GtkToolShell *shell)
123 {
124   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
125
126   if (iface->get_relief_style)
127     return iface->get_relief_style (shell);
128
129   return GTK_RELIEF_NONE;
130 }
131
132 /**
133  * gtk_tool_shell_rebuild_menu:
134  * @shell: a #GtkToolShell
135  *
136  * Calling this function signals the tool shell that the overflow menu item for
137  * tool items have changed. If there is an overflow menu and if it is visible
138  * when this function it called, the menu will be rebuilt.
139  *
140  * Tool items must not call this function directly, but rely on
141  * gtk_tool_item_rebuild_menu() instead.
142  *
143  * Since: 2.14
144  **/
145 void
146 gtk_tool_shell_rebuild_menu (GtkToolShell *shell)
147 {
148   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
149
150   if (iface->rebuild_menu)
151     iface->rebuild_menu (shell);
152 }
153
154 /**
155  * gtk_tool_shell_get_text_orientation:
156  * @shell: a #GtkToolShell
157  *
158  * Retrieves the current text orientation for the tool shell. Tool items must not
159  * call this function directly, but rely on gtk_tool_item_get_text_orientation()
160  * instead.
161  *
162  * Return value: the current text orientation of @shell
163  *
164  * Since: 2.20
165  **/
166 GtkOrientation
167 gtk_tool_shell_get_text_orientation (GtkToolShell *shell)
168 {
169   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
170
171   if (iface->get_text_orientation)
172     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_orientation (shell);
173
174   return GTK_ORIENTATION_HORIZONTAL;
175 }
176
177 /**
178  * gtk_tool_shell_get_text_alignment:
179  * @shell: a #GtkToolShell
180  *
181  * Retrieves the current text alignment for the tool shell. Tool items must not
182  * call this function directly, but rely on gtk_tool_item_get_text_alignment()
183  * instead.
184  *
185  * Return value: the current text alignment of @shell
186  *
187  * Since: 2.20
188  **/
189 gfloat
190 gtk_tool_shell_get_text_alignment (GtkToolShell *shell)
191 {
192   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
193
194   if (iface->get_text_alignment)
195     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_alignment (shell);
196
197   return 0.5f;
198 }
199
200 /**
201  * gtk_tool_shell_get_ellipsize_mode
202  * @shell: a #GtkToolShell
203  *
204  * Retrieves the current ellipsize mode for the tool shell. Tool items must not
205  * call this function directly, but rely on gtk_tool_item_get_ellipsize_mode()
206  * instead.
207  *
208  * Return value: the current ellipsize mode of @shell
209  *
210  * Since: 2.20
211  **/
212 PangoEllipsizeMode
213 gtk_tool_shell_get_ellipsize_mode (GtkToolShell *shell)
214 {
215   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
216
217   if (iface->get_ellipsize_mode)
218     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_ellipsize_mode (shell);
219
220   return PANGO_ELLIPSIZE_NONE;
221 }
222
223 /**
224  * gtk_tool_shell_get_text_size_group:
225  * @shell: a #GtkToolShell
226  *
227  * Retrieves the current text size group for the tool shell. Tool items must not
228  * call this function directly, but rely on gtk_tool_item_get_text_size_group()
229  * instead.
230  *
231  * Return value: (transfer none): the current text size group of @shell
232  *
233  * Since: 2.20
234  **/
235 GtkSizeGroup *
236 gtk_tool_shell_get_text_size_group (GtkToolShell *shell)
237 {
238   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
239
240   if (iface->get_text_size_group)
241     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_size_group (shell);
242
243   return NULL;
244 }