Beispiel #1
0
gboolean
on_differs_badge_button_press(GooCanvasItem *item, GooCanvasItem *target_item, GdkEventButton *event, GooCanvasItemModel *model)
{
	I7Node *self = I7_NODE(goo_canvas_item_model_get_parent(GOO_CANVAS_ITEM_MODEL(model)));
	I7Skein *skein = I7_SKEIN(goo_canvas_item_model_get_parent(GOO_CANVAS_ITEM_MODEL(self)));
	if(event->type == GDK_2BUTTON_PRESS && event->button == 1) {
		g_signal_emit_by_name(skein, "differs-badge-activate", self);
		return TRUE;
	}
	return FALSE;
}
/**
 * goo_canvas_item_model_lower:
 * @model: an item model.
 * @below: (allow-none): the item model to lower @model below, or %NULL to lower @model to the
 *  bottom of the stack.
 * 
 * Lowers a model in the stacking order.
 **/
void
goo_canvas_item_model_lower          (GooCanvasItemModel *model,
				      GooCanvasItemModel *below)
{
  GooCanvasItemModel *parent, *child;
  int n_children, i, model_pos = -1, below_pos = -1;

  parent = goo_canvas_item_model_get_parent (model);
  if (!parent || model == below)
    return;

  /* Find the current position of model and below. */
  n_children = goo_canvas_item_model_get_n_children (parent);
  for (i = 0; i < n_children; i++)
    {
      child = goo_canvas_item_model_get_child (parent, i);
      if (child == model)
	model_pos = i;
      if (child == below)
	below_pos = i;
    }

  /* If below is NULL we lower the model to the bottom of the stack. */
  if (!below)
    below_pos = 0;

  g_return_if_fail (model_pos != -1);
  g_return_if_fail (below_pos != -1);

  /* Only move the model if the new position is lower in the stack. */
  if (below_pos < model_pos)
    goo_canvas_item_model_move_child (parent, model_pos, below_pos);
}
/**
 * goo_canvas_item_model_raise:
 * @model: an item model.
 * @above: (allow-none): the item model to raise @model above, or %NULL to raise @model to the top
 *  of the stack.
 * 
 * Raises a model in the stacking order.
 **/
void
goo_canvas_item_model_raise          (GooCanvasItemModel *model,
				      GooCanvasItemModel *above)
{
  GooCanvasItemModel *parent, *child;
  int n_children, i, model_pos = -1, above_pos = -1;

  parent = goo_canvas_item_model_get_parent (model);
  if (!parent || model == above)
    return;

  /* Find the current position of model and above. */
  n_children = goo_canvas_item_model_get_n_children (parent);
  for (i = 0; i < n_children; i++)
    {
      child = goo_canvas_item_model_get_child (parent, i);
      if (child == model)
	model_pos = i;
      if (child == above)
	above_pos = i;
    }

  /* If above is NULL we raise the model to the top of the stack. */
  if (!above)
    above_pos = n_children - 1;

  g_return_if_fail (model_pos != -1);
  g_return_if_fail (above_pos != -1);

  /* Only move the model if the new position is higher in the stack. */
  if (above_pos > model_pos)
    goo_canvas_item_model_move_child (parent, model_pos, above_pos);
}
Beispiel #4
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;
}
Beispiel #5
0
gboolean
on_node_button_press(GooCanvasItem *item, GooCanvasItem *target_item, GdkEventButton *event, I7Node *self)
{
	I7Skein *skein = I7_SKEIN(goo_canvas_item_model_get_parent(GOO_CANVAS_ITEM_MODEL(self)));
	if(event->type == GDK_2BUTTON_PRESS && event->button == 1) {
		g_signal_emit_by_name(skein, "node-activate", self);
		return TRUE;
	} else if(event->type == GDK_BUTTON_PRESS && event->button == 3) {
		GooCanvas *view = goo_canvas_item_get_canvas(target_item);
		g_signal_emit_by_name(view, "node-menu-popup", self);
		return TRUE;
	}
	return FALSE;
}
/**
 * goo_canvas_item_model_remove:
 * @model: an item model.
 * 
 * Removes a model from its parent. If the model is in a canvas it will be
 * removed.
 *
 * This would normally also result in the model being freed.
 **/
void
goo_canvas_item_model_remove         (GooCanvasItemModel *model)
{
  GooCanvasItemModel *parent;
  gint child_num;

  parent = goo_canvas_item_model_get_parent (model);
  if (!parent)
    return;

  child_num = goo_canvas_item_model_find_child (parent, model);
  if (child_num == -1)
    return;

  goo_canvas_item_model_remove_child (parent, child_num);
}
Beispiel #7
0
static void
on_item_created (GooCanvas          *canvas,
		 GooCanvasItem      *item,
		 GooCanvasItemModel *model,
		 gpointer            data)
{
  if (goo_canvas_item_model_get_parent (model)
      && GOO_IS_CANVAS_GROUP_MODEL (model))
    {
      g_signal_connect (item, "enter_notify_event",
			G_CALLBACK (piece_enter_notify),
			NULL);
      g_signal_connect (item, "leave_notify_event",
			G_CALLBACK (piece_leave_notify),
			NULL);
      g_signal_connect (item, "button_press_event",
			G_CALLBACK (piece_button_press),
			NULL);
    }
}