static void update_tux(gint direction) { gint rotation = 0; GooCanvasBounds bounds; gdouble scale; /* Our svg image of tux is faced south */ switch(direction) { case EAST: rotation = -90; break; case WEST: rotation = 90; break; case NORTH: rotation = 180; break; case SOUTH: rotation = 0; break; } goo_canvas_item_set_transform(tuxitem, NULL); goo_canvas_item_get_bounds(tuxitem, &bounds); scale = (gdouble) cellsize / (bounds.x2 - bounds.x1); goo_canvas_item_scale(tuxitem, scale, scale); goo_canvas_item_rotate( tuxitem, rotation, (bounds.x2-bounds.x1)/2, (bounds.y2-bounds.y1)/2); // update the running shoes if(run_fast_possible && run_fast) { goo_canvas_item_set_transform(tuxshoes, NULL); scale = (gdouble) cellsize / (bounds.x2 - bounds.x1); goo_canvas_item_scale(tuxshoes, scale, scale); goo_canvas_item_rotate( tuxshoes, rotation, (bounds.x2-bounds.x1)/2, (bounds.y2-bounds.y1)/2); } }
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; }
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)); }
static void display_paying_note(guint note, guint x, guint y) { gchar *note_str = g_strdup_printf("money/n%de.svgz", note); RsvgHandle *svg_handle; svg_handle = gc_rsvg_load(note_str); GooCanvasItem *item = goo_canvas_svg_new(boardRootItem, svg_handle, NULL); goo_canvas_item_translate(item, x, y); goo_canvas_item_scale(item, 0.25, 0.25); g_object_unref(svg_handle); g_free(note_str); }
/** Setting the bar location * @param[in] x the bar x coordinate, -1 to set the default * @param[in] y the bar y coordinate, -1 to set the default * @param[in] zoom the bar zoom factor, -1 to set the default */ static void bar_location (int x, int y, double zoom) { // Make the y coord be assigned at its bottom int ny = (y == -1 ? _default_y : y); ny += BARHEIGHT - (zoom == -1 ? _default_zoom : zoom) * BARHEIGHT; goo_canvas_item_set_transform(rootitem, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(rootitem, &bounds); int nx = (x == -1 ? (BOARDWIDTH - (bounds.x2 - bounds.x1))/2 : x); goo_canvas_item_translate(rootitem, nx, ny); goo_canvas_item_scale(rootitem, (zoom == -1 ? _default_zoom : zoom), (zoom == -1 ? _default_zoom : zoom)); //#endif }
void scale_anim_plate(void) { double delta_y; double angle; double scale; int diff; // in MODE_WEIGHT the granularity is gramm, so we use a different factor scale = (board_mode == MODE_WEIGHT) ? 2000.0 : 10.0; diff = get_weight_plate(0); delta_y = CLAMP(PLATE_Y_DELTA / scale * diff, -PLATE_Y_DELTA, PLATE_Y_DELTA); if(get_weight_plate(1) == 0) delta_y = -PLATE_Y_DELTA; /* Update the sign */ if (diff == 0) g_object_set(sign, "text", "=", NULL); else if (diff < 0) g_object_set(sign, "text", "<", NULL); else g_object_set(sign, "text", ">", NULL); if(last_delta != delta_y) { goo_canvas_item_translate(group_g, 0, -last_delta); goo_canvas_item_translate(group_d, 0, last_delta); last_delta = delta_y; angle = tan(delta_y / 138) * 180 / M_PI; goo_canvas_item_translate(group_g, 0, delta_y); goo_canvas_item_translate(group_d, 0, -delta_y); gc_item_rotate_with_center(bras, -angle, 138, 84); } if(diff == 0 && ask_for_answer) { double x_offset = BOARDWIDTH/2; double y_offset = BOARDHEIGHT*0.7; GooCanvasItem *item = goo_canvas_svg_new (boardRootItem, gc_skin_rsvg_get(), "svg-id", "#BUTTON_TEXT", NULL); SET_ITEM_LOCATION_CENTER(item, x_offset / 2, y_offset); goo_canvas_item_scale(item, 2, 1); answer_item = goo_canvas_text_new(boardRootItem, "", x_offset, y_offset, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", "white", NULL); answer_string = g_string_new(NULL); key_press(0, NULL, NULL); } else if(diff == 0) process_ok(); }
static GooCanvasItem *planegame_create_item(GooCanvasItem *parent) { RsvgHandle *svg_handle; RsvgDimensionData dimension; GooCanvasItem *itemgroup; GooCanvasItem *item; char *number = NULL; int i, min; guint y; /* Random cloud number */ if(g_random_int()%2==0) { /* Put the target */ i = plane_target; } else { min = MAX(1, plane_target - 1); i = min + g_random_int()%(plane_target - min + 3); } number = g_strdup_printf("%d", i); itemgroup = goo_canvas_group_new (parent, NULL); g_object_set_data (G_OBJECT (itemgroup), "cloud_number", GINT_TO_POINTER (i)); svg_handle = gc_rsvg_load("planegame/cloud.svgz"); rsvg_handle_get_dimensions(svg_handle, &dimension); y = (g_random_int()%(BOARDHEIGHT - 40 - (guint)(dimension.height * imageZoom))); goo_canvas_item_translate(itemgroup, BOARDWIDTH, y); item = goo_canvas_svg_new (itemgroup, svg_handle, NULL); goo_canvas_item_scale(item, imageZoom, imageZoom); g_object_unref(svg_handle); g_object_set_data (G_OBJECT (item), "cloud_number", GINT_TO_POINTER (i)); item = goo_canvas_text_new (itemgroup, number, dimension.width*imageZoom/2, dimension.height*imageZoom/2, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_big, "fill-color", "red", NULL); g_object_set_data (G_OBJECT (item), "cloud_number", GINT_TO_POINTER (i)); goo_canvas_item_animate(itemgroup, -dimension.width*imageZoom, y, 1.0, 0, TRUE, 40*BOARDWIDTH, 40, GOO_CANVAS_ANIMATE_FREEZE); /* The plane is always on top */ goo_canvas_item_raise(itemgroup, NULL); goo_canvas_item_raise(planeitem, NULL); g_free (number); return (itemgroup); }
void money_widget_add (MoneyWidget *moneyWidget, MoneyEuroType value) { GooCanvasItem *item; RsvgHandle *svg_handle; RsvgDimensionData dimension; double xratio, yratio, ratio; double block_width, block_height; MoneyItem *moneyitem; guint i, length; g_return_if_fail (moneyWidget != NULL); /* Search for an hidden item with the same value */ length = g_list_length(moneyWidget->priv->moneyItemList); for(i=0; i<length; i++) { moneyitem = \ (MoneyItem *)g_list_nth_data(moneyWidget->priv->moneyItemList, i); if(moneyitem && !moneyitem->inPocket && moneyitem->value == value) { g_object_set (moneyitem->item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); moneyitem->inPocket = TRUE; moneyWidget->priv->total += euroList[value].value; money_display_total(moneyWidget); return; } } /* There is no already suitable item create, create a new one */ if(moneyWidget->priv->next_spot > moneyWidget->priv->columns * moneyWidget->priv->lines) g_message("More money items requested than the pocket size\n"); block_width = \ (moneyWidget->priv->x2 - moneyWidget->priv->x1) / moneyWidget->priv->columns; block_height = \ (moneyWidget->priv->y2 - moneyWidget->priv->y1) / moneyWidget->priv->lines; svg_handle = gc_rsvg_load(euroList[value].image); rsvg_handle_get_dimensions(svg_handle, &dimension); xratio = block_width / (dimension.width + BORDER_GAP); yratio = block_height / (dimension.height + BORDER_GAP); ratio = yratio = MIN(xratio, yratio); item = goo_canvas_svg_new(moneyWidget->priv->rootItem, svg_handle, NULL); goo_canvas_item_translate(item, moneyWidget->priv->x1 + (moneyWidget->priv->next_spot % moneyWidget->priv->columns) * block_width + block_width/2 - (dimension.width * ratio)/2, moneyWidget->priv->y1 + (moneyWidget->priv->next_spot / moneyWidget->priv->columns) * (block_height + BORDER_GAP) + block_height/2 - (dimension.height * ratio)/2); goo_canvas_item_scale(item, ratio, ratio); moneyitem = g_malloc(sizeof(MoneyItem)); moneyitem->moneyWidget = moneyWidget; moneyitem->item = item; moneyitem->value = value; moneyitem->inPocket = TRUE; moneyWidget->priv->moneyItemList = \ g_list_append (moneyWidget->priv->moneyItemList, moneyitem); g_signal_connect(item, "button_press_event", (GCallback) item_event, moneyitem); g_object_unref(svg_handle); moneyWidget->priv->next_spot++; moneyWidget->priv->total += euroList[value].value; money_display_total(moneyWidget); }
static VALUE rg_scale(VALUE self, VALUE sx, VALUE sy) { goo_canvas_item_scale(SELF(self), NUM2DBL(sx), NUM2DBL(sy)); return self; }
/* set initial values for the next level */ static void planegame_next_level() { RsvgHandle *svg_handle = NULL; GooCanvasItem *item; gc_bar_set_level(gcomprisBoard); planegame_destroy_all_items(); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); clouds_rootitem = goo_canvas_group_new (rootitem, NULL); /* Try the next level */ speed=100+(40/(gcomprisBoard->level)); fallSpeed=10000-gcomprisBoard->level*200; /* Make the images tend to 0.5 ratio */ imageZoom=0.3+(0.5/(gcomprisBoard->level)); /* Setup and Display the plane */ planespeed_y = 0; planespeed_x = 0; svg_handle = gc_rsvg_load("planegame/tuxhelico.svgz"); plane_x = 50; plane_y = 300; planeitem = goo_canvas_group_new (rootitem, NULL); goo_canvas_item_translate(planeitem, plane_x, plane_y); item = goo_canvas_svg_new (planeitem, svg_handle, NULL); goo_canvas_item_scale(item, 0.4 * imageZoom, 0.4 * imageZoom); g_object_unref(svg_handle); /* Game rules */ plane_target = 1; plane_last_target = 10; gcomprisBoard->number_of_sublevel=plane_last_target; gcomprisBoard->sublevel=plane_target; if(gcomprisBoard->level>1) { /* No scoring after level 1 */ gc_score_end(); } else { gc_score_start(SCORESTYLE_NOTE, BOARDWIDTH - 195, BOARDHEIGHT - 30, gcomprisBoard->number_of_sublevel); gc_score_set(gcomprisBoard->sublevel); } }
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); }
/* * Do all the bar display and register the events */ void gc_config_start () { GcomprisProperties *properties = gc_prop_get(); gint y_start = 0; gint x_start = 0; gint x_text_start = 0; gint y = 0; GooCanvasItem *item; /* Pause the board */ gc_board_pause(TRUE); if(rootitem) { gc_config_stop(); return; } gc_bar_hide(TRUE); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); x_start = bounds.x1; y_start = bounds.y1; y = bounds.y2 - 26; goo_canvas_text_new (rootitem, _("GCompris Configuration"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 40, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); pixmap_checked = "#CHECKED"; pixmap_unchecked = "#UNCHECKED"; pixmap_width = 30; x_start += 60; x_text_start = x_start + 80; //-------------------------------------------------- // Locale y_start += 105; display_previous_next(x_start, y_start, "locale_previous", "locale_next"); y_flag_start = y_start - pixmap_width/2; /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.50; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_start - 100) * zoom, (-1 * bounds.y1 + y_start - 145) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "locale_reset"); gc_item_focus_init(item, NULL); /* * The current locale is the one found in the config file */ current_locale = properties->locale; set_locale_flag(current_locale); item_locale_text = goo_canvas_text_new (rootitem, gc_locale_get_name(current_locale), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Fullscreen / Window y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fullscreen"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Fullscreen"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Rememberlevel y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->rememberlevel ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "rememberlevel"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Remember level for default user"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Music y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "music"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Music"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Effect y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "effect"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Effect"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Zoom y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "zoom"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Zoom"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Timer y_start += Y_GAP; display_previous_next(x_start, y_start, "timer_previous", "timer_next"); item_timer_text = goo_canvas_text_new (rootitem, gettext(timername[properties->timer]), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Font y_start += Y_GAP; { int i; PangoFontFamily ** families; int n_families; PangoFontMap * fontmap; const gchar *current_familly_name = NULL; fontmap = pango_cairo_font_map_get_default(); pango_font_map_list_families (fontmap, & families, & n_families); for (i = 0; i < n_families; i++) { PangoFontFamily * family = families[i]; const gchar * family_name; family_name = pango_font_family_get_name (family); /* Skip font to exclude */ guint j = 0; gboolean exclude = FALSE; while(excluded_fonts[j] != NULL) { if( !g_ascii_strncasecmp(excluded_fonts[j], family_name, strlen(excluded_fonts[j])) ) { exclude = TRUE; break; } j++; } if(exclude) continue; fontlist = g_list_insert_sorted (fontlist, (gpointer)family_name, (GCompareFunc)strcmp); if(!strcmp(properties->fontface, family_name)) current_familly_name = family_name; } g_free (families); current_font_index = font_index = g_list_index(fontlist, current_familly_name); display_previous_next(x_start, y_start, "font_previous", "font_next"); /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.50; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_start - 100) * zoom, (-1 * bounds.y1 + y_start + 650) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fontface_reset"); gc_item_focus_init(item, NULL); gchar *first_font_name = g_strdup_printf(_("Font: %s"), (char *)g_list_nth_data(fontlist, font_index)); item_font_text = goo_canvas_text_new (rootitem, first_font_name, (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); } // Difficulty Filter y_start += Y_GAP; stars_group_x = x_start + 45; stars_group_y = y_start - 25; gchar *text = g_strdup_printf("<i>%s</i>", gettext(filtername)); item_filter_text = goo_canvas_text_new (rootitem, text, x_text_start, y_start, 400, GTK_ANCHOR_WEST, "use-markup", TRUE, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); g_free(text); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_ok, "ok"); is_displayed = TRUE; }
/* * 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 ); }
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); }
/* * Do all the bar display and register the events */ void gc_config_start () { GcomprisProperties *properties = gc_prop_get(); gint y_start = 0; gint x_start = 0; gint x_text_start = 0; gint y = 0; GooCanvasItem *item; /* Pause the board */ gc_board_pause(TRUE); if(rootitem) { gc_config_stop(); return; } gc_bar_hide(TRUE); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); x_start = bounds.x1; y_start = bounds.y1; y = bounds.y2 - 26; goo_canvas_text_new (rootitem, _("GCompris Configuration"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 40, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); pixmap_checked = "#CHECKED"; pixmap_unchecked = "#UNCHECKED"; pixmap_width = 30; x_start += 150; x_flag_start = x_start + 50; x_text_start = x_start + 115; //-------------------------------------------------- // Locale y_start += 105; display_previous_next(x_start, y_start, "locale_previous", "locale_next"); y_flag_start = y_start - pixmap_width/2; /* Display a bad icon if this locale is not available */ item_bad_flag = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#UNCHECKED", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); SET_ITEM_LOCATION(item_bad_flag, x_flag_start + 5, y_start - pixmap_width/2); /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.65; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_flag_start - 340) * zoom, (-1 * bounds.y1 + y_start - 120) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "locale_reset"); gc_item_focus_init(item, NULL); /* * The current locale is the one found in the config file */ current_locale = properties->locale; set_locale_flag(current_locale); item_locale_text = goo_canvas_text_new (rootitem, gc_locale_get_name(current_locale), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Fullscreen / Window y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fullscreen"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Fullscreen"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Music y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "music"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Music"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Effect y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "effect"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Effect"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Zoom y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "zoom"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Zoom"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Timer y_start += Y_GAP; display_previous_next(x_start, y_start, "timer_previous", "timer_next"); item_timer_text = goo_canvas_text_new (rootitem, gettext(timername[properties->timer]), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Skin { const gchar *one_dirent; guint i; GDir *dir; gchar *skin_dir; gchar *first_skin_name; /* Load the Pixpmaps directory file names */ skin_dir = g_strconcat(properties->package_data_dir, "/skins", NULL); dir = g_dir_open(skin_dir, 0, NULL); if (!dir) g_warning (_("Couldn't open skin dir: %s"), skin_dir); /* Fill up the skin list */ while((one_dirent = g_dir_read_name(dir)) != NULL) { if (one_dirent[0] != '.') { gchar *filename; /* Only directory here are skins */ filename = g_strdup_printf("%s/%s", properties->package_skin_dir, one_dirent); if (g_file_test ((filename), G_FILE_TEST_IS_DIR)) { gchar *skin_name = g_strdup_printf("%s", one_dirent); skinlist = g_list_append (skinlist, skin_name); } g_free(filename); } } g_dir_close(dir); /* Find the current skin index */ skin_index = 0; for(i=0; i<g_list_length(skinlist); i++) if(!strcmp((char *)g_list_nth_data(skinlist, i), properties->skin)) skin_index = i; y_start += Y_GAP; /* Should not happen. It the user found the config, there should be a skin */ if(g_list_length(skinlist) > 0) { g_warning("No skin found in %s\n", skin_dir); display_previous_next(x_start, y_start, "skin_previous", "skin_next"); first_skin_name = g_strdup_printf(_("Skin : %s"), (char *)g_list_nth_data(skinlist, skin_index)); } else { first_skin_name = g_strdup(_("SKINS NOT FOUND")); } item_skin_text = goo_canvas_text_new (rootitem, first_skin_name, (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); g_free(first_skin_name); g_free(skin_dir); } // Difficulty Filter y_start += Y_GAP; stars_group_x = x_start + 45; stars_group_y = y_start - 25; gchar *text = g_strdup_printf("<i>%s</i>", gettext(filtername)); item_filter_text = goo_canvas_text_new (rootitem, text, x_text_start, y_start, 400, GTK_ANCHOR_WEST, "use-markup", TRUE, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); g_free(text); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_ok, "ok"); is_displayed = TRUE; }
static void 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); }
/* set initial values for the next level */ static void money_next_level() { guint min_price = 0, max_price = 0; guint paid = 0; guint number_of_item = 0; guint i; gchar *display_format; gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas), "money/money-bg.png"); gc_bar_set_level(gcomprisBoard); money_destroy_all_items(); gamewon = FALSE; boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); /* The OK Button */ GooCanvasItem *item = goo_canvas_svg_new( boardRootItem, gc_skin_rsvg_get(), "svg-id", "#OK", NULL); SET_ITEM_LOCATION(item, 725, 230); g_signal_connect(item, "button_press_event", (GtkSignalFunc) moneyactivity_process_ok, NULL); gc_item_focus_init(item, NULL); tux_money = MONEY_WIDGET(money_widget_new()); money_widget_set_position(tux_money, boardRootItem, 100.0, 380.0, 700.0, 490.0, 5, 2, FALSE); /* Select level difficulty */ switch(currentMode) { case WITHOUT_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 3; max_price = 10; money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 2: number_of_item = 1; min_price = 10; max_price = 20; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 3: number_of_item = 2; min_price = 20; max_price = 30; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 4: number_of_item = 2; min_price = 30; max_price = 40; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 5: number_of_item = 3; min_price = 40; max_price = 50; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 6: number_of_item = 3; min_price = 50; max_price = 60; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 7: number_of_item = 4; min_price = 60; max_price = 70; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 8: number_of_item = 4; min_price = 70; max_price = 80; money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 9: number_of_item = 4; min_price = 50; max_price = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); break; } break; case WITH_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 2: number_of_item = 1; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 3: number_of_item = 2; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 4: number_of_item = 3; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 5: number_of_item = 4; min_price = 0; max_price = 4; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; } break; case BACK_WITHOUT_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 3; max_price = 9; paid = 10; money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 2: number_of_item = 1; min_price = 1; max_price = 19; paid = 20; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 3: number_of_item = 2; min_price = 2; max_price = 29; paid = 30; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 4: number_of_item = 2; min_price = 2; max_price = 39; paid = 40; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 5: number_of_item = 3; min_price = 3; max_price = 49; paid = 50; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 6: number_of_item = 3; min_price = 3; max_price = 60; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 7: number_of_item = 4; min_price = 4; max_price = 70; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 8: number_of_item = 4; min_price = 4; max_price = 80; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 9: number_of_item = 4; min_price = 4; max_price = 99; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); break; } break; case BACK_WITH_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 2: number_of_item = 1; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 3: number_of_item = 2; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 4: number_of_item = 3; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 5: number_of_item = 4; min_price = 0; max_price = 4; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; } break; } seller_money = MONEY_WIDGET(money_widget_new()); money_widget_set_position(seller_money, boardRootItem, 100.0, 20.0, 700.0, 130.0, 5, 2, FALSE); money_widget_set_target(seller_money, tux_money); money_widget_set_target(tux_money, seller_money); /* Display what to buy */ price_target = 0; for(i=1; i<=number_of_item; i++) { gdouble object_price; gchar *text; GooCanvasItem *item; RsvgHandle *svg_handle; RsvgDimensionData dimension; double xratio, yratio; guint offset_x = 50; guint boardwidth = BOARDWIDTH - offset_x * 2; /* Display the price */ object_price = (double) g_random_int_range(min_price/number_of_item, max_price/number_of_item); { /* Select an image list depending on the price */ gchar **imageList; guint number_of_images; if ( object_price < 5 ) { imageList = imageList1; number_of_images = NUMBER_OF_IMAGES1; } else if ( object_price < 10 ) { imageList = imageList2; number_of_images = NUMBER_OF_IMAGES2; } else { imageList = imageList3; number_of_images = NUMBER_OF_IMAGES3; } svg_handle = \ gc_rsvg_load(imageList[g_random_int_range(0, number_of_images - 1)]); rsvg_handle_get_dimensions(svg_handle, &dimension); item = goo_canvas_svg_new ( boardRootItem, svg_handle, NULL); } xratio = (gdouble)(boardwidth/(number_of_item+1)) / dimension.width; yratio = 100.0 / dimension.height; xratio = yratio = MIN(xratio, yratio); goo_canvas_item_translate(item, offset_x + (i*boardwidth)/(number_of_item+1) - dimension.width*xratio/2, 200); goo_canvas_item_scale(item, xratio, xratio); if( (currentMode == WITH_CENTS) || (currentMode == BACK_WITH_CENTS) ) { /* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */ display_format = _("$ %.2f"); /* Add random cents */ if(gcomprisBoard->level == 1) { object_price += (double)((double) g_random_int_range(1, 9))/10.0; } else { object_price += (double)((double) g_random_int_range(1, 99))/100.0; } } else { /* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */ display_format = _("$ %.0f"); } price_target += object_price; text = g_strdup_printf(display_format, object_price); goo_canvas_text_new(boardRootItem, text, offset_x + (i*boardwidth)/(number_of_item+1), 185, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_big, "fill-color", "white", NULL); g_free(text); g_object_unref(svg_handle); } if (paid) { // Calc the money back instead of the objects price price_target = paid - price_target; // Display Tux and his money display_paying_tux(paid); } }
static GooCanvasItem* create_table (GooCanvasItem *parent, gint row, gint column, gint embedding_level, gdouble x, gdouble y, gdouble rotation, gdouble scale, gint demo_item_type, gboolean show_grid_lines) { GooCanvasItem *table; /* Add a few simple items. */ table = goo_canvas_table_new (parent, "row-spacing", 4.0, "column-spacing", 4.0, NULL); if (show_grid_lines) g_object_set (table, "horz-grid-line-width", 1.0f, "vert-grid-line-width", 1.0f, NULL); goo_canvas_item_translate (table, x, y); #if 1 goo_canvas_item_rotate (table, rotation, 0, 0); #endif #if 1 goo_canvas_item_scale (table, scale, scale); #endif if (row != -1) goo_canvas_item_set_child_properties (parent, table, "row", row, "column", column, #if 1 "x-expand", TRUE, "x-fill", TRUE, #endif #if 0 "y-expand", TRUE, "y-fill", TRUE, #endif NULL); if (embedding_level) { gint level = embedding_level - 1; create_table (table, 0, 0, level, 50, 50, 0, 0.7, demo_item_type, show_grid_lines); create_table (table, 0, 1, level, 50, 50, 45, 1.0, demo_item_type, show_grid_lines); create_table (table, 0, 2, level, 50, 50, 90, 1.0, demo_item_type, show_grid_lines); create_table (table, 1, 0, level, 50, 50, 135, 1.0, demo_item_type, show_grid_lines); create_table (table, 1, 1, level, 50, 50, 180, 1.5, demo_item_type, show_grid_lines); create_table (table, 1, 2, level, 50, 50, 225, 1.0, demo_item_type, show_grid_lines); create_table (table, 2, 0, level, 50, 50, 270, 1.0, demo_item_type, show_grid_lines); create_table (table, 2, 1, level, 50, 50, 315, 1.0, demo_item_type, show_grid_lines); create_table (table, 2, 2, level, 50, 50, 360, 2.0, demo_item_type, show_grid_lines); } else if (demo_item_type == DEMO_TEXT_ITEM_2) { create_demo_item (table, demo_item_type, 0, 0, 1, 1, "(0.0,0.0)\nleft\naligned", -1, 0, 0, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 0, 1, 1, 1, "(0.5,0.0)\ncenter\naligned", -1, 0.5, 0, PANGO_ALIGN_CENTER); create_demo_item (table, demo_item_type, 0, 2, 1, 1, "(1.0,0.0)\nright\naligned", -1, 1, 0, PANGO_ALIGN_RIGHT); /* The layout width shouldn't really make any difference in this test. */ create_demo_item (table, demo_item_type, 1, 0, 1, 1, "(0.5,0.5)\ncenter\naligned", 50, 0.5, 0.5, PANGO_ALIGN_CENTER); create_demo_item (table, demo_item_type, 1, 1, 1, 1, "(0.0,1.0)\nright\naligned", 100, 0, 1.0, PANGO_ALIGN_RIGHT); create_demo_item (table, demo_item_type, 1, 2, 1, 1, "(0.0,0.5)\nleft\naligned", 200, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 2, 0, 1, 1, "(1.0,1.0)\ncenter\naligned", -1, 1, 1, PANGO_ALIGN_CENTER); create_demo_item (table, demo_item_type, 2, 1, 1, 1, "(1,0.5)\nright\naligned", -1, 1.0, 0.5, PANGO_ALIGN_RIGHT); create_demo_item (table, demo_item_type, 2, 2, 1, 1, "(0.0,0.0)\nleft\naligned", -1, 0, 0, PANGO_ALIGN_LEFT); } else if (demo_item_type == DEMO_TEXT_ITEM_3) { create_demo_item (table, demo_item_type, 0, 0, 1, 1, "width 50 align 0.0, 0.0 text left aligned", 50, 0, 0, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 0, 1, 1, 1, "width 100 align 0.5, 0.0 text center aligned", 100, 0.5, 0, PANGO_ALIGN_CENTER); create_demo_item (table, demo_item_type, 0, 2, 1, 1, "width 150 align 1.0, 0.0 text right aligned", 150, 1, 0, PANGO_ALIGN_RIGHT); create_demo_item (table, demo_item_type, 1, 0, 1, 1, "width 50 align 0.5, 0.5 text center aligned", 50, 0.5, 0.5, PANGO_ALIGN_CENTER); create_demo_item (table, demo_item_type, 1, 1, 1, 1, "width 100 align 0.0, 1.0 text right aligned", 100, 0, 1.0, PANGO_ALIGN_RIGHT); create_demo_item (table, demo_item_type, 1, 2, 1, 1, "width 200 align 0.0, 0.5 text left aligned", 200, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 2, 0, 1, 1, "width 50 align 1.0, 1.0 text center aligned", 50, 1, 1, PANGO_ALIGN_CENTER); create_demo_item (table, demo_item_type, 2, 1, 1, 1, "width 100 align 1, 0.5 text right aligned", 100, 1.0, 0.5, PANGO_ALIGN_RIGHT); create_demo_item (table, demo_item_type, 2, 2, 1, 1, "width 50 align 0.0, 0.0 text left aligned", 50, 0, 0, PANGO_ALIGN_LEFT); } else { create_demo_item (table, demo_item_type, 0, 0, 1, 1, "(0,0)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 0, 1, 1, 1, "(1,0)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 0, 2, 1, 1, "(2,0)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 1, 0, 1, 1, "(0,1)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 1, 1, 1, 1, "(1,1)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 1, 2, 1, 1, "(2,1)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 2, 0, 1, 1, "(0,2)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 2, 1, 1, 1, "(1,2)", -1, 0, 0.5, PANGO_ALIGN_LEFT); create_demo_item (table, demo_item_type, 2, 2, 1, 1, "(2,2)", -1, 0, 0.5, PANGO_ALIGN_LEFT); } return table; }
/* Setting list of available icons in the control bar */ static void bar_set (const GComprisBarFlags flags) { // Always reset the zoom factor or the calculation // will be wrong goo_canvas_item_set_transform(rootitem, NULL); _hidden = FALSE; goo_canvas_item_raise(rootitem, NULL); /* Non yet initialized : Something Wrong */ if(get_item(GC_BAR_LEVEL) == NULL) { g_message("in bar_set_level, level_item uninitialized : should not happen\n"); return; } current_flags = flags; if(gc_help_has_board(gc_board_get_current())) current_flags |= GC_BAR_HELP; if(flags&GC_BAR_ABOUT) current_flags |= GC_BAR_ABOUT; if(flags&GC_BAR_CONFIG) current_flags |= GC_BAR_CONFIG; if(flags&GC_BAR_REPEAT_ICON) current_flags |= GC_BAR_REPEAT_ICON; if(flags&GC_BAR_REPEAT) current_flags |= GC_BAR_REPEAT; update_exit_button(); GSList *list; double x = 0; for (list = buttons; list != NULL; list = list->next) { GooCanvasItem *item = (GooCanvasItem *)list->data; GComprisBarFlags flag = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT (item), "flag")); if (flag & current_flags) { GooCanvasBounds bounds; SET_ITEM_LOCATION(item, x, -20); goo_canvas_item_get_bounds(item, &bounds); gc_item_focus_init(item, NULL); x += bounds.x2 - bounds.x1 + BAR_GAP; g_object_set (item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); } else g_object_set (item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); } /* Scale the bar back to fit the buttons, no more */ SET_ITEM_LOCATION(bar_item, 0, 0); GooCanvasBounds bounds; goo_canvas_item_get_bounds(bar_item, &bounds); goo_canvas_item_scale(bar_item, x / (bounds.x2 - bounds.x1), 1); // Always center the bar with its new bounds //SET_ITEM_LOCATION(rootitem, 0, _default_y); bar_location (-1, -1, -1); }