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);
127 modest_scrollable_base_init (gpointer g_iface)
129 static gboolean initialized = FALSE;
132 /* create interface signals here. */
135 g_object_interface_install_property (g_iface,
136 g_param_spec_enum ("vscrollbar_policy",
138 "Visual policy of the vertical scrollbar",
139 GTK_TYPE_POLICY_TYPE,
140 GTK_POLICY_AUTOMATIC,
144 g_object_interface_install_property (g_iface,
145 g_param_spec_enum ("hscrollbar_policy",
147 "Visual policy of the horizontal scrollbar",
148 GTK_TYPE_POLICY_TYPE,
149 GTK_POLICY_AUTOMATIC,
158 modest_scrollable_get_type (void)
160 static GType type = 0;
162 if (G_UNLIKELY(type == 0))
164 static const GTypeInfo info =
166 sizeof (ModestScrollableIface),
167 modest_scrollable_base_init, /* base_init */
168 NULL, /* base_finalize */
169 NULL, /* class_init */
170 NULL, /* class_finalize */
171 NULL, /* class_data */
174 NULL, /* instance_init */
178 type = g_type_register_static (G_TYPE_INTERFACE,
179 "ModestScrollable", &info, 0);