void on_update_clock(ClutterTimeline *timeline, gint frame_num, gpointer data) { HandCar *all = (HandCar *)data; gchar *txt; gint64 time = -1; gint hours, minutes, seconds; if(!gst_element_query_position (all->player, &all->format, &time)) clutter_label_set_text (CLUTTER_LABEL(all->label_time), "<span size='6000'>UNKNOWN</span>"); else if (time != -1) { time /= GST_SECOND; hours = time / (60 * 60); minutes = (time - (hours *60 * 60)) / 60; seconds = time % 60; txt = g_strdup_printf ("%02d:%02d:%02d", hours, minutes, seconds); clutter_label_set_text(CLUTTER_LABEL(all->label_time), txt); g_free (txt); } }
gboolean on_event (ClutterStage *stage, ClutterEvent *event, gpointer user_data) { switch (event->type) { case CLUTTER_BUTTON_PRESS: { gint x, y; ClutterActor * actor; ClutterUnit xu2, yu2; clutter_event_get_coords (event, &x, &y); actor = clutter_stage_get_actor_at_pos (stage, x, y); if (clutter_actor_transform_stage_point (actor, CLUTTER_UNITS_FROM_DEVICE (x), CLUTTER_UNITS_FROM_DEVICE (y), &xu2, &yu2)) { gchar *txt; if (actor != CLUTTER_ACTOR (stage)) txt = g_strdup_printf ("Click on rectangle\n" "Screen coords: [%d, %d]\n" "Local coords : [%d, %d]", x, y, CLUTTER_UNITS_TO_DEVICE (xu2), CLUTTER_UNITS_TO_DEVICE (yu2)); else txt = g_strdup_printf ("Click on stage\n" "Screen coords: [%d, %d]\n" "Local coords : [%d, %d]", x, y, CLUTTER_UNITS_TO_DEVICE (xu2), CLUTTER_UNITS_TO_DEVICE (yu2)); clutter_label_set_text (CLUTTER_LABEL (label), txt); g_free (txt); } else clutter_label_set_text (CLUTTER_LABEL (label), "Unprojection failed."); } break; default: break; } return FALSE; }
static gboolean update_label_idle (gpointer data) { TestUpdate *update = data; guint width; gchar *text; text = g_strdup_printf ("Count to %d", update->count); clutter_label_set_text (CLUTTER_LABEL (update->thread_data->label), text); clutter_actor_set_width (update->thread_data->label, -1); if (update->count == 0) width = 0; else if (update->count == 100) width = 350; else width = (guint) (update->count / 100.0 * 350.0); clutter_actor_set_width (update->thread_data->progress, width); g_free (text); g_free (update); return FALSE; }
static void on_key_press_event (ClutterStage *stage, ClutterKeyEvent *event, gpointer user_data) { TestThreadData *data; switch (clutter_key_event_symbol (event)) { case CLUTTER_s: clutter_label_set_text (CLUTTER_LABEL (help_label), "Press 'q' to quit"); clutter_timeline_start (timeline); data = test_thread_data_new (); data->stage = g_object_ref (stage); data->label = g_object_ref (count_label); data->progress = g_object_ref (progress_rect); data->timeline = g_object_ref (timeline); g_thread_create (test_thread_func, data, FALSE, NULL); break; case CLUTTER_q: clutter_main_quit (); break; } }
static void astro_systray_init (AstroSystray *systray) { AstroSystrayPrivate *priv; GdkPixbuf *pixbuf; ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; gint width; gchar *font; priv = systray->priv = ASTRO_SYSTRAY_GET_PRIVATE (systray); pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/icons/bt.png", NULL); if (pixbuf) { priv->bt = clutter_texture_new_from_pixbuf (pixbuf); clutter_container_add_actor (CLUTTER_CONTAINER (systray), priv->bt); clutter_actor_set_anchor_point_from_gravity (priv->bt, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (priv->bt, 0, ASTRO_PANEL_HEIGHT ()/2); } pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/icons/nm.png", NULL); if (pixbuf) { priv->nm = clutter_texture_new_from_pixbuf (pixbuf); clutter_container_add_actor (CLUTTER_CONTAINER (systray), priv->nm); clutter_actor_set_anchor_point_from_gravity (priv->nm, CLUTTER_GRAVITY_WEST); clutter_actor_set_position (priv->nm, clutter_actor_get_width (priv->bt) + PADDING, ASTRO_PANEL_HEIGHT () /2); } width = clutter_actor_get_width (CLUTTER_ACTOR (systray)); /* Time date */ font = g_strdup_printf ("Sans %d", (int)(ASTRO_PANEL_HEIGHT () * 0.2)); priv->time = clutter_label_new_full (font, " ", &white); clutter_label_set_line_wrap (CLUTTER_LABEL (priv->time), FALSE); clutter_container_add_actor (CLUTTER_CONTAINER (systray), priv->time); clutter_actor_set_anchor_point_from_gravity (priv->time,CLUTTER_GRAVITY_WEST); set_time (systray); clutter_actor_set_position (priv->time, width + PADDING, ASTRO_PANEL_HEIGHT ()/2); g_timeout_add (1000, (GSourceFunc)set_time, systray); g_free (font); clutter_actor_show_all (CLUTTER_ACTOR (systray)); }
static gboolean test_thread_done_idle (gpointer user_data) { TestThreadData *data = user_data; g_print ("Thread completed\n"); clutter_label_set_text (CLUTTER_LABEL (data->label), "Completed"); clutter_timeline_stop (data->timeline); test_thread_data_free (data); return FALSE; }
/* Private functions */ static void astro_contact_row_set_name (AstroContactRow *row, const gchar *name) { AstroContactRowPrivate *priv; g_return_if_fail (ASTRO_IS_CONTACT_ROW (row)); g_return_if_fail (name); priv = row->priv; if (priv->name) g_free (priv->name); priv->name = g_strdup (name); clutter_label_set_text (CLUTTER_LABEL (priv->label), name); clutter_actor_set_position (priv->label, (PADDING*2)+ICON_SIZE, (ROW_HEIGHT /2)-(clutter_actor_get_height (priv->label)/2)); }
/* Public Functions */ void astro_texture_group_set_text (AstroTextureGroup *group, const gchar *text) { AstroTextureGroupPrivate *priv; g_return_if_fail (ASTRO_IS_TEXTURE_GROUP (group)); g_return_if_fail (text); priv = group->priv; clutter_label_set_text (CLUTTER_LABEL (priv->label), text); clutter_actor_set_position (priv->label, PADDING, PADDING); clutter_actor_set_size (priv->bg, GROUP_WIDTH, clutter_actor_get_height (priv->label) + (2*PADDING)); clutter_actor_set_position (priv->bg, 0, 0); }
static gboolean set_time (AstroSystray *systray) { AstroSystrayPrivate *priv; time_t rawtime; struct tm *timeinfo; char buffer [100]; g_return_val_if_fail (ASTRO_IS_SYSTRAY (systray), FALSE); priv = systray->priv; time (&rawtime); timeinfo = localtime (&rawtime); strftime (buffer, 100, "%a %d %b,%H:%M ", timeinfo); clutter_label_set_text (CLUTTER_LABEL (priv->time), buffer); return TRUE; }
static void astro_texture_group_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { AstroTextureGroupPrivate *priv; g_return_if_fail (ASTRO_IS_TEXTURE_GROUP (object)); priv = ASTRO_TEXTURE_GROUP (object)->priv; switch (prop_id) { case PROP_TEXT: g_value_set_string (value, clutter_label_get_text (CLUTTER_LABEL (priv->label))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void astro_texture_group_init (AstroTextureGroup *group) { AstroTextureGroupPrivate *priv; ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; gchar *font = NULL; priv = group->priv = ASTRO_TEXTURE_GROUP_GET_PRIVATE (group); /* The background texture */ if (!GDK_IS_PIXBUF (bg_pixbuf)) bg_pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/info_bg.png", NULL); if (!CLUTTER_IS_ACTOR (bg_texture)) { bg_texture = clutter_texture_new_from_pixbuf (bg_pixbuf); clutter_actor_show (bg_texture); } priv->bg = tidy_texture_frame_new (CLUTTER_TEXTURE (bg_texture), 15, 15, 15, 15); clutter_container_add_actor (CLUTTER_CONTAINER (group), priv->bg); clutter_actor_set_position (priv->bg, 0, 0); clutter_actor_set_size (priv->bg, GROUP_WIDTH, GROUP_HEIGHT); /* The label */ font = g_strdup_printf ("Sans %d", (gint)(GROUP_HEIGHT * 0.3)); priv->label = clutter_label_new_full (font, " ", &white); clutter_label_set_line_wrap (CLUTTER_LABEL (priv->label), TRUE); clutter_actor_set_width (priv->label, GROUP_WIDTH); clutter_container_add_actor (CLUTTER_CONTAINER (group), priv->label); clutter_actor_set_position (priv->label, PADDING, GROUP_HEIGHT /2); g_free (font); clutter_actor_show_all (CLUTTER_ACTOR (group)); }
static void _gb_player_setup_widgets (GbPlayer *self) { GbPlayerPrivate *p = GB_PLAYER_GET_PRIVATE(self); ClutterColor cc_white = {0xff, 0xff, 0xff, 0x8f}; ClutterColor cc_black = {0x00, 0x00, 0x00, 0xff}; /* title group */ p->title_group = clutter_group_new (); p->title_rect = gb_player_rounded_rect (self, 400, 36, &cc_white, 35); p->title_label = clutter_label_new_full ("DejaVu Sans", "<span size='11500'><b>Here comes the media's title</b></span>", &cc_black); clutter_label_set_use_markup (CLUTTER_LABEL(p->title_label), TRUE); clutter_actor_set_position (p->title_group, -20, 20); clutter_actor_set_position (p->title_label, 50, 10); CLUTTER_GROUP_AND_SHOW(p->title_group, p->title_rect); CLUTTER_GROUP_AND_SHOW(p->title_group, p->title_label); /* window buttons group */ p->window_buttons_group = clutter_group_new (); p->window_buttons_rect = gb_player_rounded_rect (self, 230, 90, &cc_white, 35); p->window_aspect_button = clutter_texture_new_from_pixbuf (p->fullscreen); p->window_open_file_button = clutter_texture_new_from_pixbuf (p->open_file); clutter_label_set_use_markup (CLUTTER_LABEL(p->title_label), TRUE); CLUTTER_GROUP_AND_SHOW(p->window_buttons_group, p->window_buttons_rect); CLUTTER_GROUP_AND_SHOW(p->window_buttons_group, p->window_aspect_button); CLUTTER_GROUP_AND_SHOW(p->window_buttons_group, p->window_open_file_button); clutter_actor_set_position (p->window_buttons_group, 640 - 200, 20); clutter_actor_set_position (p->window_open_file_button, 40, 20); clutter_actor_set_position (p->window_aspect_button, 130, 20); /* background group*/ p->bg_group = clutter_group_new (); p->bg_video = clutter_gst_video_texture_new (); p->bg_image = clutter_texture_new_from_pixbuf (p->bgpixbuf); p->bg_logo = clutter_texture_new_from_pixbuf (p->bglogo); CLUTTER_GROUP_AND_SHOW(p->bg_group, p->bg_image); CLUTTER_GROUP_AND_SHOW(p->bg_group, p->bg_logo); CLUTTER_GROUP_AND_SHOW(p->bg_group, p->bg_video); clutter_actor_set_position (p->bg_logo, (640 / 2) - (467 / 2), (480 / 2) - (210 / 2)); clutter_actor_set_size (p->bg_video, 640, 480); /* controls group */ p->controls_group = clutter_group_new (); p->controls_rect = gb_player_rounded_rect (self, 400, 70, &cc_white, 45); p->controls_backward = clutter_texture_new_from_pixbuf (p->backward); p->controls_forward = clutter_texture_new_from_pixbuf (p->forward); p->controls_play_pause = clutter_texture_new_from_pixbuf (p->play); p->controls_stop = clutter_texture_new_from_pixbuf (p->stop); CLUTTER_GROUP_AND_SHOW(p->controls_group, p->controls_rect); CLUTTER_GROUP_AND_SHOW(p->controls_group, p->controls_backward); CLUTTER_GROUP_AND_SHOW(p->controls_group, p->controls_forward); CLUTTER_GROUP_AND_SHOW(p->controls_group, p->controls_play_pause); clutter_actor_set_position (p->controls_group, (640 / 2) - (400 / 2), 480 - 70 - 30); clutter_actor_set_position (p->controls_backward, 30, 15); clutter_actor_set_position (p->controls_play_pause, 170, 5); clutter_actor_set_position (p->controls_forward, 300, 15); CLUTTER_GROUP_AND_SHOW(p->stage, p->bg_group); CLUTTER_GROUP_AND_SHOW(p->stage, p->title_group); CLUTTER_GROUP_AND_SHOW(p->stage, p->controls_group); CLUTTER_GROUP_AND_SHOW(p->stage, p->window_buttons_group); gtk_widget_show_all (p->window); clutter_actor_set_reactive (p->controls_backward, TRUE); clutter_actor_set_reactive (p->controls_forward, TRUE); clutter_actor_set_reactive (p->controls_play_pause, TRUE); clutter_actor_set_reactive (p->window_aspect_button, TRUE); clutter_actor_set_reactive (p->window_open_file_button, TRUE); clutter_actor_set_reactive (p->stage, TRUE); clutter_actor_hide (p->bg_video); p->videosink = clutter_gst_video_sink_new (CLUTTER_TEXTURE(p->bg_video)); g_object_set (p->player, "video-sink", p->videosink, NULL); }
int main (int argc, char *argv[]) { gchar *txt; ClutterActor *rect, *stage, *label0; int i, rotate_x = 0, rotate_y = 60, rotate_z = 0; ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff }, white = { 0xff, 0xff, 0xff, 0xff }, blue = { 0, 0xff, 0xff, 0xff }; for (i = 0; i < argc; ++i) { if (!strncmp (argv[i], "--rotate-x", 10)) { rotate_x = atoi (argv[i] + 11); } else if (!strncmp (argv[i], "--rotate-y", 10)) { rotate_y = atoi (argv[i] + 11); } else if (!strncmp (argv[i], "--rotate-z", 10)) { rotate_z = atoi (argv[i] + 11); } else if (!strncmp (argv[i], "--help", 6)) { printf ("%s [--rotage-x=degrees] [--rotage-y=degrees] " "[--rotage-z=degrees]\n", argv[0]); exit (0); } } clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr); clutter_actor_set_size (stage, 640, 480); rect = clutter_rectangle_new_with_color (&white); clutter_actor_set_size (rect, RECT_W, RECT_H); clutter_actor_set_position (rect, RECT_L, RECT_T); clutter_actor_set_rotation (rect, CLUTTER_X_AXIS, rotate_x, 0, 0, 0); clutter_actor_set_rotation (rect, CLUTTER_Y_AXIS, rotate_y, 0, 0, 0); clutter_actor_set_rotation (rect, CLUTTER_Z_AXIS, rotate_z, 0, 0, 0); clutter_group_add (CLUTTER_GROUP (stage), rect); txt = g_strdup_printf ("Rectangle: L %d, R %d, T %d, B %d\n" "Rotation : x %d, y %d, z %d", RECT_L, RECT_L + RECT_W, RECT_T, RECT_T + RECT_H, rotate_x, rotate_y, rotate_z); label0 = clutter_label_new_with_text ("Mono 8pt", txt); clutter_label_set_color (CLUTTER_LABEL (label0), &white); clutter_actor_set_position (label0, 10, 10); clutter_group_add (CLUTTER_GROUP (stage), label0); g_free (txt); label = clutter_label_new_with_text ("Mono 8pt", "Click around!"); clutter_label_set_color (CLUTTER_LABEL (label), &blue); clutter_actor_set_position (label, 10, 50); clutter_group_add (CLUTTER_GROUP (stage), label); clutter_actor_show_all (stage); g_signal_connect (stage, "event", G_CALLBACK (on_event), NULL); clutter_main(); return EXIT_SUCCESS; }
static void astro_contact_row_init (AstroContactRow *row) { AstroContactRowPrivate *priv; ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; gchar *font = NULL; GdkPixbuf *pixbuf; priv = row->priv = ASTRO_CONTACT_ROW_GET_PRIVATE (row); priv->name = NULL; priv->icon = NULL; priv->active = FALSE; /* The background texture */ if (!GDK_IS_PIXBUF (bg_pixbuf)) bg_pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/applet_bg.png", NULL); if (!CLUTTER_IS_ACTOR (bg_texture)) { bg_texture = clutter_texture_new_from_pixbuf (bg_pixbuf); clutter_actor_show (bg_texture); } priv->bg = tidy_texture_frame_new (CLUTTER_TEXTURE (bg_texture), 15, 15, 15, 15); clutter_container_add_actor (CLUTTER_CONTAINER (row), priv->bg); clutter_actor_set_position (priv->bg, 0, 0); clutter_actor_set_size (priv->bg, CSW()*0.5, ROW_HEIGHT); clutter_actor_set_opacity (priv->bg, 0); /* The icon */ priv->texture = clutter_texture_new (); clutter_container_add_actor (CLUTTER_CONTAINER (row), priv->texture); clutter_actor_set_position (priv->texture, PADDING, PADDING); clutter_actor_set_size (priv->texture, ICON_SIZE, ICON_SIZE); /* The label */ font = g_strdup_printf ("Sans %d", (gint)(ROW_HEIGHT * 0.3)); priv->label = clutter_label_new_full (font, " ", &white); clutter_label_set_line_wrap (CLUTTER_LABEL (priv->label), FALSE); clutter_actor_set_width (priv->label, CSW()/2); clutter_container_add_actor (CLUTTER_CONTAINER (row), priv->label); clutter_actor_set_position (priv->label, (PADDING*2) + ICON_SIZE, ROW_HEIGHT /2); g_free (font); /* Contact bar */ pixbuf = gdk_pixbuf_new_from_file_at_scale (PKGDATADIR"/contact-bar.svg", -1, ROW_HEIGHT-(PADDING*4), TRUE, NULL); priv->bar = clutter_texture_new_from_pixbuf (pixbuf); clutter_container_add_actor (CLUTTER_CONTAINER (row), priv->bar); clutter_actor_set_position (priv->bar, (PADDING*2) + ICON_SIZE, ROW_HEIGHT + PADDING); clutter_actor_set_opacity (priv->bar, 0); /* Timelines */ priv->active_time = clutter_timeline_new_for_duration (200); priv->active_temp = clutter_effect_template_new (priv->active_time, clutter_sine_inc_func); priv->bar_time = clutter_timeline_new_for_duration (600); priv->bar_temp = clutter_effect_template_new (priv->bar_time, clutter_sine_inc_func); priv->active_time = clutter_timeline_new_for_duration (800); priv->alpha = clutter_alpha_new_full (priv->active_time, clutter_sine_inc_func, NULL, NULL); priv->behave = astro_behave_new (priv->alpha, (AstroBehaveAlphaFunc)_resize_alpha, row); clutter_actor_show_all (CLUTTER_ACTOR (row)); }
HandCar * handcar_new() { HandCar *all = g_new0(HandCar, 1); ClutterColor rect_color = { 0xdd, 0xdd, 0xdd, 0xee }; ClutterColor rect_border_color = { 0xee, 0xee, 0xee, 0xdd }; ClutterColor rect_entry_color = { 0xef, 0xef, 0xef, 0xee }; ClutterColor rect_entry_border_color = { 0x96, 0x96, 0x96, 0xaa }; ClutterColor label_color = { 0x55, 0x00, 0x00, 0xff }; ClutterColor time_color = { 0x00, 0x33, 0x55, 0xbb }; GError *error = NULL; all->play = gdk_pixbuf_new_from_file("imgs/start.svg", NULL); all->previous = gdk_pixbuf_new_from_file("imgs/backward.svg", NULL); all->next = gdk_pixbuf_new_from_file("imgs/forward.svg", NULL); all->stop = gdk_pixbuf_new_from_file("imgs/stop.svg", NULL); all->time = 0; all->playing = FALSE; all->player = gst_element_factory_make ("playbin", "player"); if (error) g_error ("FUDEU: %s", error->message); all->label_actor = clutter_label_new_full("DejaVu Sans", "Blind Guardian - <b>Mirror Mirror</b>", &label_color); clutter_label_set_use_markup (CLUTTER_LABEL(all->label_actor), TRUE); all->label_time = clutter_label_new_full("DejaVu Sans", "00:00", &time_color); clutter_label_set_use_markup (CLUTTER_LABEL(all->label_time), TRUE); clutter_actor_set_position (all->label_actor, 10, 15); clutter_actor_set_position (all->label_time, STAGE_WIDTH - 80, STAGE_HEIGHT - 20); all->btn_actor_play = clutter_texture_new_from_pixbuf (all->play); all->btn_actor_next = clutter_texture_new_from_pixbuf (all->next); all->btn_actor_previous = clutter_texture_new_from_pixbuf (all->previous); clutter_actor_set_position (all->btn_actor_previous, 60, 50); clutter_actor_set_position (all->btn_actor_play, 140, 50); clutter_actor_set_position (all->btn_actor_next, 200, 50); all->rect1 = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (all->rect1, 320, 30); clutter_actor_set_position (all->rect1, -5, 10); clutter_rectangle_set_border_width (CLUTTER_RECTANGLE(all->rect1), 4); clutter_rectangle_set_border_color (CLUTTER_RECTANGLE(all->rect1), &rect_border_color); all->rect2 = clutter_rectangle_new_with_color (&rect_entry_color); clutter_actor_set_size (all->rect2, 270, 20); clutter_actor_set_position (all->rect2, 20, STAGE_HEIGHT - 50); clutter_rectangle_set_border_width (CLUTTER_RECTANGLE(all->rect2), 1); clutter_rectangle_set_border_color (CLUTTER_RECTANGLE(all->rect2), &rect_entry_border_color); all->rect3 = clutter_rectangle_new_with_color (&rect_entry_color); clutter_actor_set_size (all->rect3, 270, 203); clutter_actor_set_position (all->rect3, 20, 120); clutter_rectangle_set_border_width (CLUTTER_RECTANGLE(all->rect3), 1); clutter_rectangle_set_border_color (CLUTTER_RECTANGLE(all->rect3), &rect_entry_border_color); all->entry_actor = clutter_entry_new_full ("Monospace", "Teste", &label_color); clutter_actor_set_size (all->entry_actor, 270, 20); clutter_actor_set_position (all->entry_actor, 20, STAGE_HEIGHT - 50); all->video = clutter_gst_video_texture_new (); clutter_actor_set_size (all->video, 270, 203); clutter_actor_set_position (all->video, 20, 120); clutter_actor_set_opacity (all->video, 0xff); // all->clutter_group_add_many (all->container1, all->rect1); all->videosink = clutter_gst_video_sink_new (CLUTTER_TEXTURE(all->video)); g_object_set (all->player, "video-sink", all->videosink, NULL); all->format = GST_FORMAT_TIME; clutter_actor_show(all->btn_actor_play); clutter_actor_show(all->btn_actor_next); clutter_actor_show(all->btn_actor_previous); clutter_actor_show(all->label_actor); clutter_actor_show(all->label_time); clutter_actor_show(all->rect1); clutter_actor_show(all->rect2); clutter_actor_show(all->rect3); clutter_actor_show(all->video); clutter_actor_show(all->entry_actor); return all; }