void gc_config_stop () { // Destroy the help box if(rootitem!=NULL) { goo_canvas_item_remove(rootitem); gc_board_pause(FALSE); } rootitem = NULL; stars_group = NULL; /* UnPause the board */ if(is_displayed) gc_board_pause(FALSE); gc_bar_hide(FALSE); is_displayed = FALSE; }
void gc_about_stop () { // Destroy the help box if(rootitem!=NULL) goo_canvas_item_remove(rootitem); rootitem = NULL; /* UnPause the board */ if(is_displayed) gc_board_pause(FALSE); gc_bar_hide (FALSE); is_displayed = FALSE; }
void gc_confirm_box_stop () { GcomprisBoard *gcomprisBoard = gc_board_get_current(); // Destroy the box if(rootitem!=NULL) goo_canvas_item_remove(rootitem); rootitem = NULL; if(gcomprisBoard!=NULL && confirm_displayed) gc_board_pause(FALSE); gc_bar_hide(FALSE); confirm_displayed = FALSE; }
/* * Remove the displayed help. * Do nothing if none is currently being dislayed */ void gc_help_stop () { if(help_displayed) { // Destroy the help box if(rootitem!=NULL) { goo_canvas_item_remove(rootitem); rootitem = NULL; } gc_cursor_set(caller_cursor); gc_board_pause(FALSE); } gc_bar_hide(FALSE); help_displayed = FALSE; }
/* * Remove the displayed images_selector. * Do nothing if none is currently being dislayed */ void gc_selector_images_stop () { GcomprisBoard *gcomprisBoard = gc_board_get_current(); if(gcomprisBoard != NULL && images_selector_displayed) { gc_board_pause(FALSE); } // Destroy the image_selector box if(rootitem!=NULL) goo_canvas_item_remove(rootitem); rootitem = NULL; current_root_set = NULL; gc_bar_hide(FALSE); images_selector_displayed = FALSE; }
/* * Remove the displayed file_selector. * Do nothing if none is currently being dislayed */ void gc_selector_file_stop () { GcomprisBoard *gcomprisBoard = gc_board_get_current(); if(gcomprisBoard!=NULL && file_selector_displayed) gc_board_pause(FALSE); // Destroy the file_selector box if(rootitem!=NULL) goo_canvas_item_remove(rootitem); rootitem = NULL; /* No need to destroy it since it's in rootitem but just clear it */ file_root_item = NULL; gc_bar_hide(FALSE); file_selector_displayed = FALSE; // if (current_extension) // g_free(current_extension); current_extension = NULL; }
static int display_file_selector(int the_mode, GcomprisBoard *gcomprisBoard, gchar *rootdir, gchar *file_exts, FileSelectorCallBack iscb, void *user_context) { gchar *full_rootdir; mode = the_mode; /* Get the coordinate x y of the control area from the skin */ control_area_x1 = gc_skin_get_number_default("gcompris/fileselectx", 85); control_area_y1 = gc_skin_get_number_default("gcompris/fileselecty", 80); directory_label_y = gc_skin_get_number_default("gcompris/fileselectdiry", 180); if(rootitem) return 0; gc_bar_hide(TRUE); gc_board_pause(TRUE); fileSelectorCallBack=iscb; rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#FILE_SELECTOR", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); /* Entry area */ widget_entry = gtk_entry_new (); if(mode==MODE_SAVE) gtk_entry_set_max_length(GTK_ENTRY(widget_entry), 30); goo_canvas_widget_new (rootitem, GTK_WIDGET(widget_entry), control_area_x1, control_area_y1, 230.0, 30.0, NULL); gtk_signal_connect(GTK_OBJECT(widget_entry), "activate", GTK_SIGNAL_FUNC(entry_enter_callback), widget_entry); gtk_widget_show(widget_entry); /* * Create the combo with the file types * ------------------------------------ */ if(mode==MODE_SAVE && file_exts && *file_exts != '\0') { gchar **all_type = g_strsplit(file_exts, " ", 0); guint i = 0; gtk_combo_filetypes = gtk_combo_box_new_text(); /* Extract first string */ while (all_type[i]) gtk_combo_box_append_text(GTK_COMBO_BOX(gtk_combo_filetypes), g_strdup(all_type[i++]) ); g_strfreev(all_type); goo_canvas_widget_new (rootitem, gtk_combo_filetypes, control_area_x1 + 400, control_area_y1, 250.0, 35.0, NULL); gtk_widget_show(gtk_combo_filetypes); gtk_combo_box_set_active(GTK_COMBO_BOX(gtk_combo_filetypes), 0); } /* * Buttons * ------- */ // CANCEL gc_util_button_text_svg(rootitem, BOARDWIDTH * 1/3, BOARDHEIGHT - 32, "#BUTTON_TEXT", _("CANCEL"), (GtkSignalFunc) item_event_file_selector, "/cancel/"); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 2/3, BOARDHEIGHT - 32, "#BUTTON_TEXT", (mode==MODE_LOAD ? _("LOAD") : _("SAVE")), (GtkSignalFunc) item_event_file_selector, "/ok/"); file_selector_displayed = TRUE; full_rootdir = g_strconcat(gc_prop_get()->user_dir, "/", rootdir, NULL); gc_util_create_rootdir(full_rootdir); current_rootdir = full_rootdir; current_user_context = user_context; display_files(rootitem, full_rootdir); return 0; }
/* * Do all the bar display and register the events */ void gc_config_start () { GcomprisProperties *properties = gc_prop_get(); gint y_start = 0; gint x_start = 0; gint x_text_start = 0; gint y = 0; GooCanvasItem *item; /* Pause the board */ gc_board_pause(TRUE); if(rootitem) { gc_config_stop(); return; } gc_bar_hide(TRUE); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); x_start = bounds.x1; y_start = bounds.y1; y = bounds.y2 - 26; goo_canvas_text_new (rootitem, _("GCompris Configuration"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 40, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); pixmap_checked = "#CHECKED"; pixmap_unchecked = "#UNCHECKED"; pixmap_width = 30; x_start += 60; x_text_start = x_start + 80; //-------------------------------------------------- // Locale y_start += 105; display_previous_next(x_start, y_start, "locale_previous", "locale_next"); y_flag_start = y_start - pixmap_width/2; /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.50; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_start - 100) * zoom, (-1 * bounds.y1 + y_start - 145) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "locale_reset"); gc_item_focus_init(item, NULL); /* * The current locale is the one found in the config file */ current_locale = properties->locale; set_locale_flag(current_locale); item_locale_text = goo_canvas_text_new (rootitem, gc_locale_get_name(current_locale), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Fullscreen / Window y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fullscreen"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Fullscreen"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Rememberlevel y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->rememberlevel ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "rememberlevel"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Remember level for default user"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Music y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "music"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Music"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Effect y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "effect"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Effect"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Zoom y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "zoom"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Zoom"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Timer y_start += Y_GAP; display_previous_next(x_start, y_start, "timer_previous", "timer_next"); item_timer_text = goo_canvas_text_new (rootitem, gettext(timername[properties->timer]), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // Font y_start += Y_GAP; { int i; PangoFontFamily ** families; int n_families; PangoFontMap * fontmap; const gchar *current_familly_name = NULL; fontmap = pango_cairo_font_map_get_default(); pango_font_map_list_families (fontmap, & families, & n_families); for (i = 0; i < n_families; i++) { PangoFontFamily * family = families[i]; const gchar * family_name; family_name = pango_font_family_get_name (family); /* Skip font to exclude */ guint j = 0; gboolean exclude = FALSE; while(excluded_fonts[j] != NULL) { if( !g_ascii_strncasecmp(excluded_fonts[j], family_name, strlen(excluded_fonts[j])) ) { exclude = TRUE; break; } j++; } if(exclude) continue; fontlist = g_list_insert_sorted (fontlist, (gpointer)family_name, (GCompareFunc)strcmp); if(!strcmp(properties->fontface, family_name)) current_familly_name = family_name; } g_free (families); current_font_index = font_index = g_list_index(fontlist, current_familly_name); display_previous_next(x_start, y_start, "font_previous", "font_next"); /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.50; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_start - 100) * zoom, (-1 * bounds.y1 + y_start + 650) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fontface_reset"); gc_item_focus_init(item, NULL); gchar *first_font_name = g_strdup_printf(_("Font: %s"), (char *)g_list_nth_data(fontlist, font_index)); item_font_text = goo_canvas_text_new (rootitem, first_font_name, (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); } // Difficulty Filter y_start += Y_GAP; stars_group_x = x_start + 45; stars_group_y = y_start - 25; gchar *text = g_strdup_printf("<i>%s</i>", gettext(filtername)); item_filter_text = goo_canvas_text_new (rootitem, text, x_text_start, y_start, 400, GTK_ANCHOR_WEST, "use-markup", TRUE, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); g_free(text); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_ok, "ok"); is_displayed = TRUE; }
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; }
/* * Do all the bar display and register the events */ void gc_config_start () { GcomprisProperties *properties = gc_prop_get(); gint y_start = 0; gint x_start = 0; gint x_text_start = 0; gint y = 0; GooCanvasItem *item; /* Pause the board */ gc_board_pause(TRUE); if(rootitem) { gc_config_stop(); return; } gc_bar_hide(TRUE); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); x_start = bounds.x1; y_start = bounds.y1; y = bounds.y2 - 26; goo_canvas_text_new (rootitem, _("GCompris Configuration"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 40, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); pixmap_checked = "#CHECKED"; pixmap_unchecked = "#UNCHECKED"; pixmap_width = 30; x_start += 150; x_flag_start = x_start + 50; x_text_start = x_start + 115; //-------------------------------------------------- // Locale y_start += 105; display_previous_next(x_start, y_start, "locale_previous", "locale_next"); y_flag_start = y_start - pixmap_width/2; /* Display a bad icon if this locale is not available */ item_bad_flag = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#UNCHECKED", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); SET_ITEM_LOCATION(item_bad_flag, x_flag_start + 5, y_start - pixmap_width/2); /* A repeat icon to reset the selection */ item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#REPEAT", NULL); goo_canvas_item_get_bounds(item, &bounds); double zoom = 0.65; goo_canvas_item_scale(item, zoom, zoom); goo_canvas_item_translate(item, (-1 * bounds.x1 + x_flag_start - 340) * zoom, (-1 * bounds.y1 + y_start - 120) * zoom); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "locale_reset"); gc_item_focus_init(item, NULL); /* * The current locale is the one found in the config file */ current_locale = properties->locale; set_locale_flag(current_locale); item_locale_text = goo_canvas_text_new (rootitem, gc_locale_get_name(current_locale), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Fullscreen / Window y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fullscreen ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "fullscreen"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Fullscreen"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Music y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->music ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "music"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Music"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Effect y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->fx ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "effect"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Effect"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Zoom y_start += Y_GAP; item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", (properties->zoom ? pixmap_checked : pixmap_unchecked), NULL); SET_ITEM_LOCATION(item, x_start, y_start - pixmap_width/2); g_signal_connect(item, "button_press_event", (GCallback) item_event_ok, "zoom"); gc_item_focus_init(item, NULL); goo_canvas_text_new (rootitem, _("Zoom"), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Timer y_start += Y_GAP; display_previous_next(x_start, y_start, "timer_previous", "timer_next"); item_timer_text = goo_canvas_text_new (rootitem, gettext(timername[properties->timer]), (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); // Skin { const gchar *one_dirent; guint i; GDir *dir; gchar *skin_dir; gchar *first_skin_name; /* Load the Pixpmaps directory file names */ skin_dir = g_strconcat(properties->package_data_dir, "/skins", NULL); dir = g_dir_open(skin_dir, 0, NULL); if (!dir) g_warning (_("Couldn't open skin dir: %s"), skin_dir); /* Fill up the skin list */ while((one_dirent = g_dir_read_name(dir)) != NULL) { if (one_dirent[0] != '.') { gchar *filename; /* Only directory here are skins */ filename = g_strdup_printf("%s/%s", properties->package_skin_dir, one_dirent); if (g_file_test ((filename), G_FILE_TEST_IS_DIR)) { gchar *skin_name = g_strdup_printf("%s", one_dirent); skinlist = g_list_append (skinlist, skin_name); } g_free(filename); } } g_dir_close(dir); /* Find the current skin index */ skin_index = 0; for(i=0; i<g_list_length(skinlist); i++) if(!strcmp((char *)g_list_nth_data(skinlist, i), properties->skin)) skin_index = i; y_start += Y_GAP; /* Should not happen. It the user found the config, there should be a skin */ if(g_list_length(skinlist) > 0) { g_warning("No skin found in %s\n", skin_dir); display_previous_next(x_start, y_start, "skin_previous", "skin_next"); first_skin_name = g_strdup_printf(_("Skin : %s"), (char *)g_list_nth_data(skinlist, skin_index)); } else { first_skin_name = g_strdup(_("SKINS NOT FOUND")); } item_skin_text = goo_canvas_text_new (rootitem, first_skin_name, (gdouble) x_text_start, (gdouble) y_start, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); g_free(first_skin_name); g_free(skin_dir); } // Difficulty Filter y_start += Y_GAP; stars_group_x = x_start + 45; stars_group_y = y_start - 25; gchar *text = g_strdup_printf("<i>%s</i>", gettext(filtername)); item_filter_text = goo_canvas_text_new (rootitem, text, x_text_start, y_start, 400, GTK_ANCHOR_WEST, "use-markup", TRUE, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_color_content, NULL); g_free(text); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_ok, "ok"); is_displayed = TRUE; }
static void display_confirm(gchar *title, gchar *question_text, gchar *yes_text, gchar *no_text, ConfirmCallBack iscb) { if(rootitem) return; bg_x = BG_X; bg_y = BG_Y; titre_x = T_X; titre_w = T_W; titre_y = T_Y;; titre_h = T_H; text_zone_x = T_Z_X; text_zone_w = T_Z_W; text_zone_y = T_Z_Y; text_zone_h = T_Z_H; button_x = T_B_X; button_w = T_B_W; button_y = T_B_Y; button_h = T_B_Y; button_x_int = T_B_X_INT; gc_bar_hide(TRUE); gc_board_pause(TRUE); confirmCallBack=iscb; rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); /* Title */ goo_canvas_text_new (rootitem, title, titre_x + titre_w/2, titre_y + titre_h/2, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); text = goo_canvas_text_new (rootitem, question_text, text_zone_x, text_zone_y, 500, GTK_JUSTIFY_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); /* * Buttons * ------- */ GooCanvasBounds bounds; // CANCEL no_button = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#BUTTON_TEXT", NULL); goo_canvas_item_get_bounds(no_button, &bounds); gint button_width = bounds.x2 - bounds.x1; button_x += button_width / 2; SET_ITEM_LOCATION_CENTER(no_button, button_x, button_y + 2*button_h/3); g_signal_connect(no_button, "button_press_event", (GtkSignalFunc) button_event, "/no/"); gc_item_focus_init(no_button, NULL); // CANCEL CROSS no_cross = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#UNCHECKED", NULL); SET_ITEM_LOCATION_CENTER(no_cross, button_x , button_y + 2*button_h/3); g_signal_connect(no_cross, "button_press_event", (GtkSignalFunc) button_event, "/no/"); gc_item_focus_init(no_cross, no_button); goo_canvas_text_new (rootitem, no_text, (gdouble) button_x + button_width/2 + button_x_int , (gdouble) button_y + 2*button_h/3, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_get_color("gcompris/helpfg"), NULL); // OK yes_button = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#BUTTON_TEXT", NULL); SET_ITEM_LOCATION_CENTER(yes_button, button_x , button_y + button_h/3); g_signal_connect(yes_button, "button_press_event", (GtkSignalFunc) button_event, "/yes/"); gc_item_focus_init(yes_button, NULL); // OK stick yes_stick = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#CHECKED", NULL); SET_ITEM_LOCATION_CENTER(yes_stick, button_x , button_y + button_h/3); g_signal_connect(yes_stick, "button_press_event", (GtkSignalFunc) button_event, "/yes/"); gc_item_focus_init(yes_stick, yes_button); goo_canvas_text_new (rootitem, yes_text, (gdouble) button_x + button_width/2 + button_x_int , (gdouble) button_y + button_h/3, -1, GTK_ANCHOR_WEST, "font", gc_skin_font_subtitle, "fill-color-rgba", gc_skin_get_color("gcompris/helpfg"), NULL); confirm_displayed = TRUE; }
/* * Do all the bar display and register the events */ void gc_about_start () { GdkPixbuf *pixmap = NULL; gdouble y_start = 0; gint y = 0; GooCanvasItem *item; static gchar *content = N_("Author: Bruno Coudoin\n" "Contribution: Pascal Georges, Jose Jorge, Yves Combe\n" "Graphics: Renaud Blanchard, Franck Doucet\n" "Intro Music: Djilali Sebihi\n" "Background Music: Rico Da Halvarez\n" ); /* TRANSLATORS: Replace this string with your names, one name per line. */ gchar *translators = _("translator_credits"); /* Pause the board */ gc_board_pause(TRUE); if(rootitem) { gc_about_stop(); return; } gc_bar_hide (TRUE); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); y_start = bounds.y1; y = bounds.y2 - 26; goo_canvas_text_new (rootitem, _("About GCompris"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 35, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); goo_canvas_text_new (rootitem, _("GCompris Home Page: http://gcompris.net"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 58, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_subtitle, NULL); gchar *text = g_strdup_printf("%s\n%s\n%s", _(content), _("Translators:"), translators); y_start += 100; goo_canvas_text_new (rootitem, text, (gdouble) BOARDWIDTH/2-320, (gdouble) y_start, -1, GTK_ANCHOR_NORTH_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); g_free(text); // Version item = \ goo_canvas_text_new (rootitem, "GCompris V" VERSION, (gdouble) 0, (gdouble) y_start, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_subtitle, NULL); goo_canvas_item_get_bounds(item, &bounds); gdouble x = BOARDWIDTH - (bounds.x2 - bounds.x1) - 20; g_object_set( (GooCanvasItem*)item, "x", x, NULL); y_start += 180; /* Location for a potential sponsor */ gchar *sponsor_image = gc_file_find_absolute("sponsor_about.png"); if(sponsor_image) { pixmap = gc_pixmap_load("sponsor_about.png"); goo_canvas_text_new (rootitem, "Version parrainée par", (gdouble) BOARDWIDTH*0.75, (gdouble) y_start - gdk_pixbuf_get_height(pixmap), -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); item = goo_canvas_image_new (rootitem, pixmap, (gdouble) (BOARDWIDTH*0.75) - gdk_pixbuf_get_width(pixmap)/2, (gdouble) y_start - gdk_pixbuf_get_height(pixmap) + 15, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif g_free(sponsor_image); } else { // Default sponsor is the FSF RsvgHandle *svg_handle; svg_handle = gc_skin_rsvg_get(); item = goo_canvas_svg_new (rootitem, svg_handle, "svg-id", "#FSF_LOGO", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); goo_canvas_item_get_bounds(item, &bounds); SET_ITEM_LOCATION_CENTER(item, (BOARDWIDTH*0.75), y_start + 50 - (bounds.y2 - bounds.y1) / 2); item = goo_canvas_text_new (rootitem, "Free Software Foundation\nhttp://www.fsf.org", (gdouble) (BOARDWIDTH*0.75), (gdouble) y_start + 80, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_subtitle, NULL); } // Copyright item = goo_canvas_text_new (rootitem, "Copyright 2000-2013 Bruno Coudoin and Others", (gdouble) BOARDWIDTH/2, (gdouble) y - 55, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // License item = goo_canvas_text_new (rootitem, _("This software is a GNU Package and is released under the GNU General Public License"), (gdouble) BOARDWIDTH/2, (gdouble) y - 40, -1, GTK_ANCHOR_CENTER, "font", "sans 8", "fill-color-rgba", gc_skin_color_content, NULL); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_ok, "ok"); is_displayed = TRUE; }
void gc_selector_images_start (GcomprisBoard *gcomprisBoard, gchar *dataset, ImageSelectorCallBack iscb, void *user_context) { gint y_start = 0; gchar *dataseturl = NULL; GtkWidget *w; if(sugar_detected()) { sugar_choose_image(iscb, user_context); return; } if(rootitem) return; gc_bar_hide(TRUE); gc_board_pause(TRUE); imageSelectorCallBack = iscb; current_user_context = user_context; rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); images_selector_displayed = TRUE; goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#IMAGE_SELECTOR", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); y_start += 110; /* * Create the list scrollbar * ------------------------- */ canvas_list_selector = goo_canvas_new (); goo_canvas_widget_new (rootitem, canvas_list_selector, LIST_AREA_X1, LIST_AREA_Y1, LIST_AREA_X2 - LIST_AREA_X1, LIST_AREA_Y2 - LIST_AREA_Y1 - 35.0, NULL); gtk_widget_show (canvas_list_selector); /* Set the new canvas to the background color or it's white */ list_bg_item = goo_canvas_rect_new (goo_canvas_get_root_item(GOO_CANVAS(canvas_list_selector)), 0, 0, (LIST_AREA_X2 - LIST_AREA_X1) * gc_zoom_factor_get(), (LIST_AREA_Y2 - LIST_AREA_Y1) * gc_zoom_factor_get(), "fill-color-rgba", gc_skin_get_color("gcompris/imageselectbg_left"), "line-width", 0.0, NULL); list_adj = \ GTK_ADJUSTMENT (gtk_adjustment_new (0.00, 0.00, 0.00, 10, IMAGE_HEIGHT, (LIST_AREA_Y2 - LIST_AREA_Y1) * gc_zoom_factor_get()) ); w = gtk_vscrollbar_new (list_adj); goo_canvas_widget_new (rootitem, w, LIST_AREA_X2 - 5.0, LIST_AREA_Y1, 30.0, LIST_AREA_Y2 - LIST_AREA_Y1 - 20.0, NULL); gtk_widget_show (w); /* Set the scrollwheel event */ g_signal_connect (list_adj, "value_changed", (GCallback) item_event_scroll, canvas_list_selector); /* * Create the image scrollbar * -------------------------- */ canvas_image_selector = goo_canvas_new (); goo_canvas_widget_new (rootitem, canvas_image_selector, DRAWING_AREA_X1, DRAWING_AREA_Y1, DRAWING_AREA_X2 - DRAWING_AREA_X1, DRAWING_AREA_Y2 - DRAWING_AREA_Y1, NULL); gtk_widget_show (canvas_image_selector); /* Set the new canvas to the background color or it's white */ image_bg_item = \ goo_canvas_rect_new (goo_canvas_get_root_item(GOO_CANVAS(canvas_image_selector)), 0, 0, (DRAWING_AREA_X2 - DRAWING_AREA_X1) * gc_zoom_factor_get(), (DRAWING_AREA_Y2 - DRAWING_AREA_Y1) * gc_zoom_factor_get(), "fill-color-rgba", gc_skin_get_color("gcompris/imageselectbg_right"), "line-width", 0.0, NULL); image_adj = \ GTK_ADJUSTMENT (gtk_adjustment_new (0.00, 0.00, 0.00, 10, IMAGE_HEIGHT, (DRAWING_AREA_Y2 - DRAWING_AREA_Y1) * gc_zoom_factor_get()) ); w = gtk_vscrollbar_new (image_adj); goo_canvas_widget_new (rootitem, w, DRAWING_AREA_X2 - 5.0, DRAWING_AREA_Y1, 30.0, DRAWING_AREA_Y2 - DRAWING_AREA_Y1 - 20.0, NULL); gtk_widget_show (w); /* Set the scrollwheel event */ g_signal_connect (image_adj, "value_changed", (GCallback) item_event_scroll, canvas_image_selector); /* * DISPLAY IMAGES */ /* Initial image position */ isy = 0.0; /* I need the following : -> if dataset is a file read it. -> if dataset is a directory, read all xml file in it. */ dataseturl = \ gc_file_find_absolute(dataset, NULL); /* if the file doesn't exist */ if(g_file_test ((dataseturl), G_FILE_TEST_IS_DIR) ) { g_warning("dataset %s is a directory. Trying to read xml", dataseturl); read_dataset_directory(dataseturl); } else if(dataseturl) { /* Read the given data set file, local or net */ read_xml_file(dataseturl); } else { /* Network code for dataset directory */ GSList *filelist = NULL; GSList *i = NULL; g_free(dataseturl); dataseturl = g_strconcat("boards/", dataset, NULL); /* TODO */ filelist = NULL; //gc_net_dir_read_name(dataseturl, ".xml"); for (i = filelist; i != NULL; i = g_slist_next (i)) { gchar *url = gc_file_find_absolute(i->data, NULL); g_warning("processing dataset=%s\n", (char *)i->data); read_xml_file(url); g_free(url); } g_slist_free(filelist); } g_free(dataseturl); /* * OK Button * --------- */ gc_util_button_text_svg(rootitem, (BOARDWIDTH*0.5), BOARDHEIGHT - 32, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_images_selector, "/ok/"); }