Ejemplo n.º 1
0
static gboolean
mex_content_box_key_press_event_cb (ClutterActor    *actor,
                                    ClutterKeyEvent *event,
                                    MexExpanderBox  *drawer)
{
  gboolean open;

  MexActionManager *manager = mex_action_manager_get_default ();
  MexContentBoxPrivate *priv = MEX_CONTENT_BOX (drawer)->priv;

  if (event->keyval != MEX_KEY_OK &&
      event->keyval != MEX_KEY_INFO)
    {
      return FALSE;
    }

  if (event->keyval == MEX_KEY_OK)
    {
      GList *actions;

      actions = mex_action_manager_get_actions_for_content (manager,
                                                            priv->content);

      if (actions)
        {
          MxAction *action = actions->data;

          mex_action_set_content (action, priv->content);
          mex_action_set_context (action, priv->model);

          g_signal_emit_by_name (action, "activated", 0);

          g_list_free (actions);

          return TRUE;
        }
    }

  open = !mex_expander_box_get_open (drawer);

  /* We only want to expand the box if we have either more than one action,
   * or we have description metadata. We already track this when determining
   * if the info icon should be visible, so use that to determine whether
   * we should allow opening here.
   */
  if (open && !mex_tile_get_secondary_icon (MEX_TILE (priv->tile)))
    return FALSE;

  mex_expander_box_set_open (drawer, open);
  mex_expander_box_set_open (MEX_EXPANDER_BOX (priv->box), open);

  return TRUE;
}
Ejemplo n.º 2
0
static void
mex_content_box_notify_key_focus_cb (ClutterStage  *stage,
                                     GParamSpec    *pspec,
                                     MexContentBox *self)
{
  MexContentBoxPrivate *priv = self->priv;
  ClutterActor *focus = clutter_stage_get_key_focus (stage);

  if (focus == priv->tile)
    {
      gboolean show_info;

      if (mex_content_get_metadata (priv->content,
                                    MEX_CONTENT_METADATA_SYNOPSIS) ||
          mex_content_get_metadata (priv->content,
                                    MEX_CONTENT_METADATA_DATE) ||
          mex_content_get_metadata (priv->content,
                                    MEX_CONTENT_METADATA_CREATION_DATE) ||
          mex_content_get_metadata (priv->content,
                                    MEX_CONTENT_METADATA_DURATION))
        show_info = TRUE;
      else
        {
          MexActionManager *manager = mex_action_manager_get_default ();
          GList *actions =
            mex_action_manager_get_actions_for_content (manager, priv->content);

          if (actions && actions->next)
            show_info = TRUE;
          else
            show_info = FALSE;

          g_list_free (actions);
        }

      if (show_info)
        {
          ClutterActor *icon = mx_icon_new ();
          mx_stylable_set_style_class (MX_STYLABLE (icon), "Info");
          mex_tile_set_secondary_icon (MEX_TILE (priv->tile), icon);
        }
    }
  else
    mex_tile_set_secondary_icon (MEX_TILE (priv->tile), NULL);
}
Ejemplo n.º 3
0
static void
mex_content_box_notify_open_cb (MexExpanderBox *box,
                                GParamSpec     *pspec)
{
  GList *actions;

  ClutterStage *stage = CLUTTER_STAGE (
                          clutter_actor_get_stage (CLUTTER_ACTOR (box)));
  MxFocusManager *fmanager = mx_focus_manager_get_for_stage (stage);
  MexActionManager *manager = mex_action_manager_get_default ();
  MexContentBoxPrivate *priv = MEX_CONTENT_BOX (box)->priv;
  gboolean open = mex_expander_box_get_open (box);

  if (!open)
    {
      /* If the action list has focus, push it back onto the tile */
      if (mex_actor_has_focus (fmanager, priv->action_list))
        mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->tile));
      return;
    }

  /* Refresh the info panel and the action list */
  mex_content_view_set_content (MEX_CONTENT_VIEW (priv->panel), priv->content);
  mex_action_list_refresh (MEX_ACTION_LIST (priv->action_list));

  /* See if we have any actions */
  actions = mex_action_manager_get_actions_for_content (manager,
                                                        priv->content);

  /* Push focus onto the action list if we have actions, otherwise onto
   * the tile.
   */
  if (actions)
    {
      clutter_actor_show (priv->action_list);
      mx_focus_manager_push_focus (fmanager,
                                   MX_FOCUSABLE (priv->action_list));
      g_list_free (actions);
    }
  else
    {
      clutter_actor_hide (priv->action_list);
      mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->tile));
    }
}
Ejemplo n.º 4
0
static void
_back_button_cb (ClutterActor *actor,
                 MexInfoBar   *bar)
{
  GList *actions, *l;

  actions = mex_action_manager_get_actions (mex_action_manager_get_default ());

  /* find the back action */
  for (l = actions; l; l = g_list_next (l))
    {
      MxAction *action = l->data;

      if (!g_strcmp0 (mx_action_get_name (action), "go-back"))
        g_action_activate (G_ACTION (action), NULL);
    }

  g_list_free (actions);
}
Ejemplo n.º 5
0
static gboolean
mex_content_box_key_press_event_cb (ClutterActor    *actor,
                                    ClutterKeyEvent *event,
                                    gpointer         user_data)
{
  MexActionManager *manager = mex_action_manager_get_default ();
  MexContentBoxPrivate *priv = MEX_CONTENT_BOX (actor)->priv;


  if (MEX_KEY_OK (event->keyval))
    {
      GList *actions;

      actions = mex_action_manager_get_actions_for_content (manager,
                                                            priv->content);
      /* find the first action and "activate" it */
      if (actions)
        {
          MxAction *action = actions->data;

          mex_action_set_context (action, priv->context);
          mex_action_set_content (action, priv->content);

          g_signal_emit_by_name (action, "activated", 0);

          g_list_free (actions);

          return TRUE;
        }
    }
  else if (MEX_KEY_INFO (event->keyval))
    {
      mex_content_box_toggle_open (MEX_CONTENT_BOX (actor));
    }
  else if (MEX_KEY_BACK (event->keyval))
    {
      /* close content box */
      if (priv->is_open)
        mex_content_box_toggle_open (MEX_CONTENT_BOX (actor));
    }

  return FALSE;
}
Ejemplo n.º 6
0
static void
mex_search_activate_content (MexContent *content)
{
  MxAction *action;

  MexActionManager *manager = mex_action_manager_get_default ();
  GList *actions = mex_action_manager_get_actions_for_content (manager,
                                                               content);

  if (!actions)
    return;

  /* Just execute the highest-priority action for this item. This is
   * always the 'play'/'execute' action.
   */
  action = actions->data;
  mex_action_set_content (action, content);
  g_signal_emit_by_name (action, "activated");
}