Esempio n. 1
0
static void
gletter_config_start(GcomprisBoard *agcomprisBoard,
		    GcomprisProfile *aProfile)
{
  board_conf = agcomprisBoard;
  profile_conf = aProfile;

  gchar *label;

  if (gcomprisBoard)
    pause_board(TRUE);

  label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"),
			  agcomprisBoard->name, aProfile ? aProfile->name : "");

  GcomprisBoardConf *bconf = gc_board_config_window_display(label, (GcomprisConfCallback )conf_ok);

  g_free(label);

  /* init the combo to previously saved value */
  GHashTable *config = gc_db_get_conf( profile_conf, board_conf);

  gchar *locale = g_hash_table_lookup( config, "locale");

  gc_board_config_combo_locales( bconf, locale);

  gboolean up_init = FALSE;

  gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");

  if (up_init_str && (strcmp(up_init_str, "True")==0))
    up_init = TRUE;

  gc_board_conf_separator(bconf);

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

  gc_board_config_boolean_box(bconf, _("Enable sounds"), "with_sound", with_sound);

  gc_board_conf_separator(bconf);

  gc_board_config_boolean_box(bconf, _("Uppercase only text"),
		       "uppercase_only",
		       up_init);

}
Esempio n. 2
0
static void
wordsgame_config_start(GcomprisBoard *agcomprisBoard,
		       GcomprisProfile *aProfile)
{
  GcomprisBoardConf *conf;
  board_conf = agcomprisBoard;
  profile_conf = aProfile;

  if (gcomprisBoard)
    pause_board(TRUE);

  gchar *label = g_strdup_printf(_("<b>%s</b> configuration\n for profile <b>%s</b>"),
				 agcomprisBoard->name,
				 aProfile? aProfile->name: "");

  conf = gc_board_config_window_display( label,
					 conf_ok);

  g_free(label);

  /* init the combo to previously saved value */
  GHashTable *config = gc_db_get_conf( profile_conf, board_conf);

  gchar *locale = g_hash_table_lookup( config, "locale");

  gc_board_config_combo_locales(conf, locale);
  gc_board_config_wordlist(conf, "wordsgame/default-$LOCALE.xml");
  /* upper case */
  gboolean up_init = FALSE;
  gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");

  if (up_init_str && (strcmp(up_init_str, "True")==0))
    up_init = TRUE;

  gc_board_config_boolean_box(conf, _("Uppercase only text"),
			      "uppercase_only",
			      up_init);
}
Esempio n. 3
0
void config_missing_letter(GcomprisBoardConf *bconf, GHashTable *config)
{
    GtkWidget *frame, *view, *pixmap, *question, *answer, *choice;
    GtkWidget *level, *vbox, *hbox, *label;
    GtkWidget *bbox, *button, *table;
    GtkFileFilter *file_filter;
    _config_missing *conf_data;
    int i;

    conf_data = g_new0(_config_missing,1);

    /* frame */
    frame = gtk_frame_new("");
    gtk_widget_show(frame);
    gtk_box_pack_start(GTK_BOX(bconf->main_conf_box), frame, TRUE, TRUE, 8);

    vbox = gtk_vbox_new(FALSE, 8);
    gtk_widget_show(vbox);
    gtk_container_add(GTK_CONTAINER(frame), vbox);

    /* hbox */
    hbox = gtk_hbox_new(FALSE, 8);
    gtk_widget_show(hbox);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 8);

    /* combo level */
    label = gtk_label_new(_("Level:"));
    gtk_widget_show(label);
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);

    level = gtk_combo_box_new_text();
    for(i=1; i< gcomprisBoard_missing->maxlevel; i++)
      {
        gchar *tmp;
        tmp = g_strdup_printf(_("Level %d"), i);
        gtk_combo_box_append_text(GTK_COMBO_BOX(level), tmp);
        g_free(tmp);
      }
    gtk_widget_show(level);
    gtk_box_pack_start(GTK_BOX(hbox), level, FALSE, FALSE, 8);

    /* upper case */
    gboolean up_init = FALSE;
    gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");

    if (up_init_str && (strcmp(up_init_str, "True")==0))
      up_init = TRUE;

    gc_board_config_boolean_box(bconf, _("Uppercase only text"),
				"uppercase_only",
				up_init);

    /* list view */
    GtkListStore *list = gtk_list_store_new(N_COLUMNS,
                                            G_TYPE_STRING,   /*Question */
                                            G_TYPE_STRING,   /* Answer */
                                            G_TYPE_STRING,   /* Choice */
                                            G_TYPE_STRING,   /* pixmap */
                                            GDK_TYPE_PIXBUF  /* pixbuf */
                                            );

    view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list));
    configure_colummns(GTK_TREE_VIEW(view));
    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
    gtk_tree_view_set_search_column (GTK_TREE_VIEW (view), ANSWER_COLUMN);
    gtk_widget_set_size_request(view, -1, 200);
    gtk_widget_show(view);

    GtkScrolledWindow *scroll = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL,NULL));
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
                                    GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_widget_show(GTK_WIDGET(scroll));
    gtk_container_add(GTK_CONTAINER(scroll), view);

    gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scroll), TRUE, TRUE, 10);

    /* button box */
    bbox = gtk_hbutton_box_new();
    gtk_widget_show(bbox);
    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 8);
    button = gtk_button_new_from_stock(GTK_STOCK_NEW);
    gtk_widget_show(button);
    gtk_container_add(GTK_CONTAINER(bbox), button);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(new_clicked), (gpointer) conf_data);

    button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
    gtk_widget_show(button);
    gtk_container_add(GTK_CONTAINER(bbox), button);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(delete_clicked), (gpointer) conf_data);

    button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
    gtk_widget_show(button);
    gtk_container_add(GTK_CONTAINER(bbox), button);
    g_signal_connect(G_OBJECT(button), "clicked",
                     G_CALLBACK(save_clicked), (gpointer) conf_data);

    /* table */
    table = gtk_table_new(2, 4, FALSE);
    gtk_widget_show(table);
    gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 8);

    /* answer */
    label = gtk_label_new(_("Answer"));
    gtk_widget_show(label);
    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);

    answer = gtk_entry_new();
    gtk_widget_show(answer);
    gtk_table_attach_defaults(GTK_TABLE(table), answer, 1, 2, 0, 1);

    /* pixmap */
    label = gtk_label_new(_("Picture"));
    gtk_widget_show(label);
    gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1);

    pixmap = gtk_file_chooser_button_new(_("Filename:"),
                                         GTK_FILE_CHOOSER_ACTION_OPEN);

    file_filter = gtk_file_filter_new();
    gtk_file_filter_add_pixbuf_formats(file_filter);
    gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(pixmap), file_filter);
    gtk_widget_show(pixmap);
    gtk_table_attach_defaults(GTK_TABLE(table), pixmap, 3, 4, 0, 1);

    /* question */
    label = gtk_label_new(_("Question"));
    gtk_widget_show(label);
    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);

    question = gtk_entry_new();
    gtk_widget_show(question);
    gtk_table_attach_defaults(GTK_TABLE(table), question, 1, 2, 1, 2);
    gtk_widget_set_tooltip_text(question,
				_("Replace the letter to guess "
				  "by the character '_'.") );

    /* choice */
    label = gtk_label_new(_("Choice"));
    gtk_widget_show(label);
    gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 1, 2);

    choice = gtk_entry_new();
    gtk_entry_set_max_length(GTK_ENTRY(choice), MAX_PROPOSAL);
    gtk_widget_show(choice);
    gtk_table_attach_defaults(GTK_TABLE(table), choice, 3, 4, 1, 2);
    gtk_widget_set_tooltip_text(choice, _("Enter here the letter that will be proposed. "
					  "The first letter here must be the solution."));

    conf_data -> combo_level = GTK_COMBO_BOX(level);
    conf_data -> view = GTK_TREE_VIEW(view);
    conf_data -> pixmap = GTK_FILE_CHOOSER_BUTTON(pixmap);
    conf_data -> question = GTK_ENTRY(question);
    conf_data -> answer = GTK_ENTRY(answer);
    conf_data -> choice = GTK_ENTRY(choice);

    GtkTreeSelection *selection;
    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

    g_signal_connect(G_OBJECT(selection),
                     "changed",
                     G_CALLBACK(selection_changed),
                     (gpointer) conf_data);
    g_signal_connect(G_OBJECT(frame), "destroy",
                     G_CALLBACK(destroy_conf_data), (gpointer) conf_data);
    g_signal_connect(G_OBJECT(level), "changed",
                     G_CALLBACK(level_changed), (gpointer) conf_data);
    g_signal_connect(G_OBJECT(question), "changed",
                     G_CALLBACK(text_changed), (gpointer) conf_data);
    g_signal_connect(G_OBJECT(answer), "changed",
                     G_CALLBACK(text_changed), (gpointer) conf_data);
    g_signal_connect(G_OBJECT(choice), "changed",
                     G_CALLBACK(text_changed), (gpointer) conf_data);
    g_signal_connect(G_OBJECT(pixmap), "file-set",
                     G_CALLBACK(text_changed), (gpointer) conf_data);

    gtk_combo_box_set_active(GTK_COMBO_BOX(level), 0);
}