static void mex_queue_button_init (MexQueueButton *self) { ClutterActor *temp_text; self->priv = QUEUE_BUTTON_PRIVATE (self); self->priv->inner_box = mx_box_layout_new (); self->priv->icon = mx_icon_new (); self->priv->label = mx_label_new_with_text ("Unknown queue state"); self->priv->spinner = mx_spinner_new (); self->priv->queue_model = mex_queue_model_dup_singleton (); g_signal_connect (self->priv->spinner, "looped", (GCallback)_spinner_looped_cb, self); clutter_container_add (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->label, self->priv->icon, self->priv->spinner, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->label, "expand", TRUE, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->icon, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, "x-align", MX_ALIGN_END, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->spinner, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, "x-align", MX_ALIGN_END, NULL); clutter_actor_hide (self->priv->spinner); mx_bin_set_child (MX_BIN (self), self->priv->inner_box); mx_bin_set_fill (MX_BIN (self), TRUE, FALSE); temp_text = mx_label_get_clutter_text (MX_LABEL (self->priv->label)); clutter_text_set_ellipsize (CLUTTER_TEXT (temp_text), PANGO_ELLIPSIZE_NONE); g_signal_connect (self, "notify::toggled", (GCallback)_queue_button_notify_toggled_cb, self); mx_button_set_is_toggle (MX_BUTTON (self), TRUE); }
static void mnb_launcher_button_init (MnbLauncherButton *self) { ClutterActor *label; self->priv = MNB_LAUNCHER_BUTTON_GET_PRIVATE (self); g_signal_connect (self, "leave-event", G_CALLBACK (_leave_event_cb), NULL); g_signal_connect (self, "key-focus-out", G_CALLBACK (_leave_event_cb), NULL); g_signal_connect (self, "enter-event", G_CALLBACK (_enter_event_cb), NULL); self->priv->icon = NULL; mx_stylable_set_style_class (MX_STYLABLE (self), "contentTile"); /* "app" label */ self->priv->title = (MxLabel *) mx_label_new (); mx_label_set_x_align (MX_LABEL (self->priv->title), MX_ALIGN_MIDDLE); clutter_actor_set_reactive (CLUTTER_ACTOR (self->priv->title), FALSE); mx_table_insert_actor_with_properties (MX_TABLE (self), CLUTTER_ACTOR (self->priv->title), 1, 0, "x-align", MX_ALIGN_MIDDLE, "x-expand", TRUE, "x-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, "y-expand", TRUE, "y-fill", TRUE, NULL); label = mx_label_get_clutter_text (self->priv->title); clutter_text_set_ellipsize (CLUTTER_TEXT (label), PANGO_ELLIPSIZE_END); clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE); clutter_text_set_line_wrap_mode (CLUTTER_TEXT (label), PANGO_WRAP_WORD_CHAR); /* "fav app" toggle */ self->priv->fav_toggle = g_object_ref_sink (CLUTTER_ACTOR (mx_button_new ())); mx_button_set_is_toggle (MX_BUTTON (self->priv->fav_toggle), TRUE); clutter_actor_set_name (CLUTTER_ACTOR (self->priv->fav_toggle), "mnb-launcher-button-fav-toggle"); clutter_actor_set_size (self->priv->fav_toggle, FAV_TOGGLE_SIZE, FAV_TOGGLE_SIZE); mx_table_insert_actor (MX_TABLE (self), CLUTTER_ACTOR (self->priv->fav_toggle), 0, 0); g_signal_connect (self->priv->fav_toggle, "notify::toggled", G_CALLBACK (fav_button_notify_toggled_cb), self); clutter_actor_set_reactive ((ClutterActor *) self, TRUE); }
static void mx_button_set_property (GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec) { MxButton *button = MX_BUTTON (gobject); switch (prop_id) { case PROP_LABEL: mx_button_set_label (button, g_value_get_string (value)); break; case PROP_ICON_NAME: mx_button_set_icon_name (button, g_value_get_string (value)); break; case PROP_ICON_SIZE: mx_button_set_icon_size (button, g_value_get_uint (value)); break; case PROP_IS_TOGGLE: mx_button_set_is_toggle (button, g_value_get_boolean (value)); break; case PROP_TOGGLED: mx_button_set_toggled (button, g_value_get_boolean (value)); break; case PROP_ACTION: mx_button_set_action (button, g_value_get_object (value)); break; case PROP_ICON_POSITION: mx_button_set_icon_position (button, g_value_get_enum (value)); break; case PROP_ICON_VISIBLE: mx_button_set_icon_visible (button, g_value_get_boolean (value)); break; case PROP_LABEL_VISIBLE: mx_button_set_label_visible (button, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
static void mex_music_player_set_context (MexContentView *player, MexModel *model) { MexMusicPlayerPrivate *priv = MEX_MUSIC_PLAYER (player)->priv; ClutterActor *box, *button; MexContent *content; gint i; if (priv->model) g_object_unref (priv->model); priv->model = model; if (model) g_object_ref (model); box = mex_script_get_actor (priv->script, "tracks"); clutter_actor_remove_all_children (box); for (i = 0; (content = mex_model_get_content (model, i)); i++) { const gchar *title; title = mex_content_get_metadata (content, MEX_CONTENT_METADATA_TITLE); button = mx_button_new_with_label (title); mx_stylable_set_style_class (MX_STYLABLE (button), "Track"); mx_button_set_is_toggle (MX_BUTTON (button), TRUE); g_object_set_data (G_OBJECT (button), "content", content); g_signal_connect (button, "clicked", G_CALLBACK (mex_music_player_item_clicked), player); mx_button_set_icon_position (MX_BUTTON (button), MX_POSITION_RIGHT); clutter_actor_add_child (box, button); } }
int main (int argc, char **argv) { ClutterActor *stage = stage; ClutterActor *side_box; ClutterActor *button_box; ClutterActor *box; ClutterAnimation *anim; MashLightSet *light_set; MxStyle *style; GError *error = NULL; Data data; int i; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; style = mx_style_get_default (); if (!mx_style_load_from_file (style, "lights.css", &error)) { g_warning ("Error setting style: %s", error->message); g_clear_error (&error); } stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 800, 600); side_box = mx_table_new (); clutter_actor_set_name (side_box, "side-box"); clutter_container_add_actor (CLUTTER_CONTAINER (stage), side_box); clutter_actor_set_size (side_box, 300, clutter_actor_get_height (stage)); clutter_actor_set_x (side_box, clutter_actor_get_width (stage) - clutter_actor_get_width (side_box)); button_box = mx_table_new (); mx_table_add_actor (MX_TABLE (side_box), button_box, 0, 0); data.notebook = mx_notebook_new (); mx_table_add_actor (MX_TABLE (side_box), data.notebook, 1, 0); data.model = mash_model_new_from_file (MASH_DATA_NONE, argc > 1 ? argv[1] : "suzanne.ply", &error); if (data.model == NULL) { g_warning ("Error loading model: %s", error->message); g_clear_error (&error); return 1; } light_set = mash_light_set_new (); box = clutter_box_new (clutter_fixed_layout_new ()); clutter_actor_set_size (data.model, 400, 400); clutter_actor_set_position (data.model, 50.0, 100.0); clutter_container_add_actor (CLUTTER_CONTAINER (box), data.model); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); g_signal_connect_swapped (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (TRUE)); g_signal_connect_data (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (FALSE), NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED); data.light_marker_material = cogl_material_new (); { CoglColor color; cogl_color_set_from_4ub (&color, 255, 0, 0, 255); /* Use the layer state to ignore the vertex color from the shader so that the light marker won't itself be lit */ cogl_material_set_layer_combine_constant (data.light_marker_material, 0, &color); cogl_material_set_layer_combine (data.light_marker_material, 0, "RGBA = REPLACE(CONSTANT)", NULL); } clutter_actor_set_rotation (data.model, CLUTTER_Y_AXIS, 0.0f, clutter_actor_get_width (data.model) / 2.0f, 0.0f, 0.0f); anim = clutter_actor_animate (data.model, CLUTTER_LINEAR, 3000, "rotation-angle-y", 360.0f, NULL); clutter_animation_set_loop (anim, TRUE); for (i = 0; i < N_LIGHTS; i++) { ClutterActor *table = mx_table_new (); ClutterActor *button; static ClutterActor *(* constructors[N_LIGHTS]) (void) = { mash_directional_light_new, mash_point_light_new, mash_spot_light_new }; static const ClutterColor black = { 0, 0, 0, 255 }; data.lights[i] = constructors[i] (); button = mx_button_new_with_label (G_OBJECT_TYPE_NAME (data.lights[i])); mx_table_add_actor (MX_TABLE (button_box), button, i, 0); /* Default to disable all of the lights */ g_object_set (data.lights[i], "ambient", &black, "diffuse", &black, "specular", &black, NULL); data.notebook_buttons[i] = button; clutter_container_add_actor (CLUTTER_CONTAINER (box), data.lights[i]); mash_light_set_add_light (light_set, MASH_LIGHT (data.lights[i])); add_color_prop (table, "ambient light", G_OBJECT (data.lights[i]), "ambient"); add_color_prop (table, "diffuse light", G_OBJECT (data.lights[i]), "diffuse"); add_color_prop (table, "specular light", G_OBJECT (data.lights[i]), "specular"); if (MASH_IS_POINT_LIGHT (data.lights[i])) { add_float_prop (table, "constant attenuation", G_OBJECT (data.lights[i]), "constant-attenuation", 0.0f, 10.0f); add_float_prop (table, "linear attenuation", G_OBJECT (data.lights[i]), "linear-attenuation", 0.0f, 10.0f); add_float_prop (table, "quadratic attenuation", G_OBJECT (data.lights[i]), "quadratic-attenuation", 0.0f, 10.0f); } if (MASH_IS_SPOT_LIGHT (data.lights[i])) { clutter_actor_set_x (data.lights[i], 250); add_float_prop (table, "spot cutoff", G_OBJECT (data.lights[i]), "spot-cutoff", 0.0f, 90.0f); add_float_prop (table, "spot exponent", G_OBJECT (data.lights[i]), "spot-exponent", 0.0f, 128.0f); } clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); data.notebook_pages[i] = table; } { ClutterActor *button; ClutterActor *table; CoglHandle material; float maximum_shininess; material = mash_model_get_pipeline (MASH_MODEL (data.model)); /* Before version 1.3.10 on the 1.3 branch and 1.2.14 on the 1.2 branch Cogl would remap the shininess property to the range [0,1]. After this it is just a value greater or equal to zero (but GL imposes a limit of 128.0) */ if (clutter_check_version (1, 3, 9) || (clutter_major_version == 1 && clutter_minor_version == 2 && clutter_micro_version >= 13)) maximum_shininess = 128.0f; else maximum_shininess = 1.0f; cogl_material_set_shininess (material, maximum_shininess); button = mx_button_new_with_label ("Material"); data.notebook_buttons[i] = button; mx_table_add_actor (MX_TABLE (button_box), button, i, 0); table = mx_table_new (); data.notebook_pages[i] = table; clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); add_material_color_prop (table, "emission", material, cogl_material_set_emission, cogl_material_get_emission); add_material_color_prop (table, "diffuse", material, cogl_material_set_diffuse, cogl_material_get_diffuse); add_material_color_prop (table, "ambient", material, cogl_material_set_ambient, cogl_material_get_ambient); add_material_color_prop (table, "specular", material, cogl_material_set_specular, cogl_material_get_specular); add_material_float_prop (table, "shininess", material, 0.0f, maximum_shininess, cogl_material_set_shininess, cogl_material_get_shininess); } mash_model_set_light_set (MASH_MODEL (data.model), light_set); g_object_unref (light_set); for (i = 0; i < N_PAGES; i++) { g_signal_connect (data.notebook_buttons[i], "notify::toggled", G_CALLBACK (notebook_button_cb), &data); mx_button_set_is_toggle (MX_BUTTON (data.notebook_buttons[i]), TRUE); } mx_button_set_toggled (MX_BUTTON (data.notebook_buttons[0]), TRUE); g_signal_connect (stage, "motion-event", G_CALLBACK (motion_event_cb), &data); clutter_actor_show (stage); clutter_main (); cogl_handle_unref (data.light_marker_material); return 0; }
static ClutterActor * mex_menu_item_new (MexMenu *self, MxAction *action, MexMenuActionType type) { ClutterActor *button, *layout, *icon, *vbox, *label, *arrow = NULL; button = mx_button_new (); mx_button_set_is_toggle (MX_BUTTON (button), TRUE); mx_stylable_set_style_class (MX_STYLABLE (button), "Item"); layout = mx_box_layout_new (); mx_bin_set_child (MX_BIN (button), layout); mx_bin_set_fill (MX_BIN (button), TRUE, FALSE); if (type == MEX_MENU_LEFT) { arrow = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (arrow), "Left"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow); } vbox = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL); label = mx_label_new (); mx_label_set_fade_out (MX_LABEL (label), TRUE); mx_stylable_set_style_class (MX_STYLABLE (label), "Action"); g_object_bind_property (action, "display-name", label, "text", G_BINDING_SYNC_CREATE); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label); label = mx_label_new (); mx_label_set_fade_out (MX_LABEL (label), TRUE); mx_stylable_set_style_class (MX_STYLABLE (label), "Detail"); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label); clutter_actor_hide (label); g_object_set_data (G_OBJECT (button), "detail-label", label); clutter_container_add_actor (CLUTTER_CONTAINER (layout), vbox); clutter_container_child_set (CLUTTER_CONTAINER (layout), vbox, "expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, "y-fill", FALSE, NULL); icon = mx_icon_new (); g_object_bind_property (action, "icon", icon, "icon-name", G_BINDING_SYNC_CREATE); clutter_container_add_actor (CLUTTER_CONTAINER (layout), icon); if (type == MEX_MENU_RIGHT) { arrow = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (arrow), "Right"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow); } else if (type == MEX_MENU_TOGGLE) { ClutterActor *toggle = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (toggle), "Toggle"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), toggle); g_object_set_data (G_OBJECT (button), "toggle-icon", toggle); } if (arrow) clutter_container_child_set (CLUTTER_CONTAINER (layout), arrow, "expand", FALSE, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, NULL); g_signal_connect (button, "clicked", G_CALLBACK (mex_menu_item_clicked_cb), action); g_object_weak_ref (G_OBJECT (button), (GWeakNotify)mex_menu_item_destroyed_cb, self); /* Set the item qdata on the button to mark that we created it */ g_object_set_qdata (G_OBJECT (button), mex_menu_item_quark, GINT_TO_POINTER (TRUE)); return button; }
static void construct_heading_and_top_area (MnpWorldClock *world_clock) { MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock); ClutterActor *box, *icon, *check_button, *text; GConfClient *client = gconf_client_get_default (); gboolean tfh; /* Time title */ box = mx_box_layout_new (); mx_stylable_set_style_class (MX_STYLABLE (box), "sectionHeader"); /* clutter_actor_set_name (box, */ /* "TimeTitleBox"); */ mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 4); icon = (ClutterActor *)mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (icon), "ClockIcon"); clutter_actor_set_size (icon, 36, 36); mx_box_layout_add_actor (MX_BOX_LAYOUT(box), icon, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), icon, "expand", FALSE, "x-fill", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-align", MX_ALIGN_START, NULL); text = mx_label_new_with_text (_("Time")); /* clutter_actor_set_name (text, "TimeTitle"); */ mx_box_layout_add_actor (MX_BOX_LAYOUT(box), text, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), text, "expand", TRUE, "x-fill", TRUE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-align", MX_ALIGN_START, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(world_clock), box, -1); clutter_container_child_set (CLUTTER_CONTAINER (world_clock), box, "expand", FALSE, "y-fill", FALSE, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); /* Check box */ box = mx_box_layout_new (); priv->widget_box = box; mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 6); clutter_actor_set_name (box, "TwelveHourButtonBox"); box = mx_box_layout_new (); mx_box_layout_set_orientation ((MxBoxLayout *)box, MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing ((MxBoxLayout *)box, 4); tfh = gconf_client_get_bool (client, "/apps/date-time-panel/24_h_clock", NULL); g_object_unref(client); check_button = mx_button_new (); priv->tfh_clock = check_button; mx_button_set_is_toggle (MX_BUTTON (check_button), TRUE); mx_button_set_toggled(MX_BUTTON (check_button), tfh); g_signal_connect(priv->tfh_clock, "clicked", G_CALLBACK(hour_clock_changed), world_clock); mx_stylable_set_style_class (MX_STYLABLE (check_button), "check-box"); clutter_actor_set_size ((ClutterActor *)check_button, 21, 21); mx_box_layout_add_actor (MX_BOX_LAYOUT(box), check_button, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), check_button, "expand", FALSE, "y-fill", FALSE, "x-fill", FALSE, NULL); text = mx_label_new_with_text (_("24 hour clock")); clutter_actor_set_name (text, "HourClockLabel"); mx_box_layout_add_actor (MX_BOX_LAYOUT(box), text, -1); clutter_container_child_set (CLUTTER_CONTAINER (box), text, "expand", TRUE, "y-fill", FALSE, "x-fill", TRUE, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(priv->widget_box), box, -1); clutter_container_child_set (CLUTTER_CONTAINER (priv->widget_box), box, "expand", FALSE, "y-fill", FALSE, "x-fill", TRUE, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(world_clock), priv->widget_box, -1); clutter_container_child_set (CLUTTER_CONTAINER (world_clock), box, "expand", FALSE, "y-fill", FALSE, "x-fill", TRUE, NULL); /* div = clutter_texture_new_from_file (SINGLE_DIV_LINE, NULL); mx_box_layout_add_actor (MX_BOX_LAYOUT(world_clock), div, -1); */ }