]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolshell.c
Merge branch 'windows_list'
[~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 GType
47 gtk_tool_shell_get_type (void)
48 {
49   static GType type = 0;
50
51   if (!type)
52     {
53       type = g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkToolShell"),
54                                             sizeof (GtkToolShellIface),
55                                             NULL, 0, NULL, 0);
56       g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
57     }
58
59   return type;
60 }
61
62 /**
63  * gtk_tool_shell_get_icon_size:
64  * @shell: a #GtkToolShell
65  *
66  * Retrieves the icon size for the tool shell. Tool items must not call this
67  * function directly, but rely on gtk_tool_item_get_icon_size() instead.
68  *
69  * Return value: (type int): the current size for icons of @shell
70  *
71  * Since: 2.14
72  **/
73 GtkIconSize
74 gtk_tool_shell_get_icon_size (GtkToolShell *shell)
75 {
76   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_icon_size (shell);
77 }
78
79 /**
80  * gtk_tool_shell_get_orientation:
81  * @shell: a #GtkToolShell
82  *
83  * Retrieves the current orientation for the tool shell. Tool items must not
84  * call this function directly, but rely on gtk_tool_item_get_orientation()
85  * instead.
86  *
87  * Return value: the current orientation of @shell
88  *
89  * Since: 2.14
90  **/
91 GtkOrientation
92 gtk_tool_shell_get_orientation (GtkToolShell *shell)
93 {
94   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_orientation (shell);
95 }
96
97 /**
98  * gtk_tool_shell_get_style:
99  * @shell: a #GtkToolShell
100  *
101  * Retrieves whether the tool shell has text, icons, or both. Tool items must
102  * not call this function directly, but rely on gtk_tool_item_get_style()
103  * instead.
104  *
105  * Return value: the current style of @shell
106  *
107  * Since: 2.14
108  **/
109 GtkToolbarStyle
110 gtk_tool_shell_get_style (GtkToolShell *shell)
111 {
112   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_style (shell);
113 }
114
115 /**
116  * gtk_tool_shell_get_relief_style:
117  * @shell: a #GtkToolShell
118  *
119  * Returns the relief style of buttons on @shell. Tool items must not call this
120  * function directly, but rely on gtk_tool_item_get_relief_style() instead.
121  *
122  * Return value: The relief style of buttons on @shell.
123  *
124  * Since: 2.14
125  **/
126 GtkReliefStyle
127 gtk_tool_shell_get_relief_style (GtkToolShell *shell)
128 {
129   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
130
131   if (iface->get_relief_style)
132     return iface->get_relief_style (shell);
133
134   return GTK_RELIEF_NONE;
135 }
136
137 /**
138  * gtk_tool_shell_rebuild_menu:
139  * @shell: a #GtkToolShell
140  *
141  * Calling this function signals the tool shell that the overflow menu item for
142  * tool items have changed. If there is an overflow menu and if it is visible
143  * when this function it called, the menu will be rebuilt.
144  *
145  * Tool items must not call this function directly, but rely on
146  * gtk_tool_item_rebuild_menu() instead.
147  *
148  * Since: 2.14
149  **/
150 void
151 gtk_tool_shell_rebuild_menu (GtkToolShell *shell)
152 {
153   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
154
155   if (iface->rebuild_menu)
156     iface->rebuild_menu (shell);
157 }
158
159 /**
160  * gtk_tool_shell_get_text_orientation:
161  * @shell: a #GtkToolShell
162  *
163  * Retrieves the current text orientation for the tool shell. Tool items must not
164  * call this function directly, but rely on gtk_tool_item_get_text_orientation()
165  * instead.
166  *
167  * Return value: the current text orientation of @shell
168  *
169  * Since: 2.20
170  **/
171 GtkOrientation
172 gtk_tool_shell_get_text_orientation (GtkToolShell *shell)
173 {
174   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
175
176   if (iface->get_text_orientation)
177     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_orientation (shell);
178
179   return GTK_ORIENTATION_HORIZONTAL;
180 }
181
182 /**
183  * gtk_tool_shell_get_text_alignment:
184  * @shell: a #GtkToolShell
185  *
186  * Retrieves the current text alignment for the tool shell. Tool items must not
187  * call this function directly, but rely on gtk_tool_item_get_text_alignment()
188  * instead.
189  *
190  * Return value: the current text alignment of @shell
191  *
192  * Since: 2.20
193  **/
194 gfloat
195 gtk_tool_shell_get_text_alignment (GtkToolShell *shell)
196 {
197   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
198
199   if (iface->get_text_alignment)
200     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_alignment (shell);
201
202   return 0.5f;
203 }
204
205 /**
206  * gtk_tool_shell_get_ellipsize_mode
207  * @shell: a #GtkToolShell
208  *
209  * Retrieves the current ellipsize mode for the tool shell. Tool items must not
210  * call this function directly, but rely on gtk_tool_item_get_ellipsize_mode()
211  * instead.
212  *
213  * Return value: the current ellipsize mode of @shell
214  *
215  * Since: 2.20
216  **/
217 PangoEllipsizeMode
218 gtk_tool_shell_get_ellipsize_mode (GtkToolShell *shell)
219 {
220   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
221
222   if (iface->get_ellipsize_mode)
223     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_ellipsize_mode (shell);
224
225   return PANGO_ELLIPSIZE_NONE;
226 }
227
228 /**
229  * gtk_tool_shell_get_text_size_group:
230  * @shell: a #GtkToolShell
231  *
232  * Retrieves the current text size group for the tool shell. Tool items must not
233  * call this function directly, but rely on gtk_tool_item_get_text_size_group()
234  * instead.
235  *
236  * Return value: the current text size group of @shell
237  *
238  * Since: 2.20
239  **/
240 GtkSizeGroup *
241 gtk_tool_shell_get_text_size_group (GtkToolShell *shell)
242 {
243   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
244
245   if (iface->get_text_size_group)
246     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_size_group (shell);
247
248   return NULL;
249 }