static gboolean mx_button_leave (ClutterActor *actor, ClutterCrossingEvent *event) { MxButton *button = MX_BUTTON (actor); MxWidget *widget = MX_WIDGET (actor); if (event->source != actor) return FALSE; /* hide the tooltip */ if (mx_widget_get_tooltip_text (widget)) mx_widget_hide_tooltip (widget); /* check if the widget is disabled */ if (mx_widget_get_disabled (MX_WIDGET (actor))) return FALSE; if (button->priv->is_pressed) { //clutter_ungrab_pointer (); mx_widget_long_press_cancel (widget); mx_stylable_style_pseudo_class_remove (MX_STYLABLE (widget), "active"); button->priv->is_pressed = FALSE; } mx_stylable_style_pseudo_class_remove (MX_STYLABLE (widget), "hover"); return FALSE; }
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"); }
static gboolean mx_toggle_handle_button_release_event (ClutterActor *actor, ClutterButtonEvent *event, MxToggle *toggle) { ClutterActorBox box; if (mx_widget_get_disabled (MX_WIDGET (toggle))) return FALSE; if (toggle->priv->last_move == 0) mx_toggle_set_active (toggle, !toggle->priv->active); else mx_toggle_set_active (toggle, (toggle->priv->last_move > 0.0)); toggle->priv->drag_offset = -1; toggle->priv->last_move = 0; clutter_ungrab_pointer (); /* ensure the hover state is removed if the pointer left the handle * during the grab */ clutter_actor_get_allocation_box (actor, &box); if (!clutter_actor_box_contains (&box, event->x, event->y)) mx_stylable_style_pseudo_class_remove (MX_STYLABLE (actor), "hover"); return TRUE; }
static MxFocusable* mx_toggle_move_focus (MxFocusable *focusable, MxFocusDirection direction, MxFocusable *from) { /* check if focus is being moved from us */ if (focusable == from) { MxTogglePrivate *priv = MX_TOGGLE (focusable)->priv; mx_stylable_style_pseudo_class_remove (MX_STYLABLE (focusable), "focus"); mx_stylable_style_pseudo_class_remove (MX_STYLABLE (priv->handle), "focus"); } return NULL; }
static MxFocusable* mx_slider_move_focus (MxFocusable *focusable, MxFocusDirection direction, MxFocusable *old_focus) { mx_stylable_style_pseudo_class_remove (MX_STYLABLE (focusable), "focus"); return NULL; }
static void mex_menu_item_set_toggled (ClutterActor *item, gboolean toggled) { MxStylable *icon = g_object_get_data (G_OBJECT (item), "toggle-icon"); if (toggled) mx_stylable_style_pseudo_class_add (icon, "checked"); else mx_stylable_style_pseudo_class_remove (icon, "checked"); }
static MxFocusable* mx_button_move_focus (MxFocusable *focusable, MxFocusDirection direction, MxFocusable *from) { /* check if focus is being moved from us */ if (focusable == from) mx_stylable_style_pseudo_class_remove (MX_STYLABLE (focusable), "focus"); return NULL; }
static MxFocusable * mx_combo_box_move_focus (MxFocusable *focusable, MxFocusDirection direction, MxFocusable *from) { if (focusable == from) { mx_stylable_style_pseudo_class_remove (MX_STYLABLE (focusable), "focus"); } return NULL; }
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_style_pseudo_class_remove (MX_STYLABLE (box), "hover"); }
/** * mx_button_set_toggled: * @button: a #MxButton * @toggled: #TRUE or #FALSE * * Sets the toggled state of the button. This is only really useful if the * button has #toggle-mode mode set to #TRUE. */ void mx_button_set_toggled (MxButton *button, gboolean toggled) { g_return_if_fail (MX_IS_BUTTON (button)); if (button->priv->is_toggled != toggled) { button->priv->is_toggled = toggled; if (toggled) mx_stylable_style_pseudo_class_add (MX_STYLABLE (button), "checked"); else mx_stylable_style_pseudo_class_remove (MX_STYLABLE (button), "checked"); g_object_notify (G_OBJECT (button), "toggled"); } }
static void mex_tile_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexTile *self) { ClutterActor *focus; MexTilePrivate *priv = self->priv; focus = (ClutterActor *)mx_focus_manager_get_focused (manager); if (focus) { ClutterActor *parent = clutter_actor_get_parent (focus); while (parent) { if (focus == (ClutterActor *)self) { if (!priv->has_focus) { priv->has_focus = TRUE; mx_stylable_style_pseudo_class_add (MX_STYLABLE (self), "focus"); } return; } focus = parent; parent = clutter_actor_get_parent (focus); } } priv->has_focus = FALSE; mx_stylable_style_pseudo_class_remove (MX_STYLABLE (self), "focus"); }