Exemple #1
0
/*-------------------------------------------------------------------------------*/
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);
}
Exemple #2
0
/* ==================================== */
static gboolean
animate_step()
{

  if(!gcomprisBoard)
    return FALSE;

  GooCanvasBounds bounds;
  goo_canvas_item_get_bounds(timer_item, &bounds);

  if(GOO_IS_CANVAS_SVG(timer_item))
    goo_canvas_item_translate(timer_item, timer_step_x1, timer_step_y1);
  else if(GOO_IS_CANVAS_RECT(timer_item))
    g_object_set(timer_item,
		 "x", bounds.x1 + timer_step_x1,
		 "y", bounds.y1 + timer_step_y1,
		 "height", bounds.y2 - bounds.y1 - timer_step_y1,
		 NULL);

  /* Special case for raising/lowering the boat */
  if(boat_position==BOAT_POS_MIDDLE && timer_item==canal_middle_item)
    {
      goo_canvas_item_translate(tuxboat_item, 0, timer_step_y1);
      gc_item_focus_remove(tuxboat_item, NULL);
    }

  if((bounds.y1 >= timer_item_limit_y && timer_step_y1 > 0) ||
     (bounds.y1 <= timer_item_limit_y && timer_step_y1 < 0))
    {
      gtk_timeout_remove (timer_id);
      timer_id = 0;
      animation = FALSE;
      update_water();
      gc_item_focus_init(tuxboat_item, NULL);
      g_object_set (tuxboat_item,
		    "svg-id", "#BOAT_NO_SAIL", NULL);
    }
  else if((bounds.x1 >= timer_item_limit_x && timer_step_x1 > 0) ||
     (bounds.x1 <= timer_item_limit_x && timer_step_x1 < 0))
    {
      gtk_timeout_remove (timer_id);
      timer_id = 0;
      animation = FALSE;
      update_water();
      if (gamewon)
        {
          gc_bonus_display(TRUE, GC_BONUS_FLOWER);
          gamewon = FALSE;
        }
      gc_item_focus_init(tuxboat_item, NULL);
      g_object_set (tuxboat_item,
		    "svg-id", "#BOAT_NO_SAIL", NULL);
    }

  return TRUE;
}
Exemple #3
0
static void
display_image(gchar *imagename, GooCanvasItem *root_item)
{
  GdkPixbuf *pixmap = NULL;
  GooCanvasItem *item;
  double xratio, yratio;
  double iw, ih;

  if (imagename==NULL || !images_selector_displayed)
    return;

  pixmap = gc_pixmap_load_or_null(imagename);

  /* Sad, the image is not found */
  if(!pixmap)
    return;

  iw = IMAGE_WIDTH * gc_zoom_factor_get();
  ih = IMAGE_HEIGHT * gc_zoom_factor_get();

  /* Calc the max to resize width or height */
  xratio = (double) ((iw/(double)gdk_pixbuf_get_width(pixmap)));
  yratio = (double) ((ih/(double)gdk_pixbuf_get_height(pixmap)));
  xratio = MIN(yratio, xratio);

  item = goo_canvas_image_new (root_item,
			       pixmap,
			       0,
			       0,
			       NULL);
  goo_canvas_item_translate(item, ix, iy);
  goo_canvas_item_scale(item, xratio, xratio);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  g_signal_connect(item, "button_press_event",
		   (GCallback) item_event_images_selector,
		   imagename);
  gc_item_focus_init(item, NULL);

  ix += iw + IMAGE_GAP;
  if(ix >= (DRAWING_AREA_X2 - DRAWING_AREA_X1)
     * gc_zoom_factor_get() - IMAGE_GAP)
    {
      ix = 0;
      iy += ih + IMAGE_GAP;
    }

  /* Cannot use GINT_TO_POINTER with a constant calculation */
  guint iy_calc = iy + (ih + IMAGE_GAP)*2;
  g_object_set_data (G_OBJECT (root_item), "iy", GINT_TO_POINTER (iy_calc));
}
Exemple #4
0
// if plate = 1 , move to plate g (left)
// if plate = -1, move to plate d (right)
// if plate = 0 , move to the item list
void
scale_item_move_to(ScaleItem *item, int plate)
{
  ScaleItem *scale;
  GList *list;
  gboolean found;
  int index;

  if(plate != 0)
    {
      if(item->plate)
	item->plate_index = -1;
      else
	gc_sound_play_ogg ("sounds/eraser1.wav", NULL);

      // find the first free place in the plate
      for(index=0; index < 2 * PLATE_SIZE; index++)
        {
	  found = FALSE;
	  for(list = item_list; list; list = list->next)
            {
	      scale = list->data;
	      if(scale->plate_index == index && scale->plate == plate)
		found=TRUE;
            }

	  if(!found)
            {   // move to the plate
	      gdouble x = (plate == 1 ? balance_left_x : balance_right_x);
	      gdouble y = (plate == 1
			   ? balance_left_y + last_delta
			   : balance_right_y - last_delta);

	      item->plate = plate;
	      item->plate_index = index;

	      /* Reparent */
	      g_object_ref(item->item);
	      goo_canvas_item_remove(item->item);
	      goo_canvas_item_add_child ((plate == 1 ? group_g : group_d),
					 item->item, -1);
	      g_object_unref(item->item);

	      gc_item_absolute_move(item->item,
				    x + (index % PLATE_SIZE) * ITEM_W,
				    y + PLATE_Y - ITEM_H + 5 - (index >= PLATE_SIZE ? ITEM_H : 0));
	      break;
            }
        }
      if(found)   // can't find place
	plate=0;
    }

  if(plate==0)
    {   // move the item to the list
      if(item->plate)
	gc_sound_play_ogg ("sounds/eraser1.wav", NULL);
      item->plate = 0;
      /* Reparent */
      g_object_ref(item->item);
      goo_canvas_item_remove(item->item);
      goo_canvas_item_add_child (group_m,
				 item->item, -1);
      g_object_unref(item->item);

      gc_item_absolute_move(item->item,
			    item->x,
			    item->y);
      goo_canvas_item_raise(item->item, NULL);
    }

  scale_anim_plate();
  if (!gamewon)
    gc_item_focus_init(item->item, NULL);
}
Exemple #5
0
/* Callback for the bar operations */
static gint
item_event_ok(GooCanvasItem *item,
	      GooCanvasItem *target,
	      GdkEventButton *event,
	      gchar *data)
{
  GcomprisProperties *properties = gc_prop_get();

  if(data==NULL)
    return FALSE;

  if(!strcmp((char *)data, "ok"))
    {
      /* Set the new locale in the properties */
      if (properties->locale != current_locale)
	{
	  g_free(properties->locale);
	  properties->locale = strdup(current_locale);
	}

      if(current_locale[0] == '\0') {
	/* Set the locale to the default user's locale */
	gc_locale_set(gc_locale_get_user_default());
      } else {
	gc_locale_set(current_locale);
      }

      // Font Face
      g_free(properties->fontface);
      properties->fontface = g_strdup((char *)g_list_nth_data(fontlist, font_index));
      gc_skin_update_font();

      if(properties->music || properties->fx)
	gc_sound_init();

      if(!properties->music && !properties->fx)
	gc_sound_close();
      else
	{
	  if(!properties->music)
	    gc_sound_bg_close();

	  if(!properties->fx)
	    gc_sound_fx_close();
	}
      gc_prop_save(properties);
      gc_config_stop();
    }
  else if(!strcmp((char *)data, "rememberlevel"))
    {
      properties->rememberlevel = (properties->rememberlevel ? 0 : 1);
      g_object_set(item,
                   "svg-id", (properties->rememberlevel ? pixmap_checked : pixmap_unchecked),
                   NULL);
      gc_item_focus_init(item, NULL);
    }
  else if(!strcmp((char *)data, "fullscreen"))
    {
      properties->fullscreen = (properties->fullscreen ? 0 : 1);

      gc_fullscreen_set(properties->fullscreen);

      g_object_set (item,
		    "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked),
		    NULL);

      gc_item_focus_init(item, NULL);
    }
  else if(!strcmp((char *)data, "music"))
    {
      properties->music = (properties->music ? 0 : 1);
      g_object_set (item,
		    "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked),
		    NULL);
      if(!properties->music)
	{
	  gc_sound_bg_close();
	}
      else
	{
	  gc_sound_init();
	  gc_sound_bg_reopen();
	}
      gc_item_focus_init(item, NULL);
    }
  else if(!strcmp((char *)data, "effect"))
    {
      properties->fx = (properties->fx ? 0 : 1);
      if (properties->fx)
	gc_sound_init();
      g_object_set (item,
		    "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked),
		    NULL);
      gc_item_focus_init(item, NULL);
    }
  else if(!strcmp((char *)data, "zoom"))
    {
      properties->zoom = (properties->zoom ? 0 : 1);
      gc_update_canvas_zoom();
      g_object_set (item,
		    "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked),
		    NULL);
      gc_item_focus_init(item, NULL);
    }
  else if(!strcmp((char *)data, "locale_previous"))
    {
      current_locale = get_previous_locale(current_locale);
      g_object_set (item_locale_text,
		    "text", gc_locale_get_name(current_locale),
		    NULL);
      set_locale_flag(current_locale);
    }
  else if(!strcmp((char *)data, "locale_next"))
    {
      current_locale = get_next_locale(current_locale);
      g_object_set (G_OBJECT(item_locale_text),
		    "text", gc_locale_get_name(current_locale),
		    NULL);

      set_locale_flag(current_locale);
    }
  else if(!strcmp((char *)data, "locale_reset"))
    {
      current_locale = linguas[0];
      g_object_set (G_OBJECT(item_locale_text),
		    "text", gc_locale_get_name(current_locale),
		    NULL);

      set_locale_flag(current_locale);
    }
  else if(!strcmp((char *)data, "timer_previous"))
    {
      if(properties->timer>0)
	properties->timer--;

      g_object_set (G_OBJECT(item_timer_text),
		    "text", gettext(timername[properties->timer]),
		    NULL);
    }
  else if(!strcmp((char *)data, "timer_next"))
    {
      if(properties->timer<MAX_TIMER_VALUE)
	properties->timer++;

      g_object_set (G_OBJECT(item_timer_text),
		    "text", gettext(timername[properties->timer]),
		    NULL);
    }
  else if(!strcmp((char *)data, "font_previous"))
    {
      if(font_index-- < 1)
	font_index = g_list_length(fontlist)-1;

      _update_font();
    }
  else if(!strcmp((char *)data, "font_next"))
    {
      if(font_index++ >= g_list_length(fontlist)-1)
	font_index = 0;

      _update_font();
    }
  else if(!strcmp((char *)data, "fontface_reset"))
    {
      font_index = current_font_index;
      _update_font();
    }

  return TRUE;
}
Exemple #6
0
/*
 * Same as display_image but for the dataset
 * The imagelist contains the list of images to be displayed when this dataset is selected
 */
static void
display_image_set(gchar *imagename, GSList *imagelist)
{
  GdkPixbuf *pixmap = NULL;
  GooCanvasItem *item;
  GooCanvasItem *rootitem_set;
  double xratio, yratio;
  double iw, ih;

  if (imagename == NULL || !images_selector_displayed)
    return;

  pixmap = gc_pixmap_load_or_null(imagename);
  if (!pixmap)
    return;

  iw = LIST_IMAGE_WIDTH * gc_zoom_factor_get();
  ih = LIST_IMAGE_HEIGHT * gc_zoom_factor_get();

  /* Calc the max to resize width or height */
  xratio = (double) ((iw/(double)gdk_pixbuf_get_width(pixmap)));
  yratio = (double) ((ih/(double)gdk_pixbuf_get_height(pixmap)));
  xratio = MIN(yratio, xratio);

  item = goo_canvas_image_new (goo_canvas_get_root_item(GOO_CANVAS(canvas_list_selector)),
			       pixmap,
			       0,
			       0,
			       NULL);
  goo_canvas_item_translate(item, 5, isy);
  goo_canvas_item_scale(item, xratio, xratio);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif
  g_object_set_data (G_OBJECT (item), "imagelist", imagelist);

  g_signal_connect(item, "button_press_event",
		     (GCallback) item_event_imageset_selector,
		     imagename);
  gc_item_focus_init(item, NULL);

  isy += ih + IMAGE_GAP;

  gdouble upper = MAX(isy + ih + IMAGE_GAP,
		      (LIST_AREA_Y2 - LIST_AREA_Y1)
		      * gc_zoom_factor_get());

  goo_canvas_set_bounds (GOO_CANVAS(canvas_list_selector),
			 0, 0,
			 (LIST_AREA_X2 - LIST_AREA_X1)
			 * gc_zoom_factor_get(),
			 upper);

  g_object_set(list_bg_item,
	       "height", upper,
	       NULL);

  g_object_set(list_adj,
	       "upper", upper,
	       NULL);

  /* Create a root item to put the image list in it */
  rootitem_set = \
    goo_canvas_group_new (goo_canvas_get_root_item(GOO_CANVAS(canvas_image_selector)),
			  NULL);

  g_object_set_data (G_OBJECT (item), "rootitem", rootitem_set);
  g_object_set_data (G_OBJECT (item), "imageset_done", GINT_TO_POINTER (0));
  g_object_set_data_full (G_OBJECT (item), "imagelist",
			  imagelist, (GDestroyNotify)free_stuff );
}
Exemple #7
0
/* ==================================== */
static GooCanvasItem *superbrain_create_item(GooCanvasItem *parent)
{
  int i, j;
  double x;
  double x1, x2;
  GooCanvasItem *item = NULL;
  Piece *piece = NULL;

  listPiecesClear();

  if(current_y_position < SCROLL_LIMIT)
    {
      goo_canvas_item_translate(boardRootItem, 0.0, Y_STEP);
    }

  x = (BOARDWIDTH - number_of_piece*(PIECE_WIDTH*2+PIECE_GAP))/2 + PLAYING_AREA_X;

  /* Draw a line to separate cleanly */
  x1 = x + PIECE_WIDTH;
  x2 = (BOARDWIDTH + (number_of_piece-1)*(PIECE_WIDTH*2+PIECE_GAP))/2 - PIECE_WIDTH + PLAYING_AREA_X;

  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   x2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   "stroke-color", "white",
			   "line-width", 1.0,
			   NULL);


  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   x2 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   "stroke-color", "black",
			   "line-width", 1.0,
			   NULL);

  /* Continuing the line */
  x1 = PLAYING_HELP_X;
  x2 = x1 + number_of_piece*PIECE_WIDTH;


  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   x2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2,
			   "stroke-color", "white",
			   "line-width", 1.0,
			   NULL);


  goo_canvas_polyline_new (boardRootItem, FALSE, 2,
			   x1 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   x2 + 2, current_y_position + PIECE_HEIGHT + PIECE_GAP/2 + 1,
			   "stroke-color", "black",
			   "line-width", 1.0,
			   NULL);

  /* Draw the pieces */

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

      piece = g_new(Piece, 1);
      piece->listitem = NULL;
      listPieces = g_list_append(listPieces, piece);

      piece->rootitem = goo_canvas_group_new (parent,
					      NULL);


      // Good
      piece->good = goo_canvas_rect_new (piece->rootitem,
					 x + i*(PIECE_WIDTH*2 + PIECE_GAP) - PIECE_WIDTH - PIECE_GAP_GOOD,
					 current_y_position - PIECE_HEIGHT - PIECE_GAP_GOOD,
					 PIECE_WIDTH*2 + PIECE_GAP_GOOD*2,
					 PIECE_HEIGHT*2 + PIECE_GAP_GOOD*2,
					 "fill_color_rgba", COLOR_GOOD,
					 "stroke-color", "white",
					 "line-width", 1.0,
					 "tooltip", _("This item is well placed"),
					 NULL);
      g_object_set (piece->good, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);

      // Misplaced
      piece->misplaced = goo_canvas_rect_new (piece->rootitem,
					      x + i*(PIECE_WIDTH*2 + PIECE_GAP) - PIECE_WIDTH - PIECE_GAP_GOOD,
					      current_y_position - PIECE_HEIGHT - PIECE_GAP_GOOD,
					      PIECE_WIDTH*2 + PIECE_GAP_GOOD*2,
					      PIECE_HEIGHT*2 + PIECE_GAP_GOOD*2,
					      "fill_color_rgba", COLOR_MISPLACED,
					      "stroke-color", "black",
					      "line-width", 1.0,
					      "tooltip", _("This item is misplaced"),
					      NULL);
      g_object_set (piece->misplaced, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);

      for(j=0; j<number_of_color; j++)
	{
	  item = goo_canvas_ellipse_new (piece->rootitem,
					 x + i*(PIECE_WIDTH*2 + PIECE_GAP),
					 current_y_position,
					 PIECE_WIDTH,
					 PIECE_HEIGHT,
					 "fill_color_rgba", colors[j],
					 "stroke-color", "white",
					 "line-width", (double)1,
					 NULL);
	  gc_item_focus_init(item, NULL);

	  g_object_set (item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
	  piece->listitem = g_list_append(piece->listitem, item);

	  g_signal_connect(item, "button-press-event",
			   (GCallback) item_event, piece);
	}

      piece->selecteditem = 0;
      item = g_list_nth_data(piece->listitem,
			     piece->selecteditem);
      g_object_set (item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);

    }

  return NULL;
}
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);
}
Exemple #9
0
/*
 * Do all the bar display and register the events
 */
void
gc_config_start ()
{
  GcomprisProperties	*properties = gc_prop_get();
  gint y_start = 0;
  gint x_start = 0;
  gint x_text_start = 0;
  gint y = 0;
  GooCanvasItem *item;

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

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

  gc_bar_hide(TRUE);

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

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

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

  y = bounds.y2 - 26;

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

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

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

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

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

  y_flag_start = y_start - pixmap_width/2;

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

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

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

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

  // Fullscreen / Window
  y_start += Y_GAP;

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

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


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

  // Music
  y_start += Y_GAP;

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

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


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

  // Effect
  y_start += Y_GAP;

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

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


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

  // Zoom
  y_start += Y_GAP;

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

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

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

  // Timer
  y_start += Y_GAP;

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

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

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

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

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

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

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

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

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

    y_start += Y_GAP;

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

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

  }

  // Difficulty Filter
  y_start += Y_GAP;

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


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

  is_displayed = TRUE;
}
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;

}
Exemple #11
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);
    }
}
Exemple #12
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;
}
Exemple #13
0
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);

}
Exemple #14
0
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);

}
Exemple #15
0
static void
create_panel(GooCanvasItem *parent)
{
    int n_sections;
    GList *list = NULL;
    GcomprisBoard *board;
    GdkPixbuf *pixmap = NULL;
    GooCanvasItem *item;

    gdouble x, y;
    gint int_y;
    GcomprisProperties *properties = gc_prop_get();
    g_assert(properties);

    /* In normal mode, we show all the sections in panel */
    /* in direct submenu access, we show the icon of the submenu */
    if (strcmp(properties->root_menu,"/")==0)
        panelBoards = gc_menu_getlist(properties->root_menu);
    else
        panelBoards = g_list_append(list, gcomprisBoard);

    n_sections = g_list_length(panelBoards);

    if (n_sections == 0)
        return;

    if ( (panel_h/n_sections) <= icon_size_panel)
    {
        icon_size_panel = panel_h / n_sections;
        int_y = 0;
    }
    else
    {
        int_y = (panel_h - n_sections*icon_size_panel)/n_sections;
    }

    x = panel_x + panel_w * 0.25;
    y = panel_y + int_y / 2.0 - 20;

    for (list = panelBoards; list != NULL; list = list->next)
    {
        board = (GcomprisBoard *) list->data;

        pixmap = gc_pixmap_load(board->icon_name);

        item = goo_canvas_image_new (parent,
                                     pixmap,
                                     x,
                                     y,
                                     NULL);

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

        y += int_y + icon_size_panel;

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

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

        if ( ! gc_board_is_demo_only(board) )
            gc_item_focus_init(item, NULL);
    }
}
Exemple #16
0
// show_weight:
// 0 -> no unit,
// 1 -> display g, 1000 -> display kg,
// 10000 -> random (weighted 1:2)
static ScaleItem *
scale_list_add_weight(GooCanvasItem *group,
		      gint weight, int show_weight)
{
  ScaleItem *new_item;
  GdkPixbuf *pixmap;
  gchar *weight_text;
  double x, y;
  GList *last;

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

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

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

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

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

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

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

  item_list = g_list_append(item_list, new_item);
  return new_item;
}
Exemple #17
0
/* =====================================================================
 * 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();

}
Exemple #18
0
/* Setting list of available icons in the control bar */
static void
bar_set (const GComprisBarFlags flags)
{
  // Always reset the zoom factor or the calculation
  // will be wrong
  goo_canvas_item_set_transform(rootitem, NULL);

  _hidden = FALSE;
  goo_canvas_item_raise(rootitem, NULL);

  /* Non yet initialized : Something Wrong */
  if(get_item(GC_BAR_LEVEL) == NULL)
    {
      g_message("in bar_set_level, level_item uninitialized : should not happen\n");
      return;
    }

  current_flags = flags;

  if(gc_help_has_board(gc_board_get_current()))
    current_flags |= GC_BAR_HELP;

  if(flags&GC_BAR_ABOUT)
    current_flags |= GC_BAR_ABOUT;

  if(flags&GC_BAR_CONFIG)
    current_flags |= GC_BAR_CONFIG;

  if(flags&GC_BAR_REPEAT_ICON)
    current_flags |= GC_BAR_REPEAT_ICON;

  if(flags&GC_BAR_REPEAT)
    current_flags |= GC_BAR_REPEAT;

  update_exit_button();

  GSList *list;
  double x = 0;
  for (list = buttons; list != NULL; list = list->next)
    {
      GooCanvasItem *item = (GooCanvasItem *)list->data;
      GComprisBarFlags flag =
        GPOINTER_TO_UINT(g_object_get_data(G_OBJECT (item), "flag"));

      if (flag & current_flags)
        {
          GooCanvasBounds bounds;
	  SET_ITEM_LOCATION(item, x, -20);
          goo_canvas_item_get_bounds(item, &bounds);
          gc_item_focus_init(item, NULL);
          x += bounds.x2 - bounds.x1 + BAR_GAP;

          g_object_set (item,
                        "visibility", GOO_CANVAS_ITEM_VISIBLE,
                        NULL);
        }
      else
          g_object_set (item,
                        "visibility", GOO_CANVAS_ITEM_INVISIBLE,
                        NULL);

    }

  /* Scale the bar back to fit the buttons, no more */
  SET_ITEM_LOCATION(bar_item, 0, 0);
  GooCanvasBounds bounds;
  goo_canvas_item_get_bounds(bar_item, &bounds);
  goo_canvas_item_scale(bar_item,
                        x / (bounds.x2 - bounds.x1),
                        1);

  // Always center the bar with its new bounds
  //SET_ITEM_LOCATION(rootitem, 0, _default_y);
  bar_location (-1, -1, -1);
}
Exemple #19
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);
}
Exemple #20
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;
}
Exemple #21
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;
}
Exemple #22
0
/* ==================================== */
static GooCanvasItem *wordprocessor_create()
{
  GooCanvasItem *item = NULL;
  GdkPixbuf *pixmap;
  double y;

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


  selected_tag = NULL;
  view = gtk_text_view_new ();
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
  /* Change left margin throughout the widget */
  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 1);
  g_signal_connect (view, "key-release-event",
		    G_CALLBACK (key_release_event), NULL);
  g_signal_connect (view, "event-after",
            G_CALLBACK (event_after), NULL);
  g_signal_connect (view, "motion-notify-event",
            G_CALLBACK (motion_notify_event), NULL);
  buffer = 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_ALWAYS);
  gtk_container_add (GTK_CONTAINER (sw), view);

  item = goo_canvas_widget_new (boardRootItem,
				GTK_WIDGET(sw),
				word_area_x1,
				word_area_y1,
				word_area_width,
				word_area_height,
				"anchor", GTK_ANCHOR_NW,
				NULL);
  gtk_widget_show(GTK_WIDGET(view));
  gtk_widget_show(GTK_WIDGET(sw));

  /*
   * Create the default style tags
   */
  doctype_list[0] = &type_text;
  doctype_list[1] = &type_normal;
  doctype_list[2] = &type_letter;
  doctype_list[3] = &type_small;
  doctype_list[4] = &type_big;
//  doctype_list[5] = &type_link;

  y = 20.0;
  /*
   * The save button
   */
  pixmap = gc_pixmap_load("wordprocessor/tool-save.png");
  item = \
    goo_canvas_image_new (boardRootItem,
			  pixmap,
			  17.0,
			  y,
			  NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif
  g_signal_connect(item, "button_press_event",
		   (GCallback) save_event, buffer);
  gc_item_focus_init(item, NULL);


  /*
   * The load button
   */
  pixmap = gc_pixmap_load("wordprocessor/tool-load.png");
  item = \
    goo_canvas_image_new (boardRootItem,
			  pixmap,
			  60.0,
			  y,
			  NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif
  g_signal_connect(item, "button_press_event",
		   (GCallback) load_event, buffer);
  gc_item_focus_init(item, NULL);


  y += 45;
  /*
   * Display the style buttons
   */
  y = display_style_buttons(boardRootItem,
			    20.0,
			    y);

  y += 20;
  display_style_selector(boardRootItem, y);

  y += 40;
  display_color_style_selector(boardRootItem, y);

  /* Now we can create the tags */
  create_tags(buffer, doctype_list[0]);

  gtk_widget_grab_focus(view);

 return NULL;
}
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);

}
Exemple #24
0
/*
 * Do all the bar display and register the events
 */
void
gc_config_start ()
{
  GcomprisProperties	*properties = gc_prop_get();
  gint y_start = 0;
  gint x_start = 0;
  gint x_text_start = 0;
  gint y = 0;
  GooCanvasItem *item;

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

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

  gc_bar_hide(TRUE);

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

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

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

  y = bounds.y2 - 26;

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

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

  x_start += 60;
  x_text_start = x_start + 80;

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

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

  y_flag_start = y_start - pixmap_width/2;

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

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

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

  // Fullscreen / Window
  y_start += Y_GAP;

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

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


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

  // Rememberlevel
  y_start += Y_GAP;

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

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


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


  // Music
  y_start += Y_GAP;

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

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


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

  // Effect
  y_start += Y_GAP;

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

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


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

  // Zoom
  y_start += Y_GAP;

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

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

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

  // Timer
  y_start += Y_GAP;

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

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

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

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

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

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

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

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

  // Difficulty Filter
  y_start += Y_GAP;

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


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

  is_displayed = TRUE;
}