Beispiel #1
0
static void
mex_column_get_property (GObject    *object,
                         guint       prop_id,
                         GValue     *value,
                         GParamSpec *pspec)
{
  MxAdjustment *adjustment;
  MexColumn *self = MEX_COLUMN (object);

  switch (prop_id)
    {
    case PROP_HADJUST:
      mex_column_get_adjustments (MX_SCROLLABLE (self), &adjustment, NULL);
      g_value_set_object (value, adjustment);
      break;

    case PROP_VADJUST:
      mex_column_get_adjustments (MX_SCROLLABLE (self), NULL, &adjustment);
      g_value_set_object (value, adjustment);
      break;

    case PROP_COLLAPSE_ON_FOCUS:
      g_value_set_boolean (value, mex_column_get_collapse_on_focus (self));
      break;

    case PROP_OPENED:
      g_value_set_boolean (value, mex_column_get_opened (self));

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Beispiel #2
0
static void
mex_column_set_property (GObject      *object,
                         guint         prop_id,
                         const GValue *value,
                         GParamSpec   *pspec)
{
  MexColumn *self = MEX_COLUMN (object);

  switch (prop_id)
    {
    case PROP_HADJUST:
      mex_column_set_adjustments (MX_SCROLLABLE (self), NULL,
                                  g_value_get_object (value));
      break;

    case PROP_VADJUST:
      mex_column_set_adjustments (MX_SCROLLABLE (self),
                                  g_value_get_object (value),
                                  self->priv->adjustment);
      break;

    case PROP_COLLAPSE_ON_FOCUS:
      mex_column_set_collapse_on_focus (self, g_value_get_boolean (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
static void
mx_viewport_set_property (GObject      *object,
                          guint         prop_id,
                          const GValue *value,
                          GParamSpec   *pspec)
{
  MxViewport *viewport = MX_VIEWPORT (object);
  MxViewportPrivate *priv = viewport->priv;

  switch (prop_id)
    {
    case PROP_X_ORIGIN:
      mx_viewport_set_origin (viewport,
                              g_value_get_float (value),
                              priv->y,
                              priv->z);
      break;

    case PROP_Y_ORIGIN:
      mx_viewport_set_origin (viewport,
                              priv->x,
                              g_value_get_float (value),
                              priv->z);
      break;

    case PROP_Z_ORIGIN:
      mx_viewport_set_origin (viewport,
                              priv->x,
                              priv->y,
                              g_value_get_float (value));
      break;

    case PROP_HADJUST:
      scrollable_set_adjustments (MX_SCROLLABLE (object),
                                  g_value_get_object (value),
                                  priv->vadjustment);
      break;

    case PROP_VADJUST:
      scrollable_set_adjustments (MX_SCROLLABLE (object),
                                  priv->hadjustment,
                                  g_value_get_object (value));
      break;

    case PROP_SYNC_ADJUST:
      mx_viewport_set_sync_adjustments (viewport, g_value_get_boolean (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Beispiel #4
0
static void
child_vadjustment_notify_cb (GObject    *gobject,
                             GParamSpec *arg1,
                             gpointer    user_data)
{
  MxAdjustment *vadjust;

  ClutterActor *actor = CLUTTER_ACTOR (gobject);
  MxScrollViewPrivate *priv = MX_SCROLL_VIEW (user_data)->priv;

  vadjust = mx_scroll_bar_get_adjustment (MX_SCROLL_BAR(priv->vscroll));
  if (vadjust)
    g_signal_handlers_disconnect_by_func (vadjust,
                                          child_adjustment_changed_cb,
                                          priv->vscroll);

  mx_scrollable_get_adjustments (MX_SCROLLABLE(actor), NULL, &vadjust);
  if (vadjust)
    {
      mx_scroll_bar_set_adjustment (MX_SCROLL_BAR(priv->vscroll), vadjust);
      g_signal_connect (vadjust, "changed", G_CALLBACK (
                          child_adjustment_changed_cb), priv->vscroll);
      child_adjustment_changed_cb (vadjust, priv->vscroll);
    }
}
static void
mx_viewport_get_property (GObject    *object,
                          guint       prop_id,
                          GValue     *value,
                          GParamSpec *pspec)
{
  MxAdjustment *adjustment;

  MxViewportPrivate *priv = MX_VIEWPORT (object)->priv;

  switch (prop_id)
    {
    case PROP_X_ORIGIN:
      g_value_set_float (value, priv->x);
      break;

    case PROP_Y_ORIGIN:
      g_value_set_float (value, priv->y);
      break;

    case PROP_Z_ORIGIN:
      g_value_set_float (value, priv->z);
      break;

    case PROP_HADJUST:
      scrollable_get_adjustments (MX_SCROLLABLE (object), &adjustment, NULL);
      g_value_set_object (value, adjustment);
      break;

    case PROP_VADJUST:
      scrollable_get_adjustments (MX_SCROLLABLE (object), NULL, &adjustment);
      g_value_set_object (value, adjustment);
      break;

    case PROP_SYNC_ADJUST:
      g_value_set_boolean (value, priv->sync_adjustments);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Beispiel #6
0
static void
mex_column_get_property (GObject    *object,
                         guint       prop_id,
                         GValue     *value,
                         GParamSpec *pspec)
{
  MxAdjustment *adjustment;
  MexColumn *self = MEX_COLUMN (object);

  switch (prop_id)
    {
    case PROP_LABEL:
      g_value_set_string (value, mex_column_get_label (self));
      break;

    case PROP_PLACEHOLDER_ACTOR:
      g_value_set_object (value, mex_column_get_placeholder_actor (self));
      break;

    case PROP_ICON_NAME:
      g_value_set_string (value, mex_column_get_icon_name (self));
      break;

    case PROP_HADJUST:
      mex_column_get_adjustments (MX_SCROLLABLE (self), &adjustment, NULL);
      g_value_set_object (value, adjustment);
      break;

    case PROP_VADJUST:
      mex_column_get_adjustments (MX_SCROLLABLE (self), NULL, &adjustment);
      g_value_set_object (value, adjustment);
      break;

    case PROP_COLLAPSE_ON_FOCUS:
      g_value_set_boolean (value, mex_column_get_collapse_on_focus (self));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
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 void
mex_media_controls_init (MexMediaControls *self)
{
    ClutterActor *actor;
    ClutterScript *script;
    GError *err = NULL;
    MxAdjustment *adjustment;
    ClutterActor *related_box;
    gchar *tmp;

    MexMediaControlsPrivate *priv = self->priv = MEDIA_CONTROLS_PRIVATE (self);

    priv->script = script = clutter_script_new ();

    tmp = g_build_filename (mex_get_data_dir (), "json", "media-controls.json",
                            NULL);
    clutter_script_load_from_file (script, tmp, &err);
    g_free (tmp);

    if (err)
        g_error ("Could not load media controls interface: %s", err->message);

    priv->vbox =
        (ClutterActor*) clutter_script_get_object (script, "media-controls");
    clutter_actor_set_parent (priv->vbox, CLUTTER_ACTOR (self));

    /* add shadow to media controls box */
    actor = (ClutterActor *) clutter_script_get_object (script,
            "media-controls-box");
    clutter_actor_add_effect (actor, CLUTTER_EFFECT (mex_shadow_new ()));


    /* vertical fade effect */
    priv->vertical_effect = mx_fade_effect_new ();
    clutter_actor_add_effect (priv->vbox, priv->vertical_effect);
    mx_scrollable_get_adjustments (MX_SCROLLABLE (mx_bin_get_child (MX_BIN (priv->vbox))),
                                   NULL, &adjustment);
    g_signal_connect (adjustment, "changed",
                      G_CALLBACK (notify_vertical_changed_cb), self);
    g_signal_connect (adjustment, "notify::value",
                      G_CALLBACK (notify_vertical_value_cb), self);

    /* horizontal fade effect */
    priv->horizontal_effect = mx_fade_effect_new ();
    related_box = (ClutterActor *) clutter_script_get_object (priv->script,
                  "related-box");
    clutter_actor_add_effect (related_box, priv->horizontal_effect);
    mx_scrollable_get_adjustments (MX_SCROLLABLE (related_box), &adjustment,
                                   NULL);
    g_signal_connect (adjustment, "changed",
                      G_CALLBACK (notify_horizontal_changed_cb), self);
    g_signal_connect (adjustment, "notify::value",
                      G_CALLBACK (notify_horizontal_value_cb), self);


    /* slider setup */
    priv->slider = (ClutterActor*) clutter_script_get_object (script, "slider");
    g_signal_connect (priv->slider, "notify::value",
                      G_CALLBACK (slider_value_changed_cb), self);
    g_signal_connect (priv->slider, "captured-event",
                      G_CALLBACK (slider_captured_event), self);

    priv->play_pause_action =
        (MxAction*) clutter_script_get_object (script, "play-pause-action");

    priv->stop_action =
        (MxAction*) clutter_script_get_object (script, "stop-action");

    priv->add_to_queue_action =
        (MxAction*) clutter_script_get_object (script, "add-to-queue-action");

    priv->queue_button =
        (ClutterActor *) clutter_script_get_object (script, "add-to-queue-button");

    g_signal_connect (priv->play_pause_action, "activated",
                      G_CALLBACK (mex_media_controls_play_cb), self);
    g_signal_connect (priv->stop_action, "activated",
                      G_CALLBACK (mex_media_controls_stop_cb), self);
#if 0
    g_signal_connect (priv->add_to_queue_action, "activated",
                      G_CALLBACK (mex_media_controls_add_to_queue_cb), self);
#endif

    /* proxy setup */

    priv->proxy_model = MEX_VIEW_MODEL (mex_view_model_new (NULL));
    /* FIXME: Set an arbitrary 200-item limit as we can't handle large
     *        amounts of actors without massive slow-down.
     */
    mex_view_model_set_limit (priv->proxy_model, 200);

    priv->proxy = mex_content_proxy_new (MEX_MODEL (priv->proxy_model),
                                         CLUTTER_CONTAINER (related_box),
                                         MEX_TYPE_CONTENT_TILE);

    g_signal_connect (priv->proxy, "object-created", G_CALLBACK (tile_created_cb),
                      self);

    priv->is_disabled = TRUE;
}
Beispiel #9
0
void
scroll_view_main (ClutterContainer *stage)
{
  gint width, height;
  MxAdjustment *hadjust, *vadjust;
  ClutterActor *label, *elastic, *overshoot, *scroll, *kinetic, *view, *texture;

  scroll = mx_scroll_view_new ();

  /* Make sure something underneath the kinetic scroll view swallows events
   * so that we don't end up moving the window.
   */
  g_signal_connect (scroll, "button-press-event", G_CALLBACK (true_cb), NULL);

  kinetic = mx_kinetic_scroll_view_new ();

  clutter_container_add_actor (stage, scroll);
  clutter_actor_set_position (scroll, 10, 10);
  clutter_actor_set_size (scroll, 300, 300);

  view = mx_viewport_new ();
  mx_viewport_set_sync_adjustments (MX_VIEWPORT (view), FALSE);
  clutter_container_add_actor (CLUTTER_CONTAINER (kinetic), view);
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll), kinetic);


  texture = clutter_texture_new_from_file ("redhand.png", NULL);
  clutter_container_add_actor (CLUTTER_CONTAINER (view), texture);
  g_object_set (texture, "repeat-x", TRUE, "repeat-y", TRUE, NULL);
  clutter_actor_set_size (texture, 1280, 1280);

  clutter_texture_get_base_size (CLUTTER_TEXTURE (texture),
                                 &width, &height);
  mx_scrollable_get_adjustments (MX_SCROLLABLE (view),
                                 &hadjust, &vadjust);
  mx_adjustment_set_values (hadjust,
                            0,
                            0,
                            1280,
                            width,
                            width * 3,
                            300);
  mx_adjustment_set_values (vadjust,
                            0,
                            0,
                            1280,
                            height,
                            height * 3,
                            300);

  label = mx_label_new_with_text ("Toggle over-shooting:");
  overshoot = mx_toggle_new ();
  clutter_actor_set_position (label, 320, 10);
  clutter_actor_set_position (overshoot, 330 + clutter_actor_get_width (label),
                              10);
  clutter_container_add (stage, label, overshoot, NULL);

  g_signal_connect (overshoot, "notify::active",
                    G_CALLBACK (notify_overshoot_cb), kinetic);

  label = mx_label_new_with_text ("Toggle elasticity:");
  elastic = mx_toggle_new ();
  clutter_actor_set_position (label, 320,
                              20 + clutter_actor_get_height (overshoot));
  clutter_actor_set_position (elastic, clutter_actor_get_x (overshoot),
                              clutter_actor_get_y (label));
  clutter_container_add (stage, label, elastic, NULL);

  g_signal_connect (elastic, "notify::active",
                    G_CALLBACK (notify_elastic_cb), kinetic);
}