Example #1
0
static gboolean
on_button_press (GooCanvasItem *item,
		 GooCanvasItem *target,
		 GdkEventButton *event,
		 gpointer data)
{
  GooCanvasItemModel *model = goo_canvas_item_get_model (item);
  GooCanvasItemModel *parent1, *parent2, *parent;

  if (event->button != 1 || event->type != GDK_BUTTON_PRESS)
    return FALSE;

  parent1 = g_object_get_data (G_OBJECT (model), "parent1");
  parent2 = g_object_get_data (G_OBJECT (model), "parent2");

  parent = goo_canvas_item_model_get_parent (model);
  g_object_ref (model);
  goo_canvas_item_model_remove (model);
  if (parent == parent1)
    goo_canvas_item_model_add_child (parent2, model, -1);
  else
    goo_canvas_item_model_add_child (parent1, model, -1);
  g_object_unref (model);

  return TRUE;
}
Example #2
0
/**
 * goo_canvas_path_model_new:
 * @parent: the parent model, or %NULL. If a parent is specified, it will
 *  assume ownership of the item, and the item will automatically be freed when
 *  it is removed from the parent. Otherwise call g_object_unref() to free it.
 * @path_data: the sequence of path commands, specified as a string using the
 *  same syntax as in the <ulink url="http://www.w3.org/Graphics/SVG/">Scalable
 *  Vector Graphics (SVG)</ulink> path element.
 * @...: optional pairs of property names and values, and a terminating %NULL.
 * 
 * Creates a new path model.
 * 
 * <!--PARAMETERS-->
 *
 * Here's an example showing how to create a red line from (20,20) to (40,40):
 *
 * <informalexample><programlisting>
 *  GooCanvasItemModel *path = goo_canvas_path_model_new (mygroup,
 *                                                        "M 20 20 L 40 40",
 *                                                        "stroke-color", "red",
 *                                                        NULL);
 * </programlisting></informalexample>
 * 
 * This example creates a cubic bezier curve from (20,100) to (100,100) with
 * the control points at (20,50) and (100,50):
 *
 * <informalexample><programlisting>
 *  GooCanvasItemModel *path = goo_canvas_path_model_new (mygroup,
 *                                                        "M20,100 C20,50 100,50 100,100",
 *                                                        "stroke-color", "blue",
 *                                                        NULL);
 * </programlisting></informalexample>
 *
 * This example uses an elliptical arc to create a filled circle with one
 * quarter missing:
 * 
 * <informalexample><programlisting>
 *  GooCanvasItemModel *path = goo_canvas_path_model_new (mygroup,
 *                                                        "M200,500 h-150 a150,150 0 1,0 150,-150 z",
 *                                                        "fill-color", "red",
 *                                                        "stroke-color", "blue",
 *                                                        "line-width", 5.0,
 *                                                        NULL);
 * </programlisting></informalexample>
 * 
 * Returns: a new path model.
 **/
GooCanvasItemModel*
goo_canvas_path_model_new (GooCanvasItemModel *parent,
			   const gchar        *path_data,
			   ...)
{
  GooCanvasItemModel *model;
  GooCanvasPathModel *pmodel;
  const char *first_property;
  va_list var_args;

  model = g_object_new (GOO_TYPE_CANVAS_PATH_MODEL, NULL);
  pmodel = (GooCanvasPathModel*) model;

  pmodel->path_data.path_commands = goo_canvas_parse_path_data (path_data);

  va_start (var_args, path_data);
  first_property = va_arg (var_args, char*);
  if (first_property)
    g_object_set_valist ((GObject*) model, first_property, var_args);
  va_end (var_args);

  if (parent)
    {
      goo_canvas_item_model_add_child (parent, model, -1);
      g_object_unref (model);
    }

  return model;
}
Example #3
0
/**
 * goo_canvas_polyline_model_new_line:
 * @parent: the parent model, or %NULL.
 * @x1: the x coordinate of the start of the line.
 * @y1: the y coordinate of the start of the line.
 * @x2: the x coordinate of the end of the line.
 * @y2: the y coordinate of the end of the line.
 * @...: optional pairs of property names and values, and a terminating %NULL.
 * 
 * Creates a new polyline model with a single line.
 * 
 * <!--PARAMETERS-->
 *
 * Here's an example showing how to create a line from (100,100) to (300,300).
 *
 * <informalexample><programlisting>
 *  GooCanvasItemModel *polyline = goo_canvas_polyline_model_new_line (mygroup,
 *                                                                     100.0, 100.0,
 *                                                                     300.0, 300.0,
 *                                                                     "stroke-color", "red",
 *                                                                     "line-width", 5.0,
 *                                                                     NULL);
 * </programlisting></informalexample>
 * 
 * Returns: a new polyline model.
 **/
GooCanvasItemModel*
goo_canvas_polyline_model_new_line (GooCanvasItemModel *parent,
				    gdouble             x1,
				    gdouble             y1,
				    gdouble             x2,
				    gdouble             y2,
				    ...)
{
  GooCanvasItemModel *model;
  GooCanvasPolylineModel *pmodel;
  GooCanvasPolylineData *polyline_data;
  const char *first_property;
  va_list var_args;

  model = g_object_new (GOO_TYPE_CANVAS_POLYLINE_MODEL, NULL);
  pmodel = (GooCanvasPolylineModel*) model;

  polyline_data = &pmodel->polyline_data;
  polyline_data->close_path = FALSE;
  polyline_data->num_points = 2;
  polyline_data->coords = g_slice_alloc (4 * sizeof (gdouble));
  polyline_data->coords[0] = x1;
  polyline_data->coords[1] = y1;
  polyline_data->coords[2] = x2;
  polyline_data->coords[3] = y2;

  va_start (var_args, y2);
  first_property = va_arg (var_args, char*);
  if (first_property)
    g_object_set_valist ((GObject*) model, first_property, var_args);
  va_end (var_args);

  if (parent)
    {
      goo_canvas_item_model_add_child (parent, model, -1);
      g_object_unref (model);
    }

  return model;
}
Example #4
0
/**
 * goo_canvas_rect_model_new:
 * @parent: the parent model, or %NULL. If a parent is specified, it will
 *  assume ownership of the item, and the item will automatically be freed when
 *  it is removed from the parent. Otherwise call g_object_unref() to free it.
 * @x: the x coordinate of the left of the rectangle.
 * @y: the y coordinate of the top of the rectangle.
 * @width: the width of the rectangle.
 * @height: the height of the rectangle.
 * @...: optional pairs of property names and values, and a terminating %NULL.
 * 
 * Creates a new rectangle item.
 * 
 * <!--PARAMETERS-->
 *
 * Here's an example showing how to create a rectangle at (100,100) with a
 * width of 200 and a height of 100.
 *
 * <informalexample><programlisting>
 *  GooCanvasItemModel *rect = goo_canvas_rect_model_new (mygroup, 100.0, 100.0, 200.0, 100.0,
 *                                                        "stroke-color", "red",
 *                                                        "line-width", 5.0,
 *                                                        "fill-color", "blue",
 *                                                        NULL);
 * </programlisting></informalexample>
 * 
 * Returns: a new rectangle model.
 **/
GooCanvasItemModel*
goo_canvas_rect_model_new (GooCanvasItemModel *parent,
			   gdouble             x,
			   gdouble             y,
			   gdouble             width,
			   gdouble             height,
			   ...)
{
  GooCanvasItemModel *model;
  GooCanvasRectModel *rmodel;
  GooCanvasRectData *rect_data;
  const char *first_property;
  va_list var_args;

  model = g_object_new (GOO_TYPE_CANVAS_RECT_MODEL, NULL);
  rmodel = (GooCanvasRectModel*) model;

  rect_data = &rmodel->rect_data;
  rect_data->x = x;
  rect_data->y = y;
  rect_data->width = width;
  rect_data->height = height;
  rect_data->radius_x = 0;
  rect_data->radius_y = 0;

  va_start (var_args, height);
  first_property = va_arg (var_args, char*);
  if (first_property)
    g_object_set_valist ((GObject*) model, first_property, var_args);
  va_end (var_args);

  if (parent)
    {
      goo_canvas_item_model_add_child (parent, model, -1);
      g_object_unref (model);
    }

  return model;
}
Example #5
0
/**
 * goo_canvas_polyline_model_new:
 * @parent: the parent model, or %NULL. If a parent is specified, it will
 *  assume ownership of the item, and the item will automatically be freed when
 *  it is removed from the parent. Otherwise call g_object_unref() to free it.
 * @close_path: if the last point should be connected to the first.
 * @num_points: the number of points in the polyline.
 * @...: the pairs of coordinates for each point in the line, followed by
 *  optional pairs of property names and values, and a terminating %NULL.
 * 
 * Creates a new polyline model.
 * 
 * <!--PARAMETERS-->
 *
 * Here's an example showing how to create a filled triangle with vertices
 * at (100,100), (300,100), and (200,300).
 *
 * <informalexample><programlisting>
 *  GooCanvasItemModel *polyline = goo_canvas_polyline_model_new (mygroup, TRUE, 3,
 *                                                                100.0, 100.0,
 *                                                                300.0, 100.0,
 *                                                                200.0, 300.0,
 *                                                                "stroke-color", "red",
 *                                                                "line-width", 5.0,
 *                                                                "fill-color", "blue",
 *                                                                NULL);
 * </programlisting></informalexample>
 * 
 * Returns: a new polyline model.
 **/
GooCanvasItemModel*
goo_canvas_polyline_model_new (GooCanvasItemModel *parent,
			       gboolean            close_path,
			       gint                num_points,
			       ...)
{
  GooCanvasItemModel *model;
  GooCanvasPolylineModel *pmodel;
  GooCanvasPolylineData *polyline_data;
  const char *first_property;
  va_list var_args;
  gint i;

  model = g_object_new (GOO_TYPE_CANVAS_POLYLINE_MODEL, NULL);
  pmodel = (GooCanvasPolylineModel*) model;

  polyline_data = &pmodel->polyline_data;
  polyline_data->close_path = close_path;
  polyline_data->num_points = num_points;
  if (num_points)
    polyline_data->coords = g_slice_alloc (num_points * 2 * sizeof (gdouble));

  va_start (var_args, num_points);
  for (i = 0; i < num_points * 2; i++)
    polyline_data->coords[i] = va_arg (var_args, gdouble);

  first_property = va_arg (var_args, char*);
  if (first_property)
    g_object_set_valist ((GObject*) model, first_property, var_args);
  va_end (var_args);

  if (parent)
    {
      goo_canvas_item_model_add_child (parent, model, -1);
      g_object_unref (model);
    }

  return model;
}
Example #6
0
/**
 * goo_canvas_ellipse_model_new:
 * @parent: the parent model, or %NULL. If a parent is specified, it will
 *  assume ownership of the item, and the item will automatically be freed when
 *  it is removed from the parent. Otherwise call g_object_unref() to free it.
 * @center_x: the x coordinate of the center of the ellipse.
 * @center_y: the y coordinate of the center of the ellipse.
 * @radius_x: the horizontal radius of the ellipse.
 * @radius_y: the vertical radius of the ellipse.
 * @...: optional pairs of property names and values, and a terminating %NULL.
 * 
 * Creates a new ellipse model.
 *
 * <!--PARAMETERS-->
 *
 * Here's an example showing how to create an ellipse centered at (100.0,
 * 100.0), with a horizontal radius of 50.0 and a vertical radius of 30.0.
 * It is drawn with a red outline with a width of 5.0 and filled with blue:
 *
 * <informalexample><programlisting>
 *  GooCanvasItemModel *ellipse = goo_canvas_ellipse_model_new (mygroup, 100.0, 100.0, 50.0, 30.0,
 *                                                              "stroke-color", "red",
 *                                                              "line-width", 5.0,
 *                                                              "fill-color", "blue",
 *                                                              NULL);
 * </programlisting></informalexample>
 * 
 * Returns: a new ellipse model.
 **/
GooCanvasItemModel*
goo_canvas_ellipse_model_new (GooCanvasItemModel *parent,
			      gdouble             center_x,
			      gdouble             center_y,
			      gdouble             radius_x,
			      gdouble             radius_y,
			      ...)
{
  GooCanvasItemModel *model;
  GooCanvasEllipseModel *emodel;
  GooCanvasEllipseData *ellipse_data;
  const char *first_property;
  va_list var_args;

  model = g_object_new (GOO_TYPE_CANVAS_ELLIPSE_MODEL, NULL);
  emodel = (GooCanvasEllipseModel*) model;

  ellipse_data = &emodel->ellipse_data;
  ellipse_data->center_x = center_x;
  ellipse_data->center_y = center_y;
  ellipse_data->radius_x = radius_x;
  ellipse_data->radius_y = radius_y;

  va_start (var_args, radius_y);
  first_property = va_arg (var_args, char*);
  if (first_property)
    g_object_set_valist ((GObject*) model, first_property, var_args);
  va_end (var_args);

  if (parent)
    {
      goo_canvas_item_model_add_child (parent, model, -1);
      g_object_unref (model);
    }

  return model;
}