static void mex_content_box_toggle_open (MexContentBox *box) { MexContentBoxPrivate *priv = box->priv; gboolean close_notified, next_is_open; const gchar *mimetype; /* search history items should not appear in the "open" state */ mimetype = mex_content_get_metadata (priv->content, MEX_CONTENT_METADATA_MIMETYPE); if (!g_strcmp0 (mimetype, "x-mex/search")) return; /* if the close animation was cancelled then no notify for the closed state * will have been sent, therefore notify for the opened state does not need * to be emitted */ close_notified = (!priv->is_open && !clutter_timeline_is_playing (priv->timeline)); next_is_open = !priv->is_open; if (next_is_open) { /* opening */ clutter_timeline_set_direction (priv->timeline, CLUTTER_TIMELINE_FORWARD); mx_stylable_set_style_class (MX_STYLABLE (box), "open"); /* refresh the action list */ mex_content_view_set_content (MEX_CONTENT_VIEW (priv->action_list), priv->content); priv->extras_visible = TRUE; if (close_notified) g_object_notify_by_pspec (G_OBJECT (box), properties[PROP_OPEN]); mex_push_focus (MX_FOCUSABLE (priv->action_list)); } else { priv->is_closing = TRUE; /* closing */ mex_push_focus (MX_FOCUSABLE (priv->tile)); clutter_timeline_set_direction (priv->timeline, CLUTTER_TIMELINE_BACKWARD); priv->is_closing = FALSE; priv->extras_visible = TRUE; } if (!clutter_timeline_is_playing (priv->timeline)) clutter_timeline_rewind (priv->timeline); clutter_timeline_start (priv->timeline); priv->is_open = next_is_open; }
/** * mex_menu_add_action: * @menu: A #MexMenu * @action: A #MxAction * @type: The menu action type * * Adds a menu item to @menu at the current depth. @action must be a uniquely * named action, if an action with that name already exists in the menu, this * function will do nothing. */ void mex_menu_add_action (MexMenu *menu, MxAction *action, MexMenuActionType type) { ClutterActor *item; MexMenuPrivate *priv; g_return_if_fail (MEX_IS_MENU (menu)); g_return_if_fail (MX_IS_ACTION (action)); priv = menu->priv; if (mex_menu_find_action (menu, mx_action_get_name (action), NULL)) { g_warning (G_STRLOC ": Action '%s' is already contained in this menu", mx_action_get_name (action)); return; } item = mex_menu_item_new (menu, action, type); g_hash_table_insert (priv->action_to_item, action, item); clutter_container_add_actor (CLUTTER_CONTAINER (priv->action_layout), item); if (priv->focus_on_add) { mex_push_focus (MX_FOCUSABLE (item)); priv->focus_on_add = FALSE; } }
static gboolean _close_dialog_cb (gpointer unused, MexInfoBar *self) { MexInfoBarPrivate *priv = self->priv; if (CLUTTER_ACTOR_IS_VISIBLE (priv->settings_dialog)) clutter_actor_hide (priv->settings_dialog); mex_push_focus (MX_FOCUSABLE (self)); return FALSE; }
static gboolean mex_content_box_tile_clicked_cb (ClutterActor *tile, ClutterButtonEvent *event, MexContentBox *self) { /* Because key based interactions moving the focus involve opening/closing the content box, we have to be careful about the order in which we change focus and open/close the box with mouse interactions. */ if (mex_content_box_get_open (self)) { mex_content_box_toggle_open (MEX_CONTENT_BOX (self)); mex_push_focus (MX_FOCUSABLE (tile)); } else { mex_push_focus (MX_FOCUSABLE (tile)); mex_content_box_toggle_open (MEX_CONTENT_BOX (self)); } return TRUE; }
static gboolean mex_column_button_release_event (ClutterActor *actor, ClutterButtonEvent *event) { gboolean returnval; MexColumnViewPrivate *priv = MEX_COLUMN_VIEW (actor)->priv; returnval = CLUTTER_ACTOR_CLASS (mex_column_view_parent_class)-> button_release_event (actor, event); if (!returnval && !priv->has_focus) { mex_push_focus (MX_FOCUSABLE (actor)); return TRUE; } return returnval; }
static void mex_media_controls_replace_content (MexMediaControls *self, MexContent *content) { MexPlayer *player; MxScrollable *related_box; MxAdjustment *adjustment; gdouble upper; MexMediaControlsPrivate *priv = self->priv; if (priv->content == content) return; player = mex_player_get_default (); mex_content_view_set_content (MEX_CONTENT_VIEW (player), content); if (priv->content) g_object_unref (priv->content); priv->content = g_object_ref_sink (content); mex_media_controls_update_header (self); mex_content_view_set_content (MEX_CONTENT_VIEW (priv->queue_button), content); mex_push_focus ((MxFocusable*) clutter_script_get_object (priv->script, "play-pause-button")); related_box = (MxScrollable *)clutter_script_get_object (priv->script, "related-box"); mx_scrollable_get_adjustments (MX_SCROLLABLE (related_box), &adjustment, NULL); mx_adjustment_get_values (adjustment, NULL, NULL, &upper, NULL, NULL, NULL); mx_adjustment_set_value (adjustment, upper); mx_scrollable_set_adjustments (MX_SCROLLABLE (related_box), adjustment, NULL); }
static gboolean mex_content_box_tile_clicked_cb (ClutterActor *tile, ClutterButtonEvent *event, MexContentBox *self) { MexContentBoxPrivate *priv = self->priv; if (mex_expander_box_get_open (MEX_EXPANDER_BOX (self))) { mex_expander_box_set_open (MEX_EXPANDER_BOX (self), FALSE); mex_expander_box_set_open (MEX_EXPANDER_BOX (priv->box), FALSE); } else { mex_expander_box_set_open (MEX_EXPANDER_BOX (self), TRUE); mex_expander_box_set_open (MEX_EXPANDER_BOX (priv->box), TRUE); } mex_push_focus (MX_FOCUSABLE (priv->tile)); return TRUE; }
void mex_media_controls_focus_content (MexMediaControls *self, MexContent *content) { MexMediaControlsPrivate *priv = self->priv; ClutterContainer *container; GList *children, *l; container = CLUTTER_CONTAINER (clutter_script_get_object (priv->script, "related-box")); children = clutter_container_get_children (container); for (l = children; l; l = g_list_next (l)) { if (mex_content_view_get_content (l->data) == content) { mex_push_focus (l->data); return; } } return; }
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); } }
static gboolean mex_player_key_press_event (ClutterActor *actor, ClutterKeyEvent *event) { MexPlayerPrivate *priv = MEX_PLAYER (actor)->priv; ClutterStage *stage; MxFocusManager *fmanager; stage = (ClutterStage*) clutter_actor_get_stage (actor); fmanager = mx_focus_manager_get_for_stage (stage); switch (event->keyval) { case CLUTTER_KEY_Down: { if (!priv->controls_visible && !priv->info_visible) return mex_player_set_controls_visible (MEX_PLAYER (actor), TRUE); break; } case MEX_KEY_INFO: { MexContent *content; content = priv->content; if (priv->info_visible) { /* hide the info panel */ clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE, 250, "opacity", 0x00, NULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), TRUE); mx_widget_set_disabled (MX_WIDGET (priv->controls), FALSE); priv->info_visible = FALSE; if (priv->controls_prev_visible) mex_player_set_controls_visible (MEX_PLAYER (actor), TRUE); } else { /* if you're pressing info button while the media controls are up set them as previously visible */ if (priv->controls_visible) priv->controls_prev_visible = TRUE; MxFocusable *focusable; focusable = mx_focus_manager_get_focused (fmanager); if (MEX_IS_CONTENT_TILE (focusable) && priv->controls_prev_visible == TRUE) { content = mex_content_view_get_content (MEX_CONTENT_VIEW (focusable)); /* to avoid any accidental leak */ if (priv->related_tile) { g_object_unref (priv->related_tile); priv->related_tile = NULL; } priv->related_tile = g_object_ref (focusable); } mex_content_view_set_content (MEX_CONTENT_VIEW (priv->info_panel), content); /* show the info panel */ clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE, 250, "opacity", 0xff, NULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), FALSE); mx_widget_set_disabled (MX_WIDGET (priv->controls), TRUE); priv->info_visible = TRUE; mex_player_set_controls_visible (MEX_PLAYER (actor), FALSE); mex_push_focus (MX_FOCUSABLE (priv->info_panel)); } return TRUE; } } return FALSE; }