~ubuntu-branches/debian/sid/cheese/sid

« back to all changes in this revision

Viewing changes to src/cheese-countdown.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2011-07-17 21:04:16 UTC
  • mfrom: (15.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110717210416-nt5qi659qei7a2yy
Tags: 3.0.1-2
* debian/control.in:
  - Change gir1.2-cheese-3.0 Section to libs
  - Make library packages depend against cheese-common package
  - Make cheese package recommends against hicolor-icon-theme
  - Move gst Dependency to libcheese package
* debian/patches/0002-fix-linking.patch: Add missing library to fix linking
* debian/watch:
  - Switch to .bz2 tarballs.
  - Bump version to 3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* cheese-countdown.c generated by valac 0.12.0, the Vala compiler
 
2
 * generated from cheese-countdown.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright © 2010 Yuvaraj Pandian T <yuvipanda@yuvi.in>
 
6
 * Copyright © 2010 daniel g. siegel <dgsiegel@gnome.org>
 
7
 * Copyright © 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
 
8
 *
 
9
 * Licensed under the GNU General Public License Version 2
 
10
 *
 
11
 * This program is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU General Public License as published by
 
13
 * the Free Software Foundation; either version 2 of the License, or
 
14
 * (at your option) any later version.
 
15
 *
 
16
 * This program is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU General Public License
 
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
23
 */
 
24
 
 
25
#include <glib.h>
 
26
#include <glib-object.h>
 
27
#include <clutter/clutter.h>
 
28
 
 
29
 
 
30
#define CHEESE_TYPE_COUNTDOWN (cheese_countdown_get_type ())
 
31
#define CHEESE_COUNTDOWN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_COUNTDOWN, CheeseCountdown))
 
32
#define CHEESE_COUNTDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_COUNTDOWN, CheeseCountdownClass))
 
33
#define CHEESE_IS_COUNTDOWN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_COUNTDOWN))
 
34
#define CHEESE_IS_COUNTDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_COUNTDOWN))
 
35
#define CHEESE_COUNTDOWN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_COUNTDOWN, CheeseCountdownClass))
 
36
 
 
37
typedef struct _CheeseCountdown CheeseCountdown;
 
38
typedef struct _CheeseCountdownClass CheeseCountdownClass;
 
39
typedef struct _CheeseCountdownPrivate CheeseCountdownPrivate;
 
40
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
41
#define _g_free0(var) (var = (g_free (var), NULL))
 
42
 
 
43
struct _CheeseCountdown {
 
44
        GObject parent_instance;
 
45
        CheeseCountdownPrivate * priv;
 
46
        gboolean running;
 
47
};
 
48
 
 
49
struct _CheeseCountdownClass {
 
50
        GObjectClass parent_class;
 
51
};
 
52
 
 
53
struct _CheeseCountdownPrivate {
 
54
        ClutterText* countdown_actor;
 
55
};
 
56
 
 
57
typedef void (*CheeseCountdownCountdownCallback) (void* user_data);
 
58
 
 
59
static gpointer cheese_countdown_parent_class = NULL;
 
60
static CheeseCountdownCountdownCallback cheese_countdown_completed_callback;
 
61
static gpointer cheese_countdown_completed_callback_target;
 
62
static GDestroyNotify cheese_countdown_completed_callback_target_destroy_notify;
 
63
static CheeseCountdownCountdownCallback cheese_countdown_completed_callback = NULL;
 
64
static gpointer cheese_countdown_completed_callback_target = NULL;
 
65
static GDestroyNotify cheese_countdown_completed_callback_target_destroy_notify = NULL;
 
66
static gint cheese_countdown_current_value;
 
67
static gint cheese_countdown_current_value = 0;
 
68
static gulong cheese_countdown_signal_id;
 
69
static gulong cheese_countdown_signal_id = 0UL;
 
70
static ClutterAnimation* cheese_countdown_anim;
 
71
static ClutterAnimation* cheese_countdown_anim = NULL;
 
72
 
 
73
#define COUNTDOWN_START 3
 
74
GType cheese_countdown_get_type (void) G_GNUC_CONST;
 
75
#define CHEESE_COUNTDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_COUNTDOWN, CheeseCountdownPrivate))
 
76
enum  {
 
77
        CHEESE_COUNTDOWN_DUMMY_PROPERTY
 
78
};
 
79
CheeseCountdown* cheese_countdown_new (ClutterText* countdown_actor);
 
80
CheeseCountdown* cheese_countdown_construct (GType object_type, ClutterText* countdown_actor);
 
81
static void cheese_countdown_fade_out (CheeseCountdown* self);
 
82
static void cheese_countdown_fade_in (CheeseCountdown* self);
 
83
void cheese_countdown_start (CheeseCountdown* self, CheeseCountdownCountdownCallback completed_callback, void* completed_callback_target);
 
84
void cheese_countdown_stop (CheeseCountdown* self);
 
85
static void cheese_countdown_finalize (GObject* obj);
 
86
 
 
87
 
 
88
static gpointer _g_object_ref0 (gpointer self) {
 
89
        return self ? g_object_ref (self) : NULL;
 
90
}
 
91
 
 
92
 
 
93
CheeseCountdown* cheese_countdown_construct (GType object_type, ClutterText* countdown_actor) {
 
94
        CheeseCountdown * self = NULL;
 
95
        ClutterText* _tmp0_;
 
96
        g_return_val_if_fail (countdown_actor != NULL, NULL);
 
97
        self = (CheeseCountdown*) g_object_new (object_type, NULL);
 
98
        _tmp0_ = _g_object_ref0 (countdown_actor);
 
99
        _g_object_unref0 (self->priv->countdown_actor);
 
100
        self->priv->countdown_actor = _tmp0_;
 
101
        return self;
 
102
}
 
103
 
 
104
 
 
105
CheeseCountdown* cheese_countdown_new (ClutterText* countdown_actor) {
 
106
        return cheese_countdown_construct (CHEESE_TYPE_COUNTDOWN, countdown_actor);
 
107
}
 
108
 
 
109
 
 
110
static void cheese_countdown_fade_out (CheeseCountdown* self) {
 
111
        ClutterAnimation* _tmp0_ = NULL;
 
112
        ClutterAnimation* _tmp1_;
 
113
        gulong _tmp2_;
 
114
        g_return_if_fail (self != NULL);
 
115
        _tmp0_ = clutter_actor_animate ((ClutterActor*) self->priv->countdown_actor, (gulong) CLUTTER_LINEAR, (guint) 500, "opacity", 0, NULL);
 
116
        _tmp1_ = _g_object_ref0 (_tmp0_);
 
117
        _g_object_unref0 (cheese_countdown_anim);
 
118
        cheese_countdown_anim = _tmp1_;
 
119
        _tmp2_ = g_signal_connect_after (cheese_countdown_anim, "completed", (GCallback) cheese_countdown_fade_in, self);
 
120
        cheese_countdown_signal_id = _tmp2_;
 
121
}
 
122
 
 
123
 
 
124
static void cheese_countdown_fade_in (CheeseCountdown* self) {
 
125
        gchar* _tmp0_ = NULL;
 
126
        gchar* _tmp1_;
 
127
        ClutterAnimation* _tmp2_ = NULL;
 
128
        ClutterAnimation* _tmp3_;
 
129
        gulong _tmp4_;
 
130
        g_return_if_fail (self != NULL);
 
131
        if (cheese_countdown_current_value <= 0) {
 
132
                cheese_countdown_completed_callback (cheese_countdown_completed_callback_target);
 
133
                self->running = FALSE;
 
134
                return;
 
135
        }
 
136
        _tmp0_ = g_strdup_printf ("%i", cheese_countdown_current_value);
 
137
        _tmp1_ = _tmp0_;
 
138
        clutter_text_set_text (self->priv->countdown_actor, _tmp1_);
 
139
        _g_free0 (_tmp1_);
 
140
        cheese_countdown_current_value--;
 
141
        _tmp2_ = clutter_actor_animate ((ClutterActor*) self->priv->countdown_actor, (gulong) CLUTTER_LINEAR, (guint) 500, "opacity", 255, NULL);
 
142
        _tmp3_ = _g_object_ref0 (_tmp2_);
 
143
        _g_object_unref0 (cheese_countdown_anim);
 
144
        cheese_countdown_anim = _tmp3_;
 
145
        _tmp4_ = g_signal_connect_after (cheese_countdown_anim, "completed", (GCallback) cheese_countdown_fade_out, self);
 
146
        cheese_countdown_signal_id = _tmp4_;
 
147
}
 
148
 
 
149
 
 
150
void cheese_countdown_start (CheeseCountdown* self, CheeseCountdownCountdownCallback completed_callback, void* completed_callback_target) {
 
151
        CheeseCountdownCountdownCallback _tmp0_;
 
152
        g_return_if_fail (self != NULL);
 
153
        _tmp0_ = completed_callback;
 
154
        (cheese_countdown_completed_callback_target_destroy_notify == NULL) ? NULL : (cheese_countdown_completed_callback_target_destroy_notify (cheese_countdown_completed_callback_target), NULL);
 
155
        cheese_countdown_completed_callback = NULL;
 
156
        cheese_countdown_completed_callback_target = NULL;
 
157
        cheese_countdown_completed_callback_target_destroy_notify = NULL;
 
158
        cheese_countdown_completed_callback = _tmp0_;
 
159
        cheese_countdown_completed_callback_target = completed_callback_target;
 
160
        cheese_countdown_completed_callback_target_destroy_notify = NULL;
 
161
        cheese_countdown_current_value = COUNTDOWN_START;
 
162
        self->running = TRUE;
 
163
        clutter_actor_show ((ClutterActor*) self->priv->countdown_actor);
 
164
        cheese_countdown_fade_in (self);
 
165
}
 
166
 
 
167
 
 
168
void cheese_countdown_stop (CheeseCountdown* self) {
 
169
        g_return_if_fail (self != NULL);
 
170
        clutter_actor_hide ((ClutterActor*) self->priv->countdown_actor);
 
171
        g_signal_handler_disconnect (cheese_countdown_anim, cheese_countdown_signal_id);
 
172
        self->running = FALSE;
 
173
}
 
174
 
 
175
 
 
176
static void cheese_countdown_class_init (CheeseCountdownClass * klass) {
 
177
        cheese_countdown_parent_class = g_type_class_peek_parent (klass);
 
178
        g_type_class_add_private (klass, sizeof (CheeseCountdownPrivate));
 
179
        G_OBJECT_CLASS (klass)->finalize = cheese_countdown_finalize;
 
180
}
 
181
 
 
182
 
 
183
static void cheese_countdown_instance_init (CheeseCountdown * self) {
 
184
        self->priv = CHEESE_COUNTDOWN_GET_PRIVATE (self);
 
185
}
 
186
 
 
187
 
 
188
static void cheese_countdown_finalize (GObject* obj) {
 
189
        CheeseCountdown * self;
 
190
        self = CHEESE_COUNTDOWN (obj);
 
191
        _g_object_unref0 (self->priv->countdown_actor);
 
192
        G_OBJECT_CLASS (cheese_countdown_parent_class)->finalize (obj);
 
193
}
 
194
 
 
195
 
 
196
GType cheese_countdown_get_type (void) {
 
197
        static volatile gsize cheese_countdown_type_id__volatile = 0;
 
198
        if (g_once_init_enter (&cheese_countdown_type_id__volatile)) {
 
199
                static const GTypeInfo g_define_type_info = { sizeof (CheeseCountdownClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) cheese_countdown_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CheeseCountdown), 0, (GInstanceInitFunc) cheese_countdown_instance_init, NULL };
 
200
                GType cheese_countdown_type_id;
 
201
                cheese_countdown_type_id = g_type_register_static (G_TYPE_OBJECT, "CheeseCountdown", &g_define_type_info, 0);
 
202
                g_once_init_leave (&cheese_countdown_type_id__volatile, cheese_countdown_type_id);
 
203
        }
 
204
        return cheese_countdown_type_id__volatile;
 
205
}
 
206
 
 
207
 
 
208