Пример #1
0
static void start_frigate_anim()
{
  GdkPixbuf *pixmap;
  int w;
  if (frigate_item)
    stop_frigate_anim();

  // the antisubmarine warfare frigate
  pixmap = gc_pixmap_load("submarine/asw_frigate.png");
  w = gdk_pixbuf_get_width(pixmap);

  frigate_item = goo_canvas_image_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
				       pixmap,
				       0,
				       0,
				       NULL);
  goo_canvas_item_translate(frigate_item, BOARDWIDTH, 6);
  goo_canvas_item_animate(frigate_item,
			  -w,
			  2.0,
			  1,
			  0,
			  TRUE,
			  100*1000,
			  100,
			  GOO_CANVAS_ANIMATE_RESTART);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif
}
Пример #2
0
void
init_display()
{
	int	i;

	pcb.scale = 1.0;
	for (i = 0; i < pcb.layers; i++) {
		pcb.layer[i].canvas = GOO_CANVAS(goo_canvas_new());
		gtk_object_ref(GTK_OBJECT(pcb.layer[i].canvas));
		goo_canvas_set_bounds(pcb.layer[i].canvas,
		    0, 0, pcb.width, pcb.height);
		pcb.layer[i].root =
		    goo_canvas_get_root_item(pcb.layer[i].canvas);
		goo_canvas_image_new(pcb.layer[i].root, pcb.layer[i].img, 0, 0,
		    NULL);
		init_layer_events(pcb.layer[i].root);
		show_overlays(i);
	}

	pcb.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(pcb.window), 800, 600);
	gtk_window_set_title(GTK_WINDOW(pcb.window), pcb.filename);

	init_window_events(pcb.window);

	pcb.scrolled = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(pcb.scrolled);
	gtk_container_add(GTK_CONTAINER(pcb.window), pcb.scrolled);

	redisplay();
}
Пример #3
0
/*
 * Same as draw rect but for an image
 * Returns the created item
 */
static GooCanvasItem *
draw_image(GooCanvasItem *group,
	   int x,int y, GdkPixbuf *pixmap)
{
  GooCanvasItem *item = NULL;
  int x1,y1;
  GdkPixbuf *pixmap2;

  y1=cellsize*(y)-hoogte + board_border_y;
  x1=cellsize*(x)-breedte + board_border_x;

  pixmap2 = gdk_pixbuf_scale_simple (pixmap,
				     cellsize-buffer*2,
				     cellsize-buffer*2,
				     GDK_INTERP_BILINEAR);
  item = goo_canvas_image_new (group,
			       pixmap2,
			       x1+buffer,
			       y1+buffer,
			       NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap2);
#else
  g_object_unref(pixmap2);
#endif

  return(item);
}
Пример #4
0
static void display_sponsor(GooCanvasItem *rootitem)
{
    GooCanvasItem *item;
    GdkPixbuf   *pixmap = NULL;
    /* Location for a potential sponsor */
    gchar *sponsor_image = gc_file_find_absolute("sponsor.png");
    if(sponsor_image)
    {
        pixmap = gc_pixmap_load("sponsor.png");
        item = goo_canvas_image_new (rootitem,
                                     pixmap,
                                     0.0,
                                     0.0,
                                     NULL);
        SET_ITEM_LOCATION_CENTER(item,
                                 display_x + display_w/2.0,
                                 display_y + display_h/3.0 + 150);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
        gdk_pixbuf_unref(pixmap);
#else
        g_object_unref(pixmap);
#endif
        g_free(sponsor_image);
    }
}
Пример #5
0
bool canvas_t::set_background(const std::string &filename)
{
  canvas_goocanvas *gcanvas = static_cast<canvas_goocanvas *>(this);

  GooCanvasItem *gr = gcanvas->group[CANVAS_GROUP_BG];
  int n = goo_canvas_item_get_n_children(gr);
  if(n > 0) {
    assert_cmpnum(n, 1);
    goo_canvas_item_remove_child(gr, 0);
  }

  if(filename.empty())
    return false;

  gcanvas->bg.pix.reset(gdk_pixbuf_new_from_file(filename.c_str(), nullptr));
  if(!gcanvas->bg.pix)
    return false;

  float width = gdk_pixbuf_get_width(gcanvas->bg.pix.get());
  float height = gdk_pixbuf_get_height(gcanvas->bg.pix.get());

  /* calculate required scale factor */
  gcanvas->bg.scale.x = (gcanvas->bounds.max.x - gcanvas->bounds.min.x) / width;
  gcanvas->bg.scale.y = (gcanvas->bounds.max.y - gcanvas->bounds.min.y) / height;

  GooCanvasItem *bg = goo_canvas_image_new(gr, gcanvas->bg.pix.get(),
                                          gcanvas->bounds.min.x / gcanvas->bg.scale.x - width / 2.0f,
                                          gcanvas->bounds.min.y / gcanvas->bg.scale.y - height / 2.0f,
                                          nullptr);
  goo_canvas_item_scale(bg, gcanvas->bg.scale.x, gcanvas->bg.scale.y);

  return true;
}
Пример #6
0
/* =====================================================================
 *
 * =====================================================================*/
static GooCanvasItem *colors_create_item(GooCanvasItem *parent)
{
  GdkPixbuf *pixmap;
  char *str = NULL;

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


  str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir,
			"highlight.png");
  pixmap = gc_pixmap_load(str);

  highlight_image_item = goo_canvas_image_new (boardRootItem,
					       pixmap,
					       0,
					       0,
					       NULL);

  highlight_width = gdk_pixbuf_get_width(pixmap);
  highlight_height = gdk_pixbuf_get_height(pixmap);

  g_free(str);
  g_object_set (highlight_image_item,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  gdk_pixbuf_unref(pixmap);

  /* setup the clock */
  str = g_strdup_printf("%s%d.png", "timers/clock",errors);
  pixmap = gc_skin_pixmap_load(str);

  clock_image_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   CLOCK_X,
					   CLOCK_Y,
					   NULL);

  gdk_pixbuf_unref(pixmap);
  g_free(str);

  return NULL;
}
Пример #7
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));
}
Пример #8
0
static void display_paying_tux(guint note)
{
  GdkPixbuf *pixmap = NULL;

  g_assert(boardRootItem);

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

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

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

}
Пример #9
0
static void create_item(GooCanvasItem *parent)
{
  MemoryItem *memoryItem;
  gint x, y;
  double height, width;
  double height2, width2;
  GdkPixbuf *pixmap = NULL;

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

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

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


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

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

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

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

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

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

	  memoryItem = g_malloc0(sizeof(MemoryItem));

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

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

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

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


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

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

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

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

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

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

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

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

	}
    }

  //return (NULL);
}
Пример #10
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;
}
Пример #11
0
/* ==================================== */
static void
missing_letter_create_item(GooCanvasItem *parent)
{
  int xOffset, yOffset;
  GdkPixbuf *button_pixmap = NULL;
  GdkPixbuf *pixmap = NULL;
  Board *board;

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

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

  guint vertical_separation;
  gint i;

  board_number = gcomprisBoard_missing->sublevel-1;

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

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

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

  pixmap = gc_pixmap_load(board->pixmapfile);

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

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

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

  vertical_separation = 10 + 20 / i;

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

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

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

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

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

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

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

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

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

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

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

      yOffset += gdk_pixbuf_get_height(button_pixmap) + vertical_separation;

      i++;
    }

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(button_pixmap);
#else
  g_object_unref(button_pixmap);
#endif
}
Пример #12
0
void
gc_timer_display(int ax, int ay,
		 TimerList atype, int second,
		 GcomprisTimerEnd agcomprisTimerEnd)
{
  GdkFont *gdk_font;
  GdkPixbuf *pixmap = NULL;
  GcomprisProperties *properties = gc_prop_get();

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

  gdk_font = gdk_font_load (FONT_BOARD_MEDIUM);

  gc_timer_end();

  paused = FALSE;

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

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

  type = atype;
  gcomprisTimerEnd = agcomprisTimerEnd;

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

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

	pixmap = gc_skin_pixmap_load(filename);

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

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

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

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

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

      break;
    default:
      break;
    }

  start_animation();
}
Пример #13
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);

}
Пример #14
0
/*
 * Do all the bar display and register the events
 */
void gc_about_start ()
{
  GdkPixbuf   *pixmap = NULL;
  gdouble y_start = 0;
  gint y = 0;
  GooCanvasItem *item;

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

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

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

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

  gc_bar_hide (TRUE);

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

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

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

  y = bounds.y2 - 26;

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

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

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

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

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

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

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

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

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

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

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

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

  is_displayed = TRUE;

}
Пример #15
0
/* =====================================================================
 *
 * =====================================================================*/
static GooCanvasItem *submarine_create_item(GooCanvasItem *parent) {
  GdkPixbuf *pixmap = NULL;
  char s12[12];
  int i, w, h;

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

  pixmap = gc_pixmap_load("submarine/submarine.png");
  submarine_width = gdk_pixbuf_get_width(pixmap);
  submarine_height = gdk_pixbuf_get_height(pixmap);
  submarine_item = goo_canvas_image_new (boardRootItem,
					 pixmap,
					 0,//SUBMARINE_INITIAL_X,
					 0,//SUBMARINE_INITIAL_DEPTH + SURFACE_IN_BACKGROUND - submarine_height,
					 NULL);

  gdk_pixbuf_unref(pixmap);


  pixmap = gc_pixmap_load("submarine/sub_schema.png");

  w = gdk_pixbuf_get_width(pixmap);
  h = gdk_pixbuf_get_height(pixmap);

  schema_x = (BOARDWIDTH - w)/2 ;
  schema_y = BOARDHEIGHT - h;
  goo_canvas_image_new (boardRootItem,
			pixmap,
			schema_x,
			schema_y,
			NULL);

  gdk_pixbuf_unref(pixmap);

  pixmap = gc_pixmap_load("submarine/vanne.png");

  ballast_ar_purge_item = goo_canvas_image_new (boardRootItem,
						pixmap,
						PURGE_AR + schema_x,
						schema_y -1.0,
						 NULL);
  g_signal_connect(ballast_ar_purge_item, "button-press-event",
		   (GtkSignalFunc) ballast_ar_purge_event, NULL);

  ballast_av_purge_item = goo_canvas_image_new (boardRootItem,
						pixmap,
						PURGE_AV + schema_x,
						schema_y -1.0,
						NULL);
  g_signal_connect(ballast_av_purge_item, "button-press-event",  (GtkSignalFunc) ballast_av_purge_event, NULL);

  regleur_purge_item = goo_canvas_image_new (boardRootItem,
					     pixmap,
					     REGLEUR + schema_x,
					     schema_y -2.0,
					     NULL);
  g_signal_connect(regleur_purge_item, "button-press-event",  (GtkSignalFunc) regleur_purge_event, NULL);

  ballast_av_chasse_item = goo_canvas_image_new (boardRootItem,
						 pixmap,
						 schema_x + CHASSE_BALLAST_AV_X,
						 schema_y +  CHASSE_BALLAST_AV_Y,
						 NULL);
  g_signal_connect(ballast_av_chasse_item, "button-press-event",  (GtkSignalFunc) ballast_av_chasse_event, NULL);

  ballast_ar_chasse_item = goo_canvas_image_new (boardRootItem,
						 pixmap,
						 schema_x + CHASSE_BALLAST_AR_X,
						 schema_y +  CHASSE_BALLAST_AR_Y,
						  NULL);
  g_signal_connect(ballast_ar_chasse_item, "button-press-event",
		   (GtkSignalFunc) ballast_ar_chasse_event, NULL);

  regleur_chasse_item = goo_canvas_image_new (boardRootItem,
					      pixmap,
					      schema_x + CHASSE_REGLEUR_X,
					      schema_y + CHASSE_REGLEUR_Y,
					      NULL);
  g_signal_connect(regleur_chasse_item, "button-press-event",
		   (GtkSignalFunc) regleur_chasse_event, NULL);

  gdk_pixbuf_unref(pixmap);

  // DEPTH RUDDERS
  pixmap = gc_pixmap_load("submarine/rudder.png");
  w = gdk_pixbuf_get_width(pixmap);
  h = gdk_pixbuf_get_height(pixmap);
  barre_av_item = goo_canvas_image_new (boardRootItem,
					pixmap,
					schema_x + BARRE_AV_X,
					schema_y + BARRE_AV_Y,
					 NULL);
  barre_ar_item = goo_canvas_image_new (boardRootItem,
					pixmap,
					schema_x + BARRE_AR_X,
					schema_y + BARRE_AR_Y,
					 NULL);
  gdk_pixbuf_unref(pixmap);

#define COMMAND_OFFSET 20.0
  pixmap = gc_pixmap_load("submarine/up.png");
  int w2 = gdk_pixbuf_get_width(pixmap);
  barre_av_up_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   schema_x + BARRE_AV_X + w - w2,
					   schema_y + BARRE_AV_Y - COMMAND_OFFSET,
					    NULL);
  barre_ar_up_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   schema_x + BARRE_AR_X + w - w2,
					   schema_y + BARRE_AR_Y - COMMAND_OFFSET,
					   NULL);
  engine_up_item = goo_canvas_image_new (boardRootItem,
					 pixmap,
					 schema_x + ENGINE_UP_X,
					 schema_y + ENGINE_UP_Y,
					 NULL);
  gdk_pixbuf_unref(pixmap);

  pixmap = gc_pixmap_load("submarine/down.png");
  barre_av_down_item = goo_canvas_image_new (boardRootItem,
					     pixmap,
					     schema_x + BARRE_AV_X + w - w2,
					     schema_y + BARRE_AV_Y + COMMAND_OFFSET,
					     NULL);
  barre_ar_down_item = goo_canvas_image_new (boardRootItem,
					     pixmap,
					     schema_x + BARRE_AR_X + w - w2,
					     schema_y + BARRE_AR_Y + COMMAND_OFFSET,
					     NULL);
  engine_down_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   schema_x + ENGINE_DOWN_X,
					   schema_y + ENGINE_DOWN_Y,
					   NULL);
  gdk_pixbuf_unref(pixmap);

  g_signal_connect(barre_av_up_item, "button-press-event",
		     (GtkSignalFunc) barre_av_event, GINT_TO_POINTER(UP));
  g_signal_connect(barre_ar_up_item, "button-press-event",
		     (GtkSignalFunc) barre_ar_event, GINT_TO_POINTER(UP));
  g_signal_connect(barre_av_down_item, "button-press-event",
		     (GtkSignalFunc) barre_av_event, GINT_TO_POINTER(DOWN));
  g_signal_connect(barre_ar_down_item, "button-press-event",
		     (GtkSignalFunc) barre_ar_event, GINT_TO_POINTER(DOWN));
  g_signal_connect(engine_up_item, "button-press-event",
		     (GtkSignalFunc) engine_event, GINT_TO_POINTER(UP));
  g_signal_connect(engine_down_item, "button-press-event",
		     (GtkSignalFunc) engine_event, GINT_TO_POINTER(DOWN));

  // displays the speed on the engine
  sprintf(s12,"%d",(int)submarine_horizontal_speed);
  speed_item_back = goo_canvas_text_new (boardRootItem,
					 s12,
					 (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X +1,
					 (gdouble) schema_y + ENGINE_UP_Y + 10 + 1,
					 -1,
					 GTK_ANCHOR_CENTER,
					 "font", gc_skin_font_board_title_bold,
					 "alignment", PANGO_ALIGN_CENTER,
					 "fill-color", TEXT_COLOR_BACK,
					 NULL);
  speed_item_front = goo_canvas_text_new (boardRootItem,
					  s12,
					  (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X,
					  (gdouble) schema_y + ENGINE_UP_Y + 10,
					  -1,
					  GTK_ANCHOR_CENTER,
					  "font", gc_skin_font_board_title_bold,
					  "alignment", PANGO_ALIGN_CENTER,
					  "fill-color", TEXT_COLOR_FRONT,
					  NULL);

  // displays the ballast_av_air value
  ballast_av_air_item_rect = goo_canvas_rect_new (boardRootItem,
						  schema_x + BALLAST_AV_AIR_X1,
						  schema_y + BALLAST_AV_AIR_Y1
						  + BALLAST_AV_AIR_H,
						  BALLAST_AV_AIR_W,
						  BALLAST_AV_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_av_air);
  ballast_av_air_item_back = goo_canvas_text_new (boardRootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_av_air_item_front = goo_canvas_text_new (boardRootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
  setBallastAV(ballast_av_air);

  // displays the ballast_ar_air value
  ballast_ar_air_item_rect = goo_canvas_rect_new (boardRootItem,
						  schema_x + BALLAST_AR_AIR_X1,
						  schema_y + BALLAST_AR_AIR_Y1
						  + BALLAST_AR_AIR_H,
						  BALLAST_AR_AIR_W,
						  BALLAST_AR_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_ar_air);
  ballast_ar_air_item_back = goo_canvas_text_new (boardRootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_ar_air_item_front = goo_canvas_text_new (boardRootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
    setBallastAR(ballast_ar_air);

  // displays the remaining air value
  sprintf(s12,"%d", (int)air);
  air_item_back = goo_canvas_text_new (boardRootItem,
				       s12,
				       (gdouble) schema_x + AIR_X +1,
				       (gdouble) schema_y + AIR_Y + 1,
				       -1,
				       GTK_ANCHOR_CENTER,
				       "font", gc_skin_font_board_title_bold,
				       "fill-color", TEXT_COLOR_BACK,
				       NULL);
  air_item_front = goo_canvas_text_new (boardRootItem,
					s12,
					(gdouble) schema_x + AIR_X,
					(gdouble) schema_y + AIR_Y,
					-1,
					GTK_ANCHOR_CENTER,
					"font", gc_skin_font_board_title_bold,
					"fill-color", TEXT_COLOR_FRONT,
					NULL);

  // displays the remaining battery value
  sprintf(s12,"%d", (int)battery);
  battery_item_back = goo_canvas_text_new (boardRootItem,
					   s12,
					   (gdouble) schema_x + BATTERY_X +1,
					   (gdouble) schema_y + BATTERY_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "alignment", PANGO_ALIGN_CENTER,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  battery_item_front = goo_canvas_text_new (boardRootItem,
					    s12,
					    (gdouble) schema_x + BATTERY_X,
					    (gdouble) schema_y + BATTERY_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "alignment", PANGO_ALIGN_CENTER,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);

  // displays the remaining regleur value
  regleur_item_rect = goo_canvas_rect_new (boardRootItem,
					   schema_x + REGLEUR_X1,
					   schema_y + REGLEUR_Y1 + REGLEUR_H,
					   REGLEUR_W,
					   REGLEUR_H,
					   "fill-color", "blue",
					   "line-width", 0.0,
					   NULL);

  sprintf(s12,"%d", (int)regleur);
  regleur_item_back = goo_canvas_text_new (boardRootItem,
					   s12,
					   (gdouble) schema_x + REGLEUR_TEXT_X +1,
					   (gdouble) schema_y + REGLEUR_TEXT_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  regleur_item_front = goo_canvas_text_new (boardRootItem,
					    s12,
					    (gdouble) schema_x + REGLEUR_TEXT_X,
					    (gdouble) schema_y + REGLEUR_TEXT_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);
  setRegleur(regleur);

  // displays an alert when some parameters are bad
  pixmap = gc_pixmap_load("submarine/alert_submarine.png");
  w = gdk_pixbuf_get_width(pixmap);
  h = gdk_pixbuf_get_height(pixmap);
  alert_submarine = goo_canvas_image_new (boardRootItem,
					  pixmap,
					  ALERT_SUBMARINE_X,
					  ALERT_SUBMARINE_Y,
					  NULL);
  gdk_pixbuf_unref(pixmap);
  g_object_set (alert_submarine,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  // when the submarine makes some bubbles ...
  pixmap = gc_pixmap_load("submarine/bubbling.png");

  for (i=0; i<3; i++) {
    bubbling[i] = goo_canvas_image_new (boardRootItem,
					pixmap,
					0,
					0,
					NULL);
    g_object_set (bubbling[i],
		  "visibility", GOO_CANVAS_ITEM_INVISIBLE,
		  NULL);
  }
  gdk_pixbuf_unref(pixmap);

  // whale item
  pixmap = gc_pixmap_load("submarine/whale.png");
  whale_x = g_random_int_range((int)(BOARDWIDTH/4),
			       (int)(BOARDWIDTH/2));
  whale_y = g_random_int_range((int)(SURFACE_IN_BACKGROUND + gdk_pixbuf_get_height(pixmap)*2),
			       (int)MAX_DEPTH);
  whale = goo_canvas_image_new (boardRootItem,
				pixmap,
				whale_x,
				whale_y,
				NULL);
  gdk_pixbuf_unref(pixmap);

  //  whale being hit
  pixmap = gc_pixmap_load("submarine/whale_hit.png");
  big_explosion = goo_canvas_image_new (boardRootItem,
					pixmap,
					whale_x,
					whale_y,
					NULL);
  g_object_set (big_explosion,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  gdk_pixbuf_unref(pixmap);

  // treasure item
  pixmap = gc_pixmap_load("submarine/crown.png");
  treasure_x = (BOARDWIDTH*3)/4;
  treasure_y = MAX_DEPTH;
  treasure = goo_canvas_image_new (boardRootItem,
				   pixmap,
				   0,
				   0,
				   NULL);
  goo_canvas_item_translate(treasure, treasure_x, 0);
  goo_canvas_item_animate(treasure,
			  treasure_x,
			  treasure_y,
			  0.6,
			  0,
			  TRUE,
			  6*1000,
			  40,
			  GOO_CANVAS_ANIMATE_FREEZE);
  gdk_pixbuf_unref(pixmap);

  // the triggers for air compressor and battery charger
  pixmap = gc_pixmap_load("submarine/manette.png");
  air_compressor_item = goo_canvas_image_new (boardRootItem,
					      pixmap,
					      schema_x + AIR_TRIGGER_X,
					      schema_y + AIR_TRIGGER_Y,
					      NULL);
  battery_charger_item = goo_canvas_image_new (boardRootItem,
					       pixmap,
					       schema_x + BATTERY_TRIGGER_X,
					       schema_y + BATTERY_TRIGGER_Y,
					       NULL);
  gdk_pixbuf_unref(pixmap);

  g_signal_connect(air_compressor_item, "button-press-event",
		   (GtkSignalFunc) air_compressor_event, NULL);
  g_signal_connect(battery_charger_item, "button-press-event",
		   (GtkSignalFunc) battery_charger_event, NULL);

  // the antisubmarine warfare frigate
  pixmap = gc_pixmap_load("submarine/asw_frigate.png");
  w = gdk_pixbuf_get_width(pixmap);
  frigate_item = goo_canvas_image_new (boardRootItem,
				       pixmap,
				       0,
				       0,
				       NULL);
  goo_canvas_item_translate(frigate_item, BOARDWIDTH, 2);
  goo_canvas_item_animate(frigate_item,
			  -w,
			  2.0,
			  1,
			  0,
			  TRUE,
			  30*1000,
			  40,
			  GOO_CANVAS_ANIMATE_RESTART);
  gdk_pixbuf_unref(pixmap);


  /*
   * Set the right wall
   * ------------------
   */

  switch(gcomprisBoard->level)
    {
    case 1:
      gate_top_y = 80;
      gate_bottom_y = schema_y - 100;
      break;
    case 2:
      gate_top_y = 100;
      gate_bottom_y = schema_y - 120;
      break;
    default:
      gate_top_y = 120;
      gate_bottom_y = schema_y - 120;
      break;
    }

  /* At startup, the gate is closed */
  gate_top_current_y = gate_bottom_y;
  top_gate_item = goo_canvas_rect_new (boardRootItem,
				       BOARDWIDTH - 25,
				       40,
				       27,
				       gate_top_current_y - 40,
				       "fill_color_rgba", 0x989677FF,
				       "stroke-color", "black",
				       "line-width", 2.0,
				       NULL);

  goo_canvas_rect_new (boardRootItem,
		       BOARDWIDTH - 25,
		       gate_bottom_y,
		       27,
		       schema_y - gate_bottom_y,
		       "fill_color_rgba", 0x989677FF,
		       "stroke-color", "black",
		       "line-width", 2.0,
		       NULL);


  timer_id = g_timeout_add(UPDATE_DELAY, update_timeout, NULL);
  timer_slow_id = g_timeout_add(UPDATE_DELAY_SLOW, update_timeout_slow, NULL);
  timer_very_slow_id = g_timeout_add(UPDATE_DELAY_VERY_SLOW, update_timeout_very_slow, NULL);

  return NULL;
}
Пример #16
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);
    }
}
Пример #17
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 );
}
Пример #18
0
/* =====================================================================
 *
 * =====================================================================*/
static GooCanvasItem *submarine_create_item(GooCanvasItem *parent) {
  GdkPixbuf *pixmap = NULL;
  GooCanvasItem *item = NULL;
  char s12[12];
  int i;

  GooCanvasItem *rootItem = goo_canvas_group_new (parent, NULL);

  pixmap = gc_pixmap_load("submarine/submarine.png");
  submarine_width = gdk_pixbuf_get_width(pixmap);
  submarine_height = gdk_pixbuf_get_height(pixmap);
  submarine_item = goo_canvas_image_new (rootItem,
					 pixmap,
					 0,
					 0,
					 NULL);

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


  pixmap = gc_pixmap_load("submarine/vanne.svg");
  ballast_ar_purge_item = goo_canvas_image_new (rootItem,
						pixmap,
						PURGE_AR + schema_x,
						schema_y -1.0,
						 NULL);
  g_signal_connect(ballast_ar_purge_item, "button-press-event",
		   (GCallback) ballast_ar_purge_event, NULL);

  ballast_av_purge_item = goo_canvas_image_new (rootItem,
						pixmap,
						PURGE_AV + schema_x,
						schema_y -1.0,
						NULL);
  g_signal_connect(ballast_av_purge_item, "button-press-event",
		   (GCallback) ballast_av_purge_event, NULL);

  regleur_purge_item = goo_canvas_image_new (rootItem,
					     pixmap,
					     REGLEUR + schema_x,
					     schema_y -2.0,
					     NULL);
  g_signal_connect(regleur_purge_item, "button-press-event",
		   (GCallback) regleur_purge_event, NULL);

  item = goo_canvas_image_new (rootItem,
			       pixmap,
			       schema_x + CHASSE_BALLAST_AV_X,
			       schema_y +  CHASSE_BALLAST_AV_Y,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) ballast_av_chasse_event, NULL);

  item = goo_canvas_image_new (rootItem,
			       pixmap,
			       schema_x + CHASSE_BALLAST_AR_X,
			       schema_y +  CHASSE_BALLAST_AR_Y,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) ballast_ar_chasse_event, NULL);

  regleur_chasse_item = goo_canvas_image_new (rootItem,
					      pixmap,
					      schema_x + CHASSE_REGLEUR_X,
					      schema_y + CHASSE_REGLEUR_Y,
					      NULL);
  g_signal_connect(regleur_chasse_item, "button-press-event",
		   (GCallback) regleur_chasse_event, NULL);

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

  // DEPTH RUDDERS
  pixmap = gc_pixmap_load("submarine/rudder.png");
  barre_av_item = goo_canvas_image_new (rootItem,
					pixmap,
					schema_x + BARRE_AV_X,
					schema_y + BARRE_AV_Y,
					 NULL);
  barre_ar_item = goo_canvas_image_new (rootItem,
					pixmap,
					schema_x + BARRE_AR_X,
					schema_y + BARRE_AR_Y,
					 NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // displays the speed on the engine
  sprintf(s12,"%d",(int)submarine_horizontal_speed);
  speed_item_back = goo_canvas_text_new (rootItem,
					 s12,
					 (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X +1,
					 (gdouble) schema_y + ENGINE_UP_Y + 10 + 1,
					 -1,
					 GTK_ANCHOR_CENTER,
					 "font", gc_skin_font_board_title_bold,
					 "alignment", PANGO_ALIGN_CENTER,
					 "fill-color", TEXT_COLOR_BACK,
					 NULL);
  speed_item_front = goo_canvas_text_new (rootItem,
					  s12,
					  (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X,
					  (gdouble) schema_y + ENGINE_UP_Y + 10,
					  -1,
					  GTK_ANCHOR_CENTER,
					  "font", gc_skin_font_board_title_bold,
					  "alignment", PANGO_ALIGN_CENTER,
					  "fill-color", TEXT_COLOR_FRONT,
					  NULL);

  // displays the ballast_av_air value
  ballast_av_air_item_rect = goo_canvas_rect_new (rootItem,
						  schema_x + BALLAST_AV_AIR_X1,
						  schema_y + BALLAST_AV_AIR_Y1
						  + BALLAST_AV_AIR_H,
						  BALLAST_AV_AIR_W,
						  BALLAST_AV_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_av_air);
  ballast_av_air_item_back = goo_canvas_text_new (rootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_av_air_item_front = goo_canvas_text_new (rootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
  setBallastAV(ballast_av_air);

  // displays the ballast_ar_air value
  ballast_ar_air_item_rect = goo_canvas_rect_new (rootItem,
						  schema_x + BALLAST_AR_AIR_X1,
						  schema_y + BALLAST_AR_AIR_Y1
						  + BALLAST_AR_AIR_H,
						  BALLAST_AR_AIR_W,
						  BALLAST_AR_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_ar_air);
  ballast_ar_air_item_back = goo_canvas_text_new (rootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_ar_air_item_front = goo_canvas_text_new (rootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
  setBallastAR(ballast_ar_air);

  // displays the remaining air value
  sprintf(s12,"%d", (int)air);
  air_item_back = goo_canvas_text_new (rootItem,
				       s12,
				       (gdouble) schema_x + AIR_X +1,
				       (gdouble) schema_y + AIR_Y + 1,
				       -1,
				       GTK_ANCHOR_CENTER,
				       "font", gc_skin_font_board_title_bold,
				       "fill-color", TEXT_COLOR_BACK,
				       NULL);
  air_item_front = goo_canvas_text_new (rootItem,
					s12,
					(gdouble) schema_x + AIR_X,
					(gdouble) schema_y + AIR_Y,
					-1,
					GTK_ANCHOR_CENTER,
					"font", gc_skin_font_board_title_bold,
					"fill-color", TEXT_COLOR_FRONT,
					NULL);

  // displays the remaining battery value
  sprintf(s12,"%d", (int)battery);
  battery_item_back = goo_canvas_text_new (rootItem,
					   s12,
					   (gdouble) schema_x + BATTERY_X +1,
					   (gdouble) schema_y + BATTERY_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "alignment", PANGO_ALIGN_CENTER,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  battery_item_front = goo_canvas_text_new (rootItem,
					    s12,
					    (gdouble) schema_x + BATTERY_X,
					    (gdouble) schema_y + BATTERY_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "alignment", PANGO_ALIGN_CENTER,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);

  // displays the remaining regleur value
  regleur_item_rect = goo_canvas_rect_new (rootItem,
					   schema_x + REGLEUR_X1,
					   schema_y + REGLEUR_Y1 + REGLEUR_H,
					   REGLEUR_W,
					   REGLEUR_H,
					   "fill-color", "blue",
					   "line-width", 0.0,
					   NULL);

  sprintf(s12,"%d", (int)regleur);
  regleur_item_back = goo_canvas_text_new (rootItem,
					   s12,
					   (gdouble) schema_x + REGLEUR_TEXT_X +1,
					   (gdouble) schema_y + REGLEUR_TEXT_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  regleur_item_front = goo_canvas_text_new (rootItem,
					    s12,
					    (gdouble) schema_x + REGLEUR_TEXT_X,
					    (gdouble) schema_y + REGLEUR_TEXT_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);
  setRegleur(regleur);

  // displays an alert when some parameters are bad
  pixmap = gc_pixmap_load("submarine/alert_submarine.png");
  alert_submarine = goo_canvas_image_new (rootItem,
					  pixmap,
					  ALERT_SUBMARINE_X,
					  ALERT_SUBMARINE_Y,
					  NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif
  g_object_set (alert_submarine,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  // when the submarine makes some bubbles ...
  pixmap = gc_pixmap_load("submarine/bubbling.png");

  for (i=0; i<3; i++) {
    bubbling[i] = goo_canvas_image_new (rootItem,
					pixmap,
					0,
					0,
					NULL);
    g_object_set (bubbling[i],
		  "visibility", GOO_CANVAS_ITEM_INVISIBLE,
		  NULL);
  }
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // whale item
  switch(gcomprisBoard->level)
    {
    case 1:
      whale_x = 50;
      whale_y = MAX_DEPTH - 100;
      break;
    case 2:
      whale_x = 150;
      whale_y = MAX_DEPTH - 100;
      break;
    case 3:
      whale_x = 250;
      whale_y = MAX_DEPTH - 100;
      break;
    default:
      whale_x = 380;
      whale_y = MAX_DEPTH - 100;
      break;
    }

  pixmap = gc_pixmap_load("submarine/whale.png");
  whale = goo_canvas_image_new (rootItem,
				pixmap,
				whale_x,
				whale_y,
				NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  //  whale being hit
  pixmap = gc_pixmap_load("submarine/whale_hit.png");
  big_explosion = goo_canvas_image_new (rootItem,
					pixmap,
					whale_x,
					whale_y,
					NULL);
  g_object_set (big_explosion,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

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

  // treasure item
  pixmap = gc_pixmap_load("submarine/crown.png");
  treasure_x = (BOARDWIDTH*3)/4;
  treasure_y = MAX_DEPTH;
  treasure = goo_canvas_image_new (rootItem,
				   pixmap,
				   0,
				   0,
				   NULL);
  goo_canvas_item_translate(treasure, treasure_x, 0);
  goo_canvas_item_animate(treasure,
			  treasure_x,
			  treasure_y,
			  0.6,
			  0,
			  TRUE,
			  6*1000,
			  40,
			  GOO_CANVAS_ANIMATE_FREEZE);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // the triggers for air compressor and battery charger
  pixmap = gc_pixmap_load("submarine/manette.png");
  air_compressor_item = goo_canvas_image_new (rootItem,
					      pixmap,
					      schema_x + AIR_TRIGGER_X,
					      schema_y + AIR_TRIGGER_Y,
					      NULL);
  battery_charger_item = goo_canvas_image_new (rootItem,
					       pixmap,
					       schema_x + BATTERY_TRIGGER_X,
					       schema_y + BATTERY_TRIGGER_Y,
					       NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  g_signal_connect(air_compressor_item, "button-press-event",
		   (GCallback) air_compressor_event, NULL);
  g_signal_connect(battery_charger_item, "button-press-event",
		   (GCallback) battery_charger_event, NULL);

  /*
   * Set the right wall
   * ------------------
   */

  switch(gcomprisBoard->level)
    {
    case 1:
      gate_top_y = 80;
      gate_bottom_y = schema_y - 100;
      break;
    case 2:
      gate_top_y = 100;
      gate_bottom_y = schema_y - 120;
      break;
    default:
      gate_top_y = 120;
      gate_bottom_y = schema_y - 120;
      break;
    }

  /* At startup, the gate is closed */
  gate_top_current_y = gate_bottom_y;
  top_gate_item = goo_canvas_rect_new (rootItem,
				       BOARDWIDTH - 25,
				       40,
				       27,
				       gate_top_current_y - 40,
				       "fill_color_rgba", 0x989677FF,
				       "stroke-color", "black",
				       "line-width", 2.0,
				       NULL);

  goo_canvas_rect_new (rootItem,
		       BOARDWIDTH - 25,
		       gate_bottom_y,
		       27,
		       schema_y - gate_bottom_y,
		       "fill_color_rgba", 0x989677FF,
		       "stroke-color", "black",
		       "line-width", 2.0,
		       NULL);


  timer_id = g_timeout_add(UPDATE_DELAY, update_timeout, NULL);
  timer_slow_id = g_timeout_add(UPDATE_DELAY_SLOW, update_timeout_slow, NULL);
  timer_very_slow_id = g_timeout_add(UPDATE_DELAY_VERY_SLOW, update_timeout_very_slow, NULL);

  return rootItem;
}
Пример #19
0
static GooCanvasItem *submarine_drawbackground(GooCanvasItem *parent) {

  GooCanvasItem *backgroundRootItem = goo_canvas_group_new (parent, NULL);
  GooCanvasItem *item;
  GdkPixbuf *pixmap = NULL;
  int w, h;

  pixmap = gc_pixmap_load("submarine/sub_schema.svg");

  w = gdk_pixbuf_get_width(pixmap);
  h = gdk_pixbuf_get_height(pixmap);

  schema_x = (BOARDWIDTH - w)/2 ;
  schema_y = BOARDHEIGHT - h;
  goo_canvas_image_new (backgroundRootItem, pixmap,
  			schema_x, schema_y, NULL);

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

#define COMMAND_OFFSET 20.0
  pixmap = gc_pixmap_load("submarine/up.png");
  int w2 = gdk_pixbuf_get_width(pixmap);
  w = 80; // The rudder width
  item = goo_canvas_image_new (backgroundRootItem,
			       pixmap,
			       schema_x + BARRE_AV_X + w - w2,
			       schema_y + BARRE_AV_Y - COMMAND_OFFSET,
			       NULL);
  g_signal_connect(item, "button-press-event",
		     (GCallback) barre_av_event, GINT_TO_POINTER(UP));

  item = goo_canvas_image_new (backgroundRootItem,
			       pixmap,
			       schema_x + BARRE_AR_X + w - w2,
			       schema_y + BARRE_AR_Y - COMMAND_OFFSET,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) barre_ar_event, GINT_TO_POINTER(UP));

  item = goo_canvas_image_new (backgroundRootItem,
			       pixmap,
			       schema_x + ENGINE_UP_X,
			       schema_y + ENGINE_UP_Y,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) engine_event, GINT_TO_POINTER(UP));

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

  pixmap = gc_pixmap_load("submarine/down.png");
  item = goo_canvas_image_new (backgroundRootItem,
			       pixmap,
			       schema_x + BARRE_AV_X + w - w2,
			       schema_y + BARRE_AV_Y + COMMAND_OFFSET,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) barre_av_event, GINT_TO_POINTER(DOWN));

  item = goo_canvas_image_new (backgroundRootItem,
			       pixmap,
			       schema_x + BARRE_AR_X + w - w2,
			       schema_y + BARRE_AR_Y + COMMAND_OFFSET,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) barre_ar_event, GINT_TO_POINTER(DOWN));

  item = goo_canvas_image_new (backgroundRootItem,
			       pixmap,
			       schema_x + ENGINE_DOWN_X,
			       schema_y + ENGINE_DOWN_Y,
			       NULL);
  g_signal_connect(item, "button-press-event",
		     (GCallback) engine_event, GINT_TO_POINTER(DOWN));

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

  return backgroundRootItem;
}
Пример #20
0
/* ==================================== */
static void
imageid_create_item(GooCanvasItem *parent)
{
  GooCanvasItem *item;
  GooCanvasItem *group;
  GooCanvasItem *button;
  int x, y, xp, yp;
  guint vertical_separation;
  GdkPixbuf *pixmap = NULL;
  Board *board;
  guint i;

  board_number = gcomprisBoard->sublevel-1;

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

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

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

  right_word = board->solution;

  pixmap = gc_pixmap_load(board->pixmapfile);

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

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

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

  xp = HORIZONTAL_SEPARATION;

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

  vertical_separation = 10 + 60 / i;

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

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

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

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

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

      item = goo_canvas_text_new (group,
				  board->text[i],
				  xp +  button_pixmap_width/2 + 1.0,
				  yp +  button_pixmap_height/2 + 1.0,
				  -1,
				  GTK_ANCHOR_CENTER,
				  "font", gc_skin_font_board_big,
				  "fill_color_rgba", gc_skin_color_shadow,
				  NULL);

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

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

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

      yp +=  button_pixmap_height + vertical_separation;

      i++;
    }

}
Пример #21
0
// 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;
}
int
main (int argc, char *argv[])
{
  GtkWidget *window, *scrolled_win, *canvas;
  GooCanvasItem *root, *rect_item, *text_item, *image_item;

	GdkPixbuf *pb;

  /* Initialize GTK+. */
  gtk_set_locale ();
  gtk_init (&argc, &argv);
	


	pb=gdk_pixbuf_new_from_file("test-screenshot.png", NULL);


	if(!pb) {
		printf("error: gdk_pixbuf_new_from_file");
		exit(1);
	}

  /* Create the window and widgets. */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 740, 700);
  gtk_widget_show (window);
  g_signal_connect (window, "delete_event", (GtkSignalFunc) on_delete_event,
                    NULL);

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

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

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

	image_item = goo_canvas_image_new (root, pb, 0, 0, NULL);

  /* Add a few simple items. */
  rect_item = goo_canvas_rect_new (root, 20, 20, 200, 200,
                                   "line-width", 5.0,
                                   "radius-x", 10.0,
                                   "radius-y", 5.0,
                                   "stroke-color", "red",
                                   NULL);
                                   
  GooCanvasItem *polyline0 = goo_canvas_polyline_new_line (root,
                                                        100.0, 100.0,
                                                        500.0, 500.0,
                                                        "stroke-color", "red",
                                                        "line-width", 5.0,
                                                        "start-arrow", TRUE,
                                                        NULL);
                            

  //text_item = goo_canvas_text_new (root, PACKAGE_STRING, 300, 300, -1,
                                   //GTK_ANCHOR_CENTER,
                                   //"font", "Sans 24px",
                                   //NULL);
  //goo_canvas_item_rotate (text_item, 45, 300, 300);

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

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

  return 0;
}
Пример #23
0
// show_weight:
// 0 -> no display,
// 1 -> display g,
// 1000 -> display kg, 10000 -> random (weighted 1:2)
static ScaleItem *
scale_list_add_object(GooCanvasItem *group,
		      GdkPixbuf *pixmap,
		      int weight, int plate,
		      int show_weight)
{
  GooCanvasItem *item;
  ScaleItem * new_item;

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

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

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

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

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

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

  item_list = g_list_append(item_list, new_item);
  return new_item;
}
Пример #24
0
/* ==================================== */
static GooCanvasItem *fifteen_create_item(GooCanvasItem *parent)
{
  int i;
  int x, y;
  GooCanvasItem **board;
  GooCanvasItem *text;
  char buf[20];
  GdkPixbuf *pixmap = NULL;

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

  goo_canvas_item_translate(boardRootItem,
			    (BOARDWIDTH-(4*PIECE_SIZE))/2,
			    (BOARDHEIGHT-(4*PIECE_SIZE))/2);

  /* Load the cute frame */
  pixmap = gc_pixmap_load("fifteen/fifteen_frame.png");

  goo_canvas_image_new (boardRootItem,
			pixmap,
			-1*((gdk_pixbuf_get_width(pixmap)-(4*PIECE_SIZE))/2),
			-1*((gdk_pixbuf_get_height(pixmap)-(4*PIECE_SIZE))/2)-2,
			NULL);
  gdk_pixbuf_unref(pixmap);


  board = g_new (GooCanvasItem *, 16);
  g_object_set_data (G_OBJECT (boardRootItem), "board", board);

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

    board[i] = goo_canvas_group_new (boardRootItem, NULL);

    goo_canvas_item_translate(board[i],
			      (x * PIECE_SIZE),
			      (y * PIECE_SIZE));

    goo_canvas_rect_new (board[i],
			 0.0,
			 0.0,
			 PIECE_SIZE,
			 PIECE_SIZE,
			 "fill-color", get_piece_color (i),
			 "stroke-color", "black",
			 NULL);

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

    text = goo_canvas_text_new (board[i],
				buf,
				(double) PIECE_SIZE / 2.0,
				(double) PIECE_SIZE / 2.0,
				-1,
				GTK_ANCHOR_CENTER,
				"font", gc_skin_font_board_medium,
				"fill-color", "black",
				NULL);

    g_object_set_data (G_OBJECT (board[i]), "piece_num", GINT_TO_POINTER (i));
    g_object_set_data (G_OBJECT (board[i]), "piece_pos", GINT_TO_POINTER (i));
    g_object_set_data (G_OBJECT (board[i]), "text", text);
    g_signal_connect (board[i], "button-press-event",
		      G_CALLBACK (piece_event),
		      NULL);
  }

  board[15] = NULL;

  /* Select level difficulty */
  switch(gcomprisBoard->level)
    {
    case 1:
      scramble(board, 10);
      break;
    case 2:
      scramble(board, 50);
      break;
    case 3:
    case 4:
      scramble(board, 100);
      break;
    case 5:
      scramble(board, 150);
      break;
    default:
      scramble(board, 256);
    }

  return NULL;
}
Пример #25
0
void create_mainwindow (GooCanvasItem *rootitem)
{
    GtkWidget *wdrawareagrande;
    GtkWidget *wdrawareapetite;


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

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

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

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

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

    gtk_widget_show (wdrawareagrande);

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

    gtk_widget_set_events (wdrawareapetite, GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK);

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

    gtk_widget_show (wdrawareapetite);

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


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

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

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

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


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

    gc_item_focus_init(previous_figure, NULL);

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

    gc_item_focus_init(next_figure, NULL);

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

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

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

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

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

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

    gc_item_focus_init(outline_figure, NULL);

    gc_item_focus_init(show_figure, NULL);

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


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

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

    gc_item_focus_init(symetry, NULL);


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

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

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


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


    gdk_pixbuf_unref(right_rot);
    gdk_pixbuf_unref(left_rot);

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

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


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

    gdk_pixbuf_unref(right_rot_big);
    gdk_pixbuf_unref(left_rot_big);


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

    gc_item_focus_init(r_rot_s, NULL);

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

    gc_item_focus_init(l_rot_s, NULL);

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

    gc_item_focus_init(r_rot_b, NULL);

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

    gc_item_focus_init(l_rot_b, NULL);
}
Пример #26
0
static void
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);

}