Esempio n. 1
0
static void
mex_grilo_feed_open_default (MexGriloProgram *program, MexGriloFeed *feed)
{
  MexPlayer *player = mex_player_get_default ();

  mex_content_view_set_context (MEX_CONTENT_VIEW (player),
                                MEX_MODEL (feed));
  mex_content_view_set_content (MEX_CONTENT_VIEW (player),
                                MEX_CONTENT (program));
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
int
main (int argc, char **argv)
{
  const ClutterColor grey = { 0x40, 0x40, 0x40, 0xff };

  ClutterActor *stage, *info_panel, *align;
  MxApplication *app;
  MxWindow *window;

  mex_init (&argc, &argv);

  app = mx_application_new (&argc, &argv, "mex-info-panel-test", 0);
  mex_style_load_default ();

  window = mx_application_create_window (app);
  stage = (ClutterActor *) mx_window_get_clutter_stage (window);
  clutter_stage_set_color ((ClutterStage *) stage, &grey);

  align = g_object_new (MX_TYPE_FRAME, "x-align", MX_ALIGN_MIDDLE,
                        "y-align", MX_ALIGN_END, NULL);

  mx_window_set_child (window, align);

  info_panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_FULL);
  mx_bin_set_child (MX_BIN (align), info_panel);

  mx_window_set_has_toolbar (window, FALSE);
  clutter_actor_set_size (stage, 1024, 768);

  MexFeed *feed = mex_feed_new ("source", "title");
  MexProgram *program =  mex_program_new (feed);
  mex_program_set_metadata (program, MEX_CONTENT_METADATA_TITLE,
                            "The cats on the moon");
  mex_program_set_metadata (program, MEX_CONTENT_METADATA_SYNOPSIS,
                            "An original title where cats are sent to the moon to catch all the mice which are naturally attracted there due to the large consistency of cheese, this results in a space race between NASA and CATSA, leading to war on the moon over territory claimed by cats");
  mex_program_set_metadata (program, MEX_CONTENT_METADATA_STILL,
                            "http://farm5.static.flickr.com/4013/4305303148_5cbc986a44_m.jpg");

  mex_content_view_set_content (MEX_CONTENT_VIEW (info_panel),
                                MEX_CONTENT (program));


  clutter_actor_show (stage);

  clutter_main ();

  return 0;
}
Esempio n. 4
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));
    }
}
Esempio n. 5
0
static void
mex_content_box_timeline_completed (ClutterTimeline *timeline,
                                    MexContentBox   *box)
{
  MexContentBoxPrivate *priv = box->priv;

  priv->extras_visible =
    (clutter_timeline_get_direction (timeline) == CLUTTER_TIMELINE_FORWARD);

  if (!priv->extras_visible)
    {
      /* box is now "closed" */
      mx_stylable_set_style_class (MX_STYLABLE (box), "");
      g_object_notify_by_pspec (G_OBJECT (box), properties[PROP_OPEN]);
    }

  if (!priv->is_open)
    mex_content_view_set_content (MEX_CONTENT_VIEW (priv->action_list),
                                  NULL);
}
Esempio n. 6
0
/**
 * mex_column_add_content:
 *
 * Add an item to the column for the specified content at the specified
 * position.
 */
static void
mex_column_add_content (MexColumn  *column,
                        MexContent *content,
                        guint       position)
{
  MexColumnPrivate *priv = column->priv;
  ClutterActor *box;
  MexShadow *shadow;
  ClutterColor shadow_color = { 0, 0, 0, 128 };
  GList *sibling;

  box = mex_content_box_new ();
  mex_content_view_set_content (MEX_CONTENT_VIEW (box), content);
  mex_content_view_set_context (MEX_CONTENT_VIEW (box), priv->model);

  sibling = g_list_nth (priv->children, position);
  priv->children = g_list_insert_before (priv->children, sibling, box);
  priv->n_items ++;

  /* add shadow */
  shadow = mex_shadow_new ();
  mex_shadow_set_paint_flags (shadow,
                              MEX_TEXTURE_FRAME_TOP
                              | MEX_TEXTURE_FRAME_BOTTOM);
  mex_shadow_set_radius_y (shadow, 25);
  mex_shadow_set_color (shadow, &shadow_color);
  clutter_actor_add_effect_with_name (CLUTTER_ACTOR (box), "shadow",
                                      CLUTTER_EFFECT (shadow));
  clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (shadow), FALSE);

  g_signal_connect (box, "notify::open",
                    G_CALLBACK (content_box_open_notify), column);

  /* set important if the column has focus */
  mex_content_box_set_important (MEX_CONTENT_BOX (box), priv->has_focus);

  clutter_actor_set_parent (box, CLUTTER_ACTOR (column));
}
Esempio n. 7
0
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;
}
Esempio n. 8
0
void
mex_media_controls_set_content (MexMediaControls *self,
                                MexContent       *content,
                                MexModel         *context)
{
    MexMediaControlsPrivate *priv = self->priv;
    gboolean show_description;

    g_return_if_fail (MEX_IS_CONTENT (content));

    if (priv->model == context)
    {
        if (priv->content == content)
            return;

        if (priv->content)
            g_object_unref (priv->content);
        if (content)
            priv->content = g_object_ref_sink (content);

        mex_media_controls_focus_content (self, priv->content);
        mex_media_controls_update_header (self);
        return;
    }

    if (priv->model)
    {
        g_object_unref (priv->model);
        priv->model = NULL;
    }
    if (context)
        priv->model = g_object_ref_sink (context);
    if (priv->content)
    {
        g_object_unref (priv->content);
        priv->content = NULL;
    }
    if (content)
        priv->content = g_object_ref_sink (content);
    priv->is_queue_model = FALSE;

    mex_media_controls_update_header (self);


    /* We may not have a context if we're launched by something like SetUri*/
    if (context)
    {
        MexModel *orig_model;

        orig_model = mex_model_get_model (context);
        g_object_set (G_OBJECT (priv->proxy_model), "model", orig_model, NULL);

        mex_view_model_set_start_content (priv->proxy_model, priv->content);
        mex_view_model_set_loop (priv->proxy_model, TRUE);

        /* Work out if the context was a queue FIXME unreliable */
        /* From coloumn context = MexViewModel MexAggregateModel MexQueueModel */
        /* From grid  context = MexProxyModel MexProxyModel MexQueueModel */

        if (MEX_IS_PROXY_MODEL (context))
        {
            MexModel *model_from_proxy;
            model_from_proxy =
                mex_proxy_model_get_model (MEX_PROXY_MODEL (orig_model));

            if (MEX_IS_QUEUE_MODEL (model_from_proxy))
                priv->is_queue_model = TRUE;
        }
        else if (MEX_IS_AGGREGATE_MODEL (orig_model))
        {
            MexModel *real_model;
            real_model =
                mex_aggregate_model_get_model_for_content (MEX_AGGREGATE_MODEL (orig_model), content);
            if (MEX_IS_QUEUE_MODEL (real_model))
                priv->is_queue_model = TRUE;
        }
    }
    /* Update content on the queue button */
    mex_content_view_set_content (MEX_CONTENT_VIEW (priv->queue_button),
                                  priv->content);

    /* show the description rather than the seek bar for certain content */
    show_description = !g_strcmp0 ("x-mex/tv",
                                   mex_content_get_metadata (priv->content,
                                           MEX_CONTENT_METADATA_MIMETYPE));

    mex_media_controls_show_description(self, show_description);
}
Esempio n. 9
0
static void
mex_content_box_set_content (MexContentView *view,
                             MexContent     *content)
{
  MexContentBox *box = (MexContentBox *) view;
  MexContentBoxPrivate *priv;

  priv = box->priv;

  if (priv->content == content)
    return;

  mex_content_view_set_content (MEX_CONTENT_VIEW (priv->tile), content);
  mex_content_view_set_content (MEX_CONTENT_VIEW (priv->action_list), content);

  if (priv->content)
    {
      GList *l;

      for (l = priv->bindings; l; l = l->next)
        g_object_unref (l->data);

      g_list_free (priv->bindings);
      priv->bindings = NULL;

      g_object_unref (priv->content);
      priv->content = NULL;
    }

  if (content)
    {
      int i;

      priv->content = g_object_ref_sink (content);
      for (i = 0; content_bindings[i].id != MEX_CONTENT_METADATA_NONE; i++)
        {
          const gchar *property;
          GBinding *binding;

          property = mex_content_get_property_name (content,
                                                    content_bindings[i].id);

          if (property == NULL)
            {
              /* The Content does not provide a GObject property for this
               * kind of metadata, we can only sync at creation time */
              const gchar *metadata;

              metadata = mex_content_get_metadata (content,
                                                   content_bindings[i].id);
              g_object_set (box, content_bindings[i].target, metadata, NULL);

              continue;
            }

          if (content_bindings[i].fallback)
            binding = g_object_bind_property_full (content, property,
                                                   box,
                                                   content_bindings[i].target,
                                                   G_BINDING_SYNC_CREATE,
                                                   content_bindings[i].fallback,
                                                   NULL,
                                                   content, NULL);
          else
            binding = g_object_bind_property (content, property, box,
                                              content_bindings[i].target,
                                              G_BINDING_SYNC_CREATE);

          priv->bindings = g_list_prepend (priv->bindings, binding);
        }
    }
}