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