Change the GtkClutter macro namespace
[clutter-gtk] / clutter-gtk / gtk-clutter-scrollable.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include "gtk-clutter-scrollable.h"
6
7 #define I_(str) (g_intern_static_string ((str)))
8
9 /**
10  * SECTION:gtk-clutter-scrollable
11  * @short_description: Interface for scrollable actors
12  *
13  * FIXME
14  *
15  * #GtkClutterScrollable is available since Clutter-GTK 1.0
16  */
17
18 static void
19 gtk_clutter_scrollable_base_init (gpointer g_iface)
20 {
21   static gboolean is_initialized = FALSE;
22
23   if (G_UNLIKELY (!is_initialized))
24     {
25       GParamSpec *pspec;
26
27       /**
28        * GtkClutterScrollable:hadjustment:
29        *
30        * The #GtkAdjustment that determines the value of the
31        * horizontal position for this scrollable actor.
32        *
33        * Since: 1.0
34        */
35       pspec = g_param_spec_object ("hadjustment",
36                                    "Horizontal adjustment",
37                                    "The GtkAdjustment that determines "
38                                    "the value of the horizontal position "
39                                    "for this scrollable actor",
40                                    GTK_TYPE_ADJUSTMENT,
41                                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
42       g_object_interface_install_property (g_iface, pspec);
43
44       /**
45        * GtkClutterScrollable:vadjustment:
46        *
47        * The #GtkAdjustment that determines the value of the
48        * vertical position for this scrollable actor.
49        *
50        * Since: 1.0
51        */
52       pspec = g_param_spec_object ("vadjustment",
53                                    "Vertical adjustment",
54                                    "The GtkAdjustment that determines "
55                                    "the value of the vertical position "
56                                    "for this scrollable actor",
57                                    GTK_TYPE_ADJUSTMENT,
58                                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
59       g_object_interface_install_property (g_iface, pspec);
60
61       is_initialized = TRUE;
62     }
63 }
64
65 GType
66 gtk_clutter_scrollable_get_type (void)
67 {
68   static GType scrollable_type = 0;
69
70   if (G_UNLIKELY (!scrollable_type))
71     {
72       const GTypeInfo scrollable_info =
73       {
74         sizeof (GtkClutterScrollableIface),
75         (GBaseInitFunc)     gtk_clutter_scrollable_base_init,
76         (GBaseFinalizeFunc) NULL,
77       };
78
79       scrollable_type = g_type_register_static (G_TYPE_INTERFACE,
80                                                 I_("GtkClutterScrollable"),
81                                                 &scrollable_info, 0);
82     }
83
84   return scrollable_type;
85 }
86
87 /**
88  * gtk_clutter_scrollable_set_adjustments:
89  * @scrollable: a #GtkClutterScrollable
90  * @h_adjust: a #GtkAdjustment, or %NULL
91  * @v_adjust: a #GtkAdjustment, or %NULL
92  *
93  * Sets the horizontal and vertical adjustments used to determine
94  * the position of the scrollable actor.
95  *
96  * Since: 1.0
97  */
98 void
99 gtk_clutter_scrollable_set_adjustments (GtkClutterScrollable *scrollable,
100                                         GtkAdjustment        *h_adjust,
101                                         GtkAdjustment        *v_adjust)
102 {
103   GtkClutterScrollableIface *iface;
104
105   g_return_if_fail (GTK_CLUTTER_IS_SCROLLABLE (scrollable));
106   g_return_if_fail (h_adjust == NULL || GTK_IS_ADJUSTMENT (h_adjust));
107
108   iface = GTK_CLUTTER_SCROLLABLE_GET_IFACE (scrollable);
109   if (iface->set_adjustments)
110     iface->set_adjustments (scrollable, h_adjust, v_adjust);
111 }
112
113 /**
114  * gtk_clutter_scrollable_get_adjustments:
115  * @scrollable: a #GtkClutterScrollable
116  * @h_adjust: return location for a #GtkAdjustment, or %NULL
117  * @v_adjust: return location for a #GtkAdjustment, or %NULL
118  *
119  * Retrieves the horizontal and vertical adjustments used to
120  * determine the position of the scrollable actor.
121  *
122  * Since: 1.0
123  */
124 void
125 gtk_clutter_scrollable_get_adjustments (GtkClutterScrollable  *scrollable,
126                                         GtkAdjustment        **h_adjust,
127                                         GtkAdjustment        **v_adjust)
128 {
129   GtkClutterScrollableIface *iface;
130
131   g_return_if_fail (GTK_CLUTTER_IS_SCROLLABLE (scrollable));
132
133   iface = GTK_CLUTTER_SCROLLABLE_GET_IFACE (scrollable);
134   if (iface->get_adjustments)
135     iface->get_adjustments (scrollable, h_adjust, v_adjust);
136 }