void astro_appview_advance (AstroAppview *view, gint n) { AstroAppviewPrivate *priv; static ClutterTimeline *move_time = NULL; gint new_active; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = view->priv; new_active = priv->active + n; if (new_active < 0 || new_active >= g_list_length (priv->apps)) return; priv->active = new_active; if (CLUTTER_IS_TIMELINE (move_time) &&clutter_timeline_is_playing (move_time)) { clutter_timeline_stop (move_time); g_object_unref (move_time); } move_time = clutter_effect_move (priv->move_temp, CLUTTER_ACTOR (view), (CSW()/2)- (priv->active * ASTRO_APPICON_SPACING ()), clutter_actor_get_y (CLUTTER_ACTOR (view)), NULL, NULL); g_signal_connect (move_time, "new-frame", G_CALLBACK (on_move_timeline_new_frame), view); }
static AstroWindow * get_window (AstroApplication *app) { AstroExamplePrivate *priv; ClutterColor color = { 0xff, 0xff, 0x22, 0x22 }; ClutterActor *window = NULL, *rect; g_return_val_if_fail (ASTRO_IS_EXAMPLE (app), NULL); priv = ASTRO_EXAMPLE (app)->priv; if (CLUTTER_IS_ACTOR (priv->window)) window = priv->window; else { window = astro_window_new (); rect = clutter_rectangle_new_with_color (&color); clutter_container_add_actor (CLUTTER_CONTAINER (window), rect); clutter_actor_set_size (rect, CSW (), CSH()-ASTRO_PANEL_HEIGHT()); clutter_actor_show (rect); } ASTRO_EXAMPLE (app)->priv->window = window; return ASTRO_WINDOW (window); }
static void astro_appview_show (ClutterActor *view) { AstroAppviewPrivate *priv; static ClutterTimeline *show_time = NULL; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = ASTRO_APPVIEW (view)->priv; if (CLUTTER_IS_TIMELINE (show_time) &&clutter_timeline_is_playing (show_time)) { clutter_timeline_stop (show_time); g_object_unref (show_time); } clutter_actor_set_x (view, -1* clutter_actor_get_width (view)); CLUTTER_ACTOR_CLASS (astro_appview_parent_class)->show (view); show_time = clutter_effect_move (priv->show_temp, CLUTTER_ACTOR (view), (CSW()/2)- (priv->active * ASTRO_APPICON_SPACING()), clutter_actor_get_y (CLUTTER_ACTOR (view)), NULL, NULL); g_signal_connect (show_time, "new-frame", G_CALLBACK (on_move_timeline_new_frame), view); }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterColor stage_color = { 0x34, 0x39, 0x39, 0xff }; ClutterColor white = { 0x72, 0x9f, 0xcf, 0xff }; gint i = 0; Item *item; App *app; gdouble ang = 0.0; ClutterBehaviour *behave; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 800, 600); app = g_new0(App, 1); app->off = 0.0; app->timeline = clutter_timeline_new (300); app->alpha_sine_inc = clutter_alpha_new_full (app->timeline, CLUTTER_EASE_OUT_SINE); app->alpha_ramp = clutter_alpha_new_with_func (app->timeline, label_opacity_alpha_func, NULL, NULL); for (i=0; i<N_ITEMS; i++) { item = g_new0 (Item, 1); item->actor = clutter_texture_new_from_file (ItemDetails[i].img, NULL); if (!item->actor) g_error ("Unable to load '%s'", ItemDetails[i].img); clutter_group_add (CLUTTER_GROUP(stage), item->actor); item->ellipse_behave = clutter_behaviour_ellipse_new (app->alpha_sine_inc, CSW()/4, /* center x */ CSH() - (CSH()/3), /* center y */ CSW()/2, /* width */ CSH() - (CSH()/4), /* height */ CLUTTER_ROTATE_CW, ang, ang + STEP); item->opacity_behave = clutter_behaviour_opacity_new (app->alpha_sine_inc, 0x66, 0x66); item->scale_behave = clutter_behaviour_scale_new (app->alpha_sine_inc, 0.6, 0.6, 0.6, 0.6); clutter_behaviour_apply (item->ellipse_behave, item->actor); clutter_behaviour_apply (item->opacity_behave, item->actor); clutter_behaviour_apply (item->scale_behave, item->actor); app->items = g_slist_append (app->items, item); ang += STEP; } app->label = clutter_text_new_full ("Bitstream Vera Sans 60px", "", &white); clutter_actor_set_position (app->label, CSW()/2 - 30, CSH()/3 - 40); clutter_group_add (CLUTTER_GROUP(stage), app->label); behave = clutter_behaviour_opacity_new (app->alpha_ramp, 0xff, 0); clutter_behaviour_apply (behave, app->label); g_signal_connect (app->timeline, "new-frame", G_CALLBACK(on_timeline_new_frame), app); g_signal_connect (stage, "event", G_CALLBACK (on_input), app); introduce_items (app); clutter_actor_show_all (stage); clutter_main(); return 0; }
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)); }
#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x static struct event_symbol event_symbols[] = { { CHW(CPU_CYCLES), "cpu-cycles", "cycles" }, { CHW(STALLED_CYCLES_FRONTEND), "stalled-cycles-frontend", "idle-cycles-frontend" }, { CHW(STALLED_CYCLES_BACKEND), "stalled-cycles-backend", "idle-cycles-backend" }, { CHW(INSTRUCTIONS), "instructions", "" }, { CHW(CACHE_REFERENCES), "cache-references", "" }, { CHW(CACHE_MISSES), "cache-misses", "" }, { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" }, { CHW(BRANCH_MISSES), "branch-misses", "" }, { CHW(BUS_CYCLES), "bus-cycles", "" }, { CHW(REF_CPU_CYCLES), "ref-cycles", "" }, { CSW(CPU_CLOCK), "cpu-clock", "" }, { CSW(TASK_CLOCK), "task-clock", "" }, { CSW(PAGE_FAULTS), "page-faults", "faults" }, { CSW(PAGE_FAULTS_MIN), "minor-faults", "" }, { CSW(PAGE_FAULTS_MAJ), "major-faults", "" }, { CSW(CONTEXT_SWITCHES), "context-switches", "cs" }, { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" }, { CSW(ALIGNMENT_FAULTS), "alignment-faults", "" }, { CSW(EMULATION_FAULTS), "emulation-faults", "" }, }; #define __PERF_EVENT_FIELD(config, name) \ ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT) #define PERF_EVENT_RAW(config) __PERF_EVENT_FIELD(config, RAW) #define PERF_EVENT_CONFIG(config) __PERF_EVENT_FIELD(config, CONFIG)
/* Private functions */ static void ensure_layout (AstroAppview *view) { AstroAppviewPrivate *priv; GList *l; gint groupx = 0; gint center = 0; gint i = 0; priv = view->priv; groupx = clutter_actor_get_x (CLUTTER_ACTOR (view)); center = CSW()/2; l = clutter_container_get_children (CLUTTER_CONTAINER (view)); for (l = l; l; l = l->next) { ClutterActor *icon = l->data; gint realx, diff, y_diff;; gfloat scale; realx = clutter_actor_get_x (icon) + groupx; if (realx > center && realx < CSW ()) { diff = center - (realx - center); } else if (realx > 0 && realx <= center) { diff = realx; } else { diff = 0; } scale = (gfloat)diff/center; scale = 0.2 + (0.8 * scale); clutter_actor_set_scale (icon, scale, scale); if (realx < center) { gfloat angle, sine; angle = scale * (3.14*2); sine = sin (0.5 *angle); y_diff = (CSH()/2) + (VARIANCE * sine); } else { gfloat angle, sine; angle = scale * (3.14*2); sine = sin (0.5*angle); y_diff = (CSH()/2) - (VARIANCE * sine); } clutter_actor_set_y (icon, y_diff); astro_appicon_set_blur (ASTRO_APPICON (icon), (1.0 - scale) * MAX_BLUR); i++; } }