Add dependencies
[clutter-gtk] / clutter-gtk / gtk-clutter-zoomable.c
1 #if HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include "gtk-clutter-zoomable.h"
6
7 #define I_(str) (g_intern_static_string ((str)))
8
9 /**
10  * SECTION:gtk-clutter-zoomable
11  * @short_description: Interface for zoomable actors
12  *
13  * #GtkClutterZoomable is an interface for zoomable actors, using, like
14  * #GtkClutterScrollable, the #GtkAdjustment objects from GTK+ to drive
15  * the zoom factor.
16  *
17  * #GtkClutterZoomable is available since Clutter-GTK 1.0
18  */
19
20 static void
21 gtk_clutter_zoomable_base_init (gpointer g_iface)
22 {
23   static gboolean is_initialized = FALSE;
24
25   if (G_UNLIKELY (!is_initialized))
26     {
27       GParamSpec *pspec;
28
29       /**
30        * GtkClutterZoomable:zadjustment:
31        *
32        * The #GtkAdjustment that determines the value of
33        * the zoom factor for this zoomable actor
34        *
35        * Since: 0.10
36        */
37       pspec = g_param_spec_object ("zadjustment",
38                                    "Zoom Adjustment",
39                                    "The GtkAdjustment that determines "
40                                    "the zoom factor",
41                                    GTK_TYPE_ADJUSTMENT,
42                                    G_PARAM_READWRITE |
43                                    G_PARAM_CONSTRUCT);
44       g_object_interface_install_property (g_iface, pspec);
45
46       is_initialized = TRUE;
47     }
48 }
49
50 GType
51 gtk_clutter_zoomable_get_type (void)
52 {
53   static GType zoomable_type = 0;
54
55   if (G_UNLIKELY (!zoomable_type))
56     {
57       const GTypeInfo zoomable_info =
58       {
59         sizeof (GtkClutterZoomableIface),
60         (GBaseInitFunc)     gtk_clutter_zoomable_base_init,
61         (GBaseFinalizeFunc) NULL,
62       };
63
64       zoomable_type = g_type_register_static (G_TYPE_INTERFACE,
65                                               I_("GtkClutterZoomable"),
66                                               &zoomable_info, 0);
67     }
68
69   return zoomable_type;
70 }
71
72 /**
73  * gtk_clutter_zoomable_set_adjustment:
74  * @zoomable: a #GtkClutterZoomable
75  * @z_adjust: (null-ok): a #GtkAdjustment, or %NULL
76  *
77  * Sets the adjustment used to determine the zoom factor of
78  * the zoomable actor
79  *
80  * Since: 0.10
81  */
82 void
83 gtk_clutter_zoomable_set_adjustment (GtkClutterZoomable *zoomable,
84                                      GtkAdjustment      *z_adjust)
85 {
86   GtkClutterZoomableIface *iface;
87
88   g_return_if_fail (GTK_CLUTTER_IS_ZOOMABLE (zoomable));
89   g_return_if_fail (z_adjust == NULL || GTK_IS_ADJUSTMENT (z_adjust));
90
91   iface = GTK_CLUTTER_ZOOMABLE_GET_IFACE (zoomable);
92   if (iface->set_adjustment)
93     iface->set_adjustment (zoomable, z_adjust);
94 }
95
96 /**
97  * gtk_clutter_zoomable_get_adjustment:
98  * @zoomable: a #GtkClutterZoomable
99  *
100  * Retrieves the adjustment used to determine the zoom factor of
101  * the zoomable actor
102  *
103  * Return value: (transfer none): a #GtkAdjustment
104  *
105  * Since: 0.10
106  */
107 GtkAdjustment *
108 gtk_clutter_zoomable_get_adjustment (GtkClutterZoomable *zoomable)
109 {
110   GtkClutterZoomableIface *iface;
111
112   g_return_val_if_fail (GTK_CLUTTER_IS_ZOOMABLE (zoomable), NULL);
113
114   iface = GTK_CLUTTER_ZOOMABLE_GET_IFACE (zoomable);
115   if (iface->get_adjustment)
116     return iface->get_adjustment (zoomable);
117
118   return NULL;
119 }