static void mx_button_pull (MxButton *button) { MxWidget *widget = MX_WIDGET (button); MxButtonPrivate *priv = button->priv; if (!button->priv->is_pressed) return; //clutter_ungrab_pointer (); if (button->priv->is_toggle) { mx_button_set_toggled (button, !button->priv->is_toggled); } button->priv->is_pressed = FALSE; /* activate any associated action */ if (priv->action) g_signal_emit_by_name (priv->action, "activated", 0); g_signal_emit (button, button_signals[CLICKED], 0); mx_widget_long_press_cancel (widget); mx_stylable_style_pseudo_class_remove (MX_STYLABLE (button), "active"); }
/** * mx_button_group_add: * @group: A #MxButtonGroup * @button: A #MxButton * * Add @button to the #MxButtonGroup. * */ void mx_button_group_add (MxButtonGroup *group, MxButton *button) { MxButtonGroupPrivate *priv; g_return_if_fail (MX_IS_BUTTON_GROUP (group)); g_return_if_fail (MX_IS_BUTTON (button)); priv = group->priv; priv->children = g_slist_prepend (priv->children, button); g_signal_connect (button, "notify::toggled", G_CALLBACK (button_toggled_notify_cb), group); g_signal_connect (button, "button-press-event", G_CALLBACK (button_click_intercept), group); g_signal_connect (button, "button-release-event", G_CALLBACK (button_click_intercept), group); g_object_weak_ref (G_OBJECT (button), (GWeakNotify) button_weak_notify, group); if (!priv->allow_no_active && !priv->active_button) mx_button_set_toggled (button, TRUE); }
void mnb_launcher_button_set_favorite (MnbLauncherButton *self, gboolean is_favorite) { g_return_if_fail (self); mx_button_set_toggled (MX_BUTTON (self->priv->fav_toggle), is_favorite); }
static void mex_queue_button_update (MexQueueButton *button) { MexQueueButtonPrivate *priv = button->priv; if (mex_content_get_metadata (priv->content, MEX_CONTENT_METADATA_QUEUED)) { mx_label_set_text (MX_LABEL (priv->label), _("Remove from queue")); g_signal_handlers_block_by_func (button, _queue_button_notify_toggled_cb, button); mx_button_set_toggled (MX_BUTTON (button), TRUE); g_signal_handlers_unblock_by_func (button, _queue_button_notify_toggled_cb, button); } else { mx_label_set_text (MX_LABEL (priv->label), _("Add to queue")); g_signal_handlers_block_by_func (button, _queue_button_notify_toggled_cb, button); mx_button_set_toggled (MX_BUTTON (button), FALSE); g_signal_handlers_unblock_by_func (button, _queue_button_notify_toggled_cb, button); } if (mx_spinner_get_animating (MX_SPINNER (button->priv->spinner))) { mx_label_set_text (MX_LABEL (button->priv->label), _("Adding to queue")); clutter_actor_hide (button->priv->icon); clutter_actor_show (button->priv->spinner); } else { clutter_actor_hide (button->priv->spinner); clutter_actor_show (button->priv->icon); } }
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; } }
/** * mx_button_group_set_active_button: * @group: A #MxButtonGroup * @button: (allow-none): A #MxButton * * Set the current active button in the group. The previous active button will * have #MxButton:toggled set to #FALSE. * */ void mx_button_group_set_active_button (MxButtonGroup *group, MxButton *button) { MxButtonGroupPrivate *priv; g_return_if_fail (MX_IS_BUTTON_GROUP (group)); g_return_if_fail (button == NULL || MX_IS_BUTTON (button)); priv = group->priv; if (button == priv->active_button) return; if (priv->active_button) mx_button_set_toggled (priv->active_button, FALSE); if (button) mx_button_set_toggled (button, TRUE); priv->active_button = button; g_object_notify (G_OBJECT (group), "active-button"); }
/* content view */ static void mex_music_player_set_content (MexContentView *player, MexContent *content) { MexMusicPlayerPrivate *priv = MEX_MUSIC_PLAYER (player)->priv; gchar *album_artist; const gchar *uri, *album, *artist, *title; ClutterActorIter iter; ClutterActor *child, *container; if (priv->content) g_object_unref (priv->content); priv->content = content; if (!content) return; g_object_ref (content); /* title */ title = mex_content_get_metadata (content, MEX_CONTENT_METADATA_TITLE); mx_label_set_text (MX_LABEL (priv->title_label), title); /* subtitle (album, artist) */ album = mex_content_get_metadata (content, MEX_CONTENT_METADATA_ALBUM); artist = mex_content_get_metadata (content, MEX_CONTENT_METADATA_ARTIST); album_artist = g_strconcat (album, ", ", artist , NULL); mx_label_set_text (MX_LABEL (priv->subtitle_label), album_artist); g_free (album_artist); /* uri */ uri = mex_content_get_metadata (content, MEX_CONTENT_METADATA_STREAM); clutter_media_set_uri (priv->player, uri); /* find the item in the list */ container = mex_script_get_actor (priv->script, "tracks"); clutter_actor_iter_init (&iter, container); while (clutter_actor_iter_next (&iter, &child)) { MexContent *button_content; button_content = g_object_get_data (G_OBJECT (child), "content"); mx_button_set_toggled (MX_BUTTON (child), (button_content == content)); } }
static void notebook_button_cb (ClutterActor *button, GParamSpec *spec, Data *data) { if (mx_button_get_toggled (MX_BUTTON (button))) { int i; for (i = 0; i < N_PAGES; i++) if (data->notebook_buttons[i] == button) mx_notebook_set_current_page (MX_NOTEBOOK (data->notebook), data->notebook_pages[i]); else mx_button_set_toggled (MX_BUTTON (button), FALSE); } }
static void mex_menu_uncheck_buttons (MexMenu *menu) { GList *children; MexMenuPrivate *priv = menu->priv; children = clutter_container_get_children (CLUTTER_CONTAINER (priv->action_layout)); while (children) { if (g_object_get_qdata (children->data, mex_menu_item_quark)) { mx_button_set_toggled (MX_BUTTON (children->data), FALSE); if (priv->focus_on_add) { mex_push_focus (MX_FOCUSABLE (children->data)); priv->focus_on_add = FALSE; } } children = g_list_delete_link (children, children); } }
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 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); */ }