Example #1
0
/* Dump actors */
static void _xfdashboard_dump_actor_print(ClutterActor *inActor, gint inLevel)
{
	XfdashboardStylable		*stylable;
	ClutterActorBox			allocation;
	gint					i;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));
	g_return_if_fail(inLevel>=0);

	/* Check if actor is stylable to retrieve style configuration */
	stylable=NULL;
	if(XFDASHBOARD_IS_STYLABLE(inActor)) stylable=XFDASHBOARD_STYLABLE(inActor);

	/* Dump actor */
	for(i=0; i<inLevel; i++) g_print("  ");
	clutter_actor_get_allocation_box(inActor, &allocation);
	g_print("+- %s@%p [%s%s%s%s%s%s] - geometry: %.2f,%.2f [%.2fx%.2f], mapped: %s, visible: %s, layout: %s, children: %d\n",
				G_OBJECT_TYPE_NAME(inActor), inActor,
				clutter_actor_get_name(inActor) ? " #" : "",
				clutter_actor_get_name(inActor) ? clutter_actor_get_name(inActor) : "",
				stylable && xfdashboard_stylable_get_classes(stylable) ? "." : "",
				stylable && xfdashboard_stylable_get_classes(stylable) ? xfdashboard_stylable_get_classes(stylable) : "",
				stylable && xfdashboard_stylable_get_pseudo_classes(stylable) ? ":" : "",
				stylable && xfdashboard_stylable_get_pseudo_classes(stylable) ? xfdashboard_stylable_get_pseudo_classes(stylable) : "",
				allocation.x1,
				allocation.y1,
				allocation.x2-allocation.x1,
				allocation.y2-allocation.y1,
				clutter_actor_is_mapped(inActor) ? "yes" : "no",
				clutter_actor_is_visible(inActor) ? "yes" : "no",
				clutter_actor_get_layout_manager(inActor) ? G_OBJECT_TYPE_NAME(clutter_actor_get_layout_manager(inActor)) : "none",
				clutter_actor_get_n_children(inActor));

}
/**
 * st_box_layout_get_pack_start:
 * @box: A #StBoxLayout
 *
 * Get the value of the #StBoxLayout::pack-start property.
 *
 * Returns: %TRUE if pack-start is enabled
 */
gboolean
st_box_layout_get_pack_start (StBoxLayout *box)
{
  g_return_val_if_fail (ST_IS_BOX_LAYOUT (box), FALSE);

  return clutter_box_layout_get_pack_start (CLUTTER_BOX_LAYOUT (clutter_actor_get_layout_manager (CLUTTER_ACTOR (box))));
}
static void
st_box_layout_allocate (ClutterActor          *actor,
                        const ClutterActorBox *box,
                        ClutterAllocationFlags flags)
{
  StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (actor)->priv;
  StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
  ClutterLayoutManager *layout = clutter_actor_get_layout_manager (actor);
  ClutterActorBox content_box;
  gfloat avail_width, avail_height, min_width, natural_width, min_height, natural_height;

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

  st_theme_node_get_content_box (theme_node, box, &content_box);
  clutter_actor_box_get_size (&content_box, &avail_width, &avail_height);

  clutter_layout_manager_get_preferred_width (layout, CLUTTER_CONTAINER (actor),
                                              avail_height,
                                              &min_width, &natural_width);
  clutter_layout_manager_get_preferred_height (layout, CLUTTER_CONTAINER (actor),
                                               MAX (avail_width, min_width),
                                               &min_height, &natural_height);


  /* update adjustments for scrolling */
  if (priv->vadjustment)
    {
      gdouble prev_value;

      g_object_set (G_OBJECT (priv->vadjustment),
                    "lower", 0.0,
                    "upper", MAX (min_height, avail_height),
                    "page-size", avail_height,
                    "step-increment", avail_height / 6,
                    "page-increment", avail_height - avail_height / 6,
                    NULL);

      prev_value = st_adjustment_get_value (priv->vadjustment);
      st_adjustment_set_value (priv->vadjustment, prev_value);
    }

  if (priv->hadjustment)
    {
      gdouble prev_value;

      g_object_set (G_OBJECT (priv->hadjustment),
                    "lower", 0.0,
                    "upper", MAX (min_width, avail_width),
                    "page-size", avail_width,
                    "step-increment", avail_width / 6,
                    "page-increment", avail_width - avail_width / 6,
                    NULL);

      prev_value = st_adjustment_get_value (priv->hadjustment);
      st_adjustment_set_value (priv->hadjustment, prev_value);
    }
}
static ClutterLayoutMeta *
get_layout_meta (StBoxLayoutChild *self)
{
  ClutterChildMeta *meta = CLUTTER_CHILD_META (self);
  ClutterActor *actor = clutter_child_meta_get_actor (meta);
  ClutterContainer *container = clutter_child_meta_get_container (meta);
  ClutterLayoutManager *layout = clutter_actor_get_layout_manager (CLUTTER_ACTOR (container));
  return clutter_layout_manager_get_child_meta (layout, container, actor);
}
/**
 * st_box_layout_get_vertical:
 * @box: A #StBoxLayout
 *
 * Get the value of the #StBoxLayout::vertical property.
 *
 * Returns: %TRUE if the layout is vertical
 */
gboolean
st_box_layout_get_vertical (StBoxLayout *box)
{
  ClutterLayoutManager *layout;
  ClutterOrientation orientation;

  g_return_val_if_fail (ST_IS_BOX_LAYOUT (box), FALSE);

  layout = clutter_actor_get_layout_manager (CLUTTER_ACTOR (box));
  orientation = clutter_box_layout_get_orientation (CLUTTER_BOX_LAYOUT (layout));
  return orientation == CLUTTER_ORIENTATION_VERTICAL;
}
static void
st_box_layout_style_changed (StWidget *self)
{
  StThemeNode *theme_node = st_widget_get_theme_node (self);
  ClutterBoxLayout *layout;
  double spacing;

  layout = CLUTTER_BOX_LAYOUT (clutter_actor_get_layout_manager (CLUTTER_ACTOR (self)));

  spacing = st_theme_node_get_length (theme_node, "spacing");
  clutter_box_layout_set_spacing (layout, (int)(spacing + 0.5));

  ST_WIDGET_CLASS (st_box_layout_parent_class)->style_changed (self);
}
static void
st_box_layout_get_property (GObject    *object,
                            guint       property_id,
                            GValue     *value,
                            GParamSpec *pspec)
{
  ClutterLayoutManager *layout;
  StAdjustment *adjustment;
  ClutterOrientation orientation;

  switch (property_id)
    {
    case PROP_VERTICAL:
      layout = clutter_actor_get_layout_manager (CLUTTER_ACTOR (object));
      orientation = clutter_box_layout_get_orientation (CLUTTER_BOX_LAYOUT (layout));
      g_value_set_boolean (value, orientation == CLUTTER_ORIENTATION_VERTICAL);
      break;

    case PROP_PACK_START:
      layout = clutter_actor_get_layout_manager (CLUTTER_ACTOR (object));
      g_value_set_boolean (value, clutter_box_layout_get_pack_start (CLUTTER_BOX_LAYOUT (layout)));
      break;

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

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

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
/**
 * st_box_layout_set_pack_start:
 * @box: A #StBoxLayout
 * @pack_start: %TRUE if the layout should use pack-start
 *
 * Set the value of the #StBoxLayout::pack-start property.
 *
 */
void
st_box_layout_set_pack_start (StBoxLayout *box,
                              gboolean     pack_start)
{
  ClutterBoxLayout *layout;

  g_return_if_fail (ST_IS_BOX_LAYOUT (box));

  layout = CLUTTER_BOX_LAYOUT (clutter_actor_get_layout_manager (CLUTTER_ACTOR (box)));

  if (clutter_box_layout_get_pack_start (layout) != pack_start)
    {
      clutter_box_layout_set_pack_start (layout, pack_start);
      g_object_notify (G_OBJECT (box), "pack-start");
    }
}
Example #9
0
static void
changed_cb (ClutterActor *actor,
            GParamSpec   *pspec,
            ClutterActor *text)
{
  ClutterActorAlign x_align, y_align;
  ClutterActor *box;
  ClutterLayoutManager *layout;
  ClutterLayoutMeta *meta;
  gboolean x_expand, y_expand;
  gchar *label;
  gint left, top, width, height;

  box = clutter_actor_get_parent (actor);
  layout = clutter_actor_get_layout_manager (box);
  meta = clutter_layout_manager_get_child_meta (layout,
                                                CLUTTER_CONTAINER (box),
                                                actor);

  g_object_get (actor,
                "x-align", &x_align,
                "y-align", &y_align,
                "x-expand", &x_expand,
                "y-expand", &y_expand,
                NULL);

  g_object_get (meta,
                "left-attach", &left,
                "top-attach", &top,
                "width", &width,
                "height", &height,
                NULL);

  label = g_strdup_printf ("attach: %d,%d\n"
                           "span: %d,%d\n"
                           "expand: %d,%d\n"
                           "align: %s,%s",
                           left, top, width, height,
                           x_expand, y_expand,
                           get_align_name (x_align),
                           get_align_name (y_align));
  clutter_text_set_text (CLUTTER_TEXT (text), label);
  g_free (label);
}
Example #10
0
/**
 * st_box_layout_set_vertical:
 * @box: A #StBoxLayout
 * @vertical: %TRUE if the layout should be vertical
 *
 * Set the value of the #StBoxLayout::vertical property
 *
 */
void
st_box_layout_set_vertical (StBoxLayout *box,
                            gboolean     vertical)
{
  ClutterLayoutManager *layout;
  ClutterOrientation orientation;

  g_return_if_fail (ST_IS_BOX_LAYOUT (box));

  layout = clutter_actor_get_layout_manager (CLUTTER_ACTOR (box));
  orientation = vertical ? CLUTTER_ORIENTATION_VERTICAL
                         : CLUTTER_ORIENTATION_HORIZONTAL;

  if (clutter_box_layout_get_orientation (CLUTTER_BOX_LAYOUT (layout)) != orientation)
    {
      clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (layout), orientation);
      g_object_notify (G_OBJECT (box), "vertical");
    }
}
Example #11
0
static gboolean
key_release_cb (ClutterActor *stage,
                ClutterEvent *event,
                ClutterActor *box)
{
  ClutterGridLayout *layout;
  gboolean toggle;
  guint spacing;

  layout = CLUTTER_GRID_LAYOUT (clutter_actor_get_layout_manager (box));

  switch (clutter_event_get_key_symbol (event))
    {
    case CLUTTER_KEY_c:
      toggle = clutter_grid_layout_get_column_homogeneous (layout);
      clutter_grid_layout_set_column_homogeneous (layout, !toggle);
      break;

    case CLUTTER_KEY_r:
      toggle = clutter_grid_layout_get_row_homogeneous (layout);
      clutter_grid_layout_set_row_homogeneous (layout, !toggle);
      break;

    case CLUTTER_KEY_s:
      spacing = clutter_grid_layout_get_column_spacing (layout);
      if (spacing < 12)
        spacing += 1;
      else
        spacing = 0;
      clutter_grid_layout_set_column_spacing (layout, spacing);
      clutter_grid_layout_set_row_spacing (layout, spacing);
      break;

    case CLUTTER_KEY_q:
      clutter_main_quit ();
      break;

    default:
      return FALSE;
    }

  return TRUE;
}
Example #12
0
static void
add_actor (ClutterActor *box,
           gint          left,
           gint          top,
           gint          width,
           gint          height)
{
  ClutterLayoutManager *layout;
  ClutterActor *rect, *text;
  ClutterColor color;

  clutter_color_from_hls (&color,
                          g_random_double_range (0.0, 360.0),
                          0.5,
                          0.5);
  color.alpha = 255;

  rect = clutter_actor_new ();
  clutter_actor_set_layout_manager (rect, clutter_bin_layout_new ());
  clutter_actor_set_background_color (rect, &color);
  clutter_actor_set_reactive (rect, TRUE);

  if (random_size)
    clutter_actor_set_size (rect,
                            g_random_int_range (40, 80),
                            g_random_int_range (40, 80));
  else
    clutter_actor_set_size (rect, 60, 60);

  clutter_actor_set_x_expand (rect, default_expand);
  clutter_actor_set_y_expand (rect, default_expand);

  if (!default_expand)
    {
      clutter_actor_set_x_align (rect, CLUTTER_ACTOR_ALIGN_CENTER);
      clutter_actor_set_y_align (rect, CLUTTER_ACTOR_ALIGN_CENTER);
    }

  if (random_align)
    {
      clutter_actor_set_x_align (rect, g_random_int_range (0, 3));
      clutter_actor_set_y_align (rect, g_random_int_range (0, 3));
    }

  text = clutter_text_new_with_text ("Sans 8px", NULL);
  clutter_text_set_line_alignment (CLUTTER_TEXT (text),
                                   PANGO_ALIGN_CENTER);
  clutter_actor_add_child (rect, text);

  g_signal_connect (rect, "button-release-event",
                    G_CALLBACK (button_release_cb), NULL);
  g_signal_connect (rect, "notify::x-expand",
                    G_CALLBACK (changed_cb), text);
  g_signal_connect (rect, "notify::y-expand",
                    G_CALLBACK (changed_cb), text);
  g_signal_connect (rect, "notify::x-align",
                    G_CALLBACK (changed_cb), text);
  g_signal_connect (rect, "notify::y-align",
                    G_CALLBACK (changed_cb), text);

  layout = clutter_actor_get_layout_manager (box);
  if (use_box)
    clutter_actor_add_child (box, rect);
  else
    clutter_grid_layout_attach (CLUTTER_GRID_LAYOUT (layout), rect,
                                left, top, width, height);
  changed_cb (rect, NULL, text);
}