示例#1
0
文件: config.c 项目: GNOME/gcompris
/*-------------------------------------------------------------------------------*/
static void
display_previous_next(guint x_start, guint y_start,
		      gchar *eventname_previous, gchar *eventname_next)
{
  GooCanvasItem *item;
  GooCanvasBounds bounds;

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#PREVIOUS",
			     NULL);
  goo_canvas_item_get_bounds(item, &bounds);
  SET_ITEM_LOCATION(item,
		    x_start - (bounds.x2 - bounds.x1) - 10,
		    y_start - pixmap_width/2);

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


  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#NEXT",
			     NULL);
  SET_ITEM_LOCATION(item,
		    x_start,
		    y_start - pixmap_width/2);

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_ok,
		   eventname_next);
  gc_item_focus_init(item, NULL);
}
示例#2
0
文件: menu2.c 项目: nnagabus/GCompris
/**
 * Display the number of stars representing the difficulty level at the x,y location
 * The stars are created in a group 'parent'
 * The new group in which the stars are created is returned.
 */
static GooCanvasItem *
menu_difficulty_display(GooCanvasItem *parent,
                        double x, double y,
                        double ratio,
                        gint difficulty)
{
    GooCanvasItem *stars_group = NULL;
    GooCanvasItem *item = NULL;
    gchar *svg_id = NULL;

    if(difficulty==0 || difficulty>6)
        return NULL;

    svg_id = g_strdup_printf("#DIFFICULTY%d", difficulty);

    stars_group = goo_canvas_group_new (parent, NULL);

    item = goo_canvas_svg_new (stars_group,
                               gc_skin_rsvg_get(),
                               "svg-id", svg_id,
                               "pointer-events", GOO_CANVAS_EVENTS_NONE,
                               NULL);
    SET_ITEM_LOCATION(item, x, y);

    g_free(svg_id);

    return(stars_group);
}
示例#3
0
文件: menu2.c 项目: nnagabus/GCompris
static void
display_welcome (MenuItems *menuitems)
{
    GooCanvasItem *item;
    RsvgHandle  *svg_handle;

    if (actualSectionItem)
        g_error("actualSectionItem exists in display_section !");


    actualSectionItem = goo_canvas_group_new(boardRootItem,
                        NULL);

    svg_handle = gc_skin_rsvg_get();
    item = goo_canvas_svg_new (actualSectionItem,
                               svg_handle,
                               "svg-id", "#LOGO",
                               NULL);
    SET_ITEM_LOCATION_CENTER(item,
                             display_x + display_w/2.0,
                             display_y + display_h/3.0);

    display_sponsor(actualSectionItem);

    g_signal_connect (item, "enter_notify_event",
                      (GCallback) display_welcome_event, menuitems);
    g_signal_connect (item, "leave_notify_event",
                      (GCallback) on_leave_notify, menuitems);

    menu_displayed = TRUE;
}
示例#4
0
/* Return a new button item */
GooCanvasItem *
new_button(GooCanvasItem *rootitem,
	   RsvgHandle *svg_handle,
           GComprisBarFlags flag,
           gchar *svg_id)
{
  GooCanvasItem *item =
    goo_canvas_svg_new (rootitem,
			svg_handle,
			"svg-id", svg_id,
			NULL);
  SET_ITEM_LOCATION(item, 0, 0);

  g_object_set (item,
                "visibility", GOO_CANVAS_ITEM_VISIBLE,
                NULL);
  g_object_set_data (G_OBJECT(item), "flag",
		     GUINT_TO_POINTER(flag));
  g_signal_connect (item, "enter_notify_event",
		    (GtkSignalFunc) on_enter_notify,
                    GUINT_TO_POINTER(flag));
  g_signal_connect (item, "leave_notify_event",
		    (GtkSignalFunc) on_leave_notify,
                    GUINT_TO_POINTER(flag));
  g_signal_connect(item, "button_press_event",
		   (GtkSignalFunc) item_event_bar,
		   GUINT_TO_POINTER(flag));
  return item;
}
示例#5
0
文件: menu2.c 项目: nnagabus/GCompris
/**
 * Display the demo only icon
 */
static GooCanvasItem *
menu_demo_display(GooCanvasItem *parent,
                  gdouble x, gdouble y)
{
    GooCanvasItem *item = goo_canvas_svg_new (parent,
                          gc_skin_rsvg_get(),
                          "svg-id", "#UNCHECKED",
                          "pointer-events", GOO_CANVAS_EVENTS_NONE,
                          NULL);
    SET_ITEM_LOCATION(item, x, y);
    return(item);
}
示例#6
0
static void display_paying_note(guint note, guint x, guint y)
{
  gchar *note_str = g_strdup_printf("money/n%de.svgz", note);
  RsvgHandle *svg_handle;
  svg_handle = gc_rsvg_load(note_str);
  GooCanvasItem *item = goo_canvas_svg_new(boardRootItem,
					   svg_handle,
					   NULL);
  goo_canvas_item_translate(item, x, y);
  goo_canvas_item_scale(item, 0.25, 0.25);
  g_object_unref(svg_handle);
  g_free(note_str);
}
示例#7
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);
}
示例#8
0
文件: menu2.c 项目: nnagabus/GCompris
static void menu_start (GcomprisBoard *agcomprisBoard)
{

    current_x = 0.0;
    current_y = 0.0;

    /* initialisations */
    /* in case we will make this parametrable */

    panel_x = P_X;
    panel_y = P_Y;
    panel_w = P_W;
    panel_h = P_H;

    top_x = T_X;
    top_y = T_Y;
    top_w = T_W;
    top_h = T_H;
    top_int_x = T_INT_X;
    top_arrow_size = T_ARROW_SIZE;

    display_x = D_X;
    display_y = D_Y;
    display_w = D_W;
    display_h = D_H;
    display_int_x = D_INT_X;
    display_int_y = D_INT_Y;

    info_x = I_X;
    info_y = I_Y;
    info_w = I_W;
    info_h = I_H;

    icon_size = ICON_SIZE;
    icon_size_panel = ICON_SIZE_PANEL;
    icon_size_top = ICON_SIZE_TOP;

    if(agcomprisBoard != NULL)
    {
        RsvgHandle *svg_handle;

        gcomprisBoard=agcomprisBoard;

        /* set initial values for this level */
        gcomprisBoard->level = 1;
        gcomprisBoard->maxlevel=1;

        /* Set back the bar to it's original location */
        gc_bar_set(GC_BAR_CONFIG|GC_BAR_ABOUT|GC_BAR_JOURNAL|GC_BAR_SHARE);

        menuitems = g_new(MenuItems, 1);

        svg_handle = gc_skin_rsvg_get();

        gc_set_background_by_id (goo_canvas_get_root_item(gcomprisBoard->canvas),
                                 svg_handle,
                                 "#BACKGROUND");

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

        g_object_set_data_full(G_OBJECT (boardRootItem),
                               "menuitems", menuitems, g_free);

        goo_canvas_svg_new (boardRootItem,
                            svg_handle,
                            "svg-id", "#SELECTOR",
                            "pointer-events", GOO_CANVAS_EVENTS_NONE,
                            NULL);

        goo_canvas_svg_new (boardRootItem,
                            svg_handle,
                            "svg-id", "#BUTTON_HORIZONTAL",
                            "pointer-events", GOO_CANVAS_EVENTS_NONE,
                            NULL);

        create_info_area(boardRootItem, menuitems);

        create_panel(boardRootItem);

        if (menu_position)
            display_section(menu_position);
        else
            display_welcome(menuitems);

        {
            if ( strcmp(gc_prop_get()->profile->name, GC_PROFILE_DEFAULT) != 0 )
            {
                gchar *text = g_strdup_printf(_("Profile: %s"),
                                              gc_prop_get()->profile->name);
                goo_canvas_text_new (boardRootItem,
                                     text,
                                     BOARDWIDTH - 10,
                                     BOARDHEIGHT - 30,
                                     -1,
                                     GTK_ANCHOR_EAST,
                                     "font", gc_skin_font_board_tiny,
                                     "fill-color-rgba", gc_skin_get_color("menu/text"),
                                     "alignment", PANGO_ALIGN_RIGHT,
                                     NULL);
                g_free(text);
            }
        }

        {
            gchar *text = g_strdup_printf(_("Number of activities: %d"),
                                          gc_board_get_number_of_activity());
            goo_canvas_text_new (boardRootItem,
                                 text,
                                 BOARDWIDTH - 10,
                                 BOARDHEIGHT - 10,
                                 -1,
                                 GTK_ANCHOR_EAST,
                                 "font", gc_skin_font_board_tiny,
                                 "fill-color-rgba", gc_skin_get_color("menu/text"),
                                 "alignment", PANGO_ALIGN_RIGHT,
                                 NULL);
            g_free(text);
        }

        menu_pause(FALSE);

    }

}
示例#9
0
/* set initial values for the next level */
static void planegame_next_level()
{
    RsvgHandle *svg_handle = NULL;
    GooCanvasItem *item;

    gc_bar_set_level(gcomprisBoard);

    planegame_destroy_all_items();

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

    clouds_rootitem = goo_canvas_group_new (rootitem, NULL);

    /* Try the next level */
    speed=100+(40/(gcomprisBoard->level));
    fallSpeed=10000-gcomprisBoard->level*200;
    /* Make the images tend to 0.5 ratio */
    imageZoom=0.3+(0.5/(gcomprisBoard->level));

    /* Setup and Display the plane */
    planespeed_y = 0;
    planespeed_x = 0;
    svg_handle = gc_rsvg_load("planegame/tuxhelico.svgz");
    plane_x = 50;
    plane_y = 300;

    planeitem = goo_canvas_group_new (rootitem,
                                      NULL);

    goo_canvas_item_translate(planeitem, plane_x, plane_y);

    item = goo_canvas_svg_new (planeitem,
                               svg_handle,
                               NULL);

    goo_canvas_item_scale(item,
                          0.4 * imageZoom,
                          0.4 * imageZoom);

    g_object_unref(svg_handle);

    /* Game rules */
    plane_target = 1;
    plane_last_target = 10;

    gcomprisBoard->number_of_sublevel=plane_last_target;

    gcomprisBoard->sublevel=plane_target;

    if(gcomprisBoard->level>1)
    {
        /* No scoring after level 1 */
        gc_score_end();
    }
    else
    {
        gc_score_start(SCORESTYLE_NOTE,
                       BOARDWIDTH - 195,
                       BOARDHEIGHT - 30,
                       gcomprisBoard->number_of_sublevel);
        gc_score_set(gcomprisBoard->sublevel);
    }

}
示例#10
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;
}
示例#11
0
文件: config.c 项目: GNOME/gcompris
/*
 * 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;
}
示例#12
0
文件: menu2.c 项目: nnagabus/GCompris
static void menu_create_item(GooCanvasItem *parent, MenuItems *menuitems, GcomprisBoard *board)
{
    GdkPixbuf *menu_pixmap = NULL;
    GooCanvasItem *menu_button;
    int difficulty;
    gdouble ratio, pixmap_w, pixmap_h;

    menu_pixmap = gc_pixmap_load(board->icon_name);

    ratio = get_ratio (menu_pixmap, icon_size);

    pixmap_w = gdk_pixbuf_get_width(menu_pixmap) * ratio;
    pixmap_h = gdk_pixbuf_get_height(menu_pixmap) * ratio;

    next_spot();

    menu_button = goo_canvas_image_new (parent,
                                        menu_pixmap,
                                        current_x - pixmap_w/2,
                                        current_y - pixmap_h/2,
                                        NULL);
    goo_canvas_item_scale(menu_button, ratio, ratio);

    // display board availability due to sound voice not present
    if(board->mandatory_sound_file)
    {
        gchar *soundfile = NULL;

        /* We search a fixed path sound file */
        soundfile = gc_file_find_absolute(board->mandatory_sound_file);

        if (!soundfile || !gc_prop_get()->fx) {
            GooCanvasItem *item =			\
                                            goo_canvas_svg_new (parent,
                                                    gc_skin_rsvg_get(),
                                                    "svg-id", "#SOUND_UNCHECKED",
                                                    "pointer-events", GOO_CANVAS_EVENTS_NONE,
                                                    NULL);

            GooCanvasBounds bounds;
            goo_canvas_item_get_bounds(item, &bounds);

            SET_ITEM_LOCATION(item,
                              current_x - pixmap_w/2 - 25 -
                              (bounds.x2 - bounds.x1)/2,
                              current_y - pixmap_h/2 + 28-
                              (bounds.y2 - bounds.y1)/2);
        }

        g_free(soundfile);
    }

    // display menu icon ========================== BEGIN
    if(g_ascii_strcasecmp(board->type, "menu") == 0)
    {
        GooCanvasItem *item = goo_canvas_svg_new (parent,
                              gc_skin_rsvg_get(),
                              "svg-id", "#MENUICON",
                              "pointer-events", GOO_CANVAS_EVENTS_NONE,
                              NULL);
        SET_ITEM_LOCATION(item,
                          current_x - pixmap_w/2 - 25,
                          current_y - pixmap_h/2);
    }
    else
    {
        // display difficulty stars
        if (board->difficulty != NULL)
        {
            difficulty = atoi(board->difficulty);
            menu_difficulty_display(parent,
                                    (double)current_x - pixmap_w/2 - 25,
                                    (double)current_y - pixmap_h/2,
                                    (double) 0.6,
                                    difficulty);
        }

        if ( gc_board_is_demo_only(board) )
            menu_demo_display(parent,
                              (gdouble)(current_x - pixmap_w/2 - 20),
                              (gdouble)(current_y - pixmap_h/2 + 60) );
    }


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

    // display menu icon ========================== END

    /*
     * Now everything ready, map the events
     * -------------------------------------
     */
    g_object_set_data (G_OBJECT (menu_button), "board", board);

    g_signal_connect(menu_button, "button_press_event",
                     (GCallback) item_event,
                     menuitems);
    g_signal_connect (menu_button, "enter_notify_event",
                      (GCallback) on_enter_notify, menuitems);
    g_signal_connect (menu_button, "leave_notify_event",
                      (GCallback) on_leave_notify, menuitems);

    gc_item_focus_init(menu_button, NULL);

}
示例#13
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;
}
示例#14
0
/* set initial values for the next level */
static void superbrain_next_level()
{
  guint i;
  gboolean selected_color[MAX_COLORS];

  gc_bar_set_level(gcomprisBoard);

  superbrain_destroy_all_items();
  gamewon = FALSE;

  /* Select level difficulty : should not go above MAX_PIECES */
  /* number_of_color must be upper than number_of_piece to allow unicity */

  if(gcomprisBoard->level < LEVEL_MAX_FOR_HELP)
    {
      number_of_piece = gcomprisBoard->level + 2;
      number_of_color = gcomprisBoard->level + 4;
    }
  else
    {
      number_of_piece = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 3;
      number_of_color = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 5;
    }


  current_y_position = BOARDHEIGHT - 50;

  /* Init a random solution : colors choosen are uniquely choosen */
  for(i=0; i<number_of_color; i++)
    {
      selected_color[i] = FALSE;
    }

  for(i=0; i<number_of_piece; i++)
    {
      guint j;

      j = (guint)g_random_int_range(0, number_of_color);
      while(selected_color[j])
	j = (guint)g_random_int_range(0, number_of_color);

      solution[i] = j;
      selected_color[j] = TRUE;
    }

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


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

  /* The OK Button */
  GooCanvasItem *item = goo_canvas_svg_new (boardLogoItem,
					    gc_skin_rsvg_get(),
					    "svg-id", "#OK",
					    NULL);
  SET_ITEM_LOCATION(item, 270, 50);
  g_signal_connect(item, "button_press_event",
		   (GCallback) process_ok, NULL);
  gc_item_focus_init(item, NULL);

  /* The list of the pieces */
  for(i=0; i<number_of_color; i++)
    {
      goo_canvas_ellipse_new (boardLogoItem,
			      PIECE_DISPLAY_X,
			      PIECE_DISPLAY_Y + i*((PIECE_WIDTH*1.5)*2 + PIECE_GAP/2),
			      PIECE_WIDTH * 1.5,
			      PIECE_WIDTH * 1.5,
			      "fill_color_rgba", colors[i],
			      "stroke-color", "white",
			      "line-width", (double)1,
			      NULL);
    }


  superbrain_create_item(boardRootItem);
}
示例#15
0
static int
display_file_selector(int the_mode,
		      GcomprisBoard *gcomprisBoard,
		      gchar *rootdir,
		      gchar *file_exts,
		      FileSelectorCallBack iscb,
		      void *user_context)
{
  gchar            *full_rootdir;

  mode = the_mode;

  /* Get the coordinate x y of the control area from the skin */
  control_area_x1   = gc_skin_get_number_default("gcompris/fileselectx", 85);
  control_area_y1   = gc_skin_get_number_default("gcompris/fileselecty", 80);
  directory_label_y = gc_skin_get_number_default("gcompris/fileselectdiry", 180);

  if(rootitem)
    return 0;

  gc_bar_hide(TRUE);

  gc_board_pause(TRUE);

  fileSelectorCallBack=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", "#FILE_SELECTOR",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);

  /* Entry area */
  widget_entry = gtk_entry_new ();

  if(mode==MODE_SAVE)
    gtk_entry_set_max_length(GTK_ENTRY(widget_entry), 30);

  goo_canvas_widget_new (rootitem,
				GTK_WIDGET(widget_entry),
				control_area_x1,
				control_area_y1,
				230.0,
				30.0,
				NULL);

  gtk_signal_connect(GTK_OBJECT(widget_entry), "activate",
		     GTK_SIGNAL_FUNC(entry_enter_callback),
		     widget_entry);

  gtk_widget_show(widget_entry);

  /*
   * Create the combo with the file types
   * ------------------------------------
   */
  if(mode==MODE_SAVE && file_exts && *file_exts != '\0')
  {
    gchar **all_type = g_strsplit(file_exts, " ", 0);
    guint i = 0;

    gtk_combo_filetypes = gtk_combo_box_new_text();

    /* Extract first string */
    while (all_type[i])
      gtk_combo_box_append_text(GTK_COMBO_BOX(gtk_combo_filetypes),
				g_strdup(all_type[i++]) );

    g_strfreev(all_type);

    goo_canvas_widget_new (rootitem,
			   gtk_combo_filetypes,
			   control_area_x1 + 400,
			   control_area_y1,
			   250.0,
			   35.0,
			   NULL);

    gtk_widget_show(gtk_combo_filetypes);
    gtk_combo_box_set_active(GTK_COMBO_BOX(gtk_combo_filetypes), 0);
  }

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

  // CANCEL
  gc_util_button_text_svg(rootitem,
			  BOARDWIDTH * 1/3,
			  BOARDHEIGHT - 32,
			  "#BUTTON_TEXT",
			  _("CANCEL"),
			  (GtkSignalFunc) item_event_file_selector,
			  "/cancel/");
  // OK
  gc_util_button_text_svg(rootitem,
			  BOARDWIDTH * 2/3,
			  BOARDHEIGHT - 32,
			  "#BUTTON_TEXT",
			  (mode==MODE_LOAD ? _("LOAD") : _("SAVE")),
			  (GtkSignalFunc) item_event_file_selector,
			  "/ok/");

  file_selector_displayed = TRUE;

  full_rootdir = g_strconcat(gc_prop_get()->user_dir, "/", rootdir, NULL);
  gc_util_create_rootdir(full_rootdir);

  current_rootdir = full_rootdir;
  current_user_context = user_context;

  display_files(rootitem, full_rootdir);

  return 0;

}
示例#16
0
/* set initial values for the next level */
static void money_next_level()
{
  guint		   min_price = 0, max_price = 0;
  guint		   paid = 0;
  guint		   number_of_item = 0;
  guint		   i;
  gchar		  *display_format;

  gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
		    "money/money-bg.png");

  gc_bar_set_level(gcomprisBoard);

  money_destroy_all_items();
  gamewon = FALSE;

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


  /* The OK Button */
  GooCanvasItem *item = goo_canvas_svg_new( boardRootItem,
					    gc_skin_rsvg_get(),
					    "svg-id", "#OK",
					    NULL);
  SET_ITEM_LOCATION(item, 725, 230);
  g_signal_connect(item, "button_press_event",
		   (GtkSignalFunc) moneyactivity_process_ok, NULL);
  gc_item_focus_init(item, NULL);

  tux_money = MONEY_WIDGET(money_widget_new());
  money_widget_set_position(tux_money,
			    boardRootItem,
			    100.0, 380.0,
			    700.0, 490.0,
			    5, 2,
			    FALSE);

  /* Select level difficulty */
  switch(currentMode)
    {
    case WITHOUT_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 3;
	  max_price      = 10;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 10;
	  max_price      = 20;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 20;
	  max_price      = 30;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 4:
	  number_of_item = 2;
	  min_price      = 30;
	  max_price      = 40;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 5:
	  number_of_item = 3;
	  min_price      = 40;
	  max_price      = 50;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 6:
	  number_of_item = 3;
	  min_price      = 50;
	  max_price      = 60;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 7:
	  number_of_item = 4;
	  min_price      = 60;
	  max_price      = 70;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 8:
	  number_of_item = 4;
	  min_price      = 70;
	  max_price      = 80;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 9:
	  number_of_item = 4;
	  min_price      = 50;
	  max_price      = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  break;
	}
      break;
    case WITH_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 4:
	  number_of_item = 3;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 5:
	  number_of_item = 4;
	  min_price      = 0;
	  max_price      = 4;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	}
      break;
    case BACK_WITHOUT_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 3;
	  max_price      = 9;
	  paid		 = 10;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 19;
	  paid		 = 20;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 2;
	  max_price      = 29;
	  paid		 = 30;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 4:
	  number_of_item = 2;
	  min_price      = 2;
	  max_price      = 39;
	  paid		 = 40;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 5:
	  number_of_item = 3;
	  min_price      = 3;
	  max_price      = 49;
	  paid		 = 50;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 6:
	  number_of_item = 3;
	  min_price      = 3;
	  max_price      = 60;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 7:
	  number_of_item = 4;
	  min_price      = 4;
	  max_price      = 70;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 8:
	  number_of_item = 4;
	  min_price      = 4;
	  max_price      = 80;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 9:
	  number_of_item = 4;
	  min_price      = 4;
	  max_price      = 99;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  break;
	}
      break;
    case BACK_WITH_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 4:
	  number_of_item = 3;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 5:
	  number_of_item = 4;
	  min_price      = 0;
	  max_price      = 4;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	}
      break;
    }

  seller_money = MONEY_WIDGET(money_widget_new());
  money_widget_set_position(seller_money,
			    boardRootItem,
			    100.0,  20.0,
			    700.0, 130.0,
			    5, 2,
			    FALSE);

  money_widget_set_target(seller_money, tux_money);
  money_widget_set_target(tux_money, seller_money);

  /* Display what to buy */
  price_target = 0;
  for(i=1; i<=number_of_item; i++)
  {
    gdouble object_price;
    gchar *text;
    GooCanvasItem *item;
    RsvgHandle *svg_handle;
    RsvgDimensionData dimension;
    double xratio, yratio;
    guint offset_x = 50;
    guint boardwidth = BOARDWIDTH - offset_x * 2;

    /* Display the price */
    object_price  = (double) g_random_int_range(min_price/number_of_item,
						max_price/number_of_item);

    {
      /* Select an image list depending on the price */
      gchar **imageList;
      guint number_of_images;
      if ( object_price < 5 )
	{
	  imageList = imageList1;
	  number_of_images = NUMBER_OF_IMAGES1;
	}
      else if ( object_price < 10 )
	{
	  imageList = imageList2;
	  number_of_images = NUMBER_OF_IMAGES2;
	}
      else
	{
	  imageList = imageList3;
	  number_of_images = NUMBER_OF_IMAGES3;
	}

      svg_handle =							\
	gc_rsvg_load(imageList[g_random_int_range(0, number_of_images - 1)]);

      rsvg_handle_get_dimensions(svg_handle, &dimension);

      item = goo_canvas_svg_new ( boardRootItem,
				  svg_handle,
				  NULL);
    }
    xratio =  (gdouble)(boardwidth/(number_of_item+1)) / dimension.width;
    yratio =  100.0 / dimension.height;

    xratio = yratio = MIN(xratio, yratio);
    goo_canvas_item_translate(item,
			      offset_x +
			      (i*boardwidth)/(number_of_item+1)
    			      - dimension.width*xratio/2,
    			      200);

    goo_canvas_item_scale(item, xratio, xratio);

    if( (currentMode == WITH_CENTS) ||
	(currentMode == BACK_WITH_CENTS) )
      {
	/* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */
	display_format = _("$ %.2f");
	/* Add random cents */
	if(gcomprisBoard->level == 1)
	  {
	    object_price += (double)((double) g_random_int_range(1, 9))/10.0;
	  }
	else
	  {
	    object_price += (double)((double) g_random_int_range(1, 99))/100.0;
	  }
      }
    else
      {
	/* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */
	display_format = _("$ %.0f");
      }

    price_target += object_price;
    text = g_strdup_printf(display_format, object_price);
    goo_canvas_text_new(boardRootItem,
			text,
			offset_x + (i*boardwidth)/(number_of_item+1),
			185,
			-1,
			GTK_ANCHOR_CENTER,
			"font", gc_skin_font_board_big,
			"fill-color", "white",
			NULL);
    g_free(text);
    g_object_unref(svg_handle);
  }

  if (paid)
    {
      // Calc the money back instead of the objects price
      price_target = paid - price_target;
      // Display Tux and his money
      display_paying_tux(paid);
    }
}
示例#17
0
文件: maze.c 项目: GNOME/gcompris
/* =====================================================================
 * set initial values for the next level
 * =====================================================================*/
static void maze_next_level() {
  GdkPixbuf *pixmap = NULL;

  maze_destroy_all_items();
  gc_bar_set_level(gcomprisBoard);
  setlevelproperties();

  mapActive = FALSE;

  ind = 0;
  gamewon = FALSE;
  initMaze();
  generateMaze((g_random_int()%breedte),(g_random_int()%hoogte));
  removeSet();
  /* Try the next level */
  maze_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
  draw_background(wallgroup);

  if(modeIsInvisible) {
    g_object_set (wallgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
  }

  /* make a new group for the items */
  begin=g_random_int()%hoogte;
  end=g_random_int()%hoogte;

  /* Draw the tux */
  RsvgHandle *svg_handle = gc_rsvg_load("maze/tux_top_south.svg");
  tuxitem = goo_canvas_svg_new (tuxgroup, svg_handle,
				NULL);
  g_object_unref (svg_handle);

  goo_canvas_item_translate(tuxgroup,
			    cellsize*(0)-breedte + board_border_x,
			    cellsize*(begin)-hoogte + board_border_y);

  g_signal_connect(tuxitem,
		   "button_press_event",
		   (GCallback) tux_event, NULL);

  if(run_fast_possible) {
	  /* Load the tux shoes */
	  svg_handle = gc_rsvg_load("maze/tux_shoes_top_south.svgz");
	  tuxshoes = goo_canvas_svg_new (tuxgroup, svg_handle,
					"pointer-events", GOO_CANVAS_EVENTS_NONE, NULL);
	  g_object_unref (svg_handle);

	  /* Load fast-mode switch button */
	  svg_handle = gc_rsvg_load("maze/fast-mode-button.svgz");
	  fast_mode_button = goo_canvas_svg_new (boardRootItem, svg_handle,
					NULL);
	  g_object_unref (svg_handle);
	  goo_canvas_item_translate(fast_mode_button, 10, 10);
	  g_signal_connect(fast_mode_button,
			   "button_press_event",
			   (GCallback) on_fast_mode_button_press, NULL);
	  gc_item_focus_init(fast_mode_button, NULL);
  }

  /* Draw the target */
  pixmap = gc_pixmap_load("maze/door.png");
  if(pixmap)
    {
      draw_image(mazegroup,breedte-1,end,pixmap);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif
    }

  position[ind][0]=0;
  position[ind][1]=begin;
  Maze[0][begin]=Maze[0][begin]+SET;
  viewing_direction=EAST;
  threeDactive=FALSE;

  if(run_fast_possible) {
	  // run_fast-mode should be initialized at every level, whether TRUE or FALSE
	  if (gcomprisBoard->level < 14) set_run_fast(FALSE);
	  if (gcomprisBoard->level >= 14) set_run_fast(TRUE);
  }

  update_tux(viewing_direction);

  if(!modeIs2D)
    threeDdisplay();

}
示例#18
0
/* ==================================== */
static GooCanvasItem *click_on_letter_create_item(GooCanvasItem *parent)
{

  int xOffset, yOffset, i;

  if (gcomprisBoard->sublevel == 1)
    {
      Level *level = &g_array_index (levels, Level, gcomprisBoard->level - 1);
      n_answer = g_utf8_strlen (level->answers, -1);
      g_assert( n_answer <= MAX_N_ANSWER );

      if ( uppercase_only )
	{
	  gchar *answers_up = g_utf8_strup( level->answers, -1 );
	  gchar *questions_up = g_utf8_strup( level->questions, -1 );
	  answers = shuffle_utf8(answers_up);
	  questions = shuffle_utf8(questions_up);
	  g_free(answers_up);
	  g_free(questions_up);
	}
      else
	{
	  answers = shuffle_utf8(level->answers);
	  questions = shuffle_utf8(level->questions);
	}

      /* Go to next level after this number of 'play' */
      gcomprisBoard->number_of_sublevel = g_utf8_strlen (level->questions, -1);
    }
  right_letter = g_utf8_strdown(questions[gcomprisBoard->sublevel - 1], -1);


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

  if ( ! _repeat() )
  {
    /* Sound was not played, display the letter to find instead */
    guint x = 10;
    guint y = 110;
    guint width = 80;
    guint height = 80;
    goo_canvas_rect_new (boardRootItem,
			 x,
			 y,
			 width,
			 height,
			 "stroke_color_rgba", 0xFFFFFFFFL,
			 "fill_color_rgba", 0x00005550L,
			 "line-width", (double) 2,
			 "radius-x", (double) 10,
			 "radius-y", (double) 10,
			 NULL);
    goo_canvas_text_new (boardRootItem,
			 questions[gcomprisBoard->sublevel - 1],
			 (double) x + width / 2,
			 (double) y + height / 2,
			 -1,
			 GTK_ANCHOR_CENTER,
			 "font", gc_skin_font_board_huge_bold,
			 "fill_color_rgba", 0xffffffff,
			 NULL);
  }

  /* Display the answers */
  yOffset = VERTICAL_SEPARATION - carriage_svg_dimension.height;
  xOffset = 144;
  gint text_gap_x = -5;
  gint text_gap_y = -35;

  RsvgHandle *svg_handle= carriage_svg_handle;
  RsvgDimensionData svg_dimension = carriage_svg_dimension;

  for (i = 0; i< n_answer; i++) {

    if ( i > 0 && i % N_LETTER_PER_LINE == 0 )
      {
	/* Line wrapping */
	svg_handle= cloud_svg_handle;
	svg_dimension = cloud_svg_dimension;
	xOffset = 144;
	yOffset -= svg_dimension.height;
	text_gap_x = 0;
	text_gap_y = 0;
      }

    GooCanvasItem *button_item =		\
      goo_canvas_svg_new (boardRootItem,
			  svg_handle,
			  "svg-id", "#OFF",
			  NULL);
    goo_canvas_item_translate( button_item,
			       xOffset,
			       yOffset);


    GooCanvasItem *text_item = \
      goo_canvas_text_new (boardRootItem,
			   answers[i],
			   (double) xOffset + svg_dimension.width / 2 + text_gap_x,
			   (double) yOffset + svg_dimension.height / 2 + text_gap_y,
			   -1,
			   GTK_ANCHOR_CENTER,
			   "font", gc_skin_font_board_huge_bold,
			   "fill_color_rgba", 0x000000ff,
			   NULL);

    xOffset += HORIZONTAL_SEPARATION + svg_dimension.width;

    g_signal_connect(text_item, "button_press_event",
		     (GCallback) item_event, answers[i]);
    g_signal_connect(button_item, "button_press_event",
		     (GCallback) item_event, answers[i]);
    gc_item_focus_init(text_item, button_item);
    gc_item_focus_init(button_item, NULL);
    g_object_set_data(G_OBJECT(button_item), "button_item", button_item);
    g_object_set_data(G_OBJECT(text_item), "button_item", button_item);
  }

  return NULL;
}
示例#19
0
文件: about.c 项目: laya/GCompris
/*
 * Do all the bar display and register the events
 */
void gc_about_start ()
{
  GdkPixbuf   *pixmap = NULL;
  gdouble y_start = 0;
  gint y = 0;
  GooCanvasItem *item;

  static gchar *content =
    N_("Author: Bruno Coudoin\n"
       "Contribution: Pascal Georges, Jose Jorge, Yves Combe\n"
       "Graphics: Renaud Blanchard, Franck Doucet\n"
       "Intro Music: Djilali Sebihi\n"
       "Background Music: Rico Da Halvarez\n"
       );

  /* TRANSLATORS: Replace this string with your names, one name per line. */
  gchar *translators = _("translator_credits");

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

  if(rootitem)
  {
    gc_about_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);
  y_start = bounds.y1;

  y = bounds.y2 - 26;

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

  goo_canvas_text_new (rootitem,
		       _("GCompris Home Page: http://gcompris.net"),
		       (gdouble) BOARDWIDTH/2,
		       (gdouble)  y_start + 58,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_content,
		       "fill-color-rgba", gc_skin_color_subtitle,
		       NULL);

  gchar *text = g_strdup_printf("%s\n%s\n%s",
				_(content),
				_("Translators:"),
				translators);

  y_start += 100;
  goo_canvas_text_new (rootitem,
		       text,
		       (gdouble)  BOARDWIDTH/2-320,
		       (gdouble)  y_start,
		       -1,
		       GTK_ANCHOR_NORTH_WEST,
		       "font", gc_skin_font_content,
		       "fill-color-rgba", gc_skin_color_content,
		       NULL);
  g_free(text);

  // Version
  item = \
    goo_canvas_text_new (rootitem,
		       "GCompris V" VERSION,
		       (gdouble)  0,
		       (gdouble)  y_start,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_title,
		       "fill-color-rgba", gc_skin_color_subtitle,
		       NULL);
  goo_canvas_item_get_bounds(item, &bounds);
  gdouble x = BOARDWIDTH - (bounds.x2 - bounds.x1) - 20;
  g_object_set( (GooCanvasItem*)item,
		"x",
		x,
		NULL);

  y_start += 180;
  /* Location for a potential sponsor */
  gchar *sponsor_image = gc_file_find_absolute("sponsor_about.png");
  if(sponsor_image)
    {
      pixmap = gc_pixmap_load("sponsor_about.png");
      goo_canvas_text_new (rootitem,
			   "Version parrainée par",
			   (gdouble)  BOARDWIDTH*0.75,
			   (gdouble)  y_start - gdk_pixbuf_get_height(pixmap),
			   -1,
			   GTK_ANCHOR_CENTER,
			   "font", gc_skin_font_content,
			   "fill-color-rgba", gc_skin_color_content,
			   NULL);

      item = goo_canvas_image_new (rootitem,
				   pixmap,
				   (gdouble) (BOARDWIDTH*0.75) - gdk_pixbuf_get_width(pixmap)/2,
				   (gdouble) y_start - gdk_pixbuf_get_height(pixmap) + 15,
                   NULL);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif
      g_free(sponsor_image);
    }
  else
    {
      // Default sponsor is the FSF
      RsvgHandle  *svg_handle;
      svg_handle = gc_skin_rsvg_get();
      item = goo_canvas_svg_new (rootitem,
				     svg_handle,
				     "svg-id", "#FSF_LOGO",
				     "pointer-events", GOO_CANVAS_EVENTS_NONE,
				     NULL);
      goo_canvas_item_get_bounds(item, &bounds);
      SET_ITEM_LOCATION_CENTER(item, (BOARDWIDTH*0.75),
			       y_start + 50 - (bounds.y2 - bounds.y1) / 2);

      item = goo_canvas_text_new (rootitem,
				  "Free Software Foundation\nhttp://www.fsf.org",
				  (gdouble)  (BOARDWIDTH*0.75),
				  (gdouble)  y_start + 80,
				  -1,
				  GTK_ANCHOR_CENTER,
				  "font", gc_skin_font_content,
				  "fill-color-rgba", gc_skin_color_subtitle,
				  NULL);
    }

  // Copyright
  item = goo_canvas_text_new (rootitem,
			      "Copyright 2000-2013 Bruno Coudoin and Others",
			      (gdouble)  BOARDWIDTH/2,
			      (gdouble)  y - 55,
			      -1,
			      GTK_ANCHOR_CENTER,
			      "font", gc_skin_font_content,
			      "fill-color-rgba", gc_skin_color_content,
			      NULL);

  // License
  item = goo_canvas_text_new (rootitem,
			      _("This software is a GNU Package and is released under the GNU General Public License"),
			      (gdouble)  BOARDWIDTH/2,
			      (gdouble)  y - 40,
			      -1,
			      GTK_ANCHOR_CENTER,
			      "font", "sans 8",
			      "fill-color-rgba", gc_skin_color_content,
			      NULL);

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

  is_displayed = TRUE;

}
示例#20
0
文件: imageid.c 项目: GNOME/gcompris
/* ==================================== */
static void
imageid_create_item(GooCanvasItem *parent)
{
  GooCanvasItem *item;
  GooCanvasItem *group;
  GooCanvasItem *button;
  int x, y, xp, yp;
  guint vertical_separation;
  GdkPixbuf *pixmap = NULL;
  Board *board;
  guint i;

  board_number = gcomprisBoard->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->canvas),
			  NULL);

  /* display the image */
  board = g_list_nth_data(board_list, board_number);
  g_assert(board != NULL);

  right_word = board->solution;

  pixmap = gc_pixmap_load(board->pixmapfile);

  x = IMAGE_AREA_X1 + ( IMAGE_AREA_X2 - IMAGE_AREA_X1 - gdk_pixbuf_get_width(pixmap))/2;
  y = IMAGE_AREA_Y1 + ( IMAGE_AREA_Y2 - IMAGE_AREA_Y1 - gdk_pixbuf_get_height(pixmap))/2;

  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

  xp = HORIZONTAL_SEPARATION;

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

  vertical_separation = 10 + 60 / i;

  guint button_pixmap_height = 48;
  guint button_pixmap_width = 191;
  yp = (BOARDHEIGHT -
	i *  button_pixmap_height
	- 2 * vertical_separation)/2 - 20;

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

      button = goo_canvas_svg_new (group,
				   gc_skin_rsvg_get(),
				   "svg-id", "#BUTTON_TEXT",
				   NULL);
      SET_ITEM_LOCATION(button,
			xp,
			yp);

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

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

      item = goo_canvas_text_new (group,
				  board->text[i],
				  xp +  button_pixmap_width/2 + 1.0,
				  yp +  button_pixmap_height/2 + 1.0,
				  -1,
				  GTK_ANCHOR_CENTER,
				  "font", gc_skin_font_board_big,
				  "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],
				  xp +  button_pixmap_width/2,
				  yp +  button_pixmap_height/2,
				  -1,
				  GTK_ANCHOR_CENTER,
				  "font", gc_skin_font_board_big,
				  "fill_color_rgba", gc_skin_color_text_button,
				  NULL);

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

      yp +=  button_pixmap_height + vertical_separation;

      i++;
    }

}
示例#21
0
void
money_widget_add (MoneyWidget *moneyWidget, MoneyEuroType value)
{
  GooCanvasItem *item;
  RsvgHandle    *svg_handle;
  RsvgDimensionData dimension;
  double	 xratio, yratio, ratio;
  double	 block_width, block_height;
  MoneyItem	*moneyitem;
  guint		 i, length;

  g_return_if_fail (moneyWidget != NULL);

  /* Search for an hidden item with the same value */
  length = g_list_length(moneyWidget->priv->moneyItemList);
  for(i=0; i<length; i++)
    {
      moneyitem = \
	(MoneyItem *)g_list_nth_data(moneyWidget->priv->moneyItemList,
				     i);

      if(moneyitem && !moneyitem->inPocket && moneyitem->value == value)
	{
	  g_object_set (moneyitem->item,
			"visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
	  moneyitem->inPocket = TRUE;
	  moneyWidget->priv->total += euroList[value].value;
	  money_display_total(moneyWidget);
	  return;
	}
    }

  /* There is no already suitable item create, create a new one */

  if(moneyWidget->priv->next_spot
     > moneyWidget->priv->columns * moneyWidget->priv->lines)
    g_message("More money items requested than the pocket size\n");

  block_width  = \
    (moneyWidget->priv->x2 - moneyWidget->priv->x1)
    / moneyWidget->priv->columns;
  block_height = \
    (moneyWidget->priv->y2 - moneyWidget->priv->y1) / moneyWidget->priv->lines;

  svg_handle = gc_rsvg_load(euroList[value].image);

  rsvg_handle_get_dimensions(svg_handle, &dimension);

  xratio =  block_width  / (dimension.width + BORDER_GAP);
  yratio =  block_height / (dimension.height + BORDER_GAP);
  ratio = yratio = MIN(xratio, yratio);

  item =  goo_canvas_svg_new(moneyWidget->priv->rootItem,
			   svg_handle,
			   NULL);

  goo_canvas_item_translate(item,
			    moneyWidget->priv->x1 +
			    (moneyWidget->priv->next_spot % moneyWidget->priv->columns) * block_width
			    +  block_width/2 - (dimension.width * ratio)/2,
			    moneyWidget->priv->y1 +
			    (moneyWidget->priv->next_spot / moneyWidget->priv->columns)
			    * (block_height + BORDER_GAP)
			    + block_height/2 - (dimension.height * ratio)/2);
  goo_canvas_item_scale(item,
			ratio,
  			ratio);

  moneyitem = g_malloc(sizeof(MoneyItem));
  moneyitem->moneyWidget = moneyWidget;
  moneyitem->item   = item;
  moneyitem->value  = value;
  moneyitem->inPocket = TRUE;

  moneyWidget->priv->moneyItemList = \
    g_list_append (moneyWidget->priv->moneyItemList,
		   moneyitem);

  g_signal_connect(item,
		   "button_press_event", (GCallback) item_event,
		   moneyitem);

  g_object_unref(svg_handle);

  moneyWidget->priv->next_spot++;

  moneyWidget->priv->total += euroList[value].value;

  money_display_total(moneyWidget);
}
示例#22
0
void
gc_selector_images_start (GcomprisBoard *gcomprisBoard, gchar *dataset,
			  ImageSelectorCallBack iscb,
			  void *user_context)
{

  gint		 y_start = 0;
  gchar		*dataseturl = NULL;

  GtkWidget	*w;

  if(sugar_detected())
  {
    sugar_choose_image(iscb, user_context);
    return;
  }

  if(rootitem)
    return;

  gc_bar_hide(TRUE);

  gc_board_pause(TRUE);

  imageSelectorCallBack = iscb;
  current_user_context = user_context;

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

  images_selector_displayed = TRUE;

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

  y_start += 110;

  /*
   * Create the list scrollbar
   * -------------------------
   */
  canvas_list_selector = goo_canvas_new ();

  goo_canvas_widget_new (rootitem,
			 canvas_list_selector,
			 LIST_AREA_X1,
			 LIST_AREA_Y1,
			 LIST_AREA_X2 - LIST_AREA_X1,
			 LIST_AREA_Y2 - LIST_AREA_Y1 - 35.0,
			 NULL);

  gtk_widget_show (canvas_list_selector);

  /* Set the new canvas to the background color or it's white */
  list_bg_item = goo_canvas_rect_new (goo_canvas_get_root_item(GOO_CANVAS(canvas_list_selector)),
				      0,
				      0,
				      (LIST_AREA_X2 - LIST_AREA_X1)
				      * gc_zoom_factor_get(),
				      (LIST_AREA_Y2 - LIST_AREA_Y1)
				      * gc_zoom_factor_get(),
				      "fill-color-rgba",
				      gc_skin_get_color("gcompris/imageselectbg_left"),
				      "line-width", 0.0,
				      NULL);

  list_adj = \
    GTK_ADJUSTMENT (gtk_adjustment_new (0.00, 0.00,
					0.00,
					10, IMAGE_HEIGHT,
					(LIST_AREA_Y2 - LIST_AREA_Y1)
					* gc_zoom_factor_get())
		    );

  w = gtk_vscrollbar_new (list_adj);

  goo_canvas_widget_new (rootitem,
			 w,
			 LIST_AREA_X2 - 5.0,
			 LIST_AREA_Y1,
			 30.0,
			 LIST_AREA_Y2 - LIST_AREA_Y1 - 20.0,
			 NULL);
  gtk_widget_show (w);

  /* Set the scrollwheel event */
  g_signal_connect (list_adj, "value_changed",
		    (GCallback) item_event_scroll,
		    canvas_list_selector);

  /*
   * Create the image scrollbar
   * --------------------------
   */
  canvas_image_selector = goo_canvas_new ();

  goo_canvas_widget_new (rootitem,
			 canvas_image_selector,
			 DRAWING_AREA_X1,
			 DRAWING_AREA_Y1,
			 DRAWING_AREA_X2 - DRAWING_AREA_X1,
			 DRAWING_AREA_Y2 - DRAWING_AREA_Y1,
			 NULL);

  gtk_widget_show (canvas_image_selector);

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

  image_adj = \
    GTK_ADJUSTMENT (gtk_adjustment_new (0.00, 0.00,
					0.00,
					10, IMAGE_HEIGHT,
					(DRAWING_AREA_Y2 - DRAWING_AREA_Y1)
					* gc_zoom_factor_get())
		    );

  w = gtk_vscrollbar_new (image_adj);

  goo_canvas_widget_new (rootitem,
			 w,
			 DRAWING_AREA_X2 - 5.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 (image_adj, "value_changed",
		    (GCallback) item_event_scroll,
		    canvas_image_selector);

  /*
   * DISPLAY IMAGES
   */

  /* Initial image position */
  isy = 0.0;

  /* I need  the following :
     -> if dataset is a file read it.
     -> if dataset is a directory, read all xml file in it.
  */
  dataseturl = \
    gc_file_find_absolute(dataset,
			  NULL);

  /* if the file doesn't exist */
  if(g_file_test ((dataseturl), G_FILE_TEST_IS_DIR) )
    {
      g_warning("dataset %s is a directory. Trying to read xml", dataseturl);

      read_dataset_directory(dataseturl);
    }
  else if(dataseturl)
    {
      /* Read the given data set file, local or net */
      read_xml_file(dataseturl);
    }
  else
    {
      /* Network code for dataset directory */
      GSList *filelist = NULL;
      GSList *i = NULL;

      g_free(dataseturl);
      dataseturl = g_strconcat("boards/", dataset, NULL);
      /* TODO */
      filelist = NULL; //gc_net_dir_read_name(dataseturl, ".xml");

      for (i = filelist; i != NULL; i = g_slist_next (i))
	{
	  gchar *url = gc_file_find_absolute(i->data,
					     NULL);
	  g_warning("processing dataset=%s\n", (char *)i->data);
	  read_xml_file(url);
	  g_free(url);
	}

      g_slist_free(filelist);

    }
  g_free(dataseturl);

  /*
   * OK Button
   * ---------
   */
  gc_util_button_text_svg(rootitem,
			  (BOARDWIDTH*0.5),
			  BOARDHEIGHT - 32,
			  "#BUTTON_TEXT",
			  _("OK"),
			  (GCallback) item_event_images_selector,
			  "/ok/");
}
示例#23
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();
}
示例#24
0
文件: menu2.c 项目: nnagabus/GCompris
static void
create_top(GooCanvasItem *parent, gchar *path)
{
    gchar **splitted_section;
    gint i = 1;
    GdkPixbuf *pixmap = NULL;
    gdouble ratio;
    GcomprisBoard *board;
    gchar *path1, *path2;

    GooCanvasItem *item;

    GcomprisProperties *properties = gc_prop_get();

    if (!path)
        return;

    splitted_section = g_strsplit (path, "/", 0);

    path1 = g_strdup("");

    /* splitted_section[0] is always "" */
    i = 1;

    while (splitted_section[i] != NULL)
    {

        path2 = g_strdup_printf("%s/%s", path1, splitted_section[i]);

        g_free(path1);
        path1 = path2;

        if (strcmp(path1, properties->root_menu)<0) {
            i++;
            continue;
        }

        if (current_top_x == 0.0)
        {
            current_top_x = top_x;
            current_top_y = top_y;
        }
        else
        {
            item = \
                   goo_canvas_svg_new (parent,
                                       gc_skin_rsvg_get(),
                                       "svg-id", "#MENUICON",
                                       "pointer-events", GOO_CANVAS_EVENTS_NONE,
                                       NULL);

            SET_ITEM_LOCATION(item,
                              current_top_x,
                              current_top_y + top_arrow_size);
            //	  goo_canvas_item_scale(item, ratio, ratio);

            current_top_x += top_arrow_size + top_int_x;
        }

        board = gc_menu_section_get(path1);

        pixmap = gc_pixmap_load(board->icon_name);

        ratio = get_ratio( pixmap, icon_size_top);

        item = goo_canvas_image_new (parent,
                                     pixmap,
                                     0, 0,
                                     NULL);
        goo_canvas_item_translate(item,
                                  current_top_x,
                                  current_top_y);
        goo_canvas_item_scale(item, ratio, ratio);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
        gdk_pixbuf_unref(pixmap);
#else
        g_object_unref(pixmap);
#endif

        current_top_x += top_int_x + icon_size_top;

        g_object_set_data (G_OBJECT (item), "board", board);

        g_signal_connect(item, "button_press_event",
                         (GCallback) item_event,
                         menuitems);

        gc_item_focus_init(item, NULL);

        i++;
    }

    g_strfreev(splitted_section);
    g_free(path1);

}
示例#25
0
void create_mainwindow (GooCanvasItem *rootitem)
{
    GtkWidget *wdrawareagrande;
    GtkWidget *wdrawareapetite;


    /* GCompris : suppression of all menus */
    g_assert(rootitem != NULL);

    wdrawareagrande = gtk_drawing_area_new ();
    gtk_widget_set_name (wdrawareagrande, "wdrawareagrande");
    //gtk_widget_set_size_request     (wdrawareagrande,
    //                               WIDTH_BIGAREA,
    //			   WIDTH_BIGAREA
    //			   );

    //gtk_container_add (GTK_CONTAINER (aspectframe1), wdrawareagrande);

    gtk_widget_set_events (wdrawareagrande, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK);

    /* Gcompris */
    goo_canvas_widget_new ( rootitem,
                            wdrawareagrande,
                            X_BASE_BIGAREA,
                            Y_BASE_BIGAREA,
                            WIDTH_BIGAREA,
                            WIDTH_BIGAREA,
                            NULL
                          );

    gtk_widget_show (wdrawareagrande);

    wdrawareapetite = gtk_drawing_area_new ();
    gtk_widget_set_name (wdrawareapetite, "wdrawareapetite");

    gtk_widget_set_events (wdrawareapetite, GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK);

    /* Gcompris */
    goo_canvas_widget_new ( rootitem,
                            wdrawareapetite,
                            X_BASE_SMALLAREA,
                            Y_BASE_SMALLAREA,
                            WIDTH_SMALLAREA,
                            WIDTH_SMALLAREA,
                            NULL
                          );

    gtk_widget_show (wdrawareapetite);

    g_signal_connect (GTK_OBJECT (wdrawareagrande), "expose_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_expose_event),
                      NULL);
    g_signal_connect (GTK_OBJECT (wdrawareagrande), "configure_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_configure_event),
                      NULL);
    g_signal_connect (GTK_OBJECT (wdrawareagrande), "button_press_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_button_press_event),
                      NULL);
    g_signal_connect (GTK_OBJECT (wdrawareagrande), "button_release_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_button_release_event),
                      NULL);
    g_signal_connect (GTK_OBJECT (wdrawareagrande), "motion_notify_event",
                      GTK_SIGNAL_FUNC (on_wdrawareagrande_motion_notify_event),
                      NULL);
    g_signal_connect (GTK_OBJECT (wdrawareapetite), "configure_event",
                      GTK_SIGNAL_FUNC (on_wdrawareapetite_configure_event),
                      NULL);
    g_signal_connect (GTK_OBJECT (wdrawareapetite), "expose_event",
                      GTK_SIGNAL_FUNC (on_wdrawareapetite_expose_event),
                      NULL);


    /* Gcompris */
    /* add here buttons */

    GdkPixbuf   *pixmap_show = NULL;
    GdkPixbuf   *pixmap_outline = NULL;
    GdkPixbuf   *pixmap_symetry = NULL;
    GooCanvasItem *previous_figure, *next_figure;
    GooCanvasItem *show_figure, *outline_figure, *symetry;

    previous_figure = goo_canvas_svg_new (rootitem,
                                          gc_skin_rsvg_get(),
                                          "svg-id", "#PREVIOUS",
                                          NULL);
    SET_ITEM_LOCATION_CENTER(previous_figure,
                             X_BASE_SMALLAREA,
                             Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 30);

    next_figure = goo_canvas_svg_new (rootitem,
                                      gc_skin_rsvg_get(),
                                      "svg-id", "#NEXT",
                                      NULL);
    SET_ITEM_LOCATION_CENTER(next_figure,
                             X_BASE_SMALLAREA + WIDTH_SMALLAREA,
                             Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 30);


    g_signal_connect(previous_figure, "button_press_event",
                     (GtkSignalFunc) on_arrow_clicked,
                     (gpointer) FALSE);

    gc_item_focus_init(previous_figure, NULL);

    g_signal_connect(next_figure, "button_press_event",
                     (GtkSignalFunc) on_arrow_clicked,
                     (gpointer) TRUE);

    gc_item_focus_init(next_figure, NULL);

    pixmap_show = gc_pixmap_load("tangram/gtans_show.png");

    pixmap_outline = gc_pixmap_load("tangram/gtans_outline.png");

    show_figure = goo_canvas_image_new (rootitem,
                                        pixmap_show,
                                        X_BASE_SMALLAREA,
                                        Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 80,
                                        NULL);

    outline_figure = goo_canvas_image_new (rootitem,
                                           pixmap_outline,
                                           X_BASE_SMALLAREA,
                                           Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 130,
                                           NULL);

    g_signal_connect(outline_figure, "button_press_event",
                     (GtkSignalFunc) on_outline_clicked,
                     NULL);

    g_signal_connect(show_figure, "button_press_event",
                     (GtkSignalFunc) on_show_clicked,
                     NULL);

    gc_item_focus_init(outline_figure, NULL);

    gc_item_focus_init(show_figure, NULL);

    pixmap_symetry = gc_pixmap_load("tangram/tool-flip.png");


    symetry = goo_canvas_image_new (rootitem,
                                    pixmap_symetry,
                                    X_BASE_SMALLAREA + WIDTH_SMALLAREA - 50,
                                    Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 180,
                                    NULL);

    g_signal_connect(symetry, "button_press_event",
                     (GtkSignalFunc) on_symetry_clicked,
                     NULL);

    gc_item_focus_init(symetry, NULL);


    /* rotation buttons */
    GdkPixbuf   *right_rot = NULL;
    GdkPixbuf   *left_rot = NULL;
    GdkPixbuf   *right_rot_big = NULL;
    GdkPixbuf   *left_rot_big = NULL;
    GooCanvasItem *l_rot_s, *r_rot_s, *l_rot_b,  *r_rot_b;

    right_rot       = gc_pixmap_load("tangram/gtans_rotate.png");
    left_rot        = gc_pixmap_load("tangram/gtans_rotate-left.png");

    r_rot_s = goo_canvas_image_new (rootitem,
                                    right_rot,
                                    X_BASE_SMALLAREA + WIDTH_SMALLAREA,
                                    Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60,
                                    NULL);


    l_rot_s = goo_canvas_image_new (rootitem,
                                    left_rot,
                                    X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100,
                                    Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60,
                                    NULL);


    gdk_pixbuf_unref(right_rot);
    gdk_pixbuf_unref(left_rot);

    right_rot_big   = gc_pixmap_load("tangram/gtans_2x-rotate.png");
    left_rot_big    = gc_pixmap_load("tangram/gtans_2x-rotate-left.png");

    r_rot_b = goo_canvas_image_new (rootitem,
                                    right_rot_big,
                                    X_BASE_SMALLAREA + WIDTH_SMALLAREA,
                                    Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120,
                                    NULL);


    l_rot_b = goo_canvas_image_new (rootitem,
                                    left_rot_big,
                                    X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100,
                                    Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120,
                                    NULL);

    gdk_pixbuf_unref(right_rot_big);
    gdk_pixbuf_unref(left_rot_big);


    g_signal_connect(r_rot_s, "button_press_event",
                     (GtkSignalFunc) on_rotation_clicked,
                     (gpointer) 0);

    gc_item_focus_init(r_rot_s, NULL);

    g_signal_connect(l_rot_s, "button_press_event",
                     (GtkSignalFunc) on_rotation_clicked,
                     (gpointer) 1);

    gc_item_focus_init(l_rot_s, NULL);

    g_signal_connect(r_rot_b, "button_press_event",
                     (GtkSignalFunc) on_rotation_clicked,
                     (gpointer) 2);

    gc_item_focus_init(r_rot_b, NULL);

    g_signal_connect(l_rot_b, "button_press_event",
                     (GtkSignalFunc) on_rotation_clicked,
                     (gpointer) 3);

    gc_item_focus_init(l_rot_b, NULL);
}
示例#26
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;

}
示例#27
0
/* ==================================== */
static GooCanvasItem *canal_lock_create_item(GooCanvasItem *boardRootItem)
{
  RsvgHandle *svg_handle;

  svg_handle = gc_rsvg_load("canal_lock/canal_lock.svgz");

  /* The background */
  goo_canvas_svg_new (boardRootItem, svg_handle,
		      "svg-id", "#BACKGROUND",
		      "pointer-events", GOO_CANVAS_EVENTS_NONE,
		      NULL);

  /* The boat */
  tuxboat_item = goo_canvas_svg_new (boardRootItem, svg_handle,
				     "svg-id", "#BOAT_NO_SAIL", NULL);

  g_signal_connect(tuxboat_item, "button-press-event",
                   (GtkSignalFunc) item_event,
                   NULL);
  gc_item_focus_init(tuxboat_item, NULL);

  GooCanvasBounds bounds;
  goo_canvas_item_get_bounds(tuxboat_item, &bounds);
  tuxboat_width = bounds.x2 - bounds.x1 + 20;

  /* The left lights */
  goo_canvas_svg_new (boardRootItem, svg_handle,
		      "svg-id", "#LEFT_RED_OFF",
		      "visibility", GOO_CANVAS_ITEM_VISIBLE,
		      "pointer-events", GOO_CANVAS_EVENTS_NONE,
		      NULL);
  goo_canvas_svg_new (boardRootItem, svg_handle,
		      "svg-id", "#LEFT_GREEN_OFF",
		      "visibility", GOO_CANVAS_ITEM_VISIBLE,
		      "pointer-events", GOO_CANVAS_EVENTS_NONE,
		      NULL);
  left_red_on_item =
    goo_canvas_svg_new (boardRootItem, svg_handle,
			"svg-id", "#LEFT_RED_ON",
			"visibility", GOO_CANVAS_ITEM_INVISIBLE,
			"pointer-events", GOO_CANVAS_EVENTS_NONE,
			NULL);
  left_green_on_item =
    goo_canvas_svg_new (boardRootItem, svg_handle,
			"svg-id", "#LEFT_GREEN_ON",
			"visibility", GOO_CANVAS_ITEM_INVISIBLE,
			"pointer-events", GOO_CANVAS_EVENTS_NONE,
			NULL);
  goo_canvas_svg_new (boardRootItem, svg_handle,
		      "svg-id", "#LEFT_LIGHT_BASE",
		      "pointer-events", GOO_CANVAS_EVENTS_NONE,
		      NULL);

  /* The right lights */
  goo_canvas_svg_new (boardRootItem, svg_handle,
		      "svg-id", "#RIGHT_RED_OFF",
		      "visibility", GOO_CANVAS_ITEM_VISIBLE,
		      "pointer-events", GOO_CANVAS_EVENTS_NONE,
		      NULL);
  goo_canvas_svg_new (boardRootItem, svg_handle,
		      "svg-id", "#RIGHT_GREEN_OFF",
		      "visibility", GOO_CANVAS_ITEM_VISIBLE,
		      "pointer-events", GOO_CANVAS_EVENTS_NONE,
		      NULL);
  right_red_on_item = goo_canvas_svg_new (boardRootItem, svg_handle,
					 "svg-id", "#RIGHT_RED_ON",
					 "visibility", GOO_CANVAS_ITEM_INVISIBLE,
					 "pointer-events", GOO_CANVAS_EVENTS_NONE,
					 NULL);
  right_green_on_item = goo_canvas_svg_new (boardRootItem, svg_handle,
					 "svg-id", "#RIGHT_GREEN_ON",
					 "visibility", GOO_CANVAS_ITEM_INVISIBLE,
					 "pointer-events", GOO_CANVAS_EVENTS_NONE,
					 NULL);
  goo_canvas_svg_new (boardRootItem, svg_handle,
					 "svg-id", "#RIGHT_LIGHT_BASE",
					 "pointer-events", GOO_CANVAS_EVENTS_NONE,
					 NULL);

  /* This is the middle canal */
  canal_middle_item = goo_canvas_rect_new (boardRootItem,
					   LEFT_CANAL_WIDTH,
					   BASE_LINE - LEFT_CANAL_HEIGHT,
					   MIDDLE_CANAL_WIDTH,
					   LEFT_CANAL_HEIGHT,
					   "fill_color_rgba", CANAL_COLOR,
					   "line-width", (double) 0,
					   NULL);
  goo_canvas_item_raise(tuxboat_item, canal_middle_item);

  /* This is the left lock */
  lock_left_item = goo_canvas_rect_new (boardRootItem,
					LEFT_CANAL_WIDTH - LOCK_WIDTH / 2,
					BASE_LINE - LOCK_HEIGHT_MAX,
					LOCK_WIDTH,
					LOCK_HEIGHT_MAX,
					"fill_color_rgba", LOCK_COLOR,
					"line-width", (double) 0,
					NULL);
  set_lock_event(lock_left_item);

  /* This is the right lock */
  lock_right_item = goo_canvas_rect_new (boardRootItem,
					 LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH - LOCK_WIDTH / 2,
					 BASE_LINE - LOCK_HEIGHT_MAX,
					 LOCK_WIDTH,
					 LOCK_HEIGHT_MAX,
					 "fill_color_rgba", LOCK_COLOR,
					 "line-width", (double) 0,
					 NULL);
  set_lock_event(lock_right_item);

  /* And to finish, the 2 canal locks */
  canallock_left_item =
    goo_canvas_rect_new (boardRootItem,
			 LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH * 0.1,
			 SUBCANAL_BASE_LINE - SUBCANAL_HEIGHT,
			 LOCK_WIDTH / 2,
			 SUBCANAL_HEIGHT,
			 "fill_color_rgba", CANALLOCK_COLOR,
			 "line-width", (double) 0,
			 NULL);
  set_lock_event(canallock_left_item);

  canallock_right_item =
    goo_canvas_rect_new (boardRootItem,
			 LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH * 0.9,
			 SUBCANAL_BASE_LINE - SUBCANAL_HEIGHT,
			 LOCK_WIDTH / 2,
			 SUBCANAL_HEIGHT,
			 "fill_color_rgba", CANALLOCK_COLOR,
			 "line-width", (double) 0,
			 NULL);
  set_lock_event(canallock_right_item);

  g_object_unref (svg_handle);

  return NULL;
}
示例#28
0
文件: config.c 项目: palbr/GCompris
/*
 * 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;
}
示例#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);

}
示例#30
0
/* ==================================== */
static GooCanvasItem *
hanoi_create_item(GooCanvasItem *parent)
{
  int i,j;
  double gap_x, gap_y;
  double baseline;
  GooCanvasItem *item = NULL;
  guint color_to_place;
  guint used_colors[NUMBER_OF_COLOR];
  guint w;

  boardRootItem = \
    goo_canvas_group_new (parent,
			  NULL);


  if (gcomprisBoard->level == 1)
    {
      item = goo_canvas_svg_new (boardRootItem,
				 gc_skin_rsvg_get(),
				 "svg-id", "#BAR_BG",
				 NULL);
      SET_ITEM_LOCATION_CENTER(item,
			       BOARDWIDTH/2,
			       50);

      goo_canvas_text_new (boardRootItem,
                           _("Build the same tower in the empty area as the one you see on the right-hand side."),
                           BOARDWIDTH/2,
                           50,
                           -1,
                           GTK_ANCHOR_CENTER,
                           "font", gc_skin_font_board_medium,
                           "fill_color_rgba", gc_skin_color_text_button,
                           NULL);
    }

  /*----------------------------------------*/
  /* Empty the solution */
  for(i=0; i<(number_of_item_x+2); i++)
    {
      for(j=0; j<number_of_item_y; j++)
	{
	  position[i][j] = g_malloc(sizeof(PieceItem));
	  position[i][j]->color  = -1;
	  position[i][j]->i      = i;
	  position[i][j]->j      = j;
	  position[i][j]->on_top = FALSE;
	}
    }

  /* Clear the used colors list */
  for(i=0; i<NUMBER_OF_COLOR; i++)
    used_colors[i] = FALSE;

  /* Initialize a random goal and store the color index
     in position[number_of_item_x] */
  for(i=0; i<(number_of_item_y); i++)
    {
      guint color = (guint)g_random_int_range(0, NUMBER_OF_COLOR-1);
      position[number_of_item_x+1][i]->color = color;
      used_colors[color] = TRUE;

    }

  /* Randomly place the solution */
  for (color_to_place=0; color_to_place<number_of_item_y; color_to_place++)
    {
      gboolean done;

      do
	{
	  done = FALSE;

	  i = (guint)g_random_int_range(0, number_of_item_x);

	  /* Restrict the goal to lowest items */
	  j = (guint)g_random_int_range(0, 2);

	  if(position[i][j]->color == -1)
	    {
	      done = TRUE;
	      position[i][j]->color = position[number_of_item_x+1][color_to_place]->color;
	    }
	}
      while(!done);
    }

  /* Initialize the left open positions */
  for(i=0; i<(number_of_item_x); i++)
    {
      for(j=0; j<number_of_item_y-1; j++)
	{
	  if(position[i][j]->color == -1)
	    {
	      /* Take only a color that is not part of the goal */
	      guint color = (guint)g_random_int_range(0, NUMBER_OF_COLOR-1);
	      while(used_colors[color])
		{
		  color++;
		  if(color >= NUMBER_OF_COLOR)
		    color = 0;
		}

	      position[i][j]->color = color;
	    }
	}
    }
  //dump_solution();

  /* Mark the top pieces */
  for(i=0; i<(number_of_item_x); i++)
    {
      position[i][number_of_item_y-2]->on_top = TRUE;
    }

  /*----------------------------------------*/
  /* Display it now */

  item_width  = BOARDWIDTH / (number_of_item_x + 2);
  item_height = 30;

  gap_x = item_width  * 0.1;
  gap_y = item_height * 0.25;

  baseline = BOARDHEIGHT/2 + item_height * number_of_item_y/2;

  number_of_item = 0;

  for(i=0; i<(number_of_item_x+2); i++)
    {
      if(i == number_of_item_x+1)
	{
	  /* Create the backgound for the target */
	  goo_canvas_rect_new (boardRootItem,
			       item_width * i + gap_x/2,
			       baseline - item_height * number_of_item_y - gap_y - 50,
			       item_width - gap_x,
			       item_height * number_of_item_y + gap_y*2 + 100,
			       "fill_color_rgba", 0x036ED8FF,
			       "stroke-color", "black",
			       "line-width", (double)1,
			       NULL);
	}
      else if (i == number_of_item_x)
	{
	  /* Create the backgound for the empty area */
	  goo_canvas_rect_new (boardRootItem,
			       item_width * i + gap_x/2,
			       baseline - item_height * number_of_item_y - gap_y - 50,
			       item_width - gap_x,
			       item_height * number_of_item_y + gap_y*2 + 100,
			       "fill_color_rgba", 0x48AAF1FF,
			       "stroke-color", "black",
			       "line-width", (double)1,
			       NULL);
	}

      /* Create the vertical line */
      w = 10;
      goo_canvas_rect_new (boardRootItem,
			   item_width * i + item_width/2 - w,
			   baseline - item_height * number_of_item_y - gap_y,
			   w*2,
			   (item_height + gap_y/2 - 2) * number_of_item_y,
			   "fill_color_rgba", 0xFF1030FF,
			   "stroke-color", "black",
			   "line-width", (double)1,
			   NULL);

      /* And the base line */
      item = goo_canvas_path_new (boardRootItem,
				  "M 43,19 A 22,20 0 1 1 -1,19 L 20,19 z",
				  "fill_color_rgba", 0xFF1030FF,
				  "stroke-color", "black",
				  "line-width", 1.0,
				  NULL);
      goo_canvas_item_translate(item,
				item_width * i + item_width/2 - 20,
				baseline - 25);

      for(j=0; j<number_of_item_y; j++)
	{

	  position[i][j]->x = item_width * i + gap_x;
	  position[i][j]->y = baseline - item_height * j - item_height + gap_y;

	  if(position[i][j]->color != -1)
	    {
	      char car[2];

	      GooCanvasItem *group = goo_canvas_group_new(boardRootItem,
							  NULL);
	      goo_canvas_item_translate(group,
					position[i][j]->x,
					position[i][j]->y);

	      position[i][j]->group = group;

	      item = goo_canvas_rect_new (group,
					  0,
					  0,
					  item_width - gap_x * 2,
					  item_height - gap_y,
					  "fill_color_rgba",
					  colorlist[position[i][j]->color],
					  "stroke-color", "black",
					  "line-width", (double)1,
					  NULL);

	      car[0] = symbollist[position[i][j]->color];
	      car[1] = '\0';

	      goo_canvas_text_new (group,
				   (char *)car,
				   20,
				   0,
				   -1,
				   GTK_ANCHOR_NORTH,
				   "font", "sans bold 14",
				   "fill-color", "white",
				   NULL);

	      if(i != number_of_item_x+1)
		{
		  g_signal_connect(item, "button_press_event",
				   (GCallback)gc_drag_event,
				   position[i][j]);
		  g_signal_connect(item, "button_release_event",
				   (GCallback)gc_drag_event,
				   position[i][j]);

		  g_signal_connect(item, "enter_notify_event",
				   (GCallback) item_event,
				   position[i][j]);
		  g_signal_connect(item, "leave_notify_event",
				   (GCallback) item_event,
				   position[i][j]);
		}
	    }

	}
    }

  return NULL;
}