Exemple #1
0
CCPos          *
get_cc_pos()
{
	CCPos          *p = malloc(sizeof(CCPos));

	p->x = ecore_config_int_get("controlcentre.x");
	p->y = ecore_config_int_get("controlcentre.y");
	p->width = ecore_config_int_get("controlcentre.w");
	p->height = ecore_config_int_get("controlcentre.h");
	p->shaded = ecore_config_boolean_get("controlcentre.shaded");

	return (p);
}
Exemple #2
0
void eim_config_init (Eim *e) {
#ifdef CORE_DEBUG
  printf("TRACE: eim_initialize\n");
#endif
  assert (e);

  int nb_account = 0;
  int i;
  
  /* read config file to get account properties */
  if (ecore_config_init ("eim") == ECORE_CONFIG_ERR_FAIL) {
    printf("WARNING: config file not available\n");
    /* load default config and save it*/
    _eim_load_default_config ();
    ecore_config_save ();
  }
  
  /* here we can load each configuration */
  ecore_config_load();
  nb_account = ecore_config_int_get(EIM_CONFIG_NB_ACCOUNT);
  for (i = 0; i < nb_account; i++) {
    ecore_list_append (e->account_properties, 
		       account_properties_new_from_config (i));
  }
}
void _eli_edje_frontend_config_changed(Eli_App * eap, const int tag)
{
    Eli_Edje_Frontend * eef;

    eef = eli_app_edje_frontend_get(eap);

    switch (tag) {
    case THEME:
        if (!eef->gui) break;
        else {
            char * theme;

            if ((theme = ecore_config_theme_get("/theme/gui"))) {
                eli_app_theme_change(eap, theme);
                edje_object_signal_emit(eef->gui, "theme,selected", "elitaire");
                free(theme);
            }
        }
        break;
		
    case CARDS:
    {
        char * cards;

        if ((cards = ecore_config_theme_get("/theme/cards"))) {
            if (eap->theme.cards.current) free(eap->theme.cards.current);                   eap->theme.cards.current = cards;
        }

        edje_object_signal_emit(eef->gui, "cards,selected", "elitaire");

        if (eap->theme.cards.current && eef->elitaire
                && (cards = ecore_config_theme_with_path_from_name_get(
                        eap->theme.cards.current))) {
            elitaire_object_file_set(eef->elitaire, cards);
            free(cards);
        }
        break;
    }	
    case VELOCITY:
    {    
	    int v;
	    
        v = ecore_config_int_get("velocity");
			
        if (!eef->elitaire) break;
        else {
            elitaire_object_velocity_set(eef->elitaire, v);
        }
        break;
	}
    case ANIMATIONS:
        if (!eef->elitaire) break;
        else {
            Eina_Bool b;

            b = ecore_config_boolean_get("/graphic/animations");
            elitaire_object_animations_set(eef->elitaire, b);
        }
        break;
		
    case SHADOWS:
        if (!eef->elitaire) break;
        else {
            Eina_Bool b;

            b = ecore_config_boolean_get("/graphic/shadows");
            elitaire_object_shadows_set(eef->elitaire, b);
        }
        break;
		
    case FRAME_RATE:
        if (!eef->elitaire) break;
        else {
            int fr;

            fr = ecore_config_int_get("frame_rate");
            elitaire_object_frame_rate_set(eef->elitaire, fr);
        }
        break;
		
    case LAZY:
        if (!eef->elitaire) break;
        else {
            int lazy;

            lazy = ecore_config_int_get("lazy");
            elitaire_object_lazy_mode_set(eef->elitaire, lazy);
        }
        break;
		
    default:
	    break;
    }
}
void _eli_edje_frontend_game_new(Eli_App * eap)
{
    Eli_Edje_Frontend * eef;
    Evas_Coord x, y, w, h;
    Evas_Coord l, r, t, b;
    Evas_Coord min_w, min_h;
    char * card_theme;
    int vel;
    Eina_Bool bo;

    eef = eli_app_edje_frontend_get(eap);
   
    edje_object_signal_emit(eef->gui, "win,off", "");

    /* init elitaire, set the theme, ... */
    if (!(eef->elitaire = elitaire_object_new(eef->evas)))
        return;
    
    elitaire_object_game_set(eef->elitaire, eap->current.game);

    card_theme =
        ecore_config_theme_with_path_from_name_get(eap->theme.cards.current);
    /* get and set the offset */
    eli_edje_frontend_theme_offset_get(eap, &l, &r, &t, &b);
    elitaire_object_offset_set(eef->elitaire, l, r, t, b);

    if (elitaire_object_file_set(eef->elitaire, card_theme)) {
        elitaire_object_size_min_get(eef->elitaire, &w, &h);
    }
    else {
        fprintf(stderr, _("Elitaire Error: cards file %s not found!\n"),
                eap->theme.cards.current);
        return;
    }
    free(card_theme);
    card_theme = NULL;

    /* find and set the minimum size */
    elitaire_object_size_min_get(eef->elitaire, &min_w, &min_h);
    if (!edje_object_part_exists(eef->gui, "elitaire_card_field")) {
        fprintf(stderr,
                _("Elitaire Error in %s:"
		  " elitaire_card_field does not exist!\n"),
                eap->theme.gui.current);
        return;
    }
    edje_object_part_geometry_get(eef->gui, "elitaire_card_field", &x, &y, &w, &h);
    
    if (w < min_w || h < min_h) {
        Evas_Coord win_h, win_w;

        ecore_evas_geometry_get(eef->ee, NULL, NULL, &win_w, &win_h);
        ecore_evas_resize(eef->ee, win_w + min_w - w, win_h + min_h - h);
    }
    /* move and resize */
    evas_object_move(eef->elitaire, x, y);
    evas_object_resize(eef->elitaire, w, h);
    evas_object_show(eef->elitaire);

    /* tell elitaire the ecore_config vlaues */
    vel = ecore_config_int_get("velocity");
    elitaire_object_velocity_set(eef->elitaire, vel);

    vel = ecore_config_int_get("frame_rate");
    elitaire_object_frame_rate_set(eef->elitaire, vel);

    vel = ecore_config_int_get("lazy");
    elitaire_object_lazy_mode_set(eef->elitaire, vel);

    bo = ecore_config_boolean_get("/graphic/animations");
    elitaire_object_animations_set(eef->elitaire, bo);

    bo = ecore_config_boolean_get("/graphic/shadows");
    elitaire_object_shadows_set(eef->elitaire, bo);

    /* swallow the elitaire object */
    edje_object_part_swallow(eef->gui, "elitaire_card_field", eef->elitaire);
    /* Add the callbacks */
    elitaire_object_callback_win_add(eef->elitaire, _win_game_cb, eap);
    elitaire_object_callback_points_add(eef->elitaire, _points_cb, eef);
    
    /* and now deal */
    elitaire_object_deal(eef->elitaire);

    eli_app_state_set(eap, ELI_STATE_PLAYING);
    return;
}
void ewl_frontend_dialog_config_open(Eli_App * eap)
{
    Ewl_Widget * o;
    Ewl_Widget * border_box;
    Ewl_Widget * hbox;
    Ewl_Widget * vbox;
    Ewl_Widget * main_box;
    Ewl_Widget * radio_b[2];

    /* one open config dialog should be enough */
    if (conf_win) return;
    /* Setup and show the configuration window */
    conf_win = ewl_dialog_new();
    ewl_dialog_action_position_set(EWL_DIALOG(conf_win), EWL_POSITION_BOTTOM);
    ewl_window_title_set(EWL_WINDOW(conf_win), _("Configuration"));
    ewl_window_name_set(EWL_WINDOW(conf_win), "Elitaire");
    ewl_window_class_set(EWL_WINDOW(conf_win), "Elitaire");
    ewl_window_leader_foreign_set(EWL_WINDOW(conf_win),
		    		EWL_EMBED_WINDOW(eap->main_win));
    ewl_callback_append(conf_win, EWL_CALLBACK_DELETE_WINDOW, destroy_cb,
                        NULL);
    ewl_dialog_has_separator_set(EWL_DIALOG(conf_win), 1);
    ewl_object_fill_policy_set(EWL_OBJECT(conf_win), EWL_FLAG_FILL_NONE);
    ewl_widget_show(conf_win);
    
    /* the main_box contain the border_boxes */
    ewl_dialog_active_area_set(EWL_DIALOG(conf_win), EWL_POSITION_TOP);
    main_box = ewl_vbox_new();
    ewl_container_child_append(EWL_CONTAINER(conf_win), main_box);
    ewl_object_fill_policy_set(EWL_OBJECT(main_box), EWL_FLAG_ALIGN_CENTER);
    ewl_widget_show(main_box);

    /* Setup and show the stock icons */
    ewl_dialog_active_area_set(EWL_DIALOG(conf_win), EWL_POSITION_BOTTOM);

    o = ewl_button_new();
    ewl_stock_type_set(EWL_STOCK(o), EWL_STOCK_CANCEL);
    ewl_container_child_append(EWL_CONTAINER(conf_win), o);
    ewl_callback_append(o, EWL_CALLBACK_CLICKED, conf_win_clicked_cb,
                        conf_win);
    ewl_widget_show(o);

    o = ewl_button_new();
    ewl_stock_type_set(EWL_STOCK(o), EWL_STOCK_APPLY);
    ewl_container_child_append(EWL_CONTAINER(conf_win), o);
    ewl_callback_append(o, EWL_CALLBACK_CLICKED, conf_win_clicked_cb,
                        conf_win);
    ewl_widget_show(o);

    o = ewl_button_new();
    ewl_stock_type_set(EWL_STOCK(o), EWL_STOCK_OK);
    ewl_container_child_append(EWL_CONTAINER(conf_win), o);
    ewl_callback_append(o, EWL_CALLBACK_CLICKED, conf_win_clicked_cb,
                        conf_win);
    ewl_widget_show(o);

    /* *** Graphic Box *** */
    /* Setup and show the border box */
    border_box = ewl_border_new();
    ewl_border_label_set(EWL_BORDER(border_box), _("Graphic"));
    ewl_container_child_append(EWL_CONTAINER(main_box), border_box);
    //ewl_object_fill_policy_set(EWL_OBJECT(border_box), EWL_FLAG_FILL_HFILL);
    ewl_widget_show(border_box);

    /* Setup and show the checkbuttons */
    o = ewl_checkbutton_new();
    ewl_button_label_set(EWL_BUTTON(o), _("animated movements"));
    ewl_container_child_append(EWL_CONTAINER(border_box), o);
    ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT);
    ewl_widget_show(o);
    config.animations = ecore_config_boolean_get("/graphic/animations");
    ewl_togglebutton_checked_set(EWL_TOGGLEBUTTON(o), config.animations);
    ewl_callback_append(o, EWL_CALLBACK_CLICKED, _check_selected, NULL);

    o = ewl_checkbutton_new();
    ewl_button_label_set(EWL_BUTTON(o), _("shadows"));
    ewl_container_child_append(EWL_CONTAINER(border_box), o);
    ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT);
    ewl_widget_show(o);
    config.shadows = ecore_config_boolean_get("/graphic/shadows");
    ewl_togglebutton_checked_set(EWL_TOGGLEBUTTON(o), config.shadows);
    ewl_callback_append(o, EWL_CALLBACK_CLICKED, _check_selected, NULL);

    /* Setup and show the velocity label and seeker */
    hbox = ewl_grid_new();
    ewl_container_child_append(EWL_CONTAINER(border_box), hbox);
    ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_FILL);
    ewl_grid_column_preferred_w_use(EWL_GRID(hbox), 1);
    ewl_widget_show(hbox);

    o = ewl_label_new();
    ewl_label_text_set(EWL_LABEL(o), _("velocity:"));
    ewl_container_child_append(EWL_CONTAINER(hbox), o);
    ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE);
    ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT);
    ewl_widget_show(o);

    o = ewl_label_new();
    ewl_container_child_append(EWL_CONTAINER(hbox), o);
    ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE);
    ewl_widget_show(o);
    config.vel_label = o;

    o = ewl_hseeker_new();
    config.velocity = ecore_config_int_get("velocity");
    ewl_range_minimum_value_set(EWL_RANGE(o), 200.0);
    ewl_range_maximum_value_set(EWL_RANGE(o), 800.0);
    ewl_range_step_set(EWL_RANGE(o), 60.0);
    ewl_range_value_set(EWL_RANGE(o), (double) config.velocity);
    ewl_widget_name_set(o, "velocity");
    ewl_container_child_append(EWL_CONTAINER(border_box), o);
    ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, _hseeker_cb, NULL);
                          _hseeker_cb(o, NULL, NULL);
    ewl_widget_show(o);

    /* Setup and show the frame_rate label and seeker */
    hbox = ewl_grid_new();
    ewl_container_child_append(EWL_CONTAINER(border_box), hbox);
    ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL);
    ewl_grid_column_preferred_w_use(EWL_GRID(hbox), 1);
    ewl_widget_show(hbox);

    o = ewl_label_new();
    ewl_label_text_set(EWL_LABEL(o), _("frame rate:"));
    ewl_container_child_append(EWL_CONTAINER(hbox), o);
    ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE);
    ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT);
    ewl_widget_show(o);
    
    o = ewl_label_new();
    ewl_container_child_append(EWL_CONTAINER(hbox), o);
    ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE);
    ewl_widget_show(o);
    config.frt_label = o;

    o = ewl_hseeker_new();
    config.frame_rate = ecore_config_int_get("frame_rate");
    ewl_range_minimum_value_set(EWL_RANGE(o), 10.0);
    ewl_range_maximum_value_set(EWL_RANGE(o), 100.0);
    ewl_range_step_set(EWL_RANGE(o), 10.0);
    ewl_range_value_set(EWL_RANGE(o), (double) config.frame_rate);
    ewl_widget_name_set(o, "frame_rate");
    ewl_container_child_append(EWL_CONTAINER(border_box), o);
    ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, _hseeker_cb, NULL);
    _hseeker_cb(o, NULL, NULL);
    ewl_widget_show(o);

    /* *** Lazy Box *** */
    vbox = ewl_vbox_new();
    ewl_container_child_append(EWL_CONTAINER(main_box), vbox);
    ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_NORMAL);
    ewl_widget_show(vbox);

    border_box = ewl_border_new();
    ewl_container_child_append(EWL_CONTAINER(vbox), border_box);
    ewl_border_label_set(EWL_BORDER(border_box), _("Laziness"));
    ewl_widget_show(border_box);
    /* the radio buttons */
    config.lazy = ecore_config_int_get("lazy");
    radio_b[0] = ewl_radiobutton_new();
    ewl_button_label_set(EWL_BUTTON(radio_b[0]), _("normal mode"));
    ewl_object_alignment_set(EWL_OBJECT(radio_b[0]), EWL_FLAG_ALIGN_LEFT);
    ewl_container_child_append(EWL_CONTAINER(border_box), radio_b[0]);
    ewl_callback_append(radio_b[0], EWL_CALLBACK_CLICKED, _check_selected,
                        NULL);
    ewl_widget_show(radio_b[0]);

    radio_b[1] = ewl_radiobutton_new();
    ewl_button_label_set(EWL_BUTTON(radio_b[1]), _("lazy mode"));
    ewl_container_child_append(EWL_CONTAINER(border_box), radio_b[1]);
    ewl_object_alignment_set(EWL_OBJECT(radio_b[1]), EWL_FLAG_ALIGN_LEFT);
    ewl_radiobutton_chain_set(EWL_RADIOBUTTON(radio_b[1]),
                              EWL_RADIOBUTTON(radio_b[0]));
    ewl_callback_append(radio_b[1], EWL_CALLBACK_CLICKED, _check_selected,
                        NULL);
    ewl_widget_show(radio_b[1]);
    if (config.lazy)
        ewl_togglebutton_checked_set(EWL_TOGGLEBUTTON(radio_b[1]), 1);
    else
        ewl_togglebutton_checked_set(EWL_TOGGLEBUTTON(radio_b[0]), 1);

    /* *** Render Box *** */
    /* Setup and show the border box */
    border_box = ewl_border_new();
    ewl_border_label_set(EWL_BORDER(border_box), _("Render Engine"));
    ewl_container_child_append(EWL_CONTAINER(vbox), border_box);
    ewl_object_fill_policy_set(EWL_OBJECT(border_box), EWL_FLAG_FILL_FILL);
    ewl_object_alignment_set(EWL_OBJECT(border_box), EWL_FLAG_ALIGN_CENTER);
    ewl_object_alignment_set(EWL_OBJECT(main_box), EWL_FLAG_ALIGN_TOP);
    ewl_widget_show(border_box);

    o = ewl_text_new();
    ewl_text_text_set(EWL_TEXT(o), _("Changes only affect after new start"));
    ewl_container_child_append(EWL_CONTAINER(border_box), o);
    ewl_widget_show(o);

    /* the radio buttons */
    config.gl = ecore_config_boolean_get("/graphic/gl");
    radio_b[0] = ewl_radiobutton_new();
    ewl_button_label_set(EWL_BUTTON(radio_b[0]), _("Software"));
    ewl_container_child_append(EWL_CONTAINER(border_box), radio_b[0]);
    ewl_object_alignment_set(EWL_OBJECT(radio_b[0]), EWL_FLAG_ALIGN_LEFT);
    ewl_callback_append(radio_b[0], EWL_CALLBACK_CLICKED, _check_selected,
                        NULL);
    ewl_widget_show(radio_b[0]);

    radio_b[1] = ewl_radiobutton_new();
    ewl_button_label_set(EWL_BUTTON(radio_b[1]), _("OpenGL (testing)"));
    ewl_container_child_append(EWL_CONTAINER(border_box), radio_b[1]);
    ewl_object_alignment_set(EWL_OBJECT(radio_b[1]), EWL_FLAG_ALIGN_LEFT);
    ewl_radiobutton_chain_set(EWL_RADIOBUTTON(radio_b[1]),
                              EWL_RADIOBUTTON(radio_b[0]));
    ewl_callback_append(radio_b[1], EWL_CALLBACK_CLICKED, _check_selected,
                        NULL);
    ewl_widget_show(radio_b[1]);
    if (config.gl)
        ewl_togglebutton_checked_set(EWL_TOGGLEBUTTON(radio_b[1]), 1);
    else
        ewl_togglebutton_checked_set(EWL_TOGGLEBUTTON(radio_b[0]), 1);

}