1 /* Copyright (c) 2009, Igalia
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <modest-scrollable.h>
35 * modest_scrollable_add_with_viewport:
36 * @scrollable: a #ModestScrollable instance
37 * @widget: a #GtkWidget
39 * adds a widget to the @scrollable, wrapping it into a viewport.
40 * This is useful if @widget does not implement scroll_adjustments
44 modest_scrollable_add_with_viewport (ModestScrollable *scrollable,
47 if (MODEST_SCROLLABLE_GET_IFACE (scrollable)->add_with_viewport) {
48 MODEST_SCROLLABLE_GET_IFACE (scrollable)->add_with_viewport (scrollable, widget);
53 * modest_scrollable_get_vadjustment:
54 * @self: a #ModestScrollable
56 * obtains the vertical adjustment for @self
58 * Returns: a #GtkAdjustment
61 modest_scrollable_get_vadjustment (ModestScrollable *self)
63 if (MODEST_SCROLLABLE_GET_IFACE (self)->get_vadjustment) {
64 return MODEST_SCROLLABLE_GET_IFACE (self)->get_vadjustment (self);
71 * modest_scrollable_get_hadjustment:
72 * @self: a #ModestScrollable
74 * obtains the horizontal adjustment for @self
76 * Returns: a #GtkAdjustment
79 modest_scrollable_get_hadjustment (ModestScrollable *self)
81 if (MODEST_SCROLLABLE_GET_IFACE (self)->get_hadjustment) {
82 return MODEST_SCROLLABLE_GET_IFACE (self)->get_hadjustment (self);
89 * modest_scrollable_scroll_to:
90 * @scrollable: a #ModestScrollable instance
91 * @x: the X coordinate to scroll to
92 * @y: the Y coordinate to scroll to
94 * scrolls softly visible area of @scrollable, to show the coordinates
98 modest_scrollable_scroll_to (ModestScrollable *scrollable,
99 const gint x, const gint y)
101 if (MODEST_SCROLLABLE_GET_IFACE (scrollable)->scroll_to) {
102 MODEST_SCROLLABLE_GET_IFACE (scrollable)->scroll_to (scrollable, x, y);
107 * modest_scrollable_jump_to:
108 * @scrollable: a #ModestScrollable instance
109 * @x: the X coordinate to jump to
110 * @y: the Y coordinate to jump to
112 * scrolls visible area of @scrollable, to show the coordinates
113 * (@x, @y). Movement is immediate.
116 modest_scrollable_jump_to (ModestScrollable *scrollable,
117 const gint x, const gint y)
119 if (MODEST_SCROLLABLE_GET_IFACE (scrollable)->jump_to) {
120 MODEST_SCROLLABLE_GET_IFACE (scrollable)->jump_to (scrollable, x, y);
125 * modest_scrollable_get_vertical_policy:
126 * @scrollable: a #ModestScrollable instance
128 * returns the vertical scroll policy
130 * Returns: a #GtkPolicyType
133 modest_scrollable_get_vertical_policy (ModestScrollable *scrollable)
135 if (MODEST_SCROLLABLE_GET_IFACE (scrollable)->get_vertical_policy) {
136 return MODEST_SCROLLABLE_GET_IFACE (scrollable)->get_vertical_policy (scrollable);
138 return GTK_POLICY_NEVER;
143 * modest_scrollable_get_horizontal_policy:
144 * @scrollable: a #ModestScrollable instance
146 * returns the horizontal scroll policy
148 * Returns: a #GtkPolicyType
151 modest_scrollable_get_horizontal_policy (ModestScrollable *scrollable)
153 if (MODEST_SCROLLABLE_GET_IFACE (scrollable)->get_horizontal_policy) {
154 return MODEST_SCROLLABLE_GET_IFACE (scrollable)->get_horizontal_policy (scrollable);
156 return GTK_POLICY_NEVER;
161 * modest_scrollable_set_vertical_policy:
162 * @scrollable: a #ModestScrollable instance
163 * @policy: a #GtkPolicyType
165 * sets the vertical scroll policy
168 modest_scrollable_set_vertical_policy (ModestScrollable *scrollable,
169 GtkPolicyType policy)
171 if (MODEST_SCROLLABLE_GET_IFACE (scrollable)->set_vertical_policy) {
172 MODEST_SCROLLABLE_GET_IFACE (scrollable)->set_vertical_policy (scrollable, policy);
177 * modest_scrollable_set_horizontal_policy:
178 * @scrollable: a #ModestScrollable instance
179 * @policy: a #GtkPolicyType
181 * sets the horizontal scroll policy
184 modest_scrollable_set_horizontal_policy (ModestScrollable *scrollable,
185 GtkPolicyType policy)
187 if (MODEST_SCROLLABLE_GET_IFACE (scrollable)->set_horizontal_policy) {
188 MODEST_SCROLLABLE_GET_IFACE (scrollable)->set_horizontal_policy (scrollable, policy);
193 modest_scrollable_base_init (gpointer g_iface)
195 static gboolean initialized = FALSE;
198 /* create interface signals here. */
201 g_object_interface_install_property (g_iface,
202 g_param_spec_enum ("vertical_policy",
203 "Vertical scroll policy",
204 "Visual policy of the vertical scroll",
205 GTK_TYPE_POLICY_TYPE,
206 GTK_POLICY_AUTOMATIC,
210 g_object_interface_install_property (g_iface,
211 g_param_spec_enum ("horizontal_policy",
212 "Horizontal scroll policy",
213 "Visual policy of the horizontal scroll",
214 GTK_TYPE_POLICY_TYPE,
215 GTK_POLICY_AUTOMATIC,
224 modest_scrollable_get_type (void)
226 static GType type = 0;
228 if (G_UNLIKELY(type == 0))
230 static const GTypeInfo info =
232 sizeof (ModestScrollableIface),
233 modest_scrollable_base_init, /* base_init */
234 NULL, /* base_finalize */
235 NULL, /* class_init */
236 NULL, /* class_finalize */
237 NULL, /* class_data */
240 NULL, /* instance_init */
244 type = g_type_register_static (G_TYPE_INTERFACE,
245 "ModestScrollable", &info, 0);