1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
/*
* Authored By Neil Jagdish Patel <njp@o-hand.com>
*
* Copyright (C) 2007 OpenedHand
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <clutter/clutter.h>
#include <libaaina/aaina-library.h>
#include <libaaina/aaina-source.h>
#include <libaaina/aaina-behave.h>
#include <sources/aaina-source-directory.h>
#include <sources/aaina-source-flickr.h>
#include "aaina-slide-show.h"
static AainaSlideShow *show = NULL;
static ClutterTimeline *timeline = NULL;
/* Command line options */
static gboolean fullscreen = FALSE;
static gchar **directories = NULL;
static gchar *flickr_tags = NULL;
static GOptionEntry entries[] =
{
{
"fullscreen",
'f', 0,
G_OPTION_ARG_NONE,
&fullscreen,
"Launch Aaina in fullscreen mode",
NULL
},
{
"directory",
'd', 0,
G_OPTION_ARG_FILENAME_ARRAY,
&directories,
"The directory to load pictures from",
"PATH"
},
{
"tag",
't', 0,
G_OPTION_ARG_STRING,
&flickr_tags,
"A set of comma-separated tags to search flickr with",
"TAG"
},
{
NULL
}
};
static void on_key_release_event (ClutterStage *stage,
ClutterEvent *event,
gpointer null);
static void spin_me (ClutterBehaviour *behave,
guint32 alpha_value,
gpointer null);
static gboolean
im_spinning_around (ClutterTimeline *time)
{
if (!clutter_timeline_is_playing (timeline))
clutter_timeline_start (timeline);
return TRUE;
}
int
main (int argc, char **argv)
{
AainaLibrary *library;
AainaSource *source;
ClutterActor *stage;
ClutterAlpha *alpha;
ClutterBehaviour *behave;
ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
GError *error = NULL;
g_thread_init (NULL);
g_set_application_name ("Aaina Image Slideshow");
clutter_init_with_args (&argc, &argv,
" - Aaina Image Slideshow", entries,
NULL,
&error);
if (error)
{
g_print ("Unable to run Aaina: %s", error->message);
g_error_free (error);
return EXIT_FAILURE;
}
stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, 720, 480);
clutter_stage_hide_cursor (CLUTTER_STAGE (stage));
if (fullscreen)
clutter_stage_fullscreen (CLUTTER_STAGE (stage));
clutter_stage_set_color (CLUTTER_STAGE (stage), &black);
/* Load the test source */
library = aaina_library_new ();
if (directories && directories[0])
{
gint n_directories, i;
n_directories = g_strv_length (directories);
for (i = 0; i < n_directories; i++)
source = aaina_source_directory_new (library, directories[i]);
}
else if (flickr_tags)
source = aaina_source_flickr_new (library, flickr_tags);
else
{
g_print ("Usage: aaina -d <path>\n"
" aaina -t <tag>[,<tag>,....]\n");
return EXIT_FAILURE;
}
show = aaina_slide_show_get_default ();
clutter_group_add (CLUTTER_GROUP (stage), CLUTTER_ACTOR (show));
clutter_actor_set_position (CLUTTER_ACTOR (show), 0, 0);
clutter_actor_set_size (CLUTTER_ACTOR (show),
CLUTTER_STAGE_WIDTH (),
CLUTTER_STAGE_HEIGHT ()) ;
clutter_actor_show_all (CLUTTER_ACTOR (show));
g_object_set (G_OBJECT (show), "library", library, NULL);
clutter_actor_show_all (stage);
/*clutter_actor_set_scale (stage, 0.25, 0.25);*/
g_signal_connect (G_OBJECT (stage), "key-release-event",
G_CALLBACK (on_key_release_event), (gpointer)stage);
timeline = clutter_timeline_new (60, 30);
alpha = clutter_alpha_new_full (timeline,
alpha_sine_inc_func,
NULL, NULL);
behave = aaina_behave_new (alpha,
(AainaBehaveAlphaFunc)spin_me,
(gpointer)stage);
clutter_actor_set_rotation (stage, CLUTTER_Y_AXIS, 0,
CLUTTER_STAGE_WIDTH ()/2,
0,
CLUTTER_STAGE_HEIGHT ());
g_timeout_add (120000, (GSourceFunc)im_spinning_around, timeline);
clutter_main ();
return EXIT_SUCCESS;
}
static void
on_key_release_event (ClutterStage *stage,
ClutterEvent *event,
gpointer null)
{
static gint i = 0;
switch (clutter_key_event_symbol ((ClutterKeyEvent*)event))
{
case CLUTTER_Escape:
clutter_main_quit ();
break;
case CLUTTER_Left:
i--;
if (i == 0)
i = 359;
clutter_actor_set_rotation (CLUTTER_ACTOR (stage), CLUTTER_Y_AXIS, i,
CLUTTER_STAGE_WIDTH ()/2,
0,
CLUTTER_STAGE_HEIGHT ());
break;
case CLUTTER_Right:
i++;
if (i == 360)
i = 0;
clutter_actor_set_rotation (CLUTTER_ACTOR (stage), CLUTTER_Y_AXIS, i,
CLUTTER_STAGE_WIDTH ()/2,
0,
CLUTTER_STAGE_HEIGHT ());
break;
case CLUTTER_Up:
if (!clutter_timeline_is_playing (timeline))
clutter_timeline_start (timeline);
break;
default:
break;
}
}
static void
spin_me (ClutterBehaviour *behave,
guint32 alpha_value,
gpointer null)
{
gfloat factor = (gfloat)alpha_value / CLUTTER_ALPHA_MAX_ALPHA;
clutter_actor_set_rotation (CLUTTER_ACTOR (show), CLUTTER_Y_AXIS, factor * 360,
CLUTTER_STAGE_WIDTH ()/2, 0, 0);
}
|