/* fadable.c generated by valac 0.16.1, the Vala compiler * generated from fadable.vala, do not modify */ /* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*- * * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Michael Terry */ #include #include #include #include #include #define TYPE_FADE_TRACKER (fade_tracker_get_type ()) #define FADE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FADE_TRACKER, FadeTracker)) #define FADE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FADE_TRACKER, FadeTrackerClass)) #define IS_FADE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FADE_TRACKER)) #define IS_FADE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FADE_TRACKER)) #define FADE_TRACKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FADE_TRACKER, FadeTrackerClass)) typedef struct _FadeTracker FadeTracker; typedef struct _FadeTrackerClass FadeTrackerClass; typedef struct _FadeTrackerPrivate FadeTrackerPrivate; #define TYPE_ANIMATE_TIMER (animate_timer_get_type ()) #define ANIMATE_TIMER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ANIMATE_TIMER, AnimateTimer)) #define ANIMATE_TIMER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ANIMATE_TIMER, AnimateTimerClass)) #define IS_ANIMATE_TIMER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ANIMATE_TIMER)) #define IS_ANIMATE_TIMER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ANIMATE_TIMER)) #define ANIMATE_TIMER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ANIMATE_TIMER, AnimateTimerClass)) typedef struct _AnimateTimer AnimateTimer; typedef struct _AnimateTimerClass AnimateTimerClass; #define FADE_TRACKER_TYPE_MODE (fade_tracker_mode_get_type ()) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define TYPE_FADABLE (fadable_get_type ()) #define FADABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FADABLE, Fadable)) #define IS_FADABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FADABLE)) #define FADABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_FADABLE, FadableIface)) typedef struct _Fadable Fadable; typedef struct _FadableIface FadableIface; struct _FadeTracker { GObject parent_instance; FadeTrackerPrivate * priv; }; struct _FadeTrackerClass { GObjectClass parent_class; }; typedef enum { FADE_TRACKER_MODE_FADE_IN, FADE_TRACKER_MODE_FADE_OUT } FadeTrackerMode; struct _FadeTrackerPrivate { gdouble _alpha; GtkWidget* _widget; AnimateTimer* timer; FadeTrackerMode mode; }; typedef gdouble (*AnimateTimerEasingFunc) (gdouble x, void* user_data); struct _FadableIface { GTypeInterface parent_iface; FadeTracker* (*get_fade_tracker) (Fadable* self); void (*set_fade_tracker) (Fadable* self, FadeTracker* value); }; static gpointer fade_tracker_parent_class = NULL; GType fade_tracker_get_type (void) G_GNUC_CONST; GType animate_timer_get_type (void) G_GNUC_CONST; GType fade_tracker_mode_get_type (void) G_GNUC_CONST; #define FADE_TRACKER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_FADE_TRACKER, FadeTrackerPrivate)) enum { FADE_TRACKER_DUMMY_PROPERTY, FADE_TRACKER_ALPHA, FADE_TRACKER_WIDGET }; FadeTracker* fade_tracker_new (GtkWidget* widget); FadeTracker* fade_tracker_construct (GType object_type, GtkWidget* widget); void fade_tracker_reset (FadeTracker* self, FadeTrackerMode mode); static void fade_tracker_animate_cb (FadeTracker* self, gdouble progress); GtkWidget* fade_tracker_get_widget (FadeTracker* self); void animate_timer_reset (AnimateTimer* self, gint temp_speed); static void fade_tracker_set_alpha (FadeTracker* self, gdouble value); gdouble fade_tracker_get_alpha (FadeTracker* self); static void fade_tracker_set_widget (FadeTracker* self, GtkWidget* value); static GObject * fade_tracker_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); gdouble animate_timer_ease_out_quint (gdouble x); static gdouble _animate_timer_ease_out_quint_animate_timer_easing_func (gdouble x, gpointer self); #define ANIMATE_TIMER_INSTANT 150 AnimateTimer* animate_timer_new (AnimateTimerEasingFunc func, void* func_target, gint speed); AnimateTimer* animate_timer_construct (GType object_type, AnimateTimerEasingFunc func, void* func_target, gint speed); static void _fade_tracker_animate_cb_animate_timer_animate (AnimateTimer* _sender, gdouble progress, gpointer self); static void fade_tracker_finalize (GObject* obj); static void _vala_fade_tracker_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void _vala_fade_tracker_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); GType fadable_get_type (void) G_GNUC_CONST; void fadable_fade_in (Fadable* self); FadeTracker* fadable_get_fade_tracker (Fadable* self); void fadable_fade_out (Fadable* self); void fadable_set_fade_tracker (Fadable* self, FadeTracker* value); GType fade_tracker_mode_get_type (void) { static volatile gsize fade_tracker_mode_type_id__volatile = 0; if (g_once_init_enter (&fade_tracker_mode_type_id__volatile)) { static const GEnumValue values[] = {{FADE_TRACKER_MODE_FADE_IN, "FADE_TRACKER_MODE_FADE_IN", "fade-in"}, {FADE_TRACKER_MODE_FADE_OUT, "FADE_TRACKER_MODE_FADE_OUT", "fade-out"}, {0, NULL, NULL}}; GType fade_tracker_mode_type_id; fade_tracker_mode_type_id = g_enum_register_static ("FadeTrackerMode", values); g_once_init_leave (&fade_tracker_mode_type_id__volatile, fade_tracker_mode_type_id); } return fade_tracker_mode_type_id__volatile; } FadeTracker* fade_tracker_construct (GType object_type, GtkWidget* widget) { FadeTracker * self = NULL; GtkWidget* _tmp0_; g_return_val_if_fail (widget != NULL, NULL); _tmp0_ = widget; self = (FadeTracker*) g_object_new (object_type, "widget", _tmp0_, NULL); return self; } FadeTracker* fade_tracker_new (GtkWidget* widget) { return fade_tracker_construct (TYPE_FADE_TRACKER, widget); } void fade_tracker_reset (FadeTracker* self, FadeTrackerMode mode) { FadeTrackerMode _tmp0_; GtkWidget* _tmp1_; AnimateTimer* _tmp2_; g_return_if_fail (self != NULL); _tmp0_ = mode; self->priv->mode = _tmp0_; fade_tracker_animate_cb (self, 0.0); _tmp1_ = self->priv->_widget; gtk_widget_show (_tmp1_); _tmp2_ = self->priv->timer; animate_timer_reset (_tmp2_, 0); } static void fade_tracker_animate_cb (FadeTracker* self, gdouble progress) { FadeTrackerMode _tmp0_; GtkWidget* _tmp7_; g_return_if_fail (self != NULL); _tmp0_ = self->priv->mode; if (_tmp0_ == FADE_TRACKER_MODE_FADE_IN) { gdouble _tmp1_; gdouble _tmp2_; _tmp1_ = progress; fade_tracker_set_alpha (self, _tmp1_); _tmp2_ = progress; if (_tmp2_ == 1.0) { GtkWidget* _tmp3_; _tmp3_ = self->priv->_widget; gtk_widget_grab_focus (_tmp3_); g_signal_emit_by_name (self, "done"); } } else { gdouble _tmp4_; gdouble _tmp5_; _tmp4_ = progress; fade_tracker_set_alpha (self, 1.0 - _tmp4_); _tmp5_ = progress; if (_tmp5_ == 1.0) { GtkWidget* _tmp6_; _tmp6_ = self->priv->_widget; gtk_widget_hide (_tmp6_); g_signal_emit_by_name (self, "done"); } } _tmp7_ = self->priv->_widget; gtk_widget_queue_draw (_tmp7_); } gdouble fade_tracker_get_alpha (FadeTracker* self) { gdouble result; gdouble _tmp0_; g_return_val_if_fail (self != NULL, 0.0); _tmp0_ = self->priv->_alpha; result = _tmp0_; return result; } static void fade_tracker_set_alpha (FadeTracker* self, gdouble value) { gdouble _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = value; self->priv->_alpha = _tmp0_; g_object_notify ((GObject *) self, "alpha"); } GtkWidget* fade_tracker_get_widget (FadeTracker* self) { GtkWidget* result; GtkWidget* _tmp0_; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = self->priv->_widget; result = _tmp0_; return result; } static gpointer _g_object_ref0 (gpointer self) { return self ? g_object_ref (self) : NULL; } static void fade_tracker_set_widget (FadeTracker* self, GtkWidget* value) { GtkWidget* _tmp0_; GtkWidget* _tmp1_; g_return_if_fail (self != NULL); _tmp0_ = value; _tmp1_ = _g_object_ref0 (_tmp0_); _g_object_unref0 (self->priv->_widget); self->priv->_widget = _tmp1_; g_object_notify ((GObject *) self, "widget"); } static gdouble _animate_timer_ease_out_quint_animate_timer_easing_func (gdouble x, gpointer self) { gdouble result; result = animate_timer_ease_out_quint (x); return result; } static void _fade_tracker_animate_cb_animate_timer_animate (AnimateTimer* _sender, gdouble progress, gpointer self) { fade_tracker_animate_cb (self, progress); } static GObject * fade_tracker_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { GObject * obj; GObjectClass * parent_class; FadeTracker * self; AnimateTimer* _tmp0_; AnimateTimer* _tmp1_; parent_class = G_OBJECT_CLASS (fade_tracker_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = FADE_TRACKER (obj); _tmp0_ = animate_timer_new (_animate_timer_ease_out_quint_animate_timer_easing_func, NULL, ANIMATE_TIMER_INSTANT); _g_object_unref0 (self->priv->timer); self->priv->timer = _tmp0_; _tmp1_ = self->priv->timer; g_signal_connect_object (_tmp1_, "animate", (GCallback) _fade_tracker_animate_cb_animate_timer_animate, self, 0); return obj; } static void fade_tracker_class_init (FadeTrackerClass * klass) { fade_tracker_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (FadeTrackerPrivate)); G_OBJECT_CLASS (klass)->get_property = _vala_fade_tracker_get_property; G_OBJECT_CLASS (klass)->set_property = _vala_fade_tracker_set_property; G_OBJECT_CLASS (klass)->constructor = fade_tracker_constructor; G_OBJECT_CLASS (klass)->finalize = fade_tracker_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), FADE_TRACKER_ALPHA, g_param_spec_double ("alpha", "alpha", "alpha", -G_MAXDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), FADE_TRACKER_WIDGET, g_param_spec_object ("widget", "widget", "widget", GTK_TYPE_WIDGET, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); g_signal_new ("done", TYPE_FADE_TRACKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } static void fade_tracker_instance_init (FadeTracker * self) { self->priv = FADE_TRACKER_GET_PRIVATE (self); self->priv->_alpha = 1.0; } static void fade_tracker_finalize (GObject* obj) { FadeTracker * self; self = FADE_TRACKER (obj); _g_object_unref0 (self->priv->_widget); _g_object_unref0 (self->priv->timer); G_OBJECT_CLASS (fade_tracker_parent_class)->finalize (obj); } GType fade_tracker_get_type (void) { static volatile gsize fade_tracker_type_id__volatile = 0; if (g_once_init_enter (&fade_tracker_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (FadeTrackerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fade_tracker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FadeTracker), 0, (GInstanceInitFunc) fade_tracker_instance_init, NULL }; GType fade_tracker_type_id; fade_tracker_type_id = g_type_register_static (G_TYPE_OBJECT, "FadeTracker", &g_define_type_info, 0); g_once_init_leave (&fade_tracker_type_id__volatile, fade_tracker_type_id); } return fade_tracker_type_id__volatile; } static void _vala_fade_tracker_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { FadeTracker * self; self = FADE_TRACKER (object); switch (property_id) { case FADE_TRACKER_ALPHA: g_value_set_double (value, fade_tracker_get_alpha (self)); break; case FADE_TRACKER_WIDGET: g_value_set_object (value, fade_tracker_get_widget (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } static void _vala_fade_tracker_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { FadeTracker * self; self = FADE_TRACKER (object); switch (property_id) { case FADE_TRACKER_ALPHA: fade_tracker_set_alpha (self, g_value_get_double (value)); break; case FADE_TRACKER_WIDGET: fade_tracker_set_widget (self, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } } void fadable_fade_in (Fadable* self) { FadeTracker* _tmp0_; FadeTracker* _tmp1_; _tmp0_ = fadable_get_fade_tracker (self); _tmp1_ = _tmp0_; fade_tracker_reset (_tmp1_, FADE_TRACKER_MODE_FADE_IN); } void fadable_fade_out (Fadable* self) { FadeTracker* _tmp0_; FadeTracker* _tmp1_; _tmp0_ = fadable_get_fade_tracker (self); _tmp1_ = _tmp0_; fade_tracker_reset (_tmp1_, FADE_TRACKER_MODE_FADE_OUT); } FadeTracker* fadable_get_fade_tracker (Fadable* self) { g_return_val_if_fail (self != NULL, NULL); return FADABLE_GET_INTERFACE (self)->get_fade_tracker (self); } void fadable_set_fade_tracker (Fadable* self, FadeTracker* value) { g_return_if_fail (self != NULL); FADABLE_GET_INTERFACE (self)->set_fade_tracker (self, value); } static void fadable_base_init (FadableIface * iface) { static gboolean initialized = FALSE; if (!initialized) { initialized = TRUE; g_object_interface_install_property (iface, g_param_spec_object ("fade-tracker", "fade-tracker", "fade-tracker", TYPE_FADE_TRACKER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); } } GType fadable_get_type (void) { static volatile gsize fadable_type_id__volatile = 0; if (g_once_init_enter (&fadable_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (FadableIface), (GBaseInitFunc) fadable_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; GType fadable_type_id; fadable_type_id = g_type_register_static (G_TYPE_INTERFACE, "Fadable", &g_define_type_info, 0); g_type_interface_add_prerequisite (fadable_type_id, GTK_TYPE_WIDGET); g_once_init_leave (&fadable_type_id__volatile, fadable_type_id); } return fadable_type_id__volatile; }