The config dialog is now accessable. A bit more work done on the slide_in tab, but it still a bit glitchy.
This commit is contained in:
@ -1,12 +1,7 @@
|
||||
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
||||
#include "ecdb.h"
|
||||
|
||||
typedef struct Config_Data Config_Data;
|
||||
struct Config_Data
|
||||
{
|
||||
char ** array;
|
||||
unsigned int count;
|
||||
};
|
||||
#include <dirent.h>
|
||||
#include <Ecore_Str.h>
|
||||
|
||||
static void destroy_cb(Ewl_Widget *w, void *event, void *data);
|
||||
static void conf_clicked_cb(Ewl_Widget *w, void *event, void *data);
|
||||
@ -14,12 +9,15 @@ static void scale_cb(Ewl_Widget *w, void *event, void *data);
|
||||
static void fps_cb(Ewl_Widget *w, void *event, void *data);
|
||||
static void engine_cb(Ewl_Widget *w, void *event, void *data);
|
||||
static void theme_cb(Ewl_Widget *w, void *event, void *data);
|
||||
static Config_Data *theme_data_init(void);
|
||||
static Config_Data *engine_data_init(void);
|
||||
static int theme_data_return_active(Config_Data *data);
|
||||
static int engine_data_return_active(Config_Data *data);
|
||||
static void combo_cb(Ewl_Widget *w, void *event, void *data);
|
||||
static void use_scale_cb(Ewl_Widget *w, void *event, void *data);
|
||||
static Eina_List *theme_data_init(void);
|
||||
static Eina_List *engine_data_init(void);
|
||||
static int theme_data_return_active(Eina_List *data);
|
||||
static int engine_data_return_active(Eina_List *data);
|
||||
static unsigned int model_data_count(void *data);
|
||||
static void *model_data_fetch(void *data, unsigned int row, unsigned int col);
|
||||
static char *theme_cut_suffix(const char *file);
|
||||
|
||||
static Ewl_Widget *conf_win = NULL;
|
||||
|
||||
@ -31,7 +29,8 @@ ecdb_config_dialog_show(void)
|
||||
Ewl_Widget *combo;
|
||||
Ewl_Model *model;
|
||||
Ewl_View *view;
|
||||
Config_Data *data;
|
||||
Eina_List *data;
|
||||
int use_scale;
|
||||
|
||||
/* Only show one config window */
|
||||
if (conf_win)
|
||||
@ -53,7 +52,7 @@ ecdb_config_dialog_show(void)
|
||||
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_object_fill_policy_set(EWL_OBJECT(main_box), EWL_FLAG_FILL_HSHRINKABLE);
|
||||
ewl_widget_show(main_box);
|
||||
|
||||
/* Setup and show the stock icons */
|
||||
@ -102,20 +101,35 @@ ecdb_config_dialog_show(void)
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(l), EWL_FLAG_FILL_NONE);
|
||||
ewl_widget_show(l);
|
||||
|
||||
use_scale = ecore_config_boolean_get("use_scale");
|
||||
|
||||
o = ewl_hseeker_new();
|
||||
ewl_range_minimum_value_set(EWL_RANGE(o), 0.0);
|
||||
ewl_range_maximum_value_set(EWL_RANGE(o), 2.0);
|
||||
ewl_range_step_set(EWL_RANGE(o), 0.1);
|
||||
ewl_range_step_set(EWL_RANGE(o), 0.25);
|
||||
ewl_range_value_set(EWL_RANGE(o), em->scalef);
|
||||
ewl_container_child_append(EWL_CONTAINER(border_box), o);
|
||||
ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, scale_cb, l);
|
||||
scale_cb(o, NULL, NULL);
|
||||
if (!use_scale)
|
||||
ewl_widget_disable(o);
|
||||
scale_cb(o, NULL, l);
|
||||
ewl_widget_show(o);
|
||||
|
||||
// Store this widget as we use it as a parameter later
|
||||
l = o;
|
||||
|
||||
o = ewl_checkbutton_new();
|
||||
ewl_button_label_set(EWL_BUTTON(o), "Use scaling?");
|
||||
ewl_container_child_append(EWL_CONTAINER(border_box), o);
|
||||
ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT);
|
||||
ewl_checkbutton_checked_set(EWL_CHECKBUTTON(o), use_scale);
|
||||
ewl_widget_show(o);
|
||||
ewl_callback_append(o, EWL_CALLBACK_CLICKED, use_scale_cb, l);
|
||||
|
||||
/* FPS */
|
||||
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_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);
|
||||
|
||||
@ -134,18 +148,18 @@ ecdb_config_dialog_show(void)
|
||||
o = ewl_hseeker_new();
|
||||
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), 5.0);
|
||||
ewl_range_step_set(EWL_RANGE(o), 15.0);
|
||||
ewl_range_value_set(EWL_RANGE(o), em->fps);
|
||||
ewl_container_child_append(EWL_CONTAINER(border_box), o);
|
||||
ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, fps_cb, l);
|
||||
fps_cb(o, NULL, NULL);
|
||||
fps_cb(o, NULL, l);
|
||||
ewl_widget_show(o);
|
||||
|
||||
/* Setup and show the border box */
|
||||
border_box = ewl_border_new();
|
||||
ewl_border_label_set(EWL_BORDER(border_box), "Rendering Engine");
|
||||
ewl_container_child_append(EWL_CONTAINER(main_box), border_box);
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(border_box), EWL_FLAG_FILL_FILL);
|
||||
ewl_object_fill_policy_set(EWL_OBJECT(border_box), EWL_FLAG_FILL_NORMAL);
|
||||
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);
|
||||
@ -161,6 +175,7 @@ ecdb_config_dialog_show(void)
|
||||
combo = ewl_combo_new();
|
||||
ewl_container_child_append(EWL_CONTAINER(border_box), combo);
|
||||
ewl_callback_append(combo, EWL_CALLBACK_VALUE_CHANGED, engine_cb, NULL);
|
||||
ewl_callback_append(combo, EWL_CALLBACK_DESTROY, combo_cb, data);
|
||||
ewl_mvc_model_set(EWL_MVC(combo), model);
|
||||
ewl_mvc_view_set(EWL_MVC(combo), view);
|
||||
ewl_mvc_data_set(EWL_MVC(combo), data);
|
||||
@ -182,6 +197,7 @@ ecdb_config_dialog_show(void)
|
||||
combo = ewl_combo_new();
|
||||
ewl_container_child_append(EWL_CONTAINER(border_box), combo);
|
||||
ewl_callback_append(combo, EWL_CALLBACK_VALUE_CHANGED, theme_cb, NULL);
|
||||
ewl_callback_append(combo, EWL_CALLBACK_DESTROY, combo_cb, data);
|
||||
ewl_mvc_model_set(EWL_MVC(combo), model);
|
||||
ewl_mvc_view_set(EWL_MVC(combo), view);
|
||||
ewl_mvc_data_set(EWL_MVC(combo), data);
|
||||
@ -225,95 +241,228 @@ scale_cb(Ewl_Widget *w, void *event __UNUSED__, void *data)
|
||||
|
||||
value = ewl_range_value_get(EWL_RANGE(w));
|
||||
ecore_config_float_set("scale", value);
|
||||
snprintf(buffer, 10, "%f", value);
|
||||
snprintf(buffer, 10, "%.1f", value);
|
||||
ewl_label_text_set(EWL_LABEL(data), buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
fps_cb(Ewl_Widget *w, void *event __UNUSED__, void *data)
|
||||
{
|
||||
double value;
|
||||
int value;
|
||||
char buffer[10];
|
||||
|
||||
value = ewl_range_value_get(EWL_RANGE(w));
|
||||
ecore_config_int_set("frame_rate", value);
|
||||
snprintf(buffer, 10, "%f", value);
|
||||
snprintf(buffer, 10, "%d", value);
|
||||
ewl_label_text_set(EWL_LABEL(data), buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
engine_cb(Ewl_Widget *w, void *event __UNUSED__, void *data)
|
||||
{
|
||||
Config_Data *d;
|
||||
Eina_List *l;
|
||||
Ewl_Selection_Idx *idx;
|
||||
char *eng;
|
||||
|
||||
d = ewl_mvc_data_get(EWL_MVC(w));
|
||||
l = ewl_mvc_data_get(EWL_MVC(w));
|
||||
idx = ewl_mvc_selected_get(EWL_MVC(w));
|
||||
if (!idx)
|
||||
return;
|
||||
free(em->engine);
|
||||
|
||||
ecore_config_string_set("engine", d->array[idx->row]);
|
||||
em->engine = strdup(d->array[idx->row]);
|
||||
eng = eina_list_nth(l, idx->row);
|
||||
ecore_config_string_set("engine", eng);
|
||||
em->engine = strdup(eng);
|
||||
free(idx);
|
||||
}
|
||||
|
||||
static void
|
||||
theme_cb(Ewl_Widget *w, void *event __UNUSED__, void *data)
|
||||
{
|
||||
Config_Data *d;
|
||||
Eina_List *l;
|
||||
Ewl_Selection_Idx *idx;
|
||||
char *theme;
|
||||
|
||||
d = ewl_mvc_data_get(EWL_MVC(w));
|
||||
l = ewl_mvc_data_get(EWL_MVC(w));
|
||||
idx = ewl_mvc_selected_get(EWL_MVC(w));
|
||||
if (!idx)
|
||||
return;
|
||||
free(em->theme_path);
|
||||
|
||||
ecore_config_theme_set("theme", d->array[idx->row]);
|
||||
em->theme_path = ecore_config_theme_with_path_get("theme");
|
||||
theme = eina_list_nth(l, idx->row);
|
||||
ecore_config_theme_set("theme", theme);
|
||||
em->theme_path = strdup(theme);
|
||||
free(idx);
|
||||
}
|
||||
|
||||
static Config_Data *
|
||||
static Eina_List *
|
||||
theme_data_init(void)
|
||||
{
|
||||
Config_Data *ret;
|
||||
Eina_List *ret = NULL;
|
||||
char *dirs;
|
||||
char **dirs_array;
|
||||
struct dirent *file;
|
||||
DIR *rep;
|
||||
int i = 0;
|
||||
|
||||
ret = malloc(sizeof(Config_Data));
|
||||
dirs = ecore_config_theme_search_path_get();
|
||||
dirs_array = ecore_str_split(dirs, "|", -1);
|
||||
free(dirs);
|
||||
|
||||
if (!dirs_array)
|
||||
{
|
||||
printf("No possible theme paths!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((dirs = dirs_array[i]))
|
||||
{
|
||||
rep = opendir(dirs);
|
||||
if (rep)
|
||||
{
|
||||
while ((file = readdir(rep)))
|
||||
{
|
||||
if ((strlen(file->d_name) > 4) &&
|
||||
(ecore_str_has_suffix(file->d_name, ".edj")))
|
||||
ret = eina_list_append(ret, theme_cut_suffix(file->d_name));
|
||||
}
|
||||
closedir(rep);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
free(*dirs_array);
|
||||
free(dirs_array);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
printf("No themes available!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
theme_data_return_active(Config_Data *data)
|
||||
theme_data_return_active(Eina_List *l)
|
||||
{
|
||||
return 0;
|
||||
int i;
|
||||
char *theme, *tmp_theme;
|
||||
|
||||
theme = ecore_config_theme_get("theme");
|
||||
|
||||
EINA_LIST_FOREACH(l, l, tmp_theme)
|
||||
{
|
||||
if (!strcmp(tmp_theme, theme))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
free(theme);
|
||||
return i;
|
||||
}
|
||||
|
||||
static Config_Data *
|
||||
static Eina_List *
|
||||
engine_data_init(void)
|
||||
{
|
||||
Config_Data *ret;
|
||||
Eina_List *l, *ret = NULL;
|
||||
char *eng;
|
||||
int i;
|
||||
const char *accepted_engines[] = {"software_x11", "xrender_x11",
|
||||
"opengl_x11", NULL};
|
||||
|
||||
ret = malloc(sizeof(Config_Data));
|
||||
l = ecore_evas_engines_get();
|
||||
|
||||
EINA_LIST_FOREACH(l, l, eng)
|
||||
{
|
||||
for (i = 0; accepted_engines[i]; i++)
|
||||
{
|
||||
if (!strcmp(accepted_engines[i], eng))
|
||||
{
|
||||
ret = eina_list_append(ret, strdup(eng));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ecore_evas_engines_free(l);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
engine_data_return_active(Config_Data *data)
|
||||
engine_data_return_active(Eina_List *l)
|
||||
{
|
||||
return 0;
|
||||
int i = 0;
|
||||
char *eng, *tmp_eng;
|
||||
|
||||
eng = ecore_config_string_get("engine");
|
||||
|
||||
EINA_LIST_FOREACH(l, l, tmp_eng)
|
||||
{
|
||||
if (!strcmp(tmp_eng, eng))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
free(eng);
|
||||
return i;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
model_data_count(void *data)
|
||||
{
|
||||
Config_Data *cd = data;
|
||||
return cd->count;
|
||||
Eina_List *l = data;
|
||||
return eina_list_count(l);
|
||||
}
|
||||
|
||||
static void *
|
||||
model_data_fetch(void *data, unsigned int row, unsigned int col __UNUSED__)
|
||||
{
|
||||
Config_Data *cd = data;
|
||||
return cd->array[row];
|
||||
Eina_List *l = data;
|
||||
return eina_list_nth(l, row);
|
||||
}
|
||||
|
||||
static char *
|
||||
theme_cut_suffix(const char *file)
|
||||
{
|
||||
char *new_file, *pt, *end;
|
||||
|
||||
end = strrchr(file, '.');
|
||||
|
||||
new_file = malloc(end - file + 1);
|
||||
pt = new_file;
|
||||
|
||||
while (file != end)
|
||||
*pt++ = *file++;
|
||||
|
||||
*pt = '\0';
|
||||
|
||||
return new_file;
|
||||
}
|
||||
|
||||
static void
|
||||
combo_cb(Ewl_Widget *w, void *event __UNUSED__, void *data)
|
||||
{
|
||||
char *str;
|
||||
|
||||
EINA_LIST_FREE(data, str)
|
||||
free(str);
|
||||
|
||||
eina_list_free(data);
|
||||
}
|
||||
|
||||
static void
|
||||
use_scale_cb(Ewl_Widget *w, void *event __UNUSED__, void *data)
|
||||
{
|
||||
int use_scale;
|
||||
|
||||
use_scale = ewl_checkbutton_is_checked(EWL_CHECKBUTTON(w));
|
||||
ecore_config_boolean_set("use_scale", use_scale);
|
||||
|
||||
if (use_scale)
|
||||
ewl_widget_enable(EWL_WIDGET(data));
|
||||
else
|
||||
ewl_widget_disable(EWL_WIDGET(data));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user