Exemplo n.º 1
0
void xfdashboard_stage_interface_set_background_color(XfdashboardStageInterface *self, const ClutterColor *inColor)
{
	XfdashboardStageInterfacePrivate	*priv;

	g_return_if_fail(XFDASHBOARD_IS_STAGE_INTERFACE(self));

	priv=self->priv;


	/* Set value if changed */
	if((priv->backgroundColor && !inColor) ||
		(!priv->backgroundColor && inColor) ||
		(inColor && clutter_color_equal(inColor, priv->backgroundColor)==FALSE))
	{
		/* Set value */
		if(priv->backgroundColor)
		{
			clutter_color_free(priv->backgroundColor);
			priv->backgroundColor=NULL;
		}

		if(inColor) priv->backgroundColor=clutter_color_copy(inColor);

		/* Notify about property change */
		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardStageInterfaceProperties[PROP_BACKGROUND_COLOR]);
	}
}
static void
champlain_path_layer_init (ChamplainPathLayer *self)
{
  ChamplainPathLayerPrivate *priv;

  self->priv = GET_PRIVATE (self);
  priv = self->priv;
  priv->view = NULL;

  priv->visible = TRUE;
  priv->fill = FALSE;
  priv->stroke = TRUE;
  priv->stroke_width = 2.0;
  priv->nodes = NULL;
  priv->dash = NULL;
  priv->num_dashes = 0;
  priv->redraw_scheduled = FALSE;

  priv->fill_color = clutter_color_copy (&DEFAULT_FILL_COLOR);
  priv->stroke_color = clutter_color_copy (&DEFAULT_STROKE_COLOR);

  priv->right_canvas = clutter_canvas_new ();
  priv->left_canvas = clutter_canvas_new ();

  clutter_canvas_set_size (CLUTTER_CANVAS (priv->right_canvas), 255, 255);
  clutter_canvas_set_size (CLUTTER_CANVAS (priv->left_canvas), 0, 0);

  g_signal_connect (priv->right_canvas, "draw", G_CALLBACK (redraw_path), self);
  g_signal_connect (priv->left_canvas, "draw", G_CALLBACK (redraw_path), self);

  priv->path_actor = clutter_actor_new ();
  clutter_actor_add_child (CLUTTER_ACTOR (self), priv->path_actor);
  clutter_actor_set_size (priv->path_actor, 255, 255);

  priv->right_actor = clutter_actor_new ();
  clutter_actor_set_size (priv->right_actor, 255, 255);
  clutter_actor_set_content (priv->right_actor, priv->right_canvas);
  clutter_actor_add_child (priv->path_actor, priv->right_actor);

  priv->left_actor = clutter_actor_new ();
  clutter_actor_set_size (priv->left_actor, 255, 255);
  clutter_actor_set_content (priv->left_actor, priv->left_canvas);
  clutter_actor_add_child (priv->path_actor, priv->left_actor);
}
/**
 * champlain_point_set_color:
 * @point: a #ChamplainPoint
 * @color: (allow-none): The color of the point or NULL to reset the background to the
 *         default color. The color parameter is copied.
 *
 * Set the color of the point.
 *
 * Since: 0.10
 */
void
champlain_point_set_color (ChamplainPoint *point,
    const ClutterColor *color)
{
  g_return_if_fail (CHAMPLAIN_IS_POINT (point));

  ChamplainPointPrivate *priv = point->priv;

  if (priv->color != NULL)
    clutter_color_free (priv->color);

  if (color == NULL)
    color = &DEFAULT_COLOR;

  priv->color = clutter_color_copy (color);
  g_object_notify (G_OBJECT (point), "color");
  clutter_content_invalidate (priv->canvas);
}
/**
 * champlain_path_layer_set_stroke_color:
 * @layer: a #ChamplainPathLayer
 * @color: (allow-none): The path's stroke color or NULL to reset to the
 *         default color. The color parameter is copied.
 *
 * Set the path's stroke color.
 *
 * Since: 0.10
 */
void
champlain_path_layer_set_stroke_color (ChamplainPathLayer *layer,
    const ClutterColor *color)
{
  g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer));

  ChamplainPathLayerPrivate *priv = layer->priv;

  if (priv->stroke_color != NULL)
    clutter_color_free (priv->stroke_color);

  if (color == NULL)
    color = &DEFAULT_STROKE_COLOR;

  priv->stroke_color = clutter_color_copy (color);
  g_object_notify (G_OBJECT (layer), "stroke-color");

  schedule_redraw (layer);
}
static void
champlain_point_init (ChamplainPoint *point)
{
  ChamplainPointPrivate *priv = GET_PRIVATE (point);

  point->priv = priv;

  priv->color = clutter_color_copy (&DEFAULT_COLOR);
  priv->size = 12;
  priv->canvas = clutter_canvas_new ();
  g_signal_connect (priv->canvas, "draw", G_CALLBACK (draw), point);
  clutter_canvas_set_size (CLUTTER_CANVAS (priv->canvas), priv->size, priv->size);
  clutter_actor_set_size (CLUTTER_ACTOR (point), priv->size, priv->size);
  clutter_actor_set_content (CLUTTER_ACTOR (point), priv->canvas);
  clutter_actor_set_translation (CLUTTER_ACTOR (point), -priv->size/2, -priv->size/2, 0.0);
  clutter_content_invalidate (priv->canvas);

  g_signal_connect (point, "notify::selected", G_CALLBACK (notify_selected), NULL);
}
Exemplo n.º 6
0
void xfdashboard_text_box_set_hint_text_color(XfdashboardTextBox *self, const ClutterColor *inColor)
{
	XfdashboardTextBoxPrivate	*priv;

	g_return_if_fail(XFDASHBOARD_IS_TEXT_BOX(self));
	g_return_if_fail(inColor);

	priv=self->priv;

	/* Set value if changed */
	if(!priv->hintTextColor || !clutter_color_equal(inColor, priv->hintTextColor))
	{
		if(priv->hintTextColor) clutter_color_free(priv->hintTextColor);
		priv->hintTextColor=clutter_color_copy(inColor);

		clutter_text_set_color(CLUTTER_TEXT(priv->actorHintLabel), priv->hintTextColor);
		clutter_actor_queue_redraw(CLUTTER_ACTOR(self));

		/* Notify about property change */
		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardTextBoxProperties[PROP_HINT_TEXT_COLOR]);
	}
}
Exemplo n.º 7
0
void xfdashboard_text_box_set_text_color(XfdashboardTextBox *self, const ClutterColor *inColor)
{
	XfdashboardTextBoxPrivate	*priv;
	ClutterColor				selectionColor;

	g_return_if_fail(XFDASHBOARD_IS_TEXT_BOX(self));
	g_return_if_fail(inColor);

	priv=self->priv;

	/* Set value if changed */
	if(!priv->textColor || !clutter_color_equal(inColor, priv->textColor))
	{
		if(priv->textColor) clutter_color_free(priv->textColor);
		priv->textColor=clutter_color_copy(inColor);

		clutter_text_set_color(CLUTTER_TEXT(priv->actorTextBox), priv->textColor);

		/* Selection text and background color is inverted text color if not set */
		if(!priv->selectionColorSet)
		{
			selectionColor.red=0xff-priv->textColor->red;
			selectionColor.green=0xff-priv->textColor->green;
			selectionColor.blue=0xff-priv->textColor->blue;
			selectionColor.alpha=priv->textColor->alpha;
			clutter_text_set_selected_text_color(CLUTTER_TEXT(priv->actorTextBox), &selectionColor);

			/* Selection color is the same as text color */
			clutter_text_set_selection_color(CLUTTER_TEXT(priv->actorTextBox), priv->textColor);
		}

		/* Redraw actor in new color */
		clutter_actor_queue_redraw(CLUTTER_ACTOR(self));

		/* Notify about property change */
		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardTextBoxProperties[PROP_TEXT_COLOR]);
	}
}
Exemplo n.º 8
0
void xfdashboard_text_box_set_selection_background_color(XfdashboardTextBox *self, const ClutterColor *inColor)
{
	XfdashboardTextBoxPrivate	*priv;
	ClutterColor				selectionColor;

	g_return_if_fail(XFDASHBOARD_IS_TEXT_BOX(self));

	priv=self->priv;

	/* Set value if changed */
	if(priv->selectionBackgroundColor!=inColor ||
		(priv->selectionBackgroundColor &&
			inColor &&
			!clutter_color_equal(inColor, priv->selectionBackgroundColor)))
	{
		/* Freeze notifications and collect them */
		g_object_freeze_notify(G_OBJECT(self));

		/* Release old color */
		if(priv->selectionBackgroundColor)
		{
			clutter_color_free(priv->selectionBackgroundColor);
			priv->selectionBackgroundColor=NULL;

			/* Check if any selection color is set */
			priv->selectionColorSet=((priv->selectionTextColor && priv->selectionBackgroundColor) ? TRUE : FALSE);

			/* Notify about property change */
			g_object_notify_by_pspec(G_OBJECT(self), XfdashboardTextBoxProperties[PROP_SELECTION_BACKGROUND_COLOR]);
		}

		/* Set new color if available */
		if(inColor)
		{
			priv->selectionBackgroundColor=clutter_color_copy(inColor);
			clutter_text_set_selection_color(CLUTTER_TEXT(priv->actorTextBox), priv->selectionBackgroundColor);

			/* Any selection color was set */
			priv->selectionColorSet=TRUE;

			/* Notify about property change */
			g_object_notify_by_pspec(G_OBJECT(self), XfdashboardTextBoxProperties[PROP_SELECTION_BACKGROUND_COLOR]);
		}

		/* Selection text and background color is inverted text color if not set */
		if(!priv->selectionColorSet)
		{
			selectionColor.red=0xff-priv->textColor->red;
			selectionColor.green=0xff-priv->textColor->green;
			selectionColor.blue=0xff-priv->textColor->blue;
			selectionColor.alpha=priv->textColor->alpha;
			clutter_text_set_selected_text_color(CLUTTER_TEXT(priv->actorTextBox), &selectionColor);

			/* Selection color is the same as text color */
			clutter_text_set_selection_color(CLUTTER_TEXT(priv->actorTextBox), priv->textColor);
		}

		/* Redraw actor in new color */
		clutter_actor_queue_redraw(CLUTTER_ACTOR(self));

		/* Thaw notifications and send them now */
		g_object_thaw_notify(G_OBJECT(self));
	}
}