Example #1
0
static void
mx_notebook_allocate (ClutterActor          *actor,
                      const ClutterActorBox *box,
                      ClutterAllocationFlags flags)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (actor)->priv;
  GList *l;
  MxPadding padding;
  ClutterActorBox childbox;

  CLUTTER_ACTOR_CLASS (mx_notebook_parent_class)->allocate (actor, box, flags);

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  childbox.x1 = 0 + padding.left;
  childbox.x2 = box->x2 - box->x1 - padding.right;

  childbox.y1 = 0 + padding.top;
  childbox.y2 = box->y2 - box->y1 - padding.bottom;

  for (l = priv->children; l; l = l->next)
    {
      ClutterActor *child;

      child = CLUTTER_ACTOR (l->data);

      if (CLUTTER_ACTOR_IS_VISIBLE (l->data))
        clutter_actor_allocate (child, &childbox, flags);
    }
}
Example #2
0
static void
mx_notebook_foreach (ClutterContainer *container,
                     ClutterCallback   callback,
                     gpointer          callback_data)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (container)->priv;

  g_list_foreach (priv->children, (GFunc) callback, callback_data);
}
Example #3
0
static void
mx_notebook_pick (ClutterActor       *actor,
                  const ClutterColor *color)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (actor)->priv;

  CLUTTER_ACTOR_CLASS (mx_notebook_parent_class)->pick (actor, color);

  if (priv->current_page)
    clutter_actor_paint (priv->current_page);
}
Example #4
0
static MxFocusable *
mx_notebook_accept_focus (MxFocusable *focusable,
                          MxFocusHint  hint)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (focusable)->priv;

  if (priv->current_page && MX_IS_FOCUSABLE (priv->current_page))
    return mx_focusable_accept_focus (MX_FOCUSABLE (priv->current_page), hint);
  else
    return NULL;
}
Example #5
0
static void
mx_notebook_remove (ClutterContainer *container,
                    ClutterActor     *actor)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (container)->priv;

  GList *item = NULL;

  item = g_list_find (priv->children, actor);

  if (item == NULL)
    {
      g_warning ("Actor of type '%s' is not a child of container of type '%s'",
                 g_type_name (G_OBJECT_TYPE (actor)),
                 g_type_name (G_OBJECT_TYPE (container)));
      return;
    }

  /* If it was the current page, select either the previous or
   * the next, whichever exists first.
   */
  if (actor == priv->current_page)
    {
      priv->current_page = item->prev ? item->prev->data :
        (item->next ? item->next->data : NULL);
      g_object_notify (G_OBJECT (container), "current-page");
    }

  g_object_ref (actor);

  priv->children = g_list_delete_link (priv->children, item);
  clutter_actor_remove_child (CLUTTER_ACTOR (container), actor);

  g_object_unref (actor);

  mx_notebook_update_children (MX_NOTEBOOK (container));
}
Example #6
0
static void
notebook_button_cb (ClutterActor *button, GParamSpec *spec, Data *data)
{
  if (mx_button_get_toggled (MX_BUTTON (button)))
    {
      int i;

      for (i = 0; i < N_PAGES; i++)
        if (data->notebook_buttons[i] == button)
          mx_notebook_set_current_page (MX_NOTEBOOK (data->notebook),
                                        data->notebook_pages[i]);
        else
          mx_button_set_toggled (MX_BUTTON (button), FALSE);
    }
}
Example #7
0
static void
mx_notebook_set_property (GObject      *object,
                          guint         property_id,
                          const GValue *value,
                          GParamSpec   *pspec)
{
  switch (property_id)
    {
    case PROP_CURRENT_PAGE:
      mx_notebook_set_current_page (MX_NOTEBOOK (object),
                                    (ClutterActor *)g_value_get_object (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
Example #8
0
static void
mx_notebook_add (ClutterContainer *container,
                 ClutterActor     *actor)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (container)->priv;

  clutter_actor_add_child (CLUTTER_ACTOR (container), actor);
  priv->children = g_list_append (priv->children, actor);

  if (!priv->current_page)
    {
      priv->current_page = actor;
      clutter_actor_set_opacity (actor, 0xff);
      g_object_notify (G_OBJECT (container), "current-page");
    }
  else
    clutter_actor_hide (actor);
}
Example #9
0
static void
mx_notebook_get_property (GObject    *object,
                          guint       property_id,
                          GValue     *value,
                          GParamSpec *pspec)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (object)->priv;

  switch (property_id)
    {
    case PROP_CURRENT_PAGE:
      g_value_set_object (value, priv->current_page);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
Example #10
0
static void
mx_notebook_get_preferred_height (ClutterActor *actor,
                                  gfloat        for_width,
                                  gfloat       *min_height_p,
                                  gfloat       *natural_height_p)
{
  MxNotebookPrivate *priv = MX_NOTEBOOK (actor)->priv;
  GList *l;
  MxPadding padding;

  mx_widget_get_padding (MX_WIDGET (actor), &padding);

  if (min_height_p)
    *min_height_p = 0;

  if (natural_height_p)
    *natural_height_p = 0;

  for (l = priv->children; l; l = l->next)
    {
      gfloat child_min, child_nat;

      clutter_actor_get_preferred_height (CLUTTER_ACTOR (l->data), for_width,
                                          &child_min, &child_nat);

      if (min_height_p)
        *min_height_p = MAX (*min_height_p, child_min);

      if (natural_height_p)
        *natural_height_p = MAX (*natural_height_p, child_nat);
    }

  if (min_height_p)
    *min_height_p += padding.top + padding.bottom;

  if (natural_height_p)
    *natural_height_p += padding.top + padding.bottom;

}
Example #11
0
static void
mx_notebook_paint (ClutterActor *actor)
{
  GList *l;

  MxNotebookPrivate *priv = MX_NOTEBOOK (actor)->priv;

  CLUTTER_ACTOR_CLASS (mx_notebook_parent_class)->paint (actor);

  for (l = priv->children; l; l = l->next)
    {
      ClutterActor *child = CLUTTER_ACTOR (l->data);

      if (child == priv->current_page)
        continue;

      if (CLUTTER_ACTOR_IS_VISIBLE (child))
        clutter_actor_paint (child);
    }

  if (priv->current_page)
    clutter_actor_paint (priv->current_page);
}