Ejemplo n.º 1
0
int
main ()
{
  GtkWidget *window, *scrolled_win, *canvas;
  GooCanvasItem *root, *rect_item, *text_item;

  /* Initialize GTK+. */
  gtk_init ();

  /* Create the window and widgets. */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
  gtk_widget_show (window);
  g_signal_connect (window, "delete_event", G_CALLBACK (on_delete_event),
		    NULL);

  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
				       GTK_SHADOW_IN);
  gtk_widget_show (scrolled_win);
  gtk_container_add (GTK_CONTAINER (window), scrolled_win);

  canvas = goo_canvas_new ();
  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
  gtk_widget_show (canvas);
  gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  /* Add a few simple items. */
  rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400,
				   "line-width", 10.0,
				   "radius-x", 20.0,
				   "radius-y", 10.0,
				   "stroke-color", "yellow",
				   "fill-color", "red",
				   NULL);

  text_item = goo_canvas_text_new (root, "Hello World", 300, 300, -1,
				   GOO_CANVAS_ANCHOR_CENTER,
				   "font", "Sans 24",
				   NULL);
  goo_canvas_item_rotate (text_item, 45, 300, 300);

  /* Connect a signal handler for the rectangle item. */
  g_signal_connect (rect_item, "button_press_event",
		    G_CALLBACK (on_rect_button_press), NULL);

  /* Pass control to the GTK+ main event loop. */
  gtk_main ();

  return 0;
}
Ejemplo n.º 2
0
static void
create_width_for_height_table (GooCanvasItem *root,
			       gdouble        x,
			       gdouble        y,
			       gdouble        width,
			       gdouble        height,
			       gdouble        rotation)
{
  GooCanvasItem *table, *item;
  gchar *text = "This is a long paragraph that will have to be split over a few lines so we can see if its allocated height changes when its allocated width is changed.";

  table = goo_canvas_table_new (root,
#if 1
				"width", width,
				"height", height,
#endif
                                NULL);
  goo_canvas_item_translate (table, x, y);
  goo_canvas_item_rotate (table, rotation, 0, 0);

  item = goo_canvas_rect_new (table, 0.0, 0.0, width - 2, 10.0,
			      "fill-color", "red",
			      NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 0,
					"column", 0,
					"x-shrink", TRUE,
					NULL);

#if 1
  item = goo_canvas_text_new (table, text, 0, 0, -1, GOO_CANVAS_ANCHOR_NW, NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 1,
					"column", 0,
					"x-expand", TRUE,
					"x-fill", TRUE,
					"x-shrink", TRUE,
					"y-expand", TRUE,
					"y-fill", TRUE,
					NULL);
  g_object_set_data (G_OBJECT (item), "id", "Text Item");
  g_signal_connect (item, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);
#endif

  item = goo_canvas_rect_new (table, 0.0, 0.0, width - 2, 10.0,
			      "fill-color", "red",
			      NULL);
  goo_canvas_item_set_child_properties (table, item,
					"row", 2,
					"column", 0,
					"x-shrink", TRUE,
					NULL);
}
Ejemplo n.º 3
0
/* =====================================================================
 * set initial values for the next level
 * =====================================================================*/
static void colors_next_level() {
  gchar *str = NULL;
  int i, list_length;
  GList * list = NULL;
  int * item;

  colors_destroy_all_items();
  gamewon = FALSE;

  gc_score_set(gcomprisBoard->sublevel);
  gc_bar_set_level(gcomprisBoard);

  /* initialize board only once*/
  if (gcomprisBoard->sublevel == 1) {
    errors = MAX_ERRORS;
    // we generate a list of color indexes in a random order
    while (g_list_length(listColors) > 0)
      listColors = g_list_remove(listColors, g_list_nth_data(listColors,0));

    for (i=0; i<LAST_COLOR; i++)
      list = g_list_append(list, GINT_TO_POINTER(i));

    while((list_length = g_list_length(list))) {
      i = list_length == 1 ? 0 : g_random_int_range(0,g_list_length(list)-1);
      item = g_list_nth_data(list, i);
      listColors = g_list_append(listColors, item);
      list = g_list_remove(list, item);
    }

    /* set background */
    str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, backgroundFile);
    g_warning("background = %s\n", str);
    gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas), str);
    g_free(str);
  }

  colors_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));

  /* show text of color to find */
  color_item = goo_canvas_text_new (boardRootItem,
				    colors[GPOINTER_TO_INT(g_list_nth_data(listColors,0))],
				    (color_x1+color_x2)/2,
				    (color_y1+color_y2)/2,
				    -1,
				    GTK_ANCHOR_CENTER,
				    "font", gc_skin_font_board_title_bold,
				    "fill-color", "darkblue",
				    NULL);

}
Ejemplo n.º 4
0
/*
 * Request score
 *
 */
static void request_score()
{
  double x_offset = 390;
  double y_offset = 150;
  gchar *tmpstr;

  /* Set the maximum text to calc the background */
  tmpstr =  g_strdup_printf(_("Points = %s"), "00000");
  answer_item = goo_canvas_text_new (boardRootItem,
				     tmpstr,
				     (double) x_offset,
				     (double) y_offset,
				     -1,
				     GTK_ANCHOR_CENTER,
				     "font", gc_skin_font_board_title_bold,
				     "fill-color", "white",
				     NULL);
  g_free(tmpstr);

  GooCanvasBounds bounds;
  goo_canvas_item_get_bounds (answer_item, &bounds);
  goo_canvas_convert_to_item_space(goo_canvas_item_get_canvas(answer_item),
				   answer_item,
				   &bounds.x1, &bounds.y1);
  goo_canvas_convert_to_item_space(goo_canvas_item_get_canvas(answer_item),
				   answer_item,
				   &bounds.x2, &bounds.y2);

  int gap = 15;
  GooCanvasItem *item =				\
    goo_canvas_rect_new (boardRootItem,
			 bounds.x1 - gap,
			 bounds.y1 - gap,
			 (bounds.x2 - bounds.x1) + gap*2,
			 (bounds.y2 - bounds.y1) + gap*2,
			 "stroke_color_rgba", 0xFFFFFFFFL,
			 "fill_color_rgba", 0X5599FFCCL,
			 "line-width", (double) 2,
			 "radius-x", (double) 10,
			 "radius-y", (double) 10,
			 NULL);
  goo_canvas_item_raise(answer_item, item);

  /* Set the correct initial text */
  tmpstr = g_strdup_printf(_("Points = %s"), answer_string);
  g_object_set(answer_item,
	       "text", tmpstr,
	       NULL);
  g_free(tmpstr);
}
Ejemplo n.º 5
0
static void display_paying_tux(guint note)
{
  GdkPixbuf *pixmap = NULL;

  g_assert(boardRootItem);

  pixmap = gc_pixmap_load("money/tux_graduate.png");
  goo_canvas_image_new (boardRootItem,
			pixmap,
			20,
			130,
			NULL);
  gdk_pixbuf_unref(pixmap);

  if (note == 30)
    {
      display_paying_note(20, 20, 200);
      display_paying_note(10, 30, 250);
    }
  else if (note == 40)
    {
      display_paying_note(20, 20, 200);
      display_paying_note(20, 30, 250);
    }
  else if (note == 100)
    {
      display_paying_note(50, 20, 200);
      display_paying_note(50, 30, 250);
    }
  else
    display_paying_note(note, 20, 200);

  /* Set here the way to display money. Change only the money sign, and it's place, always keep %d */
  gchar *text = g_strdup_printf(_("Tux just bought some items in your shop.\n"
				  "He gives you $ %d, please give back his change."),
				note);
  goo_canvas_text_new(boardRootItem,
		      text,
		      BOARDWIDTH / 2,
		      320,
		      -1,
		      GTK_ANCHOR_CENTER,
		      "font", gc_skin_font_board_medium,
		      "fill-color", "white",
		      "alignment", PANGO_ALIGN_CENTER,
		      NULL);
  g_free(text);

}
Ejemplo n.º 6
0
void
money_widget_set_position (MoneyWidget *moneyWidget,
			   GooCanvasItem *rootItem,
			   double x1,
			   double y1,
			   double x2,
			   double y2,
			   guint  columns,
			   guint  lines,
			   gboolean display_total)
{
  g_return_if_fail (moneyWidget != NULL);

  moneyWidget->priv->rootItem = rootItem;
  moneyWidget->priv->x1 = x1;
  moneyWidget->priv->y1 = y1;
  moneyWidget->priv->x2 = x2;
  moneyWidget->priv->y2 = y2;
  moneyWidget->priv->columns = columns;
  moneyWidget->priv->lines = lines;
  moneyWidget->priv->next_spot = 0;
  moneyWidget->priv->display_total = display_total;

  /* Uncomment to display the limits
    goo_canvas_item_new (GOO_CANVAS_GROUP(rootItem),
			 goo_canvas_rect_get_type (),
			 "x1", (double) x1,
			 "y1", (double) y1,
			 "x2", (double) x2,
			 "y2", (double) y2,
			 "stroke-color", "red",
			 "width_pixels", 2,
			 NULL);
  */

  moneyWidget->priv->item_total =  \
    goo_canvas_text_new(rootItem,
			"",
			x1+(x2-x1)/2,
			y2 + 10,
			-1,
			GTK_ANCHOR_CENTER,
			"font", gc_skin_font_board_big,
			"fill-color", "white",
			NULL);

}
Ejemplo n.º 7
0
TextboxItem *textbox_item_new (Sheet *sheet, Textbox *textbox)
{
	GooCanvasItem *item;
	TextboxItem *textbox_item;
	TextboxItemPriv *priv;
	Coords pos;
	ItemData *item_data;

	g_return_val_if_fail (sheet != NULL, NULL);
	g_return_val_if_fail (IS_SHEET (sheet), NULL);

	item_data_get_pos (ITEM_DATA (textbox), &pos);

	item = g_object_new (TYPE_TEXTBOX_ITEM, NULL);

	g_object_set (item, "parent", sheet->object_group, NULL);

	textbox_item = TEXTBOX_ITEM (item);
	g_object_set (textbox_item, "data", textbox, NULL);

	priv = textbox_item->priv;

	priv->text_canvas_item = goo_canvas_text_new (
	    GOO_CANVAS_ITEM (textbox_item), textbox_get_text (textbox), 0.0, 0.0, -1,
	    GOO_CANVAS_ANCHOR_SW, "font", TEXTBOX_FONT, "fill-color", NORMAL_COLOR, NULL);

	item_data = ITEM_DATA (textbox);

	item_data->rotated_handler_id =
	    g_signal_connect_object (G_OBJECT (textbox), "rotated",
	                             G_CALLBACK (textbox_rotated_callback), G_OBJECT (textbox_item), 0);
	item_data->flipped_handler_id =
	    g_signal_connect_object (G_OBJECT (textbox), "flipped",
	                             G_CALLBACK (textbox_flipped_callback), G_OBJECT (textbox_item), 0);
	item_data->moved_handler_id =
	    g_signal_connect_object (G_OBJECT (textbox), "moved", G_CALLBACK (textbox_moved_callback),
	                             G_OBJECT (textbox_item), 0);
	textbox->text_changed_handler_id = g_signal_connect_object (
	    G_OBJECT (textbox), "text_changed", G_CALLBACK (textbox_text_changed_callback),
	    G_OBJECT (textbox_item), 0);

	textbox_update_bbox (textbox);

	return textbox_item;
}
Ejemplo n.º 8
0
/* =====================================================================
 *
 * =====================================================================*/
static GooCanvasItem *
maze_create_item(GooCanvasItem *parent)
{
  gchar *message;

  boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
					NULL);

  mazegroup = goo_canvas_group_new(boardRootItem,
				   NULL);

  goo_canvas_item_translate(mazegroup,
			    breedte,
			    hoogte);

  tuxgroup = goo_canvas_group_new(mazegroup,
				   NULL);

  wallgroup = goo_canvas_group_new(boardRootItem,
				   NULL);

  if(modeIsInvisible) {
    message = _("Look at your position, then switch back to invisible mode to continue your moves");
  } else {
    message = _("Look at your position, then switch back to 3D mode to continue your moves");
  }

  warning_item = goo_canvas_text_new (boardRootItem,
				      message,
				      (double) BOARDWIDTH/2,
				      (double) BOARDHEIGHT-BARHEIGHT-25,
				      -1,
				      GTK_ANCHOR_CENTER,
				      "font", gc_skin_font_board_tiny,
				      "fill_color_rgba", gc_skin_color_content,
				      NULL);
  g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);

  return NULL;
}
Ejemplo n.º 9
0
static void
create_canvas_labels (PartItem *item, Part *part)
{
	GooCanvasItem *canvas_item;
	GSList *list, *item_list;
	GooCanvasGroup *group;

	g_return_if_fail (item != NULL);
	g_return_if_fail (IS_PART_ITEM (item));
	g_return_if_fail (part != NULL);
	g_return_if_fail (IS_PART (part));

	group = GOO_CANVAS_GROUP (item->priv->label_group);
	item_list = NULL;

	for (list = part_get_labels (part); list; list = list->next) {
		PartLabel *label = list->data;
		char *text;

		text = part_property_expand_macros (part, label->text);

		canvas_item = goo_canvas_text_new (GOO_CANVAS_ITEM (group),
		                text,
		                (double) label->pos.x,
		                (double) label->pos.y,
		                0,
		                GOO_CANVAS_ANCHOR_SOUTH_WEST,
		                "fill_color", LABEL_COLOR,
		                "font", "Sans 8",
		                NULL);

		item_list = g_slist_prepend (item_list, canvas_item);
		g_free (text);
	}
	g_slist_free_full (list, g_object_unref);

	item_list = g_slist_reverse (item_list);
	part_item_set_label_items (item, item_list);
}
Ejemplo n.º 10
0
static void
create_events_area (GtkWidget              *canvas,
		    gint                    area_num,
		    GooCanvasPointerEvents  pointer_events,
		    gchar                  *label)
{
  gint row = area_num / 3, col = area_num % 3;
  gdouble x = col * 200, y = row * 150;
  GooCanvasItem *root, *rect;
  char *view_id;
  GooCanvasLineDash *dash;

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  dash = goo_canvas_line_dash_new (2, 5.0, 5.0);

  /* Create invisible item. */
  rect = goo_canvas_rect_new (root, x + 45, y + 35, 30, 30,
			      "fill-color", "red",
			      "visibility", GOO_CANVAS_ITEM_INVISIBLE,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s invisible", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);

  /* Display a thin rect around it to indicate it is there. */
#if 1
  rect = goo_canvas_rect_new (root, x + 42.5, y + 32.5, 36, 36,
			      "line-dash", dash,
			      "line-width", 1.0,
			      "stroke-color", "gray",
			      NULL);
#endif

  /* Create unpainted item. */
  rect = goo_canvas_rect_new (root, x + 85, y + 35, 30, 30,
			      "stroke-pattern", NULL,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s unpainted", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);

  /* Display a thin rect around it to indicate it is there. */
#if 1
  rect = goo_canvas_rect_new (root, x + 82.5, y + 32.5, 36, 36,
			      "line-dash", dash,
			      "line-width", 1.0,
			      "stroke-color", "gray",
			      NULL);
#endif

  /* Create stroked item. */
  rect = goo_canvas_rect_new (root, x + 125, y + 35, 30, 30,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s stroked", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);

  /* Create filled item. */
  rect = goo_canvas_rect_new (root, x + 60, y + 75, 30, 30,
			      "fill-color", "red",
			      "stroke-pattern", NULL,
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s filled", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);

  /* Create stroked & filled item. */
  rect = goo_canvas_rect_new (root, x + 100, y + 75, 30, 30,
			      "fill-color", "red",
			      "line-width", 5.0,
			      "pointer-events", pointer_events,
			      NULL);
  view_id = g_strdup_printf ("%s stroked & filled", label);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);

  goo_canvas_text_new (root, label, x + 100, y + 130, -1, GOO_CANVAS_ANCHOR_CENTER,
		       "font", "Sans 12",
		       "fill-color", "blue",
		       NULL);

  goo_canvas_line_dash_unref (dash);
}
Ejemplo n.º 11
0
// show_weight:
// 0 -> no display,
// 1 -> display g,
// 1000 -> display kg, 10000 -> random (weighted 1:2)
static ScaleItem *
scale_list_add_object(GooCanvasItem *group,
		      GdkPixbuf *pixmap,
		      int weight, int plate,
		      int show_weight)
{
  GooCanvasItem *item;
  ScaleItem * new_item;

  item = goo_canvas_image_new(group,
			      pixmap,
			      PLATE_SIZE * ITEM_W * .5
			      - gdk_pixbuf_get_width(pixmap)/2,
			      PLATE_Y + 5 - gdk_pixbuf_get_height(pixmap),
			      NULL);
  goo_canvas_item_lower(item, NULL);

  if(show_weight)
    {   // display the object weight
      double x,y;
      gchar * text;

      x = PLATE_SIZE * ITEM_W * .5;
      y = PLATE_Y - 20.0;
      if (board_mode == MODE_WEIGHT) {
      	if (show_weight > 9999) {
          if ((weight % 500) == 0)
      	    show_weight = g_random_int_range(1,3000);
	  else
	    show_weight = 1;
        }

      	if (show_weight < 1000)
      		text = g_strdup_printf("%d g", objet_weight);
      	else
      		text = g_strdup_printf("%.1f kg", objet_weight / 1000.0);
      } else {
      	text = g_strdup_printf("%d", objet_weight);
      }

      goo_canvas_text_new(group,
			  text,
			  x + 1.0,
			  y + 1.0,
			  -1,
			  GTK_ANCHOR_CENTER,
			  "font", gc_skin_font_board_title_bold,
			  "fill_color_rgba", gc_skin_color_shadow,
			  NULL);
      goo_canvas_text_new(group,
			  text,
			  x,
			  y,
			  -1,
			  GTK_ANCHOR_CENTER,
			  "font", gc_skin_font_board_title_bold,
			  "fill_color_rgba", gc_skin_color_content,
			  NULL);
      g_free(text);
    }

  new_item = g_new0(ScaleItem, 1);
  new_item->weight = weight;
  new_item->plate = plate;
  new_item->plate_index = -1;
  new_item->item = item;

  item_list = g_list_append(item_list, new_item);
  return new_item;
}
Ejemplo n.º 12
0
// show_weight:
// 0 -> no unit,
// 1 -> display g, 1000 -> display kg,
// 10000 -> random (weighted 1:2)
static ScaleItem *
scale_list_add_weight(GooCanvasItem *group,
		      gint weight, int show_weight)
{
  ScaleItem *new_item;
  GdkPixbuf *pixmap;
  gchar *weight_text;
  double x, y;
  GList *last;

  last = g_list_last(item_list);
  if(last)
    {
      new_item = last->data;
      x = new_item->x + ITEM_W;
      y = new_item->y;
      if(x > ITEM_X_MAX)
        {
	  x = ITEM_X_MIN;
	  y += ITEM_H;
	  if(y > ITEM_Y_MAX)
	    g_warning("No more place for new item");
        }
    }
  else
    {
      x = ITEM_X_MIN;
      y = ITEM_Y_MIN;
    }

  new_item = g_new0(ScaleItem, 1);
  new_item->x = x;
  new_item->y = y;
  new_item->weight = weight;

  /* If selected, display multiples of 500g as 'g' or 'kg' randomly */
  if (show_weight > 9999) {
    if ((weight % 500) == 0)
  	show_weight = g_random_int_range(1,3000);
    else
	show_weight = 1;
  }

  if (show_weight < 1000) {
    	weight_text = g_strdup_printf("%d%s", weight, show_weight ? "\n  g" : "");
  } else {
  	int thousand = weight / 1000;
  	int hundred = (weight % 1000) / 100;
    	weight_text = g_strdup_printf("%c %c\n  kg", '0' + thousand, '0' + hundred);
  }
  pixmap = gc_pixmap_load("scale/masse.png");

  new_item->item = goo_canvas_group_new(group, NULL);
  goo_canvas_image_new(new_item->item,
		       pixmap,
		       0, 0,
		       NULL);
  goo_canvas_text_new(new_item->item,
		      weight_text,
		      18,
		      35,
		      -1,
		      GTK_ANCHOR_CENTER,
		      "font", "sans 10",
		      "fill_color_rgba", 0x000000FFL,
		      NULL);

  goo_canvas_item_translate(new_item->item,
			    new_item->x,
			    new_item->y);
  gdk_pixbuf_unref(pixmap);
  g_free(weight_text);

  gc_item_focus_init(new_item->item, NULL);
  g_signal_connect(new_item->item, "button_press_event",
		   (GtkSignalFunc)gc_drag_event, new_item);
  g_signal_connect(new_item->item, "button_release_event",
		   (GtkSignalFunc)gc_drag_event, new_item);
  g_signal_connect(new_item->item, "button_press_event",
  		   (GtkSignalFunc) scale_item_event, new_item);

  item_list = g_list_append(item_list, new_item);
  return new_item;
}
Ejemplo n.º 13
0
void
scale_anim_plate(void)
{
  double delta_y;
  double angle;
  double scale;
  int diff;

  // in MODE_WEIGHT the granularity is gramm, so we use a different factor
  scale = (board_mode == MODE_WEIGHT) ? 2000.0 : 10.0;
  diff = get_weight_plate(0);
  delta_y = CLAMP(PLATE_Y_DELTA / scale * diff,
		  -PLATE_Y_DELTA, PLATE_Y_DELTA);

  if(get_weight_plate(1) == 0)
    delta_y = -PLATE_Y_DELTA;

  /* Update the sign */
  if (diff == 0)
    g_object_set(sign, "text", "=", NULL);
  else if (diff < 0)
    g_object_set(sign, "text", "<", NULL);
  else
    g_object_set(sign, "text", ">", NULL);


  if(last_delta != delta_y)
    {
      goo_canvas_item_translate(group_g, 0, -last_delta);
      goo_canvas_item_translate(group_d, 0, last_delta);

      last_delta = delta_y;

      angle = tan(delta_y / 138) * 180 / M_PI;

      goo_canvas_item_translate(group_g, 0, delta_y);
      goo_canvas_item_translate(group_d, 0, -delta_y);

      gc_item_rotate_with_center(bras, -angle, 138, 84);
    }

  if(diff == 0 && ask_for_answer)
    {

      double x_offset = BOARDWIDTH/2;
      double y_offset = BOARDHEIGHT*0.7;

      GooCanvasItem *item = goo_canvas_svg_new (boardRootItem,
						gc_skin_rsvg_get(),
						"svg-id", "#BUTTON_TEXT",
						NULL);
      SET_ITEM_LOCATION_CENTER(item,
			       x_offset / 2,
			       y_offset);
      goo_canvas_item_scale(item, 2, 1);

      answer_item = goo_canvas_text_new(boardRootItem,
					"",
					x_offset,
					y_offset,
					-1,
					GTK_ANCHOR_CENTER,
					"font", gc_skin_font_board_title_bold,
					"fill-color", "white",
					NULL);

      answer_string = g_string_new(NULL);
      key_press(0, NULL, NULL);
    }
  else if(diff == 0)
    process_ok();
}
Ejemplo n.º 14
0
/*
 * Do all the bar display and register the events
 */
void
gc_config_start ()
{
  GcomprisProperties	*properties = gc_prop_get();
  gint y_start = 0;
  gint x_start = 0;
  gint x_text_start = 0;
  gint y = 0;
  GooCanvasItem *item;

  /* Pause the board */
  gc_board_pause(TRUE);

  if(rootitem)
  {
    gc_config_stop();
    return;
  }

  gc_bar_hide(TRUE);

  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
				   NULL);

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#DIALOG",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);

  GooCanvasBounds bounds;
  goo_canvas_item_get_bounds(item, &bounds);
  x_start = bounds.x1;
  y_start = bounds.y1;

  y = bounds.y2 - 26;

  goo_canvas_text_new (rootitem,
		       _("GCompris Configuration"),
		       (gdouble) BOARDWIDTH/2,
		       (gdouble) y_start + 40,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_title,
		       "fill-color-rgba", gc_skin_color_title,
		       NULL);

  pixmap_checked   = "#CHECKED";
  pixmap_unchecked = "#UNCHECKED";
  pixmap_width = 30;

  x_start += 150;
  x_flag_start = x_start + 50;
  x_text_start = x_start + 115;

  //--------------------------------------------------
  // Locale
  y_start += 105;

  display_previous_next(x_start, y_start, "locale_previous", "locale_next");

  y_flag_start = y_start - pixmap_width/2;

  /* Display a bad icon if this locale is not available */
  item_bad_flag = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#UNCHECKED",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);
  SET_ITEM_LOCATION(item_bad_flag,
		    x_flag_start + 5,
		    y_start - pixmap_width/2);

  /* A repeat icon to reset the selection */
  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#REPEAT",
			     NULL);
    goo_canvas_item_get_bounds(item, &bounds);
    double zoom = 0.65;
    goo_canvas_item_scale(item, zoom, zoom);
    goo_canvas_item_translate(item,
			      (-1 * bounds.x1 + x_flag_start - 340) * zoom,
			      (-1 * bounds.y1 + y_start - 120) * zoom);
  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "locale_reset");
  gc_item_focus_init(item, NULL);

  /*
   * The current locale is the one found in the config file
   */
  current_locale = properties->locale;
  set_locale_flag(current_locale);

  item_locale_text = goo_canvas_text_new (rootitem,
					  gc_locale_get_name(current_locale),
					  (gdouble) x_text_start,
					  (gdouble) y_start,
					  -1,
					  GTK_ANCHOR_WEST,
					  "font", gc_skin_font_subtitle,
					  "fill-color-rgba", gc_skin_color_content,
					  NULL);

  // Fullscreen / Window
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "fullscreen");
  gc_item_focus_init(item, NULL);


  goo_canvas_text_new (rootitem,
		       _("Fullscreen"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_subtitle,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Music
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "music");
  gc_item_focus_init(item, NULL);


  goo_canvas_text_new (rootitem,
		       _("Music"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_subtitle,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Effect
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "effect");
  gc_item_focus_init(item, NULL);


  goo_canvas_text_new (rootitem,
		       _("Effect"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_subtitle,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Zoom
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "zoom");
  gc_item_focus_init(item, NULL);

  goo_canvas_text_new (rootitem,
		       _("Zoom"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_subtitle,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Timer
  y_start += Y_GAP;

  display_previous_next(x_start, y_start, "timer_previous", "timer_next");

  item_timer_text = goo_canvas_text_new (rootitem,
					 gettext(timername[properties->timer]),
					 (gdouble) x_text_start,
					 (gdouble) y_start,
					 -1,
					 GTK_ANCHOR_WEST,
					 "font", gc_skin_font_subtitle,
					 "fill-color-rgba", gc_skin_color_content,
					 NULL);

  // Skin
  {
    const gchar *one_dirent;
    guint  i;
    GDir  *dir;
    gchar *skin_dir;
    gchar *first_skin_name;

    /* Load the Pixpmaps directory file names */
    skin_dir = g_strconcat(properties->package_data_dir, "/skins", NULL);
    dir = g_dir_open(skin_dir, 0, NULL);

    if (!dir)
      g_warning (_("Couldn't open skin dir: %s"), skin_dir);

    /* Fill up the skin list */
    while((one_dirent = g_dir_read_name(dir)) != NULL) {

      if (one_dirent[0] != '.') {
	gchar *filename;
	/* Only directory here are skins */
	filename = g_strdup_printf("%s/%s", properties->package_skin_dir, one_dirent);

	if (g_file_test ((filename), G_FILE_TEST_IS_DIR)) {
	  gchar *skin_name = g_strdup_printf("%s", one_dirent);
	  skinlist = g_list_append (skinlist, skin_name);
	}
	g_free(filename);
      }
    }
    g_dir_close(dir);

    /* Find the current skin index */
    skin_index = 0;
    for(i=0; i<g_list_length(skinlist);  i++)
      if(!strcmp((char *)g_list_nth_data(skinlist, i), properties->skin))
	skin_index = i;

    y_start += Y_GAP;

    /* Should not happen. It the user found the config, there should be a skin */
    if(g_list_length(skinlist) > 0) {
      g_warning("No skin found in %s\n", skin_dir);
      display_previous_next(x_start, y_start, "skin_previous", "skin_next");
      first_skin_name = g_strdup_printf(_("Skin : %s"), (char *)g_list_nth_data(skinlist, skin_index));
    } else {
      first_skin_name = g_strdup(_("SKINS NOT FOUND"));
    }

    item_skin_text = goo_canvas_text_new (rootitem,
					  first_skin_name,
					  (gdouble) x_text_start,
					  (gdouble) y_start,
					  -1,
					  GTK_ANCHOR_WEST,
					  "font", gc_skin_font_subtitle,
					  "fill-color-rgba", gc_skin_color_content,
					  NULL);
    g_free(first_skin_name);
    g_free(skin_dir);

  }

  // Difficulty Filter
  y_start += Y_GAP;

  stars_group_x = x_start + 45;
  stars_group_y = y_start - 25;
  gchar *text = g_strdup_printf("<i>%s</i>", gettext(filtername));
  item_filter_text = goo_canvas_text_new (rootitem,
					  text,
					  x_text_start,
					  y_start,
					  400,
					  GTK_ANCHOR_WEST,
					  "use-markup", TRUE,
					  "font", gc_skin_font_subtitle,
					  "fill-color-rgba", gc_skin_color_content,
					  NULL);
  g_free(text);


  // OK
  gc_util_button_text_svg(rootitem,
			  BOARDWIDTH * 0.5,
			  y,
			  "#BUTTON_TEXT",
			  _("OK"),
			  (GCallback) item_event_ok,
			  "ok");

  is_displayed = TRUE;
}
Ejemplo n.º 15
0
static GooCanvasItem *planegame_create_item(GooCanvasItem *parent)
{
    RsvgHandle *svg_handle;
    RsvgDimensionData dimension;
    GooCanvasItem *itemgroup;
    GooCanvasItem *item;
    char *number = NULL;
    int i, min;
    guint y;

    /* Random cloud number */
    if(g_random_int()%2==0)
    {
        /* Put the target */
        i = plane_target;
    }
    else
    {
        min = MAX(1, plane_target - 1);
        i   = min + g_random_int()%(plane_target - min + 3);
    }
    number = g_strdup_printf("%d", i);

    itemgroup = goo_canvas_group_new (parent, NULL);

    g_object_set_data (G_OBJECT (itemgroup),
                       "cloud_number", GINT_TO_POINTER (i));

    svg_handle = gc_rsvg_load("planegame/cloud.svgz");
    rsvg_handle_get_dimensions(svg_handle, &dimension);

    y = (g_random_int()%(BOARDHEIGHT - 40 -
                         (guint)(dimension.height * imageZoom)));

    goo_canvas_item_translate(itemgroup,
                              BOARDWIDTH,
                              y);

    item = goo_canvas_svg_new (itemgroup,
                               svg_handle,
                               NULL);
    goo_canvas_item_scale(item, imageZoom, imageZoom);

    g_object_unref(svg_handle);

    g_object_set_data (G_OBJECT (item),
                       "cloud_number", GINT_TO_POINTER (i));

    item = goo_canvas_text_new (itemgroup,
                                number,
                                dimension.width*imageZoom/2,
                                dimension.height*imageZoom/2,
                                -1,
                                GTK_ANCHOR_CENTER,
                                "font", gc_skin_font_board_big,
                                "fill-color", "red",
                                NULL);

    g_object_set_data (G_OBJECT (item),
                       "cloud_number", GINT_TO_POINTER (i));

    goo_canvas_item_animate(itemgroup,
                            -dimension.width*imageZoom,
                            y,
                            1.0,
                            0,
                            TRUE,
                            40*BOARDWIDTH,
                            40,
                            GOO_CANVAS_ANIMATE_FREEZE);

    /* The plane is always on top */
    goo_canvas_item_raise(itemgroup, NULL);
    goo_canvas_item_raise(planeitem, NULL);

    g_free (number);

    return (itemgroup);
}
Ejemplo n.º 16
0
/**
 * \brief defines the drawing widget on which the actual schematic will be drawn
 *
 * @param height height of the content area
 * @param width width of the content area
 */
GtkWidget *
sheet_new (gdouble height, gdouble width)
{
	GooCanvas *sheet_canvas;
	GooCanvasGroup *sheet_group;
	GooCanvasPoints *points;
	Sheet *sheet;
	GtkWidget *sheet_widget;
	GooCanvasItem *root;

	// Creation of the Canvas
	sheet = SHEET (g_object_new (TYPE_SHEET, NULL));

	sheet_canvas = GOO_CANVAS (sheet);
	g_object_set (G_OBJECT (sheet_canvas),
	              "bounds-from-origin", FALSE,
	              "bounds-padding", 4.0,
	              "background-color-rgb", 0xFFFFFF,
	              NULL);

	root = goo_canvas_get_root_item (sheet_canvas);

	sheet_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	                                root,
	                                NULL));
	sheet_widget = GTK_WIDGET (sheet);

	goo_canvas_set_bounds (GOO_CANVAS (sheet_canvas),
	                       0., 0.,
	                       width + 20., height + 20.);

	// Define vicinity around GooCanvasItem
	//sheet_canvas->close_enough = 6.0;

	sheet->priv->width = width;
	sheet->priv->height = height;

	// Create the dot grid.
	sheet->grid = grid_new (GOO_CANVAS_ITEM (sheet_group), height, width);

	// Everything outside the sheet should be gray.
	// top //
	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group),
	                     0.0,
	                     0.0,
	                     width + 20.0,
	                     20.0,
	                     "fill_color", "gray",
	                     "line-width", 0.0,
	                     NULL);

	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group),
	                     0.0,
	                     height,
	                     width + 20.0,
	                     height + 20.0,
	                     "fill_color", "gray",
	                     "line-width", 0.0,
	                     NULL);

	// right //
	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group),
	                     0.0,
	                     0.0,
	                     20.0,
	                     height + 20.0,
	                     "fill_color", "gray",
	                     "line-width", 0.0,
	                     NULL);

	goo_canvas_rect_new (GOO_CANVAS_ITEM (sheet_group),
	                     width,
	                     0.0,
	                     width + 20.0,
	                     height + 20.0,
	                     "fill_color", "gray",
	                     "line-width", 0.0,
	                     NULL);

	if (oregano_options_debug_directions()) {
		goo_canvas_polyline_new_line (GOO_CANVAS_ITEM (sheet_group),
			                          10.0, 10.0,
			                          50.0, 10.0,
			                          "stroke-color", "green",
			                          "line-width", 2.0,
			                          "end-arrow", TRUE,
			                          NULL);
		goo_canvas_text_new (GOO_CANVAS_ITEM (sheet_group),
			                 "x",
			                 90.0, 10.0,
			                 -1.0,
			                 GOO_CANVAS_ANCHOR_WEST,
			                 "fill-color", "green",
			                 NULL);


		goo_canvas_polyline_new_line (GOO_CANVAS_ITEM (sheet_group),
			                          10.0, 10.0,
			                          10.0, 50.0,
			                          "stroke-color", "red",
			                          "line-width", 2.0,
			                          "end-arrow", TRUE,
			                          NULL);
		goo_canvas_text_new (GOO_CANVAS_ITEM (sheet_group),
			                 "y",
			                 10.0, 90.0,
			                 -1.0,
			                 GOO_CANVAS_ANCHOR_CENTER,
			                 "fill-color", "red",
			                 NULL);
	}
	//  Draw a thin black border around the sheet.
	points = goo_canvas_points_new (5);
	points->coords[0] = 20.0;
	points->coords[1] = 20.0;
	points->coords[2] = width;
	points->coords[3] = 20.0;
	points->coords[4] = width;
	points->coords[5] = height;
	points->coords[6] = 20.0;
	points->coords[7] = height;
	points->coords[8] = 20.0;
	points->coords[9] = 20.0;

	goo_canvas_polyline_new (GOO_CANVAS_ITEM (sheet_group),
	      FALSE, 0,
	      "line-width", 1.0,
	      "points", points,
	      NULL);

	goo_canvas_points_unref (points);

	// Finally, create the object group that holds all objects.
	sheet->object_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	                     root,
	                     "x", 0.0,
	                     "y", 0.0,
	                     NULL));
	NG_DEBUG ("root group %p", sheet->object_group);

	sheet->priv->selected_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	     GOO_CANVAS_ITEM (sheet->object_group),
	     "x", 0.0,
	     "y", 0.0,
	     NULL));
	NG_DEBUG ("selected group %p", sheet->priv->selected_group);

	sheet->priv->floating_group = GOO_CANVAS_GROUP (goo_canvas_group_new (
	     GOO_CANVAS_ITEM (sheet->object_group),
	     "x", 0.0,
	     "y", 0.0,
	     NULL));

	NG_DEBUG ("floating group %p", sheet->priv->floating_group);

	// Hash table that maps coordinates to a specific dot.
	sheet->priv->node_dots = g_hash_table_new_full (dot_hash, dot_equal, g_free, NULL);

	//this requires object_group to be setup properly
	sheet->priv->rubberband_info = rubberband_info_new (sheet);
	sheet->priv->create_wire_info = create_wire_info_new (sheet);

	return sheet_widget;
}
Ejemplo n.º 17
0
void
gc_timer_display(int ax, int ay,
		 TimerList atype, int second,
		 GcomprisTimerEnd agcomprisTimerEnd)
{
  GdkFont *gdk_font;
  GdkPixbuf *pixmap = NULL;
  GcomprisProperties *properties = gc_prop_get();

  /* Timer is user disabled */
  if(properties->timer==0)
    return;

  gdk_font = gdk_font_load (FONT_BOARD_MEDIUM);

  gc_timer_end();

  paused = FALSE;

  boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
					NULL);

  x = ax;
  y = ay;
  second = second / properties->timer;
  timer = second;

  type = atype;
  gcomprisTimerEnd = agcomprisTimerEnd;

  switch(type)
    {
    case GCOMPRIS_TIMER_SAND:
    case GCOMPRIS_TIMER_CLOCK:
      {
	gchar		*filename = NULL;
	gint		fileid;

	fileid = (gint)timer;
	if(type==GCOMPRIS_TIMER_SAND)
	  filename = g_strdup_printf("timers/sablier%d.png", fileid);
	else
	  filename = g_strdup_printf("timers/clock%d.png", fileid);

	pixmap = gc_skin_pixmap_load(filename);

	gc_timer_item = goo_canvas_image_new (boardRootItem,
					      pixmap,
					      x,
					      y,
                          NULL);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
	gdk_pixbuf_unref(pixmap);
#else
	g_object_unref(pixmap);
#endif
	g_free(filename);
      }
      break;
    case GCOMPRIS_TIMER_TEXT:
      {
	gchar *tmpstr = g_strdup_printf("Remaining Time = %d", timer);
	/* Display the value for this timer */
	gc_timer_item = goo_canvas_text_new (boardRootItem,
					     tmpstr,
					     x,
					     y,
					     -1,
					     GTK_ANCHOR_CENTER,
					     "font_gdk", gdk_font,
					     "fill_color", "white",
					     NULL);
	g_free(tmpstr);
      }
      break;
    case GCOMPRIS_TIMER_BALLOON:
      pixmap = gc_skin_pixmap_load("timers/tuxballoon.png");
      gc_timer_item = goo_canvas_image_new (boardRootItem,
					    pixmap,
					    x,
					    y,
					    NULL);

      /* Calc the number of step needed to reach
       * the sea based on user y and second
       */
      ystep = (BOARDHEIGHT-y-gdk_pixbuf_get_height(pixmap))/second;

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif

      pixmap = gc_skin_pixmap_load("timers/sea.png");
      goo_canvas_image_new (boardRootItem,
			    pixmap,
			    0,
			    BOARDHEIGHT - gdk_pixbuf_get_height(pixmap),
			    "width", (double) gdk_pixbuf_get_width(pixmap),
			    "height", (double) gdk_pixbuf_get_height(pixmap),
			    NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif

      break;
    default:
      break;
    }

  start_animation();
}
Ejemplo n.º 18
0
static void
create_demo_item (GooCanvasItem *table,
		  gint           demo_item_type,
		  gint           row,
		  gint           column,
		  gint           rows,
		  gint           columns,
		  gchar         *text,
		  gdouble	 width,
		  gdouble        xalign,
		  gdouble	 yalign,
		  PangoAlignment text_alignment)
{
  GooCanvasItem *item = NULL;
  GtkWidget *widget;
  GValue value = { 0 };
  guint new_row;

  switch (demo_item_type)
    {
    case DEMO_RECT_ITEM:
      item = goo_canvas_rect_new (table, 0, 0, 38, 19,
				  "fill-color", "red",
				  NULL);
      break;
    case DEMO_TEXT_ITEM:
    case DEMO_TEXT_ITEM_2:
    case DEMO_TEXT_ITEM_3:
      item = goo_canvas_text_new (table, text, 0, 0, width, GOO_CANVAS_ANCHOR_NW,
				  "alignment",  text_alignment,
				  NULL);
      break;
    case DEMO_WIDGET_ITEM:
      widget = gtk_button_new_with_label (text);
      item = goo_canvas_widget_new (table, widget, 0, 0, -1, -1, NULL);
      break;
    }

  g_value_init (&value, G_TYPE_UINT);
  g_value_set_uint (&value, row);
  goo_canvas_item_set_child_property (table, item, "row", &value);
  g_value_set_uint (&value, column);
  goo_canvas_item_set_child_property (table, item, "column", &value);
  g_value_set_uint (&value, rows);
  goo_canvas_item_set_child_property (table, item, "rows", &value);
  g_value_set_uint (&value, columns);
  goo_canvas_item_set_child_property (table, item, "columns", &value);

  goo_canvas_item_set_child_properties (table, item,
					"x-expand", TRUE,
					"y-expand", TRUE,
					"x-align", xalign,
					"y-align", yalign,
					NULL);

  /* Test the get function. */
  goo_canvas_item_get_child_property (table, item, "row", &value);
  new_row = g_value_get_uint (&value);
  if (new_row != row)
    g_warning ("Got bad row setting: %i should be: %i\n", new_row, row);

  /* If we make the item's fill the cells then alignment can't be used. */
#if 0
  goo_canvas_item_set_child_properties (table, item,
					"x-fill", TRUE,
					"y-fill", TRUE,
					NULL);
#endif

  g_object_set_data (G_OBJECT (item), "id", text);
  g_signal_connect (item, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);
}
Ejemplo n.º 19
0
/*
 * Do all the bar display and register the events
 */
static void
bar_start (GooCanvas *theCanvas)
{
  GcomprisProperties *properties = gc_prop_get();
  RsvgHandle  *svg_handle;
  GooCanvasBounds bounds;

  _default_y = BOARDHEIGHT - BARHEIGHT;
  _default_zoom = 1.0;

  bar_reset_sound_id();

  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(theCanvas), NULL);

  svg_handle = gc_skin_rsvg_get();
  bar_item = goo_canvas_svg_new (rootitem,
				 svg_handle,
				 "svg-id", "#BAR_BG",
				 "pointer-events", GOO_CANVAS_EVENTS_NONE,
				 NULL);
  SET_ITEM_LOCATION(bar_item, 0, 0);

  /*
   * The Order in which buttons are created represents
   * also the order in which they will be displayed
   */

  // EXIT
  if(properties->disable_quit == 0)
    buttons = g_slist_append(buttons,
                             new_button(rootitem,
					svg_handle,
                                        GC_BAR_EXIT,
                                        "#EXIT"));

  // ABOUT
  buttons = g_slist_append(buttons,
                           new_button(rootitem,
				      svg_handle,
                                      GC_BAR_ABOUT,
                                      "#ABOUT"));

  // CONFIG
  if(properties->disable_config == 0)
    buttons = g_slist_append(buttons,
                             new_button(rootitem,
					svg_handle,
                                        GC_BAR_CONFIG,
                                        "#CONFIG"));

  // HELP
  buttons = g_slist_append(buttons,
                           new_button(rootitem,
				      svg_handle,
                                      GC_BAR_HELP,
                                      "#HELP"));

  // LEVEL (Multiple buttons for this one)
  GooCanvasItem *rootitem_level = goo_canvas_group_new (rootitem, NULL);
  g_object_set (rootitem_level,
		"visibility", GOO_CANVAS_ITEM_VISIBLE,
		NULL);
  g_object_set_data (G_OBJECT(rootitem_level), "flag",
		     GUINT_TO_POINTER(GC_BAR_LEVEL));
  buttons = g_slist_append(buttons, rootitem_level);

  GooCanvasItem *item = new_button(rootitem_level,
				   svg_handle,
				   GC_BAR_LEVEL_DOWN,
				   "#LEVEL_DOWN");

  g_object_set (item,
		"visibility", (properties->disable_level ?
			       GOO_CANVAS_ITEM_INVISIBLE :
			       GOO_CANVAS_ITEM_VISIBLE),
		NULL);

  item = new_button(rootitem_level,
		    svg_handle,
		    GC_BAR_LEVEL,
		    "#LEVEL_UP");
  goo_canvas_item_translate(item, 50, 0);
  g_object_set (item,
		"visibility", (properties->disable_level ?
			       GOO_CANVAS_ITEM_INVISIBLE :
			       GOO_CANVAS_ITEM_VISIBLE),
		NULL);

  goo_canvas_item_get_bounds(item, &bounds);

  level_item =
    goo_canvas_text_new (rootitem_level,
			 "",
			 bounds.x1 - 10,
			 (bounds.y2 - bounds.y1) / 2 + 8,
			 -1,
			 GTK_ANCHOR_CENTER,
			 "font", gc_skin_font_board_title_bold,
			 "fill-color-rgba", gc_skin_color_text_button,
			 NULL);
  current_level = 1;

  // REPEAT (Default)
  buttons = g_slist_append(buttons,
                           new_button(rootitem,
				      svg_handle,
                                      GC_BAR_REPEAT,
                                      "#REPEAT"));

  // REPEAT ICON
  buttons = g_slist_append(buttons,
                           new_button(rootitem,
				      svg_handle,
                                      GC_BAR_REPEAT_ICON,
                                      "#REPEAT"));

  // HOME
  buttons = g_slist_append(buttons,
                           new_button(rootitem,
				      svg_handle,
                                      GC_BAR_HOME,
                                      "#HOME"));

  update_exit_button();

  bar_set(0);

  _hidden = FALSE;
}
Ejemplo n.º 20
0
GtkWidget *
create_canvas_fifteen (void)
{
	GtkWidget *vbox;
	GtkWidget *alignment;
	GtkWidget *frame;
	GtkWidget *canvas;
	GtkWidget *button;
	GooCanvasItem **board;
	GooCanvasItem *root, *rect, *text;
	int i, x, y;
	char buf[20];

	vbox = gtk_vbox_new (FALSE, 4);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
	gtk_widget_show (vbox);

	alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
	gtk_box_pack_start (GTK_BOX (vbox), alignment, TRUE, TRUE, 0);
	gtk_widget_show (alignment);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (alignment), frame);
	gtk_widget_show (frame);

	/* Create the canvas and board */

	canvas = goo_canvas_new ();
	g_object_set (G_OBJECT (canvas),
		      "automatic-bounds", TRUE,
		      "bounds-from-origin", FALSE,
		      NULL);
	root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

	gtk_widget_set_size_request (canvas,
				     PIECE_SIZE * 4 + 1, PIECE_SIZE * 4 + 1);
#if 0
	goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0,
			       PIECE_SIZE * 4 + 1, PIECE_SIZE * 4 + 1);
#endif
	gtk_container_add (GTK_CONTAINER (frame), canvas);
	gtk_widget_show (canvas);

	board = g_new (GooCanvasItem *, 16);
	g_object_set_data (G_OBJECT (canvas), "board", board);
	g_signal_connect (canvas, "destroy",
			  G_CALLBACK (free_stuff),
			  board);

	for (i = 0; i < 15; i++) {
		y = i / 4;
		x = i % 4;

		board[i] = goo_canvas_group_new (root, NULL);
		goo_canvas_item_translate (board[i], x * PIECE_SIZE,
					   y * PIECE_SIZE);
		setup_item_signals (board[i]);

		rect = goo_canvas_rect_new (board[i], 0, 0,
					    PIECE_SIZE, PIECE_SIZE,
					    "fill_color", get_piece_color (i),
					    "stroke_color", "black",
					    "line-width", 1.0,
					    NULL);

		sprintf (buf, "%d", i + 1);

		text = goo_canvas_text_new (board[i], buf,
					    PIECE_SIZE / 2.0, PIECE_SIZE / 2.0,
					    -1, GTK_ANCHOR_CENTER,
					    "font", "Sans bold 24",
					    "fill_color", "black",
					    NULL);

		g_object_set_data (G_OBJECT (board[i]), "text", text);

		g_object_set_data (G_OBJECT (board[i]), "piece_num", GINT_TO_POINTER (i));
		g_object_set_data (G_OBJECT (board[i]), "piece_pos", GINT_TO_POINTER (i));

	}

	board[15] = NULL;

	/* Scramble button */

	button = gtk_button_new_with_label ("Scramble");
	gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
	g_object_set_data (G_OBJECT (button), "board", board);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (scramble),
			  canvas);
	gtk_widget_show (button);

	return vbox;
}
Ejemplo n.º 21
0
static GooCanvasItem *gletters_create_item(GooCanvasItem *parent)
{
  GooCanvasItem *item;
  gint i,j,k;
  guint x;
  gunichar *lettersItem;
  gchar *str_p, *letter;

  if (!letters_table)
    {
      letters_table = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, destroy_canvas_item);
    }

  /* Beware, since we put the letters in a hash table, we do not allow the same
   * letter to be displayed two times
   */

  g_warning("dump: %d, %s\n",gcomprisBoard->level,letters_array[gcomprisBoard->level-1]);

  k = g_utf8_strlen(letters_array[gcomprisBoard->level-1],-1);

  lettersItem = g_new(gunichar,1);
  gint attempt=0;
  do
    {
      attempt++;
      str_p = letters_array[gcomprisBoard->level-1];
      i = g_random_int_range(0,k);

      for(j = 0; j < i; j++)
	{
	  str_p=g_utf8_next_char(str_p);
	}

      *lettersItem = g_utf8_get_char (str_p);

    } while((attempt<MAX_RAND_ATTEMPTS) && (item_find_by_title(lettersItem)!=NULL));

  if (item_find_by_title(lettersItem)!=NULL)
    {
      g_free(lettersItem);
      return NULL;
    }

  letter = g_new0(gchar, 6);
  g_unichar_to_utf8 ( *lettersItem, letter);

  if (with_sound)
    {
      gchar *str2 = NULL;
      gchar *letter_unichar_name = gc_sound_alphabet(letter);

      str2 = g_strdup_printf("voices/$LOCALE/alphabet/%s", letter_unichar_name);

      gc_sound_play_ogg(str2, NULL);

      g_free(letter_unichar_name);
      g_free(str2);
    }

  item = \
    goo_canvas_group_new (parent,
			  NULL);
  goo_canvas_item_translate(item, 0, -12);

  x = g_random_int_range( 80, BOARDWIDTH-160);
  goo_canvas_text_new (item,
		       letter,
		       x,
		       -20,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_board_huge_bold,
		       "fill_color_rgba", 0x8c8cFFFF,
		       NULL);
  x -= 2;
  goo_canvas_text_new (item,
		       letter,
		       x,
		       -22,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_board_huge_bold,
		       "fill_color_rgba", 0x254c87FF,
		       NULL);

  g_object_set_data (G_OBJECT(item), "unichar_key", lettersItem);
  g_object_set_data (G_OBJECT(item), "utf8_key", letter);

  item_list = g_list_append (item_list, item);
  ++actors_count;

  /* Add letter to hash table of all falling letters. */
  g_hash_table_insert (letters_table, lettersItem, item);

  g_free(letter);

  return (item);
}
Ejemplo n.º 22
0
static void create_item(GooCanvasItem *parent)
{
  MemoryItem *memoryItem;
  gint x, y;
  double height, width;
  double height2, width2;
  GdkPixbuf *pixmap = NULL;

  // Calc width and height of one card
  width  = (base_x2-(currentMode == MODE_TUX ? base_x1_tux : base_x1))/numberOfColumn;
  height = (base_y2-base_y1)/numberOfLine;

  // Respect the card ratio
  if( width * 1.418 > height)
    width = height * 0.704;
  else
    height = width * 1.418;

  /* Remove a little bit of space for the card shadow */
  height2 = height * 0.95;
  width2  = width  * 0.95;


  if (currentUiMode == UIMODE_SOUND) {
    goo_canvas_rect_new (parent,
			 (currentMode == MODE_TUX ? base_x1_tux : base_x1) - 20,
			 base_y1 - 15,
			 width * numberOfColumn + 20*2,
			 height * numberOfLine + 15*2,
			 "stroke_color_rgba", 0xFFFFFFFFL,
			 "fill_color_rgba",   0x66666690L,
			 "line-width", (double) 2,
			 "radius-x", (double) 10,
			 "radius-y", (double) 10,
			 NULL);
  }

  if (currentMode == MODE_TUX){
    GdkPixbuf *pixmap_tux =  gc_pixmap_load("memory/tux-teacher.png");

    tux = goo_canvas_image_new (parent,
				pixmap_tux,
				50,
				140,
				NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
    gdk_pixbuf_unref(pixmap_tux);
#else
    g_object_unref(pixmap_tux);
#endif

    tux_score = goo_canvas_text_new (parent,
				     "",
				     (double) 115,
				     (double) 235,
				     -1,
				     GTK_ANCHOR_CENTER,
				     "font", gc_skin_font_board_huge_bold,
				     "fill_color_rgba", 0xFF0F0FFF,
				     NULL);

    player_score = goo_canvas_text_new (parent,
					"",
					(double) 100,
					(double) BASE_CARD_Y2 - 20,
					-1,
					GTK_ANCHOR_CENTER,
					"font", gc_skin_font_board_huge_bold,
					"fill_color_rgba", 0xFF0F0FFF,
					NULL);
  }

  for(x=0; x<numberOfColumn; x++)
    {
      for(y=0; y<numberOfLine; y++)
	{

	  memoryItem = g_malloc0(sizeof(MemoryItem));

	  memoryItem->rootItem = \
	    goo_canvas_group_new (parent,
				  NULL);
	  goo_canvas_item_translate(memoryItem->rootItem,
				    (currentMode == MODE_TUX ? base_x1_tux : base_x1) + x*width,
				    base_y1 + y*height);

	  if (currentUiMode == UIMODE_SOUND)
	    pixmap = gc_pixmap_load("memory/Tux_mute.png");
	  else
	    pixmap = gc_pixmap_load("memory/backcard.png");

	  memoryItem->backcardItem = \
	    goo_canvas_image_new (memoryItem->rootItem,
				  pixmap,
				  0,
				  0,
				  NULL);
	  goo_canvas_item_scale(memoryItem->backcardItem,
				width2 / gdk_pixbuf_get_width(pixmap),
				height2 / gdk_pixbuf_get_height(pixmap));
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
	  gdk_pixbuf_unref(pixmap);
#else
	  g_object_unref(pixmap);
#endif

	  if (currentUiMode != UIMODE_SOUND){
	    pixmap = gc_pixmap_load("memory/emptycard.png");
	    memoryItem->framecardItem = \
	      goo_canvas_image_new (memoryItem->rootItem,
				    pixmap,
				    0,
				    0,
				    NULL);
	    goo_canvas_item_scale(memoryItem->framecardItem,
				  (width2 / gdk_pixbuf_get_width(pixmap)),
				  (height2 / gdk_pixbuf_get_height(pixmap)));
	    g_object_set (memoryItem->framecardItem, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
	    gdk_pixbuf_unref(pixmap);
#else
	    g_object_unref(pixmap);
#endif
	  }


	  // Display the image itself while taking care of its size and maximize the ratio
	  get_image(memoryItem, x, y);

	  if (currentUiMode == UIMODE_SOUND){
	    pixmap = gc_pixmap_load("memory/Tux_play.png");
	    memoryItem->frontcardItem =	\
	      goo_canvas_image_new (memoryItem->rootItem,
				    pixmap,
				    0,
				    0,
				    NULL);
	    goo_canvas_item_scale(memoryItem->frontcardItem,
				  (width2 / gdk_pixbuf_get_width(pixmap)),
				  (height2 / gdk_pixbuf_get_height(pixmap)));
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
	    gdk_pixbuf_unref(pixmap);
#else
	    g_object_unref(pixmap);
#endif
	  }
	  else {

	    if(memoryItem->type & (TYPE_IMAGE|TYPE_ENUMERATE_IMAGE)) {
              pixmap = gc_pixmap_load(memoryItem->data);

	      memoryItem->frontcardItem =	\
		goo_canvas_image_new (memoryItem->rootItem,
				      pixmap,
				      0.0,
				      0.0,
				      NULL);

	      /* scale only in ENUMERATE (image size too big) */
		 if(memoryItem->type == TYPE_ENUMERATE_IMAGE) {
		    goo_canvas_item_scale(memoryItem->frontcardItem,
					  (0.9*width2 / gdk_pixbuf_get_width(pixmap)),
					  (0.9*height2 / gdk_pixbuf_get_height(pixmap)));
		    goo_canvas_item_translate(memoryItem->frontcardItem,
					      0.1 * width2,
					      0.1 * height2);
		 } else {
	            goo_canvas_item_translate(memoryItem->frontcardItem,
					      (width2 - gdk_pixbuf_get_width(pixmap))/2,
					      (height2 - gdk_pixbuf_get_height(pixmap))/2);
		 }
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
	      gdk_pixbuf_unref(pixmap);
#else
	      g_object_unref(pixmap);
#endif

	    } else {
	      gchar *font;
	      if (memoryItem->type & (TYPE_ADD|TYPE_MINUS|TYPE_MULT|TYPE_DIV))
		font = op_fonts[gcomprisBoard->level];
	      else
		font = TEXT_FONT;
	      /* It's a letter */
	      memoryItem->frontcardItem =	 \
		goo_canvas_text_new (memoryItem->rootItem,
				     memoryItem->data,
				     (double) (width2)/2,
				     (double) (height2)/2,
				     -1,
				     GTK_ANCHOR_CENTER,
				     "font", font,
				     "fill_color_rgba", 0x000000FF,
				     NULL);

	      if(memoryItem->type == TYPE_WORDNUMBER){
	        gcompris_adapt_font_size(GOO_CANVAS_TEXT(memoryItem->frontcardItem), width2, height2);
	      }
	    }
	  }

	  g_object_set (memoryItem->frontcardItem, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
	  g_signal_connect(memoryItem->rootItem, "button_press_event",
			     (GCallback) item_event,
			     memoryItem);

	}
    }

  //return (NULL);
}
Ejemplo n.º 23
0
void gc_help_start (GcomprisBoard *gcomprisBoard)
{

  gchar *item_id = "#UP";
  GooCanvasItem *item;
  gint y = 0;
  gint y_start = 0;
  gint x_start = 0;
  gchar   *name = NULL;
  gchar   *text_to_display = NULL;

  if(rootitem)
    return;

  gc_board_pause(TRUE);

  caller_cursor = gc_cursor_get();
  gc_cursor_set(GCOMPRIS_DEFAULT_CURSOR);

  item_selected = NULL;
  item_selected_text = NULL;

  name = gcomprisBoard->title;
  gc_help_has_board(gcomprisBoard);

  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
				   NULL);

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#DIALOG",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);

  GooCanvasBounds bounds;
  guint pixmap_width = 40;
  goo_canvas_item_get_bounds(item, &bounds);
  x_start = bounds.x1;
  y_start = bounds.y1;

  y = bounds.y2 - 26;

  y_start += 15;
  if(gcomprisBoard->section && gcomprisBoard->name) {
    text_to_display = g_strdup_printf("%s/%s", gcomprisBoard->section, gcomprisBoard->name);
     goo_canvas_text_new (rootitem,
			  text_to_display,
			  BOARDWIDTH*0.10,
			  y_start,
			  -1,
			  GTK_ANCHOR_NW,
			  "font", gc_skin_font_board_tiny,
			  "fill-color-rgba", gc_skin_color_title,
			  NULL);
    g_free(text_to_display);
  }

  y_start += 30;
  goo_canvas_text_new (rootitem,
		       name,
		       BOARDWIDTH/2,
		       y_start,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_title,
		       "fill-color-rgba", gc_skin_color_title,
		       NULL);


  y_start += 80;

  // Prerequisite Button
  if(prerequisite)
    {
      item_prerequisite = goo_canvas_svg_new (rootitem,
					      gc_skin_rsvg_get(),
					      "svg-id", item_id,
					      NULL);
      SET_ITEM_LOCATION(item_prerequisite,
			(BOARDWIDTH*0.2) - pixmap_width/2,
			y_start  - 10)

      g_signal_connect(item_prerequisite, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "prerequisite");
      gc_item_focus_init(item_prerequisite, NULL);

      item_prerequisite_text = \
	goo_canvas_text_new (rootitem,
			     _("Prerequisite"),
			     BOARDWIDTH*0.20,
			     y_start   + GAP_TO_BUTTON,
			     -1,
			     GTK_ANCHOR_CENTER,
			     "font", gc_skin_font_content,
			     "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
			     NULL);
      g_signal_connect(item_prerequisite_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "prerequisite");
    }

  // Goal Button
  if(goal)
    {
      item_goal = goo_canvas_svg_new (rootitem,
				      gc_skin_rsvg_get(),
				      "svg-id", item_id,
				      NULL);
      SET_ITEM_LOCATION(item_goal,
			(BOARDWIDTH*0.4) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_goal, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "goal");
      gc_item_focus_init(item_goal, NULL);

      item_goal_text = goo_canvas_text_new (rootitem,
					    _("Goal"),
					    BOARDWIDTH*0.4,
					    y_start   + GAP_TO_BUTTON,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_content,
					    "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					    NULL);
      g_signal_connect(item_goal_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "goal");
    }

  // Manual Button
  if(manual)
    {
      item_manual = goo_canvas_svg_new (rootitem,
					gc_skin_rsvg_get(),
					"svg-id", item_id,
					NULL);
      SET_ITEM_LOCATION(item_manual,
			(BOARDWIDTH*0.6) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_manual, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "manual");
      gc_item_focus_init(item_manual, NULL);

      item_manual_text = goo_canvas_text_new (rootitem,
					      _("Manual"),
					      BOARDWIDTH*0.6,
					      y_start   + GAP_TO_BUTTON,
					      -1,
					      GTK_ANCHOR_CENTER,
					      "font", gc_skin_font_content,
					      "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					      NULL);
      g_signal_connect(item_manual_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "manual");
    }

  // Credit Button
  if(credit)
    {
      item_credit = goo_canvas_svg_new (rootitem,
					gc_skin_rsvg_get(),
					"svg-id", item_id,
					NULL);
      SET_ITEM_LOCATION(item_credit,
			(BOARDWIDTH*0.8) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_credit, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "credit");
      gc_item_focus_init(item_credit, NULL);

      item_credit_text = goo_canvas_text_new (rootitem,
					      _("Credit"),
					      BOARDWIDTH*0.8,
					      y_start   + GAP_TO_BUTTON,
					      -1,
					      GTK_ANCHOR_CENTER,
					      "font", gc_skin_font_content,
					      "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					      NULL);
      g_signal_connect(item_credit_text, "button_press_event",
			 (GtkSignalFunc) item_event_help,
			 "credit");
    }

  // CONTENT

  // default text to display

  if(prerequisite)
    {
      text_to_display = prerequisite;
      select_item(item_prerequisite, item_prerequisite_text);
    }
  else if(goal)
    {
      text_to_display = goal;
      select_item(item_goal, item_goal_text);
    }
  else if(manual)
    {
      text_to_display = manual;
      select_item(item_manual, item_manual_text);
    }
  else if(credit)
    {
      text_to_display = credit;
      select_item(item_credit, item_credit_text);
    }

  y_start += 45;

  /* Create a scrolled area for the text content */
  GtkWidget *view;
  GtkWidget *sw;
  view = gtk_text_view_new ();
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
  gtk_text_view_set_editable(GTK_TEXT_VIEW (view), FALSE);
  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW (view), FALSE);

  gtk_signal_connect(GTK_OBJECT(view), "button-press-event",
		     (GtkSignalFunc) event_disable_right_click_popup, NULL);

  PangoFontDescription *font_desc;
  font_desc = pango_font_description_from_string (gc_skin_font_content);
  gtk_widget_modify_font (view, font_desc);
  pango_font_description_free (font_desc);

  GdkColor fg_color;
  GdkColor bg_color;
  gc_skin_get_gdkcolor("gcompris/helpfg", &fg_color);
  gc_skin_get_gdkcolor("gcompris/helpbg", &bg_color);
  gtk_widget_modify_base(view, GTK_STATE_NORMAL, &bg_color);
  gtk_widget_modify_text(view, GTK_STATE_NORMAL, &fg_color);

  buffer_content = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  gtk_container_add (GTK_CONTAINER (sw), view);

  goo_canvas_widget_new (rootitem,
			 sw,
			 x_start + 40,
			 y_start,
			 618.0,
			 280.0,
			 NULL);
  gtk_widget_show_all (sw);

  set_content(text_to_display);
  // OK
  gc_util_button_text_svg(rootitem,
			  BOARDWIDTH * 0.5,
			  y,
			  "#BUTTON_TEXT",
			  _("OK"),
			  (GtkSignalFunc) item_event_help,
			  "ok");

  gc_bar_hide(TRUE);

  help_displayed = TRUE;
}
Ejemplo n.º 24
0
// part_browser_create
//
// Creates a new part browser. This is only called once per schematic window.
GtkWidget *
part_browser_create (SchematicView *schematic_view)
{
	Browser *br;
	GtkBuilder *gui;
	GError *perror = NULL;
	char *msg;
	GtkWidget *w, *view;
	GtkCellRenderer *cell_text;
	GtkTreeViewColumn *cell_column;
	static GtkTargetEntry dnd_types[] =
		{ { "x-application/oregano-part", 0, DRAG_PART_INFO } };

	static int dnd_num_types = sizeof (dnd_types) / sizeof (dnd_types[0]);
	GtkTreePath *path;

	if ((gui = gtk_builder_new ()) == NULL) {
		oregano_error (_("Could not create part browser"));
		return NULL;
	} 
	else 
		gtk_builder_set_translation_domain (gui, NULL);

	br = g_new0 (Browser, 1);
	br->preview = NULL;
	br->schematic_view = schematic_view;
	br->hidden = FALSE;

	schematic_view_set_browser (schematic_view, br);

	if (gtk_builder_add_from_file (gui, OREGANO_UIDIR "/part-browser.ui", 
	    &perror) <= 0) {
		msg = perror->message;
		oregano_error_with_title (_("Could not create part browser"), msg);
		g_error_free (perror);
		return NULL;
	}

	view = GTK_WIDGET (gtk_builder_get_object (gui, "viewport1"));
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view), 
	    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (view),
	                                            115);
	
	w = goo_canvas_new ();
	gtk_container_add (GTK_CONTAINER (view), GTK_WIDGET (w));
	
	br->canvas = w;

	g_signal_connect (w, "realize", (GCallback) preview_realized, br);

	//gtk_widget_set_size_request (w, PREVIEW_WIDTH,
	//	PREVIEW_HEIGHT + PREVIEW_TEXT_HEIGHT);
	goo_canvas_set_bounds (GOO_CANVAS (w), 0, 0, PREVIEW_WIDTH,
		(PREVIEW_HEIGHT + PREVIEW_TEXT_HEIGHT));

	br->description = GOO_CANVAS_TEXT (goo_canvas_text_new (
	           goo_canvas_get_root_item (GOO_CANVAS (br->canvas)), 
	           "", 0.0, PREVIEW_HEIGHT - 9.0, 100.0, GOO_CANVAS_ANCHOR_NORTH_WEST,
	           "font", "sans 9", 
	           NULL));  

	// Set up dnd. 
	g_signal_connect (G_OBJECT (br->canvas), "drag_data_get",
		G_CALLBACK (drag_data_get), br);

	gtk_drag_source_set (br->canvas, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
		dnd_types, dnd_num_types, GDK_ACTION_MOVE);

	br->filter_entry = GTK_ENTRY (gtk_builder_get_object (gui, "part_search"));

	g_signal_connect (G_OBJECT (br->filter_entry), "changed",
		G_CALLBACK (part_search_change), br);
	g_signal_connect (G_OBJECT (br->filter_entry), "activate",
		G_CALLBACK (part_search_activate), br);

	// Buttons. 
	w = GTK_WIDGET (gtk_builder_get_object (gui, "place_button"));
	g_signal_connect (G_OBJECT (w), "clicked",
		G_CALLBACK (place_cmd), br);

	// Update the libraries option menu 
	br->library = g_list_nth_data (oregano.libraries, 0);
	part_browser_setup_libs (br, gui);

	// Parts list. 
	w = GTK_WIDGET (gtk_builder_get_object (gui, "parts_list"));
	br->list = w;

	// Create the List Model for TreeView, this is a Real model 
	br->real_model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
	cell_text = gtk_cell_renderer_text_new ();
	cell_column = gtk_tree_view_column_new_with_attributes (
		"", cell_text, 
	    "text", 0,
	    NULL);

	// Create the sort model for the items, this sort the real model 
	br->sort_model = gtk_tree_model_sort_new_with_model (
		GTK_TREE_MODEL (br->real_model));

	gtk_tree_sortable_set_sort_column_id (
		GTK_TREE_SORTABLE (br->sort_model),
		0, GTK_SORT_ASCENDING);

	// Create the filter sorted model. This filter items based on user
	//   request for fast item search 
	br->filter_model = gtk_tree_model_filter_new (br->sort_model, NULL);
	gtk_tree_model_filter_set_visible_func (
		GTK_TREE_MODEL_FILTER (br->filter_model),
		part_list_filter_func, br, NULL);

	// If we have TreeFilter use it, if not, just use sorting model only 
	if (br->filter_model)
		gtk_tree_view_set_model (GTK_TREE_VIEW (w), br->filter_model);
	else
		gtk_tree_view_set_model (GTK_TREE_VIEW (w), br->sort_model);

	gtk_tree_view_append_column (GTK_TREE_VIEW (w), cell_column);
	update_list (br);

	// Set up TreeView dnd.
	g_signal_connect (G_OBJECT (w), "drag_data_get",
		G_CALLBACK (drag_data_get), br);

	gtk_drag_source_set (w, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
		dnd_types, dnd_num_types, GDK_ACTION_MOVE);

	g_signal_connect (G_OBJECT (w), "cursor_changed", 
		G_CALLBACK (select_row), br);
	g_signal_connect (G_OBJECT (w), "row_activated", 
	    G_CALLBACK (part_selected), br);

	br->viewport = GTK_WIDGET (gtk_builder_get_object (gui, 
	    "part_browser_vbox"));

	path = gtk_tree_path_new_first ();
	gtk_tree_view_set_cursor (GTK_TREE_VIEW (w), path, NULL, FALSE);
	gtk_tree_path_free (path);

	gtk_widget_unparent (br->viewport);
	return br->viewport;
}
Ejemplo n.º 25
0
/*
 * Do all the bar display and register the events
 */
void
gc_config_start ()
{
  GcomprisProperties	*properties = gc_prop_get();
  gint y_start = 0;
  gint x_start = 0;
  gint x_text_start = 0;
  gint y = 0;
  GooCanvasItem *item;

  /* Pause the board */
  gc_board_pause(TRUE);

  if(rootitem)
  {
    gc_config_stop();
    return;
  }

  gc_bar_hide(TRUE);

  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
				   NULL);

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#DIALOG",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);

  GooCanvasBounds bounds;
  goo_canvas_item_get_bounds(item, &bounds);
  x_start = bounds.x1;
  y_start = bounds.y1;

  y = bounds.y2 - 26;

  goo_canvas_text_new (rootitem,
		       _("GCompris Configuration"),
		       (gdouble) BOARDWIDTH/2,
		       (gdouble) y_start + 40,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_title,
		       "fill-color-rgba", gc_skin_color_title,
		       NULL);

  pixmap_checked   = "#CHECKED";
  pixmap_unchecked = "#UNCHECKED";
  pixmap_width = 30;

  x_start += 60;
  x_text_start = x_start + 80;

  //--------------------------------------------------
  // Locale
  y_start += 105;

  display_previous_next(x_start, y_start, "locale_previous", "locale_next");

  y_flag_start = y_start - pixmap_width/2;

  /* A repeat icon to reset the selection */
  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#REPEAT",
			     NULL);
    goo_canvas_item_get_bounds(item, &bounds);
    double zoom = 0.50;
    goo_canvas_item_scale(item, zoom, zoom);
    goo_canvas_item_translate(item,
			      (-1 * bounds.x1 + x_start - 100) * zoom,
			      (-1 * bounds.y1 + y_start - 145) * zoom);
  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "locale_reset");
  gc_item_focus_init(item, NULL);

  /*
   * The current locale is the one found in the config file
   */
  current_locale = properties->locale;
  set_locale_flag(current_locale);

  item_locale_text = goo_canvas_text_new (rootitem,
					  gc_locale_get_name(current_locale),
					  (gdouble) x_text_start,
					  (gdouble) y_start,
					  -1,
					  GTK_ANCHOR_WEST,
					  "font", gc_skin_font_content,
					  "fill-color-rgba", gc_skin_color_content,
					  NULL);

  // Fullscreen / Window
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "fullscreen");
  gc_item_focus_init(item, NULL);


  goo_canvas_text_new (rootitem,
		       _("Fullscreen"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_content,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Rememberlevel
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->rememberlevel ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "rememberlevel");
  gc_item_focus_init(item, NULL);


  goo_canvas_text_new (rootitem,
		       _("Remember level for default user"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_content,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);


  // Music
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "music");
  gc_item_focus_init(item, NULL);


  goo_canvas_text_new (rootitem,
		       _("Music"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_content,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Effect
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "effect");
  gc_item_focus_init(item, NULL);


  goo_canvas_text_new (rootitem,
		       _("Effect"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_content,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Zoom
  y_start += Y_GAP;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked),
			     NULL);
  SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   "zoom");
  gc_item_focus_init(item, NULL);

  goo_canvas_text_new (rootitem,
		       _("Zoom"),
		       (gdouble) x_text_start,
		       (gdouble) y_start,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_content,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);

  // Timer
  y_start += Y_GAP;

  display_previous_next(x_start, y_start, "timer_previous", "timer_next");

  item_timer_text = goo_canvas_text_new (rootitem,
					 gettext(timername[properties->timer]),
					 (gdouble) x_text_start,
					 (gdouble) y_start,
					 -1,
					 GTK_ANCHOR_WEST,
					 "font", gc_skin_font_content,
					 "fill-color-rgba", gc_skin_color_content,
					 NULL);

  // Font
  y_start += Y_GAP;
  {
    int i;
    PangoFontFamily ** families;
    int n_families;
    PangoFontMap * fontmap;
    const gchar *current_familly_name = NULL;

    fontmap = pango_cairo_font_map_get_default();
    pango_font_map_list_families (fontmap, & families, & n_families);
    for (i = 0; i < n_families; i++) {
        PangoFontFamily * family = families[i];
        const gchar * family_name;
        family_name = pango_font_family_get_name (family);

	/* Skip font to exclude */
	guint j = 0;
	gboolean exclude = FALSE;
	while(excluded_fonts[j] != NULL) {
	  if( !g_ascii_strncasecmp(excluded_fonts[j], family_name,
				   strlen(excluded_fonts[j])) ) {
	    exclude = TRUE;
	    break;
	  }
	  j++;
	}
	if(exclude)
	  continue;
	fontlist = g_list_insert_sorted (fontlist, (gpointer)family_name,
					 (GCompareFunc)strcmp);
	if(!strcmp(properties->fontface, family_name))
	  current_familly_name = family_name;
    }
    g_free (families);

    current_font_index = font_index = g_list_index(fontlist, current_familly_name);
    display_previous_next(x_start, y_start, "font_previous", "font_next");

    /* A repeat icon to reset the selection */
    item = goo_canvas_svg_new (rootitem,
			       gc_skin_rsvg_get(),
			       "svg-id", "#REPEAT",
			       NULL);
    goo_canvas_item_get_bounds(item, &bounds);
    double zoom = 0.50;
    goo_canvas_item_scale(item, zoom, zoom);
    goo_canvas_item_translate(item,
			      (-1 * bounds.x1 + x_start - 100) * zoom,
			      (-1 * bounds.y1 + y_start + 650) * zoom);
    g_signal_connect(item, "button_press_event",
		     (GCallback) item_event_ok,
		     "fontface_reset");
    gc_item_focus_init(item, NULL);

    gchar *first_font_name = g_strdup_printf(_("Font: %s"), (char *)g_list_nth_data(fontlist, font_index));
    item_font_text = goo_canvas_text_new (rootitem,
					  first_font_name,
					  (gdouble) x_text_start,
					  (gdouble) y_start,
					  -1,
					  GTK_ANCHOR_WEST,
					  "font", gc_skin_font_content,
					  "fill-color-rgba", gc_skin_color_content,
					  NULL);
  }

  // Difficulty Filter
  y_start += Y_GAP;

  stars_group_x = x_start + 45;
  stars_group_y = y_start - 25;
  gchar *text = g_strdup_printf("<i>%s</i>", gettext(filtername));
  item_filter_text = goo_canvas_text_new (rootitem,
					  text,
					  x_text_start,
					  y_start,
					  400,
					  GTK_ANCHOR_WEST,
					  "use-markup", TRUE,
					  "font", gc_skin_font_content,
					  "fill-color-rgba", gc_skin_color_content,
					  NULL);
  g_free(text);


  // OK
  gc_util_button_text_svg(rootitem,
			  BOARDWIDTH * 0.5,
			  y,
			  "#BUTTON_TEXT",
			  _("OK"),
			  (GCallback) item_event_ok,
			  "ok");

  is_displayed = TRUE;
}
Ejemplo n.º 26
0
/* ==================================== */
static void
missing_letter_create_item(GooCanvasItem *parent)
{
  int xOffset, yOffset;
  GdkPixbuf *button_pixmap = NULL;
  GdkPixbuf *pixmap = NULL;
  Board *board;

  /* This are the values of the area in which we must display the image */
  gint img_area_x = 290;
  gint img_area_y = 80;
  gint img_area_w = 440;
  gint img_area_h = 310;

  /* this is the coordinate of the text to find */
  gint txt_area_x = 515;
  gint txt_area_y = 435;

  guint vertical_separation;
  gint i;

  board_number = gcomprisBoard_missing->sublevel-1;

  g_assert(board_number >= 0  && board_number < g_list_length(board_list));

  boardRootItem = \
    goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard_missing->canvas),
			  NULL);

  button_pixmap = gc_pixmap_load("missing_letter/button.png");
  /* display the image */
  board = g_list_nth_data(board_list, board_number);
  g_assert(board != NULL);

  pixmap = gc_pixmap_load(board->pixmapfile);

  text = goo_canvas_text_new (boardRootItem,
			      _(board->question),
			      (double) txt_area_x,
			      (double) txt_area_y,
			      -1,
			      GTK_ANCHOR_CENTER,
			      "font", gc_skin_font_board_huge_bold,
			      "fill_color_rgba", 0xFFFFFFFFL,
			      NULL);

  goo_canvas_image_new (boardRootItem,
			pixmap,
			img_area_x+(img_area_w - gdk_pixbuf_get_width(pixmap))/2,
			img_area_y+(img_area_h - gdk_pixbuf_get_height(pixmap))/2,
			NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  /* Calc the number of proposals */
  i = 0;
  while(board->text[i++]);

  vertical_separation = 10 + 20 / i;

  yOffset = ( BOARDHEIGHT
	      - i * gdk_pixbuf_get_height(button_pixmap)
	      - 2 * vertical_separation) / 2 - 20;
  xOffset = (img_area_x - gdk_pixbuf_get_width(button_pixmap))/2;

  i = 0;
  while(board->text[i])
    {
      GooCanvasItem *button;
      GooCanvasItem *item;
      GooCanvasItem *group = goo_canvas_group_new (boardRootItem,
						   NULL);

      button = goo_canvas_image_new (group,
				     button_pixmap,
				     xOffset,
				     yOffset,
				     NULL);

      g_object_set_data(G_OBJECT(group),
		      "answer", board->answer);

      g_object_set_data(G_OBJECT(group),
		      "button", button);

      g_object_set_data(G_OBJECT(group),
			"solution", GINT_TO_POINTER(board->solution));

      g_signal_connect(button, "button_press_event",
		       (GCallback) item_event,
		       GINT_TO_POINTER(i));

      item = goo_canvas_text_new (group,
				  board->text[i],
				  xOffset + gdk_pixbuf_get_width(button_pixmap)/2 + 1.0,
				  yOffset + gdk_pixbuf_get_height(button_pixmap)/2 + 1.0,
				  -1,
				  GTK_ANCHOR_CENTER,
				  "font", gc_skin_font_board_huge_bold,
				  "fill_color_rgba", gc_skin_color_shadow,
				  NULL);

      g_signal_connect(item, "button_press_event",
		       (GCallback) item_event,
		       GINT_TO_POINTER(i));

      item = goo_canvas_text_new (group,
				  board->text[i],
				  xOffset + gdk_pixbuf_get_width(button_pixmap)/2,
				  yOffset + gdk_pixbuf_get_height(button_pixmap)/2,
				  -1,
				  GTK_ANCHOR_CENTER,
				  "font", gc_skin_font_board_huge_bold,
				  "fill_color_rgba", gc_skin_color_text_button,
				  NULL);

      g_signal_connect(item, "button_press_event",
		       (GCallback) item_event,
		       GINT_TO_POINTER(i));

      yOffset += gdk_pixbuf_get_height(button_pixmap) + vertical_separation;

      i++;
    }

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(button_pixmap);
#else
  g_object_unref(button_pixmap);
#endif
}
Ejemplo n.º 27
0
/*
 * Compute the anchor shapes to link field1 to field2 from ent1 to ent2
 *
 * if @shapes is not NULL, then the shapes in the list are reused, and the ones which don't need
 * to exist anymore are removed
 *
 * Returns a list of BrowserCanvasCanvasShapes structures
 */
GSList *
browser_canvas_util_compute_connect_shapes (GooCanvasItem *parent, GSList *shapes,
					  BrowserCanvasTable *ent1, GdaMetaTableColumn *field1, 
					  BrowserCanvasTable *ent2, GdaMetaTableColumn *field2,
					  guint nb_connect, guint ext)
{
	GSList *retval = shapes;
	GooCanvasItem *item;
	GooCanvasPoints *points;
	gdouble xl1, xr1, xl2, xr2, yt1, yt2; /* X boundings and Y top of ent1 and ent2 */
	gdouble x1, x2; /* X positions of the lines extremities close to ent1 and ent2 */
	gdouble x1offset, x2offset; /* offsets for the horizontal part of the lines */
	double sq = 5.;
	double eps = 0.5;
	GooCanvasBounds bounds;

	BrowserCanvasCanvasShape *shape;
	gchar *id;

	if (!field1 || !field2)
		return browser_canvas_util_compute_anchor_shapes (parent, shapes, ent1, ent2, 1, ext, FALSE);

	/* line made of 4 points */
	points = goo_canvas_points_new (4);
	browser_canvas_table_get_anchor_bounds (ent1, &bounds);
	xl1 = bounds.x1;
	yt1 = bounds.y1;
	xr1 = bounds.x2;
	browser_canvas_table_get_anchor_bounds (ent2, &bounds);
	xl2 = bounds.x1;
	yt2 = bounds.y1;
	xr2 = bounds.x2;

	if (xl2 > xr1) {
		x1 = xr1 + eps;
		x2 = xl2 - eps;
		x1offset = 2 * sq;
		x2offset = -2 * sq;
	}
	else {
		if (xl1 >= xr2) {
			x1 = xl1 - eps;
			x2 = xr2 + eps;
			x1offset = - 2 * sq;
			x2offset = 2 * sq;
		}
		else {
			if ((xl1 + xr1) < (xl2 + xr2)) {
				x1 = xl1 - eps;
				x2 = xl2 - eps;
				x1offset = -2 * sq;
				x2offset = -2 * sq;
			}
			else {
				x1 = xr1 + eps;
				x2 = xr2 + eps;
				x1offset = 2 * sq;
				x2offset = 2 * sq;
			}
		}
	}

	points->coords[0] = x1;
	points->coords[1] = browser_canvas_table_get_column_ypos (ent1, field1) + yt1;

	points->coords[2] = x1 + x1offset;
	points->coords[3] = points->coords[1];

	points->coords[4] = x2 + x2offset;
	points->coords[5] = browser_canvas_table_get_column_ypos (ent2, field2) + yt2;

	points->coords[6] = x2;
	points->coords[7] = points->coords[5];

	id = g_strdup_printf ("c%d", nb_connect);
	shape = browser_canvas_canvas_shape_find (retval, id);
	if (shape) {
		g_object_set (shape->item, "points", points, NULL);
		shape->_used = TRUE;
		g_free (id);
	}
	else {
		item = goo_canvas_polyline_new_line (parent, 
						     points->coords[0], points->coords [1],
						     points->coords[2], points->coords [3],
						     "close-path", FALSE,
						     "points", points, NULL);
		retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
	}

	/* extension marks as text */
	if (ext & CANVAS_SHAPE_EXT_JOIN_OUTER_1) {
		gdouble mxoff = 0., myoff = 0.;
		GooCanvasAnchorType atype;
		
		compute_text_marks_offsets (points->coords[4], points->coords[5], 
					    points->coords[2], points->coords[3],
					    &mxoff, &myoff, &atype);
		
		id = g_strdup_printf ("ce%d1", nb_connect);
		shape = browser_canvas_canvas_shape_find (retval, id);
		if (shape) {
			g_object_set (shape->item, 
				      "x", points->coords[2] + mxoff,
				      "y", points->coords[3] + myoff, 
				      "anchor", atype, NULL);
			shape->_used = TRUE;
			g_free (id);
		}
		else {
			item = goo_canvas_text_new (parent, "*", 
						    points->coords[2] + mxoff,
						    points->coords[3] + myoff, -1,
						    atype, NULL);
			retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
		}
	}
	
	if (ext & CANVAS_SHAPE_EXT_JOIN_OUTER_2) {
		gdouble mxoff, myoff;
		GooCanvasAnchorType atype;
		
		compute_text_marks_offsets (points->coords[2], points->coords[3], 
					    points->coords[4], points->coords[5],
					    &mxoff, &myoff, &atype);

		id = g_strdup_printf ("ce%d2", nb_connect);
		shape = browser_canvas_canvas_shape_find (retval, id);
		if (shape) {
			g_object_set (shape->item, 
				      "x", points->coords[2] + mxoff,
				      "y", points->coords[3] + myoff, 
				      "anchor", atype, NULL);
			shape->_used = TRUE;
			g_free (id);
		}
		else {
			item = goo_canvas_text_new (parent, "*", 
						    points->coords[2] + mxoff,
						    points->coords[3] + myoff, -1,
						    atype, NULL);
			retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
		}
	}

	goo_canvas_points_unref (points);

	return retval;
}
Ejemplo n.º 28
0
static void
display_confirm(gchar *title,
		gchar *question_text,
		gchar *yes_text,
		gchar *no_text,
		ConfirmCallBack iscb) {

  if(rootitem)
    return;

  bg_x = BG_X;
  bg_y = BG_Y;

  titre_x = T_X;
  titre_w = T_W;
  titre_y = T_Y;;
  titre_h = T_H;


  text_zone_x = T_Z_X;
  text_zone_w = T_Z_W;
  text_zone_y = T_Z_Y;
  text_zone_h = T_Z_H;


  button_x = T_B_X;
  button_w = T_B_W;
  button_y = T_B_Y;
  button_h = T_B_Y;
  button_x_int = T_B_X_INT;

  gc_bar_hide(TRUE);

  gc_board_pause(TRUE);

  confirmCallBack=iscb;

  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
				   NULL);

  goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#DIALOG",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);

  /* Title */
  goo_canvas_text_new (rootitem,
		       title,
		       titre_x + titre_w/2,
		       titre_y + titre_h/2,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_title,
		       "fill-color-rgba",  gc_skin_color_title,
		       NULL);

  text = goo_canvas_text_new (rootitem,
			      question_text,
			      text_zone_x,
			      text_zone_y,
			      500,
			      GTK_JUSTIFY_CENTER,
			      "font", gc_skin_font_title,
			      "fill-color-rgba",  gc_skin_color_title,
			      NULL);

  /*
   * Buttons
   * -------
   */

  GooCanvasBounds bounds;
  // CANCEL
  no_button = goo_canvas_svg_new (rootitem,
				  gc_skin_rsvg_get(),
				  "svg-id", "#BUTTON_TEXT",
				  NULL);
  goo_canvas_item_get_bounds(no_button, &bounds);
  gint button_width = bounds.x2 - bounds.x1;
  button_x += button_width / 2;
  SET_ITEM_LOCATION_CENTER(no_button,
			   button_x,
			   button_y + 2*button_h/3);

  g_signal_connect(no_button, "button_press_event",
		     (GtkSignalFunc) button_event,
		     "/no/");

  gc_item_focus_init(no_button, NULL);

  // CANCEL CROSS
  no_cross = goo_canvas_svg_new (rootitem,
				 gc_skin_rsvg_get(),
				 "svg-id", "#UNCHECKED",
				 NULL);
  SET_ITEM_LOCATION_CENTER(no_cross,
			   button_x ,
			   button_y + 2*button_h/3);

  g_signal_connect(no_cross, "button_press_event",
		     (GtkSignalFunc) button_event,
		     "/no/");
  gc_item_focus_init(no_cross, no_button);


  goo_canvas_text_new (rootitem,
		       no_text,
		       (gdouble)  button_x + button_width/2 + button_x_int ,
		       (gdouble)  button_y + 2*button_h/3,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_subtitle,
		       "fill-color-rgba", gc_skin_get_color("gcompris/helpfg"),
		       NULL);

  // OK
  yes_button = goo_canvas_svg_new (rootitem,
				   gc_skin_rsvg_get(),
				   "svg-id", "#BUTTON_TEXT",
				   NULL);

  SET_ITEM_LOCATION_CENTER(yes_button,
			   button_x ,
			   button_y + button_h/3);

  g_signal_connect(yes_button, "button_press_event",
		     (GtkSignalFunc) button_event,
		     "/yes/");

  gc_item_focus_init(yes_button, NULL);

  // OK stick
  yes_stick = goo_canvas_svg_new (rootitem,
				    gc_skin_rsvg_get(),
				    "svg-id", "#CHECKED",
				     NULL);
  SET_ITEM_LOCATION_CENTER(yes_stick,
			   button_x ,
			   button_y + button_h/3);


  g_signal_connect(yes_stick, "button_press_event",
		     (GtkSignalFunc) button_event,
		     "/yes/");
  gc_item_focus_init(yes_stick, yes_button);

  goo_canvas_text_new (rootitem,
		       yes_text,
		       (gdouble)  button_x + button_width/2 + button_x_int ,
		       (gdouble)  button_y + button_h/3,
		       -1,
		       GTK_ANCHOR_WEST,
		       "font", gc_skin_font_subtitle,
		       "fill-color-rgba", gc_skin_get_color("gcompris/helpfg"),
		       NULL);

  confirm_displayed = TRUE;

}
Ejemplo n.º 29
0
static void
display_files(GooCanvasItem *root_item, gchar *rootdir)
{
  GooCanvasItem *item;
  const gchar *one_dirent;
  GDir  *dir;

  /* Initial image position */
  guint ix  = 0.0;
  guint iy  = 30.0;

  GtkWidget	  *w;
  GooCanvasItem *bg_item;

  GtkWidget *canvas; /* The scrolled part */

  GList  *dir_list  = NULL;
  GList  *file_list = NULL;
  GList  *listrunner;

  GtkAdjustment *adj;

  if(!rootitem)
    return;

  /* Display the directory content */
  dir = g_dir_open(rootdir, 0, NULL);

  if (!dir) {
    g_warning("gcompris_file_selector : no root directory found in %s", rootdir);
    g_free(rootdir);
    return;
  }

  /* Delete the previous file root if any */
  if(file_root_item)
    goo_canvas_item_remove(file_root_item);

  /* Create a root item to put the image list in it */
  file_root_item = goo_canvas_group_new (root_item, NULL);

  /*
   * Create the scrollbar
   * --------------------
   */
  canvas = goo_canvas_new();

  goo_canvas_widget_new (file_root_item,
			 canvas,
			 DRAWING_AREA_X1,
			 DRAWING_AREA_Y1,
			 DRAWING_AREA_X2 - DRAWING_AREA_X1 - 20.0,
			 DRAWING_AREA_Y2 - DRAWING_AREA_Y1 - 35.0,
			 NULL);

  gtk_widget_show (canvas);

  /* Set the new canvas to the background color or it's white */
  bg_item = goo_canvas_rect_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
				 0,
				 0,
				 DRAWING_AREA_X2 - DRAWING_AREA_X1 + 200,
				 DRAWING_AREA_Y2 - DRAWING_AREA_Y1,
				 "fill-color-rgba", gc_skin_get_color("gcompris/fileselectbg"),
				 "line-width", 0.0,
				 NULL);


  adj = \
    GTK_ADJUSTMENT (gtk_adjustment_new (0.00, 0.00,
					IMAGE_HEIGHT,
					10, IMAGE_HEIGHT,
					(DRAWING_AREA_Y2 - DRAWING_AREA_Y1)/3)
		    );
  w = gtk_vscrollbar_new (adj);

  goo_canvas_widget_new (file_root_item,
			 w,
			 DRAWING_AREA_X2 - 15.0,
			 DRAWING_AREA_Y1,
			 30.0,
			 DRAWING_AREA_Y2 - DRAWING_AREA_Y1 - 20.0,
			 NULL);
  gtk_widget_show (w);

  /* Set the scrollwheel event */
  g_signal_connect (adj, "value_changed",
		    (GtkSignalFunc) item_event_scroll,
		    canvas);

  /* Display the directory name
   * --------------------------
   */

  item = goo_canvas_text_new (file_root_item,
			      rootdir,
			      (gdouble)control_area_x1,
			      (gdouble)directory_label_y,
			      -1,
			      GTK_ANCHOR_NW,
			      "font", "Sans 7",
			      "fill-color-rgba",
			      gc_skin_get_color("gcompris/fileselectcol"),
			      NULL);

  /* Insert all files in a sorted list */

  while((one_dirent = g_dir_read_name(dir)) != NULL)
    {
      gchar *filename;

      filename = g_strdup_printf("%s/%s",
				 rootdir, (gchar*)(one_dirent));

      if(g_file_test(filename, G_FILE_TEST_IS_DIR))
	{
	  dir_list = g_list_insert_sorted(dir_list, filename,
					  (GCompareFunc)strcmp);
	}
      else
	{
	  file_list = g_list_insert_sorted(file_list, filename,
					   (GCompareFunc)strcmp);
	}
    }

  /* Concat the directory list and file list */
  file_list = g_list_concat(dir_list, file_list);

  g_list_free(dir_list);
  dir_list = NULL;

  /* We have the list sorted, now display it */
  listrunner = g_list_first(file_list);
  while(listrunner)
    {
      /* add the file to the display */
      gchar *svg_id;

      gchar *allfilename = listrunner->data;
      gchar *filename    = g_path_get_basename(allfilename);
      gchar *ext = g_strrstr(filename, ".");
      gchar *file_wo_ext = g_strdup(filename);

      if(ext)
	{
	  gchar *ext2 = g_strrstr(file_wo_ext, ".");
	  *ext2 = '\0';
	}

      if(g_file_test(allfilename, G_FILE_TEST_IS_DIR))
	svg_id = "#FOLDER";
      else
	svg_id = "#FILE";

      item = goo_canvas_svg_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
				 gc_skin_rsvg_get(),
				 "svg-id", svg_id,
				 NULL);

      SET_ITEM_LOCATION_CENTER(item,
			       ix + (IMAGE_WIDTH + IMAGE_GAP)/2,
			       iy);

      if(g_file_test(allfilename, G_FILE_TEST_IS_DIR))
	{
	  g_signal_connect(item, "button_press_event",
			   (GtkSignalFunc) item_event_directory,
			   allfilename);
	}
      else
	{
	  g_signal_connect(item, "button_press_event",
			   (GtkSignalFunc) item_event_file_selector,
			   allfilename);
	}
      gc_item_focus_init(item, NULL);

      g_object_set_data_full (G_OBJECT (item),
			      "allfilename", allfilename, g_free);
      /* The type */
      if(ext)
	{
	  GooCanvasItem *_item = \
	    goo_canvas_text_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
				 ext,
				 ix + (IMAGE_WIDTH + IMAGE_GAP)/2,
				 iy + 10,
				 -1,
				 GTK_ANCHOR_CENTER,
				 "font", "Sans 6",
				 "fill-color-rgba",
				 gc_skin_get_color("gcompris/fileselectcol"),
				 NULL);
	  g_signal_connect(_item, "button_press_event",
			   (GtkSignalFunc) item_event_file_selector,
			   allfilename);
	  gc_item_focus_init(_item, item);
	}

      /* The filename */
      GooCanvasItem *name_item = \
	goo_canvas_text_new (goo_canvas_get_root_item(GOO_CANVAS(canvas)),
			     file_wo_ext,
			     ix + (IMAGE_WIDTH + IMAGE_GAP)/2,
			     iy + IMAGE_HEIGHT - 30,
			     -1,
			     GTK_ANCHOR_CENTER,
			     "font", "Sans 7",
			     "fill-color-rgba", gc_skin_get_color("gcompris/fileselectcol"),
			     NULL);
      g_free(file_wo_ext);
      g_free(filename);

      if(g_file_test(allfilename, G_FILE_TEST_IS_DIR))
	{
	  g_signal_connect(name_item, "button_press_event",
			   (GtkSignalFunc) item_event_directory,
			   allfilename);
	}
      else
	{
	  g_signal_connect(name_item, "button_press_event",
			   (GtkSignalFunc) item_event_file_selector,
			   allfilename);
	}
      gc_item_focus_init(name_item, item);

      ix += IMAGE_WIDTH + IMAGE_GAP;

      if(ix >= DRAWING_AREA_X2 - DRAWING_AREA_X1 -
	 (IMAGE_WIDTH + IMAGE_GAP) )
	{
	  ix=0;

	  iy+=IMAGE_HEIGHT + IMAGE_GAP;

	  goo_canvas_set_bounds (GOO_CANVAS(canvas),
				 0, 0,
				 DRAWING_AREA_X2- DRAWING_AREA_X1,
				 iy + IMAGE_HEIGHT + IMAGE_GAP);

	  if(iy >= DRAWING_AREA_Y2-DRAWING_AREA_Y1)
	    {
	      g_object_set(bg_item,
			   "height", (double)iy + IMAGE_HEIGHT + IMAGE_GAP,
			   NULL);
	      g_object_set(adj,
			   "upper", (double)iy - IMAGE_HEIGHT + IMAGE_GAP - 1,
			   NULL);
	    }
	}
      listrunner = g_list_next(listrunner);
    }

  g_dir_close(dir);
  g_list_free(file_list);

}
Ejemplo n.º 30
0
/*
 * Computes the points' coordinates of the line going from
 * @ref_pk_ent to @fk_ent (which are themselves rectangles)
 *
 * if @shapes is not NULL, then the shapes in the list are reused, and the ones which don't need
 * to exist anymore are removed
 *
 * Returns a list of BrowserCanvasCanvasShapes structures
 */
GSList *
browser_canvas_util_compute_anchor_shapes (GooCanvasItem *parent, GSList *shapes,
					   BrowserCanvasTable *fk_ent, BrowserCanvasTable *ref_pk_ent, 
					   guint nb_anchors, guint ext, gboolean with_handle)
{
	GSList *retval = shapes;
	guint i;
	gdouble fx1, fy1, fx2, fy2; /* FK entity item (bounds) */
	gdouble rx1, ry1, rx2, ry2; /* REF PK entity item  (bounds) */

	BrowserCanvasCanvasShape *shape;
	gchar *id;

	gdouble rcx, rcy; /* center of ref_pk entity item */
	gdouble cx, cy;

	gdouble rux, ruy; /* current ref_pk point for the arrow line */
	gdouble dx, dy; /* increments to compute the new ref_pk point for the arrow line */
	GooCanvasBounds bounds;

	g_return_val_if_fail (nb_anchors > 0, NULL);

	browser_canvas_table_get_anchor_bounds (fk_ent, &bounds);
	fx1 = bounds.x1;
	fy1 = bounds.y1;
	fx2 = bounds.x2;
	fy2 = bounds.y2;
	browser_canvas_table_get_anchor_bounds (ref_pk_ent, &bounds);
	rx1 = bounds.x1;
	ry1 = bounds.y1;
	rx2 = bounds.x2;
	ry2 = bounds.y2;

	/* compute the cx, cy, dx and dy values */
	rcx = (rx1 + rx2) / 2.;
	rcy = (ry1 + ry2) / 2.;
	cx = (fx1 + fx2) / 2.;
	cy = (fy1 + fy2) / 2.;
	rux = rcx;
	ruy = rcy;
	dx = 0;
	dy = 0;

	for (i = 0; i < nb_anchors; i++) {
		/* TODO:
		   - detect tables overlapping
		*/		
		if ((rcx == cx) && (rcy == cy)) {
			/* tables have the same center (includes case when they are equal) */
			gdouble Dy, Dx;
			GooCanvasPoints *ap, *points;
			GooCanvasItem *item;
			
			points = goo_canvas_points_new (4);
			ap = goo_canvas_points_new (4);

			Dy = (ry2 - ry1) / 2. / (gdouble ) (nb_anchors + 1) * (gdouble) (i + 1);
			Dx = (rx2 - rx1) * (0.8 + 0.1 * i);
			if (! compute_intersect_rect_line (rx1, ry1, rx2, ry2,
							   cx, cy, cx + Dx, cy - Dy,
							   &(ap->coords[0]), &(ap->coords[1]),
							   &(ap->coords[2]), &(ap->coords[3])))
				return retval;
			
			if (ap->coords[0] > ap->coords[2]) {
				points->coords[0] = ap->coords[0];
				points->coords[1] = ap->coords[1];
			}
			else {
				points->coords[0] = ap->coords[2];
				points->coords[1] = ap->coords[3];
			}

			points->coords[2] = cx + Dx;
			points->coords[3] = cy - Dy;

			Dy = (fy2 - fy1) / 2. / (gdouble ) (nb_anchors + 1) * (gdouble) (i + 1);
			Dx = (fx2 - fx1) * (0.8 + 0.1 * i);
			points->coords[4] = cx + Dx;
			points->coords[5] = cy + Dy;

			if (! compute_intersect_rect_line (fx1, fy1, fx2, fy2,
							   cx, cy, cx + Dx, cy + Dy,
							   &(ap->coords[0]), &(ap->coords[1]),
							   &(ap->coords[2]), &(ap->coords[3])))
				return retval;
			
			if (ap->coords[0] > ap->coords[2]) {
				points->coords[6] = ap->coords[0];
				points->coords[7] = ap->coords[1];
			}
			else {
				points->coords[6] = ap->coords[2];
				points->coords[7] = ap->coords[3];
			}
			
			id = g_strdup_printf ("a%d", i);
			shape = browser_canvas_canvas_shape_find (retval, id);
			if (shape) {
				g_object_set (shape->item, "points", points, NULL);
				shape->_used = TRUE;
				g_free (id);
			}
			else {
				item = goo_canvas_polyline_new_line (parent, 
								     points->coords[0], points->coords [1],
								     points->coords[2], points->coords [3],
								     "close-path", FALSE,
								     "points", points, NULL);
				retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
			}
			goo_canvas_points_unref (ap);
			
			/* extension marks as text */
			if (ext & CANVAS_SHAPE_EXT_JOIN_OUTER_1) {
				id = g_strdup_printf ("a%de1", i);
				shape = browser_canvas_canvas_shape_find (retval, id);
				if (shape) {
					g_object_set (shape->item, 
						      "x", points->coords[2] + 5.,
						      "y", points->coords[3] - 5., NULL);
					shape->_used = TRUE;
					g_free (id);
				}
				else {
					item = goo_canvas_text_new (parent, "*", 
								    points->coords[2] + 5.,
								    points->coords[3] - 5., -1,
								    GOO_CANVAS_ANCHOR_SOUTH, NULL);
					retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
				}
			}

			if (ext & CANVAS_SHAPE_EXT_JOIN_OUTER_2) {
				id = g_strdup_printf ("a%de2", i);
				if (shape) {
					g_object_set (shape->item, 
						      "x", points->coords[4] + 5.,
						      "y", points->coords[5] + 5., NULL);
					shape->_used = TRUE;
					g_free (id);
				}
				else {
					item = goo_canvas_text_new (parent, "*", 
								    points->coords[4] + 5.,
								    points->coords[5] + 5., -1,
								    GOO_CANVAS_ANCHOR_NORTH, NULL);
					retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
				}
			}
			
			goo_canvas_points_unref (points);
		}
		else {
			GooCanvasPoints *ap, *points;
			GooCanvasItem *item;

			points = goo_canvas_points_new (2);
			ap = goo_canvas_points_new (4);

			if (nb_anchors > 1) {
				if ((dx == 0) && (dy == 0)) {
					/* compute perpendicular to D={(rcx, rcy), (cx, cy)} */
					gdouble vx = (rcx - cx), vy = (rcy - cy);
					gdouble tmp;
					
					tmp = vx;
					vx = vy;
					vy = - tmp;
					
					/* compute intersect of ref_pkey rectangle and D=[vx, vy] passing at (rcx, rcy) */
					if (! compute_intersect_rect_line (rx1, ry1, rx2, ry2,
									   rcx, rcy, rcx + vx, rcy + vy,
									   &(ap->coords[0]), &(ap->coords[1]),
									   &(ap->coords[2]), &(ap->coords[3])))
						return retval;
					dx = (ap->coords[2] - ap->coords[0]) / (gdouble) (nb_anchors  + 1);
					dy = (ap->coords[3] - ap->coords[1]) / (gdouble) (nb_anchors  + 1);
					rux = ap->coords[0];
					ruy = ap->coords[1];
				}

				rux += dx;
				ruy += dy;
			}
			
			/* compute the 4 intersection points */
			if (! compute_intersect_rect_line (rx1, ry1, rx2, ry2,
							   rux, ruy, cx, cy,
							   &(ap->coords[0]), &(ap->coords[1]),
							   &(ap->coords[2]), &(ap->coords[3])))
				return retval;
			if (! compute_intersect_rect_line (fx1, fy1, fx2, fy2,
							   rux, ruy, cx, cy,
							   &(ap->coords[4]), &(ap->coords[5]),
							   &(ap->coords[6]), &(ap->coords[7])))
				return retval;
			
			/* choosing between point coords(0,1) and coords(2,3) */
			if (((ap->coords[0] - ap->coords[4]) * (ap->coords[0] - ap->coords[4]) + 
			     (ap->coords[1] - ap->coords[5]) * (ap->coords[1] - ap->coords[5])) <
			    ((ap->coords[2] - ap->coords[4]) * (ap->coords[2] - ap->coords[4]) + 
			     (ap->coords[3] - ap->coords[5]) * (ap->coords[3] - ap->coords[5]))) {
				points->coords[0] = ap->coords[0];
				points->coords[1] = ap->coords[1];
			}
			else {
				points->coords[0] = ap->coords[2];
				points->coords[1] = ap->coords[3];
			}
			
			/* choosing between point coords(4,5) and coords(6,7) */
			if (((points->coords[0] - ap->coords[4]) * (points->coords[0] - ap->coords[4]) +
			     (points->coords[1] - ap->coords[5]) * (points->coords[1] - ap->coords[5])) <
			    ((points->coords[0] - ap->coords[6]) * (points->coords[0] - ap->coords[6]) +
			     (points->coords[1] - ap->coords[7]) * (points->coords[1] - ap->coords[7]))) {
				points->coords[2] = ap->coords[4];
				points->coords[3] = ap->coords[5];
			}
			else {
				points->coords[2] = ap->coords[6];
				points->coords[3] = ap->coords[7];
			}
			
			id = g_strdup_printf ("a%d", i);
			shape = browser_canvas_canvas_shape_find (retval, id);
			if (shape) {
				g_object_set (shape->item, "points", points, NULL);
				shape->_used = TRUE;
				g_free (id);
			}
			else {
				item = goo_canvas_polyline_new_line (parent, 
								     points->coords[0], points->coords [1],
								     points->coords[2], points->coords [3],
								     "close-path", FALSE,
								     "points", points, NULL);
				retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
			}
			goo_canvas_points_unref (ap);

			/* extension marks as text */
			if (ext & CANVAS_SHAPE_EXT_JOIN_OUTER_1) {
				gdouble mxoff = 0., myoff = 0.;
				GooCanvasAnchorType atype;

				compute_text_marks_offsets (points->coords[0], points->coords[1], 
							    points->coords[2], points->coords[3],
							    &mxoff, &myoff, &atype);
				id = g_strdup_printf ("a%de1", i);
				shape = browser_canvas_canvas_shape_find (retval, id);
				if (shape) {
					g_object_set (shape->item, 
						      "x", points->coords[2] + mxoff,
						      "y", points->coords[3] + myoff, 
						      "anchor", atype, NULL);
					shape->_used = TRUE;
					g_free (id);
				}
				else {
					item = goo_canvas_text_new (parent, "*", 
								    points->coords[2] + mxoff,
								    points->coords[3] + myoff, -1,
								    atype, NULL);
					retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
				}
			}

			if (ext & CANVAS_SHAPE_EXT_JOIN_OUTER_2) {
				gdouble mxoff, myoff;
				GooCanvasAnchorType atype;
				
				compute_text_marks_offsets (points->coords[2], points->coords[3], 
							    points->coords[0], points->coords[1],
							    &mxoff, &myoff, &atype);

				id = g_strdup_printf ("a%de2", i);
				if (shape) {
					g_object_set (shape->item, 
						      "x", points->coords[0] + mxoff,
						      "y", points->coords[1] + myoff, 
						      "anchor", atype, NULL);
					shape->_used = TRUE;
					g_free (id);
				}
				else {
					item = goo_canvas_text_new (parent, "*", 
								    points->coords[0] + mxoff,
								    points->coords[1] + myoff, -1,
								    atype, NULL);
					retval = browser_canvas_canvas_shape_add_to_list (retval, id, item);
				}
			}

			goo_canvas_points_unref (points);
		}
	}

	return retval;
}