Browse Source

[Eve] New settings: flame flattening, text only zoom, minimum font size.

SVN revision: 52802
master
Leandro Pereira 12 years ago
parent
commit
09b8d366aa
  1. 4
      TODO
  2. 119
      src/bin/chrome.c
  3. 50
      src/bin/eve_state.c
  4. 3
      src/bin/eve_state.geneet
  5. 8
      src/bin/eve_state.h
  6. 25
      src/bin/main.c

4
TODO

@ -15,10 +15,6 @@ UI
Preferences / State
-------------------
* tweaks:
- bool: frame flattening
- bool: text only zoom
- int: font minimum (some people really need bigger fonts) maybe just allow few options such as 6, 8, 10, 12, 14, 16 and 18.
* preferences (runtime, save at eet):
- toggle: use start page (otherwise home page)
- string: proxy

119
src/bin/chrome.c

@ -15,6 +15,7 @@ typedef struct _More_Menu_Set_Params More_Menu_Set_Params;
typedef struct _More_Menu_Filter_Context More_Menu_Filter_Context;
typedef struct _More_Menu_Config More_Menu_Config;
typedef struct _More_Menu_Config_List More_Menu_Config_List;
typedef struct _More_Menu_Config_List_Int More_Menu_Config_List_Int;
typedef struct _More_Menu_Config_Spinner More_Menu_Config_Spinner;
typedef More_Menu_Item *(*More_Menu_Callback)(Browser_Window *win, More_Menu_Item *current_item);
@ -65,7 +66,8 @@ typedef enum {
CONFIG_TYPE_LIST,
CONFIG_TYPE_STRING,
CONFIG_TYPE_PASSWORD,
CONFIG_TYPE_SPINNER
CONFIG_TYPE_SPINNER,
CONFIG_TYPE_LIST_INT,
} More_Menu_Config_Type;
typedef enum {
@ -81,6 +83,9 @@ typedef enum {
EVE_CONFIG_AUTO_SHRINK_IMAGES,
EVE_CONFIG_POPUP_ALLOW,
EVE_CONFIG_RESTORE_STATE,
EVE_CONFIG_FRAME_FLATTENING,
EVE_CONFIG_TEXT_ONLY_ZOOM,
EVE_CONFIG_MINIMUM_FONT_SIZE,
EVE_CONFIG_LAST
} Eve_Config;
@ -112,6 +117,12 @@ struct _More_Menu_Config_List {
const char *value;
};
struct _More_Menu_Config_List_Int {
const char *title;
const int value;
Eina_Bool is_default : 1;
};
struct _More_Menu_Config_Spinner {
const int min;
const int max;
@ -229,6 +240,37 @@ static More_Menu_Item more_menu_config[] =
.conf_get = config_allow_popup_get,
.conf_set = config_allow_popup_set
}}, NULL, ITEM_FLAG_NONE },
{ ITEM_TYPE_CONFIG, "Frame flattening",
(More_Menu_Config[]) {{
.type = CONFIG_TYPE_CHECKBOX,
.conf = EVE_CONFIG_FRAME_FLATTENING,
.conf_get = config_frame_flattening_get,
.conf_set = config_frame_flattening_set
}}, NULL, ITEM_FLAG_NONE },
{ ITEM_TYPE_CONFIG, "Text only zoom",
(More_Menu_Config[]) {{
.type = CONFIG_TYPE_CHECKBOX,
.conf = EVE_CONFIG_TEXT_ONLY_ZOOM,
.conf_get = config_text_only_zoom_get,
.conf_set = config_text_only_zoom_set
}}, NULL, ITEM_FLAG_NONE },
{ ITEM_TYPE_CONFIG, "Minimum font size",
(More_Menu_Config[]) {{
.type = CONFIG_TYPE_LIST_INT,
.conf = EVE_CONFIG_MINIMUM_FONT_SIZE,
.conf_get = config_minimum_font_size_get,
.conf_set = config_minimum_font_size_set,
.data = (More_Menu_Config_List_Int[]) {
{ "6pt", 6, EINA_FALSE },
{ "8pt", 8, EINA_FALSE },
{ "10pt", 10, EINA_FALSE },
{ "12pt (default)", 12, EINA_TRUE },
{ "14pt", 14, EINA_FALSE },
{ "16pt", 16, EINA_FALSE },
{ "18pt", 18, EINA_FALSE },
{ NULL, 0, EINA_FALSE }
}
}}, NULL, ITEM_FLAG_ARROW },
{ ITEM_TYPE_CONFIG, "User agent",
(More_Menu_Config[]) {{
.type = CONFIG_TYPE_LIST,
@ -1081,6 +1123,9 @@ chrome_config_apply(Evas_Object *chrome)
ewk_view_setting_scripts_window_open_set(view, config_allow_popup_get(config));
view_touch_interface_set(view, config_enable_touch_interface_get(config));
window_mouse_enabled_set(win->win, config_enable_mouse_cursor_get(config));
ewk_view_zoom_text_only_set(view, config_text_only_zoom_get(config));
ewk_view_setting_enable_frame_flattening_set(view, config_frame_flattening_get(config));
ewk_view_setting_font_minimum_size_set(view, config_minimum_font_size_get(config));
}
static void
@ -1136,6 +1181,21 @@ conf_updated(More_Menu_Config *mmc, void *new_value)
SET_PREF_TO_ALL_VIEWS(ewk_view_setting_scripts_window_open_set, *((int *)new_value));
break;
}
case EVE_CONFIG_TEXT_ONLY_ZOOM:
{
SET_PREF_TO_ALL_VIEWS(ewk_view_zoom_text_only_set, *((int*)new_value));
break;
}
case EVE_CONFIG_FRAME_FLATTENING:
{
SET_PREF_TO_ALL_VIEWS(ewk_view_setting_enable_frame_flattening_set, *((int*)new_value));
break;
}
case EVE_CONFIG_MINIMUM_FONT_SIZE:
{
SET_PREF_TO_ALL_VIEWS(ewk_view_setting_font_minimum_size_set, *((int*)new_value));
break;
}
case EVE_CONFIG_TOUCH_INTERFACE:
{
SET_PREF_TO_ALL_VIEWS(view_touch_interface_set, *((int*)new_value));
@ -1380,6 +1440,29 @@ callback_menu_config_list_set(Browser_Window *win __UNUSED__, More_Menu_Item *i)
}
}
static void
callback_menu_config_list_int_set(Browser_Window *win __UNUSED__, More_Menu_Item *i)
{
More_Menu_Config *p = i->data;
More_Menu_Config_List_Int *l = p->data;
void (*conf_set)(Config *, const int);
const char *title = NULL;
int item;
for (item = 0; l[item].title; item++)
{
if (!strcmp(l[item].title, i->text))
{
if ((conf_set = p->conf_set))
{
conf_set(config, l[item].value);
conf_updated(p, (int[]){ l[item].value });
}
break;
}
}
}
static More_Menu_Item *
more_menu_config_list_create(More_Menu_Item *i, More_Menu_Config *p)
{
@ -1387,7 +1470,7 @@ more_menu_config_list_create(More_Menu_Item *i, More_Menu_Config *p)
More_Menu_Item *mmi;
const char *(*conf_get)(void *);
const char *configuration = NULL;
int item, n_items;
int n_items, item;
if (!list) return NULL;
for (n_items = 0; list[n_items].title; n_items++);
@ -1399,7 +1482,35 @@ more_menu_config_list_create(More_Menu_Item *i, More_Menu_Config *p)
mmi[item].next = callback_menu_config_list_set;
mmi[item].type = ITEM_TYPE_CALLBACK_NO_HIDE;
mmi[item].data = p;
mmi[item].flags = (configuration && !strcmp(list[item].value, configuration)) ? ITEM_FLAG_SELECTED : ITEM_FLAG_NONE;
mmi[item].flags = (configuration && !strcmp(configuration, list[item].value)) ? ITEM_FLAG_SELECTED : ITEM_FLAG_NONE;
mmi[item].flags |= ITEM_FLAG_DYNAMIC;
}
mmi[item].type = ITEM_TYPE_LAST;
return mmi;
}
static More_Menu_Item *
more_menu_config_list_int_create(More_Menu_Item *i, More_Menu_Config *p)
{
More_Menu_Config_List_Int *list = p->data;
More_Menu_Item *mmi;
int (*conf_get)(void *);
int configuration = 0;
int n_items, item;
if (!list) return NULL;
for (n_items = 0; list[n_items].title; n_items++);
if (!(mmi = calloc(n_items + 1, sizeof(*mmi)))) return NULL;
if ((conf_get = p->conf_get)) configuration = conf_get(config);
for (item = 0; item < n_items; item++) {
mmi[item].text = eina_stringshare_add(list[item].title);
mmi[item].next = callback_menu_config_list_int_set;
mmi[item].type = ITEM_TYPE_CALLBACK_NO_HIDE;
mmi[item].data = p;
mmi[item].flags = configuration == list[item].value ? ITEM_FLAG_SELECTED : ITEM_FLAG_NONE;
mmi[item].flags |= ITEM_FLAG_DYNAMIC;
}
@ -1499,6 +1610,8 @@ more_menu_config_create(Evas_Object *parent, More_Menu_Item *item, More_Menu_Con
switch (config->type) {
case CONFIG_TYPE_LIST:
return more_menu_config_list_create(item, config);
case CONFIG_TYPE_LIST_INT:
return more_menu_config_list_int_create(item, config);
case CONFIG_TYPE_STRING:
more_menu_config_string_ask(parent, item, config, EINA_FALSE);
break;

50
src/bin/eve_state.c

@ -22,6 +22,9 @@ struct _Config {
const char * proxy;
unsigned char restore_state;
const char * user_agent;
unsigned char frame_flattening;
unsigned char text_only_zoom;
int minimum_font_size;
const char *__eet_filename;
};
@ -105,6 +108,9 @@ _config_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "proxy", proxy, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "restore_state", restore_state, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "user_agent", user_agent, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "frame_flattening", frame_flattening, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "text_only_zoom", text_only_zoom, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "minimum_font_size", minimum_font_size, EET_T_INT);
}
static inline void
@ -116,7 +122,7 @@ _config_shutdown(void)
}
Config *
config_new(unsigned char allow_popup, unsigned char enable_auto_load_images, unsigned char enable_auto_shrink_images, unsigned char enable_javascript, unsigned char enable_mouse_cursor, unsigned char enable_plugins, unsigned char enable_private_mode, unsigned char enable_touch_interface, const char * home_page, const char * proxy, unsigned char restore_state, const char * user_agent)
config_new(unsigned char allow_popup, unsigned char enable_auto_load_images, unsigned char enable_auto_shrink_images, unsigned char enable_javascript, unsigned char enable_mouse_cursor, unsigned char enable_plugins, unsigned char enable_private_mode, unsigned char enable_touch_interface, const char * home_page, const char * proxy, unsigned char restore_state, const char * user_agent, unsigned char frame_flattening, unsigned char text_only_zoom, int minimum_font_size)
{
Config *config = calloc(1, sizeof(Config));
@ -138,6 +144,9 @@ config_new(unsigned char allow_popup, unsigned char enable_auto_load_images, uns
config->proxy = eina_stringshare_add(proxy);
config->restore_state = restore_state;
config->user_agent = eina_stringshare_add(user_agent ? user_agent : "eve");
config->frame_flattening = frame_flattening;
config->text_only_zoom = text_only_zoom;
config->minimum_font_size = minimum_font_size;
return config;
}
@ -307,6 +316,45 @@ config_user_agent_set(Config *config, const char *user_agent)
eina_stringshare_replace(&(config->user_agent), user_agent);
}
inline unsigned char
config_frame_flattening_get(const Config *config)
{
return config->frame_flattening;
}
inline void
config_frame_flattening_set(Config *config, unsigned char frame_flattening)
{
EINA_SAFETY_ON_NULL_RETURN(config);
config->frame_flattening = frame_flattening;
}
inline unsigned char
config_text_only_zoom_get(const Config *config)
{
return config->text_only_zoom;
}
inline void
config_text_only_zoom_set(Config *config, unsigned char text_only_zoom)
{
EINA_SAFETY_ON_NULL_RETURN(config);
config->text_only_zoom = text_only_zoom;
}
inline int
config_minimum_font_size_get(const Config *config)
{
return config->minimum_font_size;
}
inline void
config_minimum_font_size_set(Config *config, int minimum_font_size)
{
EINA_SAFETY_ON_NULL_RETURN(config);
config->minimum_font_size = minimum_font_size;
}
Config *
config_load(const char *filename)
{

3
src/bin/eve_state.geneet

@ -11,6 +11,9 @@ Config {
proxy : str;
restore_state : uchar;
user_agent : str default "eve";
frame_flattening : uchar;
text_only_zoom : uchar;
minimum_font_size : int;
}
Hist_Item {

8
src/bin/eve_state.h

@ -17,7 +17,7 @@ typedef struct _Session_Window Session_Window;
typedef struct _Session Session;
/* Config */
Config *config_new(unsigned char allow_popup, unsigned char enable_auto_load_images, unsigned char enable_auto_shrink_images, unsigned char enable_javascript, unsigned char enable_mouse_cursor, unsigned char enable_plugins, unsigned char enable_private_mode, unsigned char enable_touch_interface, const char * home_page, const char * proxy, unsigned char restore_state, const char * user_agent);
Config *config_new(unsigned char allow_popup, unsigned char enable_auto_load_images, unsigned char enable_auto_shrink_images, unsigned char enable_javascript, unsigned char enable_mouse_cursor, unsigned char enable_plugins, unsigned char enable_private_mode, unsigned char enable_touch_interface, const char * home_page, const char * proxy, unsigned char restore_state, const char * user_agent, unsigned char frame_flattening, unsigned char text_only_zoom, int minimum_font_size);
void config_free(Config *config);
void config_allow_popup_set(Config *config, unsigned char allow_popup);
@ -44,6 +44,12 @@ void config_restore_state_set(Config *config, unsigned char restore_state);
unsigned char config_restore_state_get(const Config *config);
void config_user_agent_set(Config *config, const char * user_agent);
const char * config_user_agent_get(const Config *config);
void config_frame_flattening_set(Config *config, unsigned char frame_flattening);
unsigned char config_frame_flattening_get(const Config *config);
void config_text_only_zoom_set(Config *config, unsigned char text_only_zoom);
unsigned char config_text_only_zoom_get(const Config *config);
void config_minimum_font_size_set(Config *config, int minimum_font_size);
int config_minimum_font_size_get(const Config *config);
Config *config_load(const char *filename);
Eina_Bool config_save(Config *config, const char *filename);

25
src/bin/main.c

@ -715,17 +715,20 @@ elm_main(int argc, char **argv)
#undef BOOL_OPT
config = config_new(EINA_TRUE /* allow_popup */,
EINA_TRUE /* enable_auto_load_images */,
EINA_TRUE /* enable_auto_shrink_images */,
EINA_TRUE /* enable_javascript */,
enable_mouse_cursor,
enable_plugins,
EINA_FALSE /* enable_private_mode */,
enable_touch_interface,
DEFAULT_URL /* home_page */,
NULL /* proxy */,
EINA_FALSE /* restore_state */,
user_agent_str);
EINA_TRUE /* enable_auto_load_images */,
EINA_TRUE /* enable_auto_shrink_images */,
EINA_TRUE /* enable_javascript */,
enable_mouse_cursor,
enable_plugins,
EINA_FALSE /* enable_private_mode */,
enable_touch_interface,
DEFAULT_URL /* home_page */,
NULL /* proxy */,
EINA_FALSE /* restore_state */,
user_agent_str,
EINA_FALSE /* frame_flattening */,
EINA_FALSE /* text_only_zoom */,
12 /* minimum_font_size */);
if (!config_save(config, path))
{
r = -1;

Loading…
Cancel
Save