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