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;
}
Beispiel #2
0
static void
mex_tile_get_property (GObject    *object,
                       guint       property_id,
                       GValue     *value,
                       GParamSpec *pspec)
{
  MexTile *self = MEX_TILE (object);

  switch (property_id)
    {
    case PROP_PRIMARY_ICON:
      g_value_set_object (value, mex_tile_get_primary_icon (self));
      break;

    case PROP_SECONDARY_ICON:
      g_value_set_object (value, mex_tile_get_secondary_icon (self));
      break;

    case PROP_LABEL:
      g_value_set_string (value, mex_tile_get_label (self));
      break;

    case PROP_SECONDARY_LABEL:
      g_value_set_string (value, mex_tile_get_secondary_label (self));
      break;

    case PROP_HEADER_VISIBLE:
      g_value_set_boolean (value, mex_tile_get_header_visible (self));
      break;

    case PROP_IMPORTANT:
      g_value_set_boolean (value, mex_tile_get_important (self));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}