Back to index

gcompris  8.2.2
Defines | Functions
gcompris_config.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MAX_TIMER_VALUE   3
#define MAX_SCREEN_VALUE   2

Functions

void gc_config_start ()
void gc_config_stop ()

Define Documentation

#define MAX_SCREEN_VALUE   2

Definition at line 25 of file gcompris_config.h.

#define MAX_TIMER_VALUE   3

Definition at line 24 of file gcompris_config.h.


Function Documentation

void gc_config_start ( )

Definition at line 145 of file config.c.

{
  GcomprisProperties *properties = gc_prop_get();
  GdkPixbuf   *pixmap = NULL;
  gint y_start = 0;
  gint x_start = 0;
  gint x_text_start = 0;
  gint x_flag_start = 0;
  gint y = 0;
  GnomeCanvasItem *item, *item2;

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

  if(rootitem)
    return;

  gc_bar_hide(TRUE);

  rootitem = \
    gnome_canvas_item_new (gnome_canvas_root(gc_get_canvas()),
                        gnome_canvas_group_get_type (),
                        "x", (double)0,
                        "y", (double)0,
                        NULL);

  pixmap = gc_skin_pixmap_load("help_bg.png");
  y_start = (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap))/2;
  x_start = (BOARDWIDTH - gdk_pixbuf_get_width(pixmap))/2;
  item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                            gnome_canvas_pixbuf_get_type (),
                            "pixbuf", pixmap,
                            "x", (double) x_start,
                            "y", (double) y_start,
                            NULL);
  y = BOARDHEIGHT - (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap))/2;
  gdk_pixbuf_unref(pixmap);

  gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                      gnome_canvas_text_get_type (),
                      "text", _("GCompris Configuration"),
                      "font", gc_skin_font_title,
                      "x", (double) BOARDWIDTH/2 + 1.0,
                      "y", (double) y_start + 40 + 1.0,
                      "anchor", GTK_ANCHOR_CENTER,
                      "fill_color_rgba", gc_skin_color_shadow,
                      "weight", PANGO_WEIGHT_HEAVY,
                      NULL);
  gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                      gnome_canvas_text_get_type (),
                      "text", _("GCompris Configuration"),
                      "font", gc_skin_font_title,
                      "x", (double) BOARDWIDTH/2,
                      "y", (double) y_start + 40,
                      "anchor", GTK_ANCHOR_CENTER,
                      "fill_color_rgba", gc_skin_color_title,
                      "weight", PANGO_WEIGHT_HEAVY,
                      NULL);

  pixmap_checked   = gc_skin_pixmap_load("button_checked.png");
  pixmap_unchecked = gc_skin_pixmap_load("button_unchecked.png");


  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");

  item_locale_flag = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                                       gnome_canvas_pixbuf_get_type (),
                                       "pixbuf", NULL,
                                       "x", (double) x_flag_start,
                                       "y", (double) y_start - gdk_pixbuf_get_width(pixmap_checked)/2,
                                       NULL);

  /* Display a bad icon if this locale is not available */
  pixmap   = gc_skin_pixmap_load("mini_bad.png");
  item_bad_flag = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                                    gnome_canvas_pixbuf_get_type (),
                                    "pixbuf", pixmap,
                                    "x", (double) x_flag_start - 20,
                                    "y", (double) y_start - gdk_pixbuf_get_width(pixmap_checked)/2,
                                    NULL);
  gdk_pixbuf_unref(pixmap);

  /*
   * The current locale is the one found in the config file
   */
  current_locale = properties->locale;
  set_locale_flag(current_locale);

  item_locale_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                                       gnome_canvas_text_get_type (),
                                       "text", gc_locale_get_name(current_locale),
                                       "font", gc_skin_font_subtitle,
                                       "x", (double) x_text_start,
                                       "y", (double) y_start,
                                       "anchor", GTK_ANCHOR_WEST,
                                       "fill_color_rgba", gc_skin_color_content,
                                       NULL);

  // Fullscreen / Window
  y_start += Y_GAP;

  item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                            gnome_canvas_pixbuf_get_type (),
                            "pixbuf", (properties->fullscreen ? pixmap_checked : pixmap_unchecked),
                            "x", (double) x_start,
                            "y", (double) y_start - gdk_pixbuf_get_width(pixmap_checked)/2,
                            NULL);

  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) item_event_ok,
                   "fullscreen");
  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) gc_item_focus_event,
                   NULL);


  gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                      gnome_canvas_text_get_type (),
                      "text", _("Fullscreen"),
                      "font", gc_skin_font_subtitle,
                      "x", (double) x_text_start,
                      "y", (double) y_start,
                      "anchor", GTK_ANCHOR_WEST,
                      "fill_color_rgba", gc_skin_color_content,
                      NULL);

  // Screen size
  y_start += Y_GAP;

  display_previous_next(x_start, y_start, "screen_previous", "screen_next");

  item_screen_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                                       gnome_canvas_text_get_type (),
                                       "text", gettext(screenname[properties->screensize]),
                                       "font", gc_skin_font_subtitle,
                                       "x", (double) x_text_start,
                                       "y", (double) y_start,
                                       "anchor", GTK_ANCHOR_WEST,
                                       "fill_color_rgba", gc_skin_color_content,
                                       NULL);

  // Music
  y_start += Y_GAP;

  item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                            gnome_canvas_pixbuf_get_type (),
                            "pixbuf", (properties->music ? pixmap_checked : pixmap_unchecked),
                            "x", (double) x_start,
                            "y", (double) y_start - gdk_pixbuf_get_width(pixmap_checked)/2,
                            NULL);

  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) item_event_ok,
                   "music");
  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) gc_item_focus_event,
                   NULL);


  gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                      gnome_canvas_text_get_type (),
                      "text", _("Music"),
                      "font", gc_skin_font_subtitle,
                      "x", (double) x_text_start,
                      "y", (double) y_start,
                      "anchor", GTK_ANCHOR_WEST,
                      "fill_color_rgba", gc_skin_color_content,
                      NULL);

  // Effect
  y_start += Y_GAP;

  item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                            gnome_canvas_pixbuf_get_type (),
                            "pixbuf", (properties->fx ? pixmap_checked : pixmap_unchecked),
                            "x", (double) x_start,
                            "y", (double) y_start - gdk_pixbuf_get_width(pixmap_checked)/2,
                            NULL);

  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) item_event_ok,
                   "effect");
  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) gc_item_focus_event,
                   NULL);


  gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                      gnome_canvas_text_get_type (),
                      "text", _("Effect"),
                      "font", gc_skin_font_subtitle,
                      "x", (double) x_text_start,
                      "y", (double) y_start,
                      "anchor", GTK_ANCHOR_WEST,
                      "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 = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                                      gnome_canvas_text_get_type (),
                                      "text", gettext(timername[properties->timer]),
                                      "font", gc_skin_font_subtitle,
                                      "x", (double) x_text_start,
                                      "y", (double) y_start,
                                      "anchor", GTK_ANCHOR_WEST,
                                      "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/skins/%s", properties->package_data_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 = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                                       gnome_canvas_text_get_type (),
                                       "text", first_skin_name,
                                       "font", gc_skin_font_subtitle,
                                       "x", (double) x_text_start,
                                       "y", (double) y_start,
                                       "anchor", GTK_ANCHOR_WEST,
                                       "fill_color_rgba", gc_skin_color_content,
                                       NULL);
    g_free(first_skin_name);
    g_free(skin_dir);

  }

  // Difficulty Filter
  y_start += Y_GAP;

  //  display_previous_next(x_start, y_start, "filter_style_previous", "filter_style_next");

  stars_group_x = x_start + 45;
  stars_group_y = y_start - 25;

  item_filter_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                                       gnome_canvas_text_get_type (),
                                       "markup", gettext(filtername[0]),
                                       "font", gc_skin_font_subtitle,
                                       "x", (double) x_text_start,
                                       "y", (double) y_start,
                                       "anchor", GTK_ANCHOR_WEST,
                                       "fill_color_rgba", gc_skin_color_content,
                                       NULL);


  // OK
  pixmap = gc_skin_pixmap_load("button_large.png");
  item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                            gnome_canvas_pixbuf_get_type (),
                            "pixbuf", pixmap,
                            "x", (double) (BOARDWIDTH*0.5) - gdk_pixbuf_get_width(pixmap)/2,
                            "y", (double) y - gdk_pixbuf_get_height(pixmap) - 5,
                            NULL);

  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) item_event_ok,
                   "ok");
  gtk_signal_connect(GTK_OBJECT(item), "event",
                   (GtkSignalFunc) gc_item_focus_event,
                   NULL);

  gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                      gnome_canvas_text_get_type (),
                      "text", _("OK"),
                      "font", gc_skin_font_title,
                      "x", (double)  BOARDWIDTH*0.5 + 1.0,
                      "y", (double)  y - gdk_pixbuf_get_height(pixmap) + 20 + 1.0,
                      "anchor", GTK_ANCHOR_CENTER,
                      "fill_color_rgba", gc_skin_color_shadow,
                      "weight", PANGO_WEIGHT_HEAVY,
                      NULL);
  item2 = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
                             gnome_canvas_text_get_type (),
                             "text", _("OK"),
                             "font", gc_skin_font_title,
                             "x", (double)  BOARDWIDTH*0.5,
                             "y", (double)  y - gdk_pixbuf_get_height(pixmap) + 20,
                             "anchor", GTK_ANCHOR_CENTER,
                             "fill_color_rgba", gc_skin_color_text_button,
                             "weight", PANGO_WEIGHT_HEAVY,
                             NULL);
  gtk_signal_connect(GTK_OBJECT(item2), "event",
                   (GtkSignalFunc) item_event_ok,
                   "ok");
  gtk_signal_connect(GTK_OBJECT(item2), "event",
                   (GtkSignalFunc) gc_item_focus_event,
                   item);
  gdk_pixbuf_unref(pixmap);


  is_displayed = TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gc_config_stop ( )

Definition at line 495 of file config.c.

{
  // Destroy the help box
  if(rootitem!=NULL)
    {
      gtk_object_destroy(GTK_OBJECT(rootitem));
      gc_board_pause(FALSE);
    }
  rootitem = NULL;

  stars_group = NULL;

  if(pixmap_unchecked)
    gdk_pixbuf_unref(pixmap_unchecked);
  pixmap_unchecked = NULL;

  if(pixmap_checked)
    gdk_pixbuf_unref(pixmap_checked);
  pixmap_checked = NULL;

  /* UnPause the board */
  if(is_displayed)
    gc_board_pause(FALSE);

  gc_bar_hide(FALSE);

  is_displayed = FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function: