]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolshell.c
Updated Russian translation
[~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, see <http://www.gnu.org/licenses/>.
16  *
17  * Author:
18  *   Mathias Hasselmann
19  */
20
21 #include "config.h"
22 #include "gtktoolshell.h"
23 #include "gtkwidget.h"
24 #include "gtkintl.h"
25
26
27 /**
28  * SECTION:gtktoolshell
29  * @Short_description: Interface for containers containing GtkToolItem widgets
30  * @Title: GtkToolShell
31  *
32  * The #GtkToolShell interface allows container widgets to provide additional
33  * information when embedding #GtkToolItem widgets.
34  *
35  * @see_also: #GtkToolbar, #GtkToolItem
36  */
37
38 /**
39  * GtkToolShell:
40  *
41  * Dummy structure for accessing instances of #GtkToolShellIface.
42  */
43
44
45 typedef GtkToolShellIface GtkToolShellInterface;
46 G_DEFINE_INTERFACE (GtkToolShell, gtk_tool_shell, GTK_TYPE_WIDGET);
47
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);
52
53 static void
54 gtk_tool_shell_default_init (GtkToolShellInterface *iface)
55 {
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;
60 }
61
62 static GtkReliefStyle
63 gtk_tool_shell_real_get_relief_style (GtkToolShell *shell)
64 {
65   return GTK_RELIEF_NONE;
66 }
67
68 static GtkOrientation
69 gtk_tool_shell_real_get_text_orientation (GtkToolShell *shell)
70 {
71   return GTK_ORIENTATION_HORIZONTAL;
72 }
73
74 static gfloat
75 gtk_tool_shell_real_get_text_alignment (GtkToolShell *shell)
76 {
77   return 0.5f;
78 }
79
80 static PangoEllipsizeMode
81 gtk_tool_shell_real_get_ellipsize_mode (GtkToolShell *shell)
82 {
83   return PANGO_ELLIPSIZE_NONE;
84 }
85
86
87 /**
88  * gtk_tool_shell_get_icon_size:
89  * @shell: a #GtkToolShell
90  *
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.
93  *
94  * Return value: (type int): the current size for icons of @shell
95  *
96  * Since: 2.14
97  **/
98 GtkIconSize
99 gtk_tool_shell_get_icon_size (GtkToolShell *shell)
100 {
101   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_icon_size (shell);
102 }
103
104 /**
105  * gtk_tool_shell_get_orientation:
106  * @shell: a #GtkToolShell
107  *
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()
110  * instead.
111  *
112  * Return value: the current orientation of @shell
113  *
114  * Since: 2.14
115  **/
116 GtkOrientation
117 gtk_tool_shell_get_orientation (GtkToolShell *shell)
118 {
119   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_orientation (shell);
120 }
121
122 /**
123  * gtk_tool_shell_get_style:
124  * @shell: a #GtkToolShell
125  *
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()
128  * instead.
129  *
130  * Return value: the current style of @shell
131  *
132  * Since: 2.14
133  **/
134 GtkToolbarStyle
135 gtk_tool_shell_get_style (GtkToolShell *shell)
136 {
137   return GTK_TOOL_SHELL_GET_IFACE (shell)->get_style (shell);
138 }
139
140 /**
141  * gtk_tool_shell_get_relief_style:
142  * @shell: a #GtkToolShell
143  *
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.
146  *
147  * Return value: The relief style of buttons on @shell.
148  *
149  * Since: 2.14
150  **/
151 GtkReliefStyle
152 gtk_tool_shell_get_relief_style (GtkToolShell *shell)
153 {
154   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
155
156   return iface->get_relief_style (shell);
157 }
158
159 /**
160  * gtk_tool_shell_rebuild_menu:
161  * @shell: a #GtkToolShell
162  *
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.
166  *
167  * Tool items must not call this function directly, but rely on
168  * gtk_tool_item_rebuild_menu() instead.
169  *
170  * Since: 2.14
171  **/
172 void
173 gtk_tool_shell_rebuild_menu (GtkToolShell *shell)
174 {
175   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
176
177   if (iface->rebuild_menu)
178     iface->rebuild_menu (shell);
179 }
180
181 /**
182  * gtk_tool_shell_get_text_orientation:
183  * @shell: a #GtkToolShell
184  *
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()
187  * instead.
188  *
189  * Return value: the current text orientation of @shell
190  *
191  * Since: 2.20
192  **/
193 GtkOrientation
194 gtk_tool_shell_get_text_orientation (GtkToolShell *shell)
195 {
196   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
197
198   return iface->get_text_orientation (shell);
199 }
200
201 /**
202  * gtk_tool_shell_get_text_alignment:
203  * @shell: a #GtkToolShell
204  *
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()
207  * instead.
208  *
209  * Return value: the current text alignment of @shell
210  *
211  * Since: 2.20
212  **/
213 gfloat
214 gtk_tool_shell_get_text_alignment (GtkToolShell *shell)
215 {
216   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
217
218   return iface->get_text_alignment (shell);
219 }
220
221 /**
222  * gtk_tool_shell_get_ellipsize_mode
223  * @shell: a #GtkToolShell
224  *
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()
227  * instead.
228  *
229  * Return value: the current ellipsize mode of @shell
230  *
231  * Since: 2.20
232  **/
233 PangoEllipsizeMode
234 gtk_tool_shell_get_ellipsize_mode (GtkToolShell *shell)
235 {
236   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
237
238   return iface->get_ellipsize_mode (shell);
239 }
240
241 /**
242  * gtk_tool_shell_get_text_size_group:
243  * @shell: a #GtkToolShell
244  *
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()
247  * instead.
248  *
249  * Return value: (transfer none): the current text size group of @shell
250  *
251  * Since: 2.20
252  **/
253 GtkSizeGroup *
254 gtk_tool_shell_get_text_size_group (GtkToolShell *shell)
255 {
256   GtkToolShellIface *iface = GTK_TOOL_SHELL_GET_IFACE (shell);
257
258   if (iface->get_text_size_group)
259     return GTK_TOOL_SHELL_GET_IFACE (shell)->get_text_size_group (shell);
260
261   return NULL;
262 }