static void update_combox_index (AnerleyPresenceChooser *self) { AnerleyPresenceChooserPrivate *priv = GET_PRIVATE (self); MxComboBox *combo = MX_COMBO_BOX (self); g_signal_handlers_block_by_func (combo, _combo_index_changed, NULL); switch (priv->presence) { case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE: mx_combo_box_set_index (combo, 0); break; case TP_CONNECTION_PRESENCE_TYPE_BUSY: mx_combo_box_set_index (combo, 1); break; case TP_CONNECTION_PRESENCE_TYPE_AWAY: case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY: mx_combo_box_set_index (combo, 2); break; default: mx_combo_box_set_index (combo, 3); break; } g_signal_handlers_unblock_by_func (combo, _combo_index_changed, NULL); }
static void mx_combo_box_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { MxComboBox *combo = (MxComboBox*) object; switch (property_id) { case PROP_ACTIVE_TEXT: mx_combo_box_set_active_text (combo, g_value_get_string (value)); break; case PROP_ACTIVE_ICON_NAME: mx_combo_box_set_active_icon_name (combo, g_value_get_string (value)); break; case PROP_INDEX: mx_combo_box_set_index (combo, g_value_get_int (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
int main(int argc, char *argv[]) { clutter_init(&argc, &argv); ClutterActor *stage = NULL; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; stage = clutter_stage_get_default(); clutter_stage_set_title(CLUTTER_STAGE(stage), "Mx test"); clutter_stage_set_color(CLUTTER_STAGE(stage), &black); clutter_actor_set_size(stage, WIN_W, WIN_H); Assistant *assistant = g_new0(Assistant, 1); assistant->script = require_script(GUI_SCRIPT); assistant->stage = stage; ClutterActor *root = CLUTTER_ACTOR(require_object_from_script(assistant->script, "root")); assistant->slider = CLUTTER_ACTOR(require_object_from_script(assistant->script, "slider")); assistant->combo_box = CLUTTER_ACTOR(require_object_from_script(assistant->script, "combo_box")); clutter_container_add_actor(CLUTTER_CONTAINER(stage), root); // Combo box contents: MxComboBox *combo_box = MX_COMBO_BOX(assistant->combo_box); mx_combo_box_append_text(combo_box, "Foo"); mx_combo_box_append_text(combo_box, "Spam"); mx_combo_box_append_text(combo_box, "Lorem ipsum"); mx_combo_box_set_index(combo_box, 0); // DONE g_signal_connect(stage, "key-press-event", G_CALLBACK(key_event_cb), assistant); clutter_script_connect_signals(assistant->script, assistant); assistant->ready_ = TRUE; clutter_actor_show(stage); clutter_main(); return 0; }
static void mx_combo_box_action_activated_cb (ClutterActor *menu, MxAction *action, MxComboBox *box) { gint index; index = GPOINTER_TO_INT (g_object_get_data ((GObject*) action, "index")); mx_combo_box_set_index (box, index); /* reset the combobox style */ mx_stylable_set_style_pseudo_class (MX_STYLABLE (box), NULL); }