示例#1
0
void taninitstart(void){

  int i;

  for (i = PXSTART; i<PXNBR+PXSTART; i++){
    tabpxnam[i] = NULL;
    tabpxpx[i] = NULL;
  }

  for (i = 0; i<GCNBR; i++)
    tabcolalloc[i] = FALSE;

  editmode = FALSE;
  figgrande = figuredebut;
  figtabsize = 0;

  tansetnewfigurepart1(-1);

  tansetdefconfig();

  tanclampgrandefig();


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


  create_mainwindow(boardRootItem);

  tanloadfigtab(figfilename);

}
示例#2
0
static void
create_focus_box (GtkWidget     *canvas,
		  gdouble        x,
		  gdouble        y,
		  gdouble        width,
		  gdouble        height,
		  gchar         *color)
{
  GooCanvasItem *root, *item;

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
  item = goo_canvas_rect_new (root, x, y, width, height,
			      "stroke-pattern", NULL,
			      "fill-color", color,
			      "line-width", 5.0,
			      "can-focus", TRUE,
			      NULL);
  g_object_set_data (G_OBJECT (item), "id", color);

  g_signal_connect (item, "focus_in_event",
		    G_CALLBACK (on_focus_in), NULL);
  g_signal_connect (item, "focus_out_event",
		    G_CALLBACK (on_focus_out), NULL);

  g_signal_connect (item, "button_press_event",
		    G_CALLBACK (on_button_press), NULL);

  g_signal_connect (item, "key_press_event",
		    G_CALLBACK (on_key_press), NULL);
}
示例#3
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
}
示例#4
0
static AtkObject*
goo_canvas_accessible_ref_child (AtkObject *object,
				 gint       child_num)
{
  GtkAccessible *accessible;
  GtkWidget *widget;
  GooCanvasItem *root;
  AtkObject *atk_object;

  /* Canvas only has one child, so return NULL if index is non zero */
  if (child_num != 0)
    return NULL;

  accessible = GTK_ACCESSIBLE (object);
  widget = accessible->widget;

  /* Check if widget still exists. */
  if (widget == NULL)
    return NULL;

  root = goo_canvas_get_root_item (GOO_CANVAS (widget));
  if (!root)
    return NULL;

  atk_object = atk_gobject_accessible_for_object (G_OBJECT (root));
  g_object_ref (atk_object);

  return atk_object;
}
示例#5
0
文件: wordsgame.c 项目: laya/GCompris
static void wordsgame_add_new_item()
{

  g_assert(gcomprisBoard->canvas!=NULL);
  wordsgame_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));

}
示例#6
0
文件: display.c 项目: bert/depcb
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();
}
示例#7
0
文件: imageid.c 项目: GNOME/gcompris
/* set initial values for the next level */
static void
imageid_next_level()
{
  gc_bar_set_level(gcomprisBoard);

  imageid_destroy_all_items();
  selected_button = NULL;
  gamewon = FALSE;

  destroy_board_list();
  init_xml(gcomprisBoard->level);

  gcomprisBoard->number_of_sublevel = g_list_length(board_list);

  gc_score_end();
  gc_score_start(SCORESTYLE_NOTE,
		 BOARDWIDTH - 195,
		 BOARDHEIGHT - 30,
		 gcomprisBoard->number_of_sublevel);

  gc_score_set(gcomprisBoard->sublevel);

  /* Try the next level */
  imageid_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
}
示例#8
0
/* =====================================================================
 *
 * =====================================================================*/
static void start_board (GcomprisBoard *agcomprisBoard) {
  if(agcomprisBoard!=NULL) {
    gcomprisBoard=agcomprisBoard;
    gcomprisBoard->level=1;
    gcomprisBoard->maxlevel=LAST_BOARD;
    gcomprisBoard->sublevel = 1;
    gcomprisBoard->number_of_sublevel = 8;

    gc_bar_set(GC_BAR_LEVEL);
    gc_score_start(SCORESTYLE_NOTE,
		   BOARDWIDTH - 195,
		   BOARDHEIGHT - 30,
		   gcomprisBoard->number_of_sublevel);

    gamewon = FALSE;
    init_xml();

    g_signal_connect(goo_canvas_get_root_item(gcomprisBoard->canvas),
		     "button_press_event",
    		     (GtkSignalFunc) item_event, NULL);

    colors_next_level();
    pause_board(FALSE);
  }
}
示例#9
0
/* =====================================================================
 * set initial values for the next level
 * =====================================================================*/
static void submarine_next_level()
{
  ballast_av_purge_open = ballast_ar_purge_open = regleur_purge_open = FALSE;
  ballast_av_chasse_open = ballast_ar_chasse_open = regleur_chasse_open = FALSE;
  air_charging = battery_charging = FALSE;
  barre_av_angle = barre_ar_angle = 0.0;
  depth = SUBMARINE_INITIAL_DEPTH;
  submarine_horizontal_speed = speed_ordered = 0.0;
  submarine_x = SUBMARINE_INITIAL_X;
  weight = WEIGHT_INITIAL;
  regleur = REGLEUR_INITIAL;
  air = AIR_INITIAL;
  battery = BATTERY_INITIAL;
  ballast_av_air = ballast_ar_air = MAX_BALLAST/10.0;
  assiette = 0.0;
  submarine_destroyed = FALSE;
  treasure_captured = FALSE;

  submarine_destroy_all_items();
  gamewon = FALSE;

  /* Try the next level */
  submarine_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));

  gc_bar_set_level(gcomprisBoard);

}
示例#10
0
static void start_board (GcomprisBoard *agcomprisBoard)
{

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;

      /* disable im_context */
      gcomprisBoard->disable_im_context = TRUE;

      gcomprisBoard->level=1;
      gcomprisBoard->maxlevel=NUMBER_OF_TARGET;
      gcomprisBoard->sublevel=1;
      gcomprisBoard->number_of_sublevel=1; /* Go to next level after this number of 'play' */

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"target/target_background.svgz");

      gc_bar_set(GC_BAR_LEVEL);
      gc_bar_location(BOARDWIDTH-200, -1, 0.8);

      target_next_level();

      gamewon = FALSE;
      pause_board(FALSE);
    }
}
示例#11
0
/* =====================================================================
 *
 * =====================================================================*/
static void start_board (GcomprisBoard *agcomprisBoard) {
  if(agcomprisBoard!=NULL) {
    gcomprisBoard=agcomprisBoard;
    gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
    		      "submarine/sub_bg.svgz");
    gcomprisBoard->level=1;
    gcomprisBoard->maxlevel=4;
    gcomprisBoard->sublevel=1;
    gc_bar_set(GC_BAR_LEVEL);
    gc_bar_location(0, -1, 0.6);
    backgroundRootItem =						\
	 submarine_drawbackground(goo_canvas_get_root_item(gcomprisBoard->canvas));
    submarine_next_level();
    gamewon = FALSE;
    pause_board(FALSE);
  }
}
示例#12
0
文件: maze.c 项目: GNOME/gcompris
/* =====================================================================
 *
 * =====================================================================*/
static void start_board (GcomprisBoard *agcomprisBoard) {

  if(agcomprisBoard!=NULL) {

    gcomprisBoard=agcomprisBoard;

    /* disable im_context */
    gcomprisBoard->disable_im_context = TRUE;

    gc_set_default_background(goo_canvas_get_root_item(gcomprisBoard->canvas));

    gcomprisBoard->level=1;
    gcomprisBoard->maxlevel=20;

    /* The mode defines if we run 2D or 3D */
    /* Default mode is 2D */
    modeRelative=FALSE;
    modeIsInvisible=FALSE;
    run_fast_possible=TRUE;
    if(!gcomprisBoard->mode)
      modeIs2D=TRUE;
    else if(g_ascii_strncasecmp(gcomprisBoard->mode, "2DR", 3)==0) {
      /* 2D Relative */
      modeIs2D=TRUE;
      modeRelative=TRUE;
    } else if(g_ascii_strncasecmp(gcomprisBoard->mode, "2DI", 3)==0) {
      modeIs2D=TRUE;
      modeIsInvisible=TRUE;
    } else if(g_ascii_strncasecmp(gcomprisBoard->mode, "2D", 2)==0) {
      modeIs2D=TRUE;
    } else if(g_ascii_strncasecmp(gcomprisBoard->mode, "3D", 2)==0) {
      modeIs2D=FALSE;
      run_fast_possible=FALSE;
    }

    if(!modeIs2D || modeIsInvisible) {
      RsvgHandle *svg_handle;
      svg_handle = gc_rsvg_load("maze/maze-2d-bubble.svg");
      if(svg_handle) {
	gc_bar_set_repeat_icon(svg_handle);
	g_object_unref(svg_handle);
	gc_bar_set(GC_BAR_LEVEL|GC_BAR_REPEAT_ICON);
      } else {
	gc_bar_set(GC_BAR_LEVEL|GC_BAR_REPEAT);
      }
    } else {
      /* 2D Regular mode */
      gc_bar_set(GC_BAR_LEVEL);
    }
    gc_bar_location(-1, -1, 0.6);

    gamewon = FALSE;

    maze_next_level();
    pause_board(FALSE);
  }
}
示例#13
0
static VALUE
rg_root_item(VALUE self)
{
    VALUE root;

    root = GOBJ2RVAL(goo_canvas_get_root_item(SELF(self)));
    G_CHILD_ADD(self, root);

    return root;
}
示例#14
0
文件: wordsgame.c 项目: laya/GCompris
static void start_board (GcomprisBoard *agcomprisBoard)
{

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;

      GHashTable *config = gc_db_get_board_conf();
      gc_locale_set(g_hash_table_lookup( config, "locale"));

      gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");
      if (up_init_str && (strcmp(up_init_str, "True")==0))
	uppercase_only = TRUE;
      else
	uppercase_only = FALSE;

      g_hash_table_destroy(config);

      /* disable im_context */
      //gcomprisBoard->disable_im_context = TRUE;

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"wordsgame/scenery_background.png");


      gcomprisBoard->level = 1;
      gcomprisBoard->maxlevel = 6;
      gcomprisBoard->sublevel = 0;
      gc_bar_set(GC_BAR_LEVEL|GC_BAR_CONFIG);

      /* Default speed */
      speed=DEFAULT_SPEED;
      fallSpeed=DEFAULT_FALLSPEED;

      gc_wordlist = gc_wordlist_get_from_file("wordsgame/default-$LOCALE.xml");

      if(!gc_wordlist)
	{
	  /* Fallback to english */
	  gc_wordlist = gc_wordlist_get_from_file("wordsgame/default-en.xml");

	  if(!gc_wordlist)
	    {
	      gcomprisBoard = NULL;
	      gc_dialog(_("Error: We can't find\na list of words to play this game.\n"), gc_board_end);
	      return;
	    }
	}
      if(gc_wordlist)
      {
        gcomprisBoard->maxlevel = gc_wordlist->number_of_level;
      }
      wordsgame_next_level();
    }
}
示例#15
0
文件: maze.c 项目: GNOME/gcompris
static void
twoDdisplay()
{
  gc_sound_play_ogg ("sounds/flip.wav", NULL);
  gc_set_default_background(goo_canvas_get_root_item(gcomprisBoard->canvas));

  if (threedgroup)
    g_object_set (threedgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
  g_object_set (boardRootItem, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
  threeDactive=FALSE;
}
示例#16
0
/* set initial values for the next level */
static void target_next_level()
{

  gc_bar_set_level(gcomprisBoard);

  target_destroy_all_items();
  gamewon = FALSE;

  /* Try the next level */
  target_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
}
示例#17
0
int
main ()
{
  GtkWidget *window, *scrolled_win, *canvas;
  GooCanvasItem *root, *rect_item, *text_item;

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

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

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

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

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

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

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

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

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

  return 0;
}
示例#18
0
/* ======================================= */
static void
end_board ()
{
  if(gcomprisBoard!=NULL)
    {
      gc_drag_stop(goo_canvas_get_root_item(gcomprisBoard->canvas));
      pause_board(TRUE);
      hanoi_destroy_all_items();
    }
  gcomprisBoard = NULL;
}
示例#19
0
文件: maze.c 项目: GNOME/gcompris
static void
threeDdisplay()
{
  gc_sound_play_ogg ("sounds/flip.wav", NULL);
  gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
		    "maze/maze-bg.svgz");
  g_object_set (boardRootItem, "visibility",
		GOO_CANVAS_ITEM_INVISIBLE, NULL);
  threeDactive=TRUE;
  draw3D();
}
示例#20
0
static void
missing_letter_next_sublevel()
{
  missing_letter_destroy_all_items();
  selected_button = NULL;
  gamewon = FALSE;

  gc_score_set(gcomprisBoard_missing->sublevel);

  /* Try the next level */
  missing_letter_create_item(goo_canvas_get_root_item(gcomprisBoard_missing->canvas));
}
示例#21
0
文件: imageid.c 项目: GNOME/gcompris
static void
imageid_next_sublevel()
{
  imageid_destroy_all_items();
  selected_button = NULL;
  gamewon = FALSE;

  gc_score_set(gcomprisBoard->sublevel);

  /* Try the next level */
  imageid_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
}
示例#22
0
/* set initial values for the next level */
static void
click_on_letter_next_level()
{
  gc_bar_set_level(gcomprisBoard);

  click_on_letter_destroy_all_items();
  gamewon = FALSE;
  selected_button = NULL;
  /* Try the next level */
  gc_sound_play_ogg("voices/$LOCALE/misc/click_on_letter.ogg", NULL);
  click_on_letter_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
  gc_score_set_max(gcomprisBoard->number_of_sublevel);
  gc_score_set(gcomprisBoard->sublevel);
}
示例#23
0
DrawSelection *
draw_selection_new (GooCanvas *canvas)
{
   GooCanvasItem *root;
   DrawSelection *sel;

   root = goo_canvas_get_root_item(canvas);
   sel = g_object_new(DRAW_TYPE_SELECTION,
                      "parent", root,
                      "stroke-color", "#000000",
                      "line-width", 1.0,
                      "line-join", CAIRO_LINE_JOIN_ROUND,
                      NULL);

   return sel;
}
示例#24
0
文件: gtans.c 项目: GNOME/gcompris
static void start_board (GcomprisBoard *agcomprisBoard)
{

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;

      gcomprisBoard->level = 1;
      gcomprisBoard->maxlevel = 1;
      gc_bar_set(0);

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"tangram/gtans_bg.svgz");

      selectedgrande = FALSE;
      taninitstart();
    }
}
示例#25
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;
}
示例#26
0
static void
create_canvas (GtkGrid *grid, gint row, gchar *text, gchar *id)
{
  GtkWidget *label, *canvas;
  GooCanvasItem *root, *rect;
  char *view_id;

  label = gtk_label_new (text);
  gtk_grid_attach (grid, label, 0, row, 1, 1);
  gtk_widget_show (label);

  canvas = goo_canvas_new ();

  gtk_widget_set_size_request (canvas, 200, 100);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 200, 100);
  gtk_grid_attach (grid, canvas, 1, row, 1, 1);
  gtk_widget_show (canvas);

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));

  rect = goo_canvas_rect_new (root, 0, 0, 200, 100,
			      "stroke-pattern", NULL,
			      "fill-color", "yellow",
			      NULL);
  view_id = g_strdup_printf ("%s-yellow", id);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);

  rect = goo_canvas_rect_new (root, 20, 20, 60, 60,
			      "stroke-pattern", NULL,
			      "fill-color", "blue",
			      NULL);
  view_id = g_strdup_printf ("%s-blue", id);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);

  rect = goo_canvas_rect_new (root, 120, 20, 60, 60,
			      "stroke-pattern", NULL,
			      "fill-color", "red",
			      NULL);
  view_id = g_strdup_printf ("%s-red", id);
  g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
  setup_item_signals (rect);
}
示例#27
0
/* set initial values for the next level */
static void hanoi_next_level()
{

  gc_bar_set_level(gcomprisBoard);

  hanoi_destroy_all_items();
  gamewon = FALSE;

  /* Select level difficulty */
  switch(gcomprisBoard->level)
    {
    case 1:
      number_of_item_x = 3;
      number_of_item_y = 5;
      break;
    case 2:
      number_of_item_x = 4;
      number_of_item_y = 5;
      break;
    case 3:
      number_of_item_x = 5;
      number_of_item_y = 6;
    case 4:
      number_of_item_x = 6;
      number_of_item_y = 7;
      break;
    case 5:
      number_of_item_x = 6;
      number_of_item_y = 8;
      break;
    case 6:
      number_of_item_x = 5;
      number_of_item_y = 9;
      break;
    default:
      number_of_item_x = 5;
      number_of_item_y = 7;
    }


  /* Try the next level */
  hanoi_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
}
示例#28
0
文件: maze.c 项目: GNOME/gcompris
static void
draw3D()
{
#define MAINX 400
#define MAINY 240
#define MAINSX 400
#define MAINSY 240

  if (threedgroup!=NULL)
    {
      goo_canvas_item_remove(threedgroup);
      threedgroup = NULL;
    }
  if (!threeDactive) return;
  threedgroup = goo_canvas_group_new(goo_canvas_get_root_item(gcomprisBoard->canvas),
				     NULL);
  Display3(vector_ctor(position[ind][0],position[ind][1]),viewing_direction,
	   screenparam_ctor(MAINX,MAINY,MAINSX,MAINSY,0.95*MAINSX,0.95*MAINSY));
}
示例#29
0
/* create a new canvas */
canvas_goocanvas::canvas_goocanvas()
  : canvas_t(goo_canvas_new())
{
  GooCanvasItem *root = goo_canvas_get_root_item(GOO_CANVAS(widget));

  /* create the groups */
  for(unsigned int gr = 0; gr < group.size(); gr++)
    group[gr] = goo_canvas_group_new(root, nullptr);

  GObject *w = G_OBJECT(widget);
  g_signal_connect_swapped(w, "destroy",
                           G_CALLBACK(canvas_delete), this);

  g_object_set(w, "anchor", GTK_ANCHOR_CENTER, nullptr);

  gtk_widget_set_events(widget,
                        GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                        GDK_SCROLL_MASK | GDK_POINTER_MOTION_MASK |
                        GDK_POINTER_MOTION_HINT_MASK);
}
示例#30
0
static void
add_widget_clicked (GtkWidget *button, gpointer data)
{
  GooCanvasItem *root, *witem;
  GtkWidget *widget;

  if (num_added_widgets % 2)
    widget = gtk_label_new ("Hello World");
  else
    widget = gtk_entry_new ();

  root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
  witem = goo_canvas_widget_new (root, widget,
				 num_added_widgets * 50,
				 num_added_widgets * 50,
				 200, 50, NULL);

  added_widget_items = g_list_prepend (added_widget_items, witem);
  num_added_widgets++;
}