コード例 #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;
}
コード例 #2
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;
}