[go: up one dir, main page]

File: test-score.c

package info (click to toggle)
clutter 0.8.0-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 11,808 kB
  • ctags: 10,141
  • sloc: ansic: 60,915; xml: 27,567; sh: 9,271; makefile: 848
file content (110 lines) | stat: -rw-r--r-- 3,189 bytes parent folder | download
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
#include <stdio.h>
#include <stdlib.h>
#include <clutter/clutter.h>

static gint level = 1;

static void
on_timeline_started (ClutterScore    *score,
                     ClutterTimeline *timeline)
{
  gint i;

  for (i = 0; i < level; i++)
    g_print (" ");

  g_print ("Started timeline: `%s'\n",
           (gchar *) g_object_get_data (G_OBJECT (timeline), "timeline-name"));

  level += 1;
}

static void
on_timeline_completed (ClutterScore    *score,
                       ClutterTimeline *timeline)
{
  gint i;

  level -= 1;

  for (i = 0; i < level; i++)
    g_print (" ");

  g_print ("Completed timeline: `%s'\n",
           (gchar *) g_object_get_data (G_OBJECT (timeline), "timeline-name"));
}

int
main (int argc, char **argv)
{
  ClutterScore    *score;
  ClutterTimeline *timeline_1;
  ClutterTimeline *timeline_2;
  ClutterTimeline *timeline_3;
  ClutterTimeline *timeline_4;
  ClutterTimeline *timeline_5;
  GSList *timelines;

  clutter_init (&argc, &argv);

  timeline_1 = clutter_timeline_new_for_duration (1000);
  g_object_set_data_full (G_OBJECT (timeline_1),
                          "timeline-name", g_strdup ("Timeline 1"),
                          g_free);

  timeline_2 = clutter_timeline_new_for_duration (1000);
  clutter_timeline_add_marker_at_time (timeline_2, "foo", 500);
  g_object_set_data_full (G_OBJECT (timeline_2),
                          "timeline-name", g_strdup ("Timeline 2"),
                          g_free);

  timeline_3 = clutter_timeline_new_for_duration (1000);
  g_object_set_data_full (G_OBJECT (timeline_3),
                          "timeline-name", g_strdup ("Timeline 3"),
                          g_free);

  timeline_4 = clutter_timeline_new_for_duration (1000);
  g_object_set_data_full (G_OBJECT (timeline_4),
                          "timeline-name", g_strdup ("Timeline 4"),
                          g_free);

  timeline_5 = clutter_timeline_new_for_duration (1000);
  g_object_set_data_full (G_OBJECT (timeline_5),
                          "timeline-name", g_strdup ("Timeline 5"),
                          g_free);

  score = clutter_score_new();
  g_signal_connect (score, "timeline-started",
                    G_CALLBACK (on_timeline_started),
                    NULL);
  g_signal_connect (score, "timeline-completed",
                    G_CALLBACK (on_timeline_completed),
                    NULL);
  g_signal_connect (score, "completed",
                    G_CALLBACK (clutter_main_quit),
                    NULL);

  clutter_score_append (score, NULL,       timeline_1);
  clutter_score_append (score, timeline_1, timeline_2);
  clutter_score_append (score, timeline_1, timeline_3);
  clutter_score_append (score, timeline_3, timeline_4);

  clutter_score_append_at_marker (score, timeline_2, "foo", timeline_5);

  timelines = clutter_score_list_timelines (score);
  g_assert (5 == g_slist_length (timelines));
  g_slist_free (timelines);

  clutter_score_start (score);

  clutter_main ();

  g_object_unref (timeline_1);
  g_object_unref (timeline_2);
  g_object_unref (timeline_3);
  g_object_unref (timeline_4);
  g_object_unref (timeline_5);
  g_object_unref (score);

  return EXIT_SUCCESS;
}