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