/*-------------------------------------------------------------------------------*/ static void display_previous_next(guint x_start, guint y_start, gchar *eventname_previous, gchar *eventname_next) { GooCanvasItem *item; GooCanvasBounds bounds; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#PREVIOUS", NULL); goo_canvas_item_get_bounds(item, &bounds); SET_ITEM_LOCATION(item, x_start - (bounds.x2 - bounds.x1) - 10, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, eventname_previous); gc_item_focus_init(item, NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#NEXT", NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, eventname_next); gc_item_focus_init(item, NULL); }
/* Return a new button item */ GooCanvasItem * new_button(GooCanvasItem *rootitem, RsvgHandle *svg_handle, GComprisBarFlags flag, gchar *svg_id) { GooCanvasItem *item = goo_canvas_svg_new (rootitem, svg_handle, "svg-id", svg_id, NULL); SET_ITEM_LOCATION(item, 0, 0); g_object_set (item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); g_object_set_data (G_OBJECT(item), "flag", GUINT_TO_POINTER(flag)); g_signal_connect (item, "enter_notify_event", (GtkSignalFunc) on_enter_notify, GUINT_TO_POINTER(flag)); g_signal_connect (item, "leave_notify_event", (GtkSignalFunc) on_leave_notify, GUINT_TO_POINTER(flag)); g_signal_connect(item, "button_press_event", (GtkSignalFunc) item_event_bar, GUINT_TO_POINTER(flag)); return item; }
/** * Display the number of stars representing the difficulty level at the x,y location * The stars are created in a group 'parent' * The new group in which the stars are created is returned. */ static GooCanvasItem * menu_difficulty_display(GooCanvasItem *parent, double x, double y, double ratio, gint difficulty) { GooCanvasItem *stars_group = NULL; GooCanvasItem *item = NULL; gchar *svg_id = NULL; if(difficulty==0 || difficulty>6) return NULL; svg_id = g_strdup_printf("#DIFFICULTY%d", difficulty); stars_group = goo_canvas_group_new (parent, NULL); item = goo_canvas_svg_new (stars_group, gc_skin_rsvg_get(), "svg-id", svg_id, "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); SET_ITEM_LOCATION(item, x, y); g_free(svg_id); return(stars_group); }
/** * Display the demo only icon */ static GooCanvasItem * menu_demo_display(GooCanvasItem *parent, gdouble x, gdouble y) { GooCanvasItem *item = goo_canvas_svg_new (parent, gc_skin_rsvg_get(), "svg-id", "#UNCHECKED", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); SET_ITEM_LOCATION(item, x, y); return(item); }
/* set initial values for the next level */ static void superbrain_next_level() { guint i; gboolean selected_color[MAX_COLORS]; gc_bar_set_level(gcomprisBoard); superbrain_destroy_all_items(); gamewon = FALSE; /* Select level difficulty : should not go above MAX_PIECES */ /* number_of_color must be upper than number_of_piece to allow unicity */ if(gcomprisBoard->level < LEVEL_MAX_FOR_HELP) { number_of_piece = gcomprisBoard->level + 2; number_of_color = gcomprisBoard->level + 4; } else { number_of_piece = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 3; number_of_color = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 5; } current_y_position = BOARDHEIGHT - 50; /* Init a random solution : colors choosen are uniquely choosen */ for(i=0; i<number_of_color; i++) { selected_color[i] = FALSE; } for(i=0; i<number_of_piece; i++) { guint j; j = (guint)g_random_int_range(0, number_of_color); while(selected_color[j]) j = (guint)g_random_int_range(0, number_of_color); solution[i] = j; selected_color[j] = TRUE; } boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); boardLogoItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); /* The OK Button */ GooCanvasItem *item = goo_canvas_svg_new (boardLogoItem, gc_skin_rsvg_get(), "svg-id", "#OK", NULL); SET_ITEM_LOCATION(item, 270, 50); g_signal_connect(item, "button_press_event", (GCallback) process_ok, NULL); gc_item_focus_init(item, NULL); /* The list of the pieces */ for(i=0; i<number_of_color; i++) { goo_canvas_ellipse_new (boardLogoItem, PIECE_DISPLAY_X, PIECE_DISPLAY_Y + i*((PIECE_WIDTH*1.5)*2 + PIECE_GAP/2), PIECE_WIDTH * 1.5, PIECE_WIDTH * 1.5, "fill_color_rgba", colors[i], "stroke-color", "white", "line-width", (double)1, NULL); } superbrain_create_item(boardRootItem); }
/* * 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; }
void gc_help_start (GcomprisBoard *gcomprisBoard) { gchar *item_id = "#UP"; GooCanvasItem *item; gint y = 0; gint y_start = 0; gint x_start = 0; gchar *name = NULL; gchar *text_to_display = NULL; if(rootitem) return; gc_board_pause(TRUE); caller_cursor = gc_cursor_get(); gc_cursor_set(GCOMPRIS_DEFAULT_CURSOR); item_selected = NULL; item_selected_text = NULL; name = gcomprisBoard->title; gc_help_has_board(gcomprisBoard); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; guint pixmap_width = 40; goo_canvas_item_get_bounds(item, &bounds); x_start = bounds.x1; y_start = bounds.y1; y = bounds.y2 - 26; y_start += 15; if(gcomprisBoard->section && gcomprisBoard->name) { text_to_display = g_strdup_printf("%s/%s", gcomprisBoard->section, gcomprisBoard->name); goo_canvas_text_new (rootitem, text_to_display, BOARDWIDTH*0.10, y_start, -1, GTK_ANCHOR_NW, "font", gc_skin_font_board_tiny, "fill-color-rgba", gc_skin_color_title, NULL); g_free(text_to_display); } y_start += 30; goo_canvas_text_new (rootitem, name, BOARDWIDTH/2, y_start, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); y_start += 80; // Prerequisite Button if(prerequisite) { item_prerequisite = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", item_id, NULL); SET_ITEM_LOCATION(item_prerequisite, (BOARDWIDTH*0.2) - pixmap_width/2, y_start - 10) g_signal_connect(item_prerequisite, "button_press_event", (GtkSignalFunc) item_event_help, "prerequisite"); gc_item_focus_init(item_prerequisite, NULL); item_prerequisite_text = \ goo_canvas_text_new (rootitem, _("Prerequisite"), BOARDWIDTH*0.20, y_start + GAP_TO_BUTTON, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"), NULL); g_signal_connect(item_prerequisite_text, "button_press_event", (GtkSignalFunc) item_event_help, "prerequisite"); } // Goal Button if(goal) { item_goal = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", item_id, NULL); SET_ITEM_LOCATION(item_goal, (BOARDWIDTH*0.4) - pixmap_width/2, y_start - 10); g_signal_connect(item_goal, "button_press_event", (GtkSignalFunc) item_event_help, "goal"); gc_item_focus_init(item_goal, NULL); item_goal_text = goo_canvas_text_new (rootitem, _("Goal"), BOARDWIDTH*0.4, y_start + GAP_TO_BUTTON, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"), NULL); g_signal_connect(item_goal_text, "button_press_event", (GtkSignalFunc) item_event_help, "goal"); } // Manual Button if(manual) { item_manual = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", item_id, NULL); SET_ITEM_LOCATION(item_manual, (BOARDWIDTH*0.6) - pixmap_width/2, y_start - 10); g_signal_connect(item_manual, "button_press_event", (GtkSignalFunc) item_event_help, "manual"); gc_item_focus_init(item_manual, NULL); item_manual_text = goo_canvas_text_new (rootitem, _("Manual"), BOARDWIDTH*0.6, y_start + GAP_TO_BUTTON, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"), NULL); g_signal_connect(item_manual_text, "button_press_event", (GtkSignalFunc) item_event_help, "manual"); } // Credit Button if(credit) { item_credit = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", item_id, NULL); SET_ITEM_LOCATION(item_credit, (BOARDWIDTH*0.8) - pixmap_width/2, y_start - 10); g_signal_connect(item_credit, "button_press_event", (GtkSignalFunc) item_event_help, "credit"); gc_item_focus_init(item_credit, NULL); item_credit_text = goo_canvas_text_new (rootitem, _("Credit"), BOARDWIDTH*0.8, y_start + GAP_TO_BUTTON, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"), NULL); g_signal_connect(item_credit_text, "button_press_event", (GtkSignalFunc) item_event_help, "credit"); } // CONTENT // default text to display if(prerequisite) { text_to_display = prerequisite; select_item(item_prerequisite, item_prerequisite_text); } else if(goal) { text_to_display = goal; select_item(item_goal, item_goal_text); } else if(manual) { text_to_display = manual; select_item(item_manual, item_manual_text); } else if(credit) { text_to_display = credit; select_item(item_credit, item_credit_text); } y_start += 45; /* Create a scrolled area for the text content */ GtkWidget *view; GtkWidget *sw; view = gtk_text_view_new (); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); gtk_text_view_set_editable(GTK_TEXT_VIEW (view), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW (view), FALSE); gtk_signal_connect(GTK_OBJECT(view), "button-press-event", (GtkSignalFunc) event_disable_right_click_popup, NULL); PangoFontDescription *font_desc; font_desc = pango_font_description_from_string (gc_skin_font_content); gtk_widget_modify_font (view, font_desc); pango_font_description_free (font_desc); GdkColor fg_color; GdkColor bg_color; gc_skin_get_gdkcolor("gcompris/helpfg", &fg_color); gc_skin_get_gdkcolor("gcompris/helpbg", &bg_color); gtk_widget_modify_base(view, GTK_STATE_NORMAL, &bg_color); gtk_widget_modify_text(view, GTK_STATE_NORMAL, &fg_color); buffer_content = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (sw), view); goo_canvas_widget_new (rootitem, sw, x_start + 40, y_start, 618.0, 280.0, NULL); gtk_widget_show_all (sw); set_content(text_to_display); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GtkSignalFunc) item_event_help, "ok"); gc_bar_hide(TRUE); help_displayed = TRUE; }
/* 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); }
/* * Do all the bar display and register the events */ static void bar_start (GooCanvas *theCanvas) { GcomprisProperties *properties = gc_prop_get(); RsvgHandle *svg_handle; GooCanvasBounds bounds; _default_y = BOARDHEIGHT - BARHEIGHT; _default_zoom = 1.0; bar_reset_sound_id(); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(theCanvas), NULL); svg_handle = gc_skin_rsvg_get(); bar_item = goo_canvas_svg_new (rootitem, svg_handle, "svg-id", "#BAR_BG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); SET_ITEM_LOCATION(bar_item, 0, 0); /* * The Order in which buttons are created represents * also the order in which they will be displayed */ // EXIT if(properties->disable_quit == 0) buttons = g_slist_append(buttons, new_button(rootitem, svg_handle, GC_BAR_EXIT, "#EXIT")); // ABOUT buttons = g_slist_append(buttons, new_button(rootitem, svg_handle, GC_BAR_ABOUT, "#ABOUT")); // CONFIG if(properties->disable_config == 0) buttons = g_slist_append(buttons, new_button(rootitem, svg_handle, GC_BAR_CONFIG, "#CONFIG")); // HELP buttons = g_slist_append(buttons, new_button(rootitem, svg_handle, GC_BAR_HELP, "#HELP")); // LEVEL (Multiple buttons for this one) GooCanvasItem *rootitem_level = goo_canvas_group_new (rootitem, NULL); g_object_set (rootitem_level, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); g_object_set_data (G_OBJECT(rootitem_level), "flag", GUINT_TO_POINTER(GC_BAR_LEVEL)); buttons = g_slist_append(buttons, rootitem_level); GooCanvasItem *item = new_button(rootitem_level, svg_handle, GC_BAR_LEVEL_DOWN, "#LEVEL_DOWN"); g_object_set (item, "visibility", (properties->disable_level ? GOO_CANVAS_ITEM_INVISIBLE : GOO_CANVAS_ITEM_VISIBLE), NULL); item = new_button(rootitem_level, svg_handle, GC_BAR_LEVEL, "#LEVEL_UP"); goo_canvas_item_translate(item, 50, 0); g_object_set (item, "visibility", (properties->disable_level ? GOO_CANVAS_ITEM_INVISIBLE : GOO_CANVAS_ITEM_VISIBLE), NULL); goo_canvas_item_get_bounds(item, &bounds); level_item = goo_canvas_text_new (rootitem_level, "", bounds.x1 - 10, (bounds.y2 - bounds.y1) / 2 + 8, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color-rgba", gc_skin_color_text_button, NULL); current_level = 1; // REPEAT (Default) buttons = g_slist_append(buttons, new_button(rootitem, svg_handle, GC_BAR_REPEAT, "#REPEAT")); // REPEAT ICON buttons = g_slist_append(buttons, new_button(rootitem, svg_handle, GC_BAR_REPEAT_ICON, "#REPEAT")); // HOME buttons = g_slist_append(buttons, new_button(rootitem, svg_handle, GC_BAR_HOME, "#HOME")); update_exit_button(); bar_set(0); _hidden = FALSE; }
/* * 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; }
/* 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 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++; } }
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); }
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); }