diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index ee79b01..7f883c1 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -16,7 +16,7 @@ bin_PROGRAMS += eve_ql endif eve_LDADD = @ELEMENTARY_LIBS@ @EWEBKIT_LIBS@ @EDBUS_LIBS@ -eve_SOURCES = main.c view.c chrome.c favorite.c history.c prefs.c +eve_SOURCES = main.c view.c chrome.c eve_state.c if BUILD_QUICKLAUNCH ############################################################################ @@ -27,7 +27,7 @@ if BUILD_QUICKLAUNCH ############################################################################ eve_qldir = $(quicklauncher_libdir) eve_ql_LTLIBRARIES = eve_ql.la -eve_ql_la_SOURCES = main.c view.c chrome.c +eve_ql_la_SOURCES = main.c view.c chrome.c eve_state.h eve_ql_la_LIBADD = @ELEMENTARY_LIBS@ @EWEBKIT_LIBS@ @EDBUS_LIBS@ eve_ql_la_CFLAGS = eve_ql_la_LDFLAGS = -module -avoid-version -no-undefined @@ -37,5 +37,5 @@ eve_ql_CFLAGS = -DELM_LIB_QUICKLAUNCH=1 eve_ql_LDFLAGS = endif -noinst_HEADERS = gettext.h private.h favorite.h history.h prefs.h -EXTRA_DIST = gettext.h private.h favorite.h history.h prefs.h +noinst_HEADERS = gettext.h private.h eve_state.h +EXTRA_DIST = gettext.h private.h eve_state.h diff --git a/src/bin/chrome.c b/src/bin/chrome.c index 84be3c2..a8a9481 100644 --- a/src/bin/chrome.c +++ b/src/bin/chrome.c @@ -13,9 +13,9 @@ typedef struct _More_Menu_Item More_Menu_Item; typedef struct _More_Menu_Set_Params More_Menu_Set_Params; typedef struct _More_Menu_Filter_Context More_Menu_Filter_Context; -typedef struct _More_Menu_Preference More_Menu_Preference; -typedef struct _More_Menu_Preference_List More_Menu_Preference_List; -typedef struct _More_Menu_Preference_Spinner More_Menu_Preference_Spinner; +typedef struct _More_Menu_Config More_Menu_Config; +typedef struct _More_Menu_Config_List More_Menu_Config_List; +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); @@ -45,7 +45,7 @@ typedef enum { ITEM_TYPE_CALLBACK, ITEM_TYPE_CALLBACK_NO_HIDE, ITEM_TYPE_SEPARATOR, - ITEM_TYPE_PREFERENCE + ITEM_TYPE_CONFIG } More_Menu_Item_Type; typedef enum { @@ -56,28 +56,28 @@ typedef enum { } More_Menu_Item_Flags; typedef enum { - PREF_TYPE_CHECKBOX, - PREF_TYPE_LIST, - PREF_TYPE_STRING, - PREF_TYPE_PASSWORD, - PREF_TYPE_SPINNER -} More_Menu_Preference_Type; + CONFIG_TYPE_CHECKBOX, + CONFIG_TYPE_LIST, + CONFIG_TYPE_STRING, + CONFIG_TYPE_PASSWORD, + CONFIG_TYPE_SPINNER +} More_Menu_Config_Type; typedef enum { - EVE_PREF_ENABLE_JAVASCRIPT, - EVE_PREF_ENABLE_PLUGINS, - EVE_PREF_HOME_PAGE, - EVE_PREF_PROXY, - EVE_PREF_USER_AGENT, - EVE_PREF_TOUCH_INTERFACE, - EVE_PREF_MOUSE_CURSOR, - EVE_PREF_ENABLE_PRIVATE_MODE, - EVE_PREF_AUTO_LOAD_IMAGES, - EVE_PREF_AUTO_SHRINK_IMAGES, - EVE_PREF_POPUP_ALLOW, - EVE_PREF_RESTORE_STATE, - EVE_PREF_LAST -} Eve_Preference; + EVE_CONFIG_ENABLE_JAVASCRIPT, + EVE_CONFIG_ENABLE_PLUGINS, + EVE_CONFIG_HOME_PAGE, + EVE_CONFIG_PROXY, + EVE_CONFIG_USER_AGENT, + EVE_CONFIG_TOUCH_INTERFACE, + EVE_CONFIG_MOUSE_CURSOR, + EVE_CONFIG_ENABLE_PRIVATE_MODE, + EVE_CONFIG_AUTO_LOAD_IMAGES, + EVE_CONFIG_AUTO_SHRINK_IMAGES, + EVE_CONFIG_POPUP_ALLOW, + EVE_CONFIG_RESTORE_STATE, + EVE_CONFIG_LAST +} Eve_Config; struct _More_Menu_Item { @@ -94,20 +94,20 @@ struct _More_Menu_Filter_Context double time; }; -struct _More_Menu_Preference { - More_Menu_Preference_Type type; - Eve_Preference pref; - void *pref_get; - void *pref_set; +struct _More_Menu_Config { + More_Menu_Config_Type type; + Eve_Config conf; + void *conf_get; + void *conf_set; void *data; }; -struct _More_Menu_Preference_List { +struct _More_Menu_Config_List { const char *title; const char *value; }; -struct _More_Menu_Preference_Spinner { +struct _More_Menu_Config_Spinner { const int min; const int max; const char *format; @@ -133,47 +133,47 @@ static More_Menu_Item more_menu_history[] = { ITEM_TYPE_LAST, NULL, NULL, NULL, ITEM_FLAG_NONE } }; -static More_Menu_Item more_menu_preferences[] = +static More_Menu_Item more_menu_config[] = { - { ITEM_TYPE_PREFERENCE, "Enable JavaScript", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_ENABLE_JAVASCRIPT, - .pref_get = prefs_enable_javascript_get, - .pref_set = prefs_enable_javascript_set, + { ITEM_TYPE_CONFIG, "Enable JavaScript", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_ENABLE_JAVASCRIPT, + .conf_get = config_enable_javascript_get, + .conf_set = config_enable_javascript_set, }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Enable plugins", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_ENABLE_PLUGINS, - .pref_get = prefs_enable_plugins_get, - .pref_set = prefs_enable_plugins_set, + { ITEM_TYPE_CONFIG, "Enable plugins", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_ENABLE_PLUGINS, + .conf_get = config_enable_plugins_get, + .conf_set = config_enable_plugins_set, }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Private mode", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_ENABLE_PRIVATE_MODE, - .pref_get = prefs_enable_private_mode_get, - .pref_set = prefs_enable_private_mode_set, + { ITEM_TYPE_CONFIG, "Private mode", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_ENABLE_PRIVATE_MODE, + .conf_get = config_enable_private_mode_get, + .conf_set = config_enable_private_mode_set, }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Save and restore session", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_RESTORE_STATE, - .pref_get = prefs_restore_state_get, - .pref_set = prefs_restore_state_set, + { ITEM_TYPE_CONFIG, "Save and restore session", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_RESTORE_STATE, + .conf_get = config_restore_state_get, + .conf_set = config_restore_state_set, }}, NULL, ITEM_FLAG_NONE }, { ITEM_TYPE_SEPARATOR, NULL, NULL, NULL, ITEM_FLAG_NONE }, { ITEM_TYPE_STATIC_FOLDER, "Home page", (More_Menu_Item[]) { { ITEM_TYPE_CALLBACK_NO_HIDE, "Set to current page", more_menu_home_page_current_set, NULL, ITEM_FLAG_NONE }, { ITEM_TYPE_CALLBACK_NO_HIDE, "Set to default", more_menu_home_page_default_set, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Set to an URL", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_STRING, - .pref = EVE_PREF_HOME_PAGE, - .pref_get = prefs_home_page_get, - .pref_set = prefs_home_page_set, + { ITEM_TYPE_CONFIG, "Set to an URL", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_STRING, + .conf = EVE_CONFIG_HOME_PAGE, + .conf_get = config_home_page_get, + .conf_set = config_home_page_set, }}, NULL, ITEM_FLAG_ARROW }, { ITEM_TYPE_LAST, NULL, NULL, NULL, ITEM_FLAG_NONE }, }, NULL, ITEM_FLAG_ARROW }, @@ -189,48 +189,48 @@ static More_Menu_Item more_menu_preferences[] = }, NULL, ITEM_FLAG_ARROW }, { ITEM_TYPE_STATIC_FOLDER, "Tweaks", (More_Menu_Item[]) { - { ITEM_TYPE_PREFERENCE, "Enable mouse cursor", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_MOUSE_CURSOR, - .pref_get = prefs_enable_mouse_cursor_get, - .pref_set = prefs_enable_mouse_cursor_set + { ITEM_TYPE_CONFIG, "Enable mouse cursor", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_MOUSE_CURSOR, + .conf_get = config_enable_mouse_cursor_get, + .conf_set = config_enable_mouse_cursor_set }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Enable touch interface", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_TOUCH_INTERFACE, - .pref_get = prefs_enable_touch_interface_get, - .pref_set = prefs_enable_touch_interface_set + { ITEM_TYPE_CONFIG, "Enable touch interface", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_TOUCH_INTERFACE, + .conf_get = config_enable_touch_interface_get, + .conf_set = config_enable_touch_interface_set }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Automatically load images", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_AUTO_LOAD_IMAGES, - .pref_get = prefs_enable_auto_load_images_get, - .pref_set = prefs_enable_auto_load_images_set + { ITEM_TYPE_CONFIG, "Automatically load images", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_AUTO_LOAD_IMAGES, + .conf_get = config_enable_auto_load_images_get, + .conf_set = config_enable_auto_load_images_set }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Automatically shrink images", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_AUTO_SHRINK_IMAGES, - .pref_get = prefs_enable_auto_shrink_images_get, - .pref_set = prefs_enable_auto_shrink_images_set + { ITEM_TYPE_CONFIG, "Automatically shrink images", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_AUTO_SHRINK_IMAGES, + .conf_get = config_enable_auto_shrink_images_get, + .conf_set = config_enable_auto_shrink_images_set }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "Allow popup windows", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_CHECKBOX, - .pref = EVE_PREF_POPUP_ALLOW, - .pref_get = prefs_allow_popup_get, - .pref_set = prefs_allow_popup_set + { ITEM_TYPE_CONFIG, "Allow popup windows", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_CHECKBOX, + .conf = EVE_CONFIG_POPUP_ALLOW, + .conf_get = config_allow_popup_get, + .conf_set = config_allow_popup_set }}, NULL, ITEM_FLAG_NONE }, - { ITEM_TYPE_PREFERENCE, "User agent", - (More_Menu_Preference[]) {{ - .type = PREF_TYPE_LIST, - .pref = EVE_PREF_USER_AGENT, - .pref_get = prefs_user_agent_get, - .pref_set = prefs_user_agent_set, - .data = (More_Menu_Preference_List[]) { + { ITEM_TYPE_CONFIG, "User agent", + (More_Menu_Config[]) {{ + .type = CONFIG_TYPE_LIST, + .conf = EVE_CONFIG_USER_AGENT, + .conf_get = config_user_agent_get, + .conf_set = config_user_agent_set, + .data = (More_Menu_Config_List[]) { { "Eve", "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 " PACKAGE_NAME "/" PACKAGE_VERSION }, { "iPhone", "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3" }, { "Safari", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8" }, @@ -250,7 +250,7 @@ static More_Menu_Item more_menu_root[] = { { ITEM_TYPE_STATIC_FOLDER, "History", more_menu_history, NULL, ITEM_FLAG_ARROW }, { ITEM_TYPE_DYNAMIC_FOLDER, "Favorites", more_menu_favorites, NULL, ITEM_FLAG_ARROW }, - { ITEM_TYPE_STATIC_FOLDER, "Preferences", more_menu_preferences, NULL, ITEM_FLAG_ARROW }, + { ITEM_TYPE_STATIC_FOLDER, "Preferences", more_menu_config, NULL, ITEM_FLAG_ARROW }, { ITEM_TYPE_SEPARATOR, NULL, NULL, NULL, ITEM_FLAG_NONE }, { ITEM_TYPE_PAGE, "ProFUSION", "http://profusion.mobi", NULL, ITEM_FLAG_NONE }, { ITEM_TYPE_PAGE, "WebKit", "http://webkit.org", NULL, ITEM_FLAG_NONE }, @@ -674,7 +674,7 @@ _history_update(const char *url, const char *title) { Hist_Item *item; - if (!url || prefs_enable_private_mode_get(prefs)) + if (!url || config_enable_private_mode_get(config)) return; if ((item = hist_items_get(hist, url))) @@ -861,14 +861,14 @@ on_view_popup_delete(void *data, Evas_Object *view, void *event_info) static More_Menu_Item * more_menu_home_page_current_set(Browser_Window *win, More_Menu_Item *mmi __UNUSED__) { - prefs_home_page_set(prefs, ewk_view_uri_get(win->current_view)); + config_home_page_set(config, ewk_view_uri_get(win->current_view)); return NULL; } static More_Menu_Item * more_menu_home_page_default_set(Browser_Window *win __UNUSED__, More_Menu_Item *mmi __UNUSED__) { - prefs_home_page_set(prefs, DEFAULT_URL); + config_home_page_set(config, DEFAULT_URL); return NULL; } @@ -1020,81 +1020,81 @@ on_action_forward(void *data, Evas_Object *o __UNUSED__, } void -chrome_prefs_apply(Evas_Object *chrome) +chrome_config_apply(Evas_Object *chrome) { Evas_Object *view = evas_object_data_get(chrome, "view"); Browser_Window *win = evas_object_data_get(chrome, "win"); - ewk_view_setting_enable_scripts_set(view, prefs_enable_javascript_get(prefs)); - ewk_view_setting_enable_plugins_set(view, prefs_enable_plugins_get(prefs)); - ewk_view_setting_user_agent_set(view, prefs_user_agent_get(prefs)); - ewk_view_setting_private_browsing_set(view, prefs_enable_private_mode_get(prefs)); - ewk_view_setting_auto_load_images_set(view, prefs_enable_auto_load_images_get(prefs)); - ewk_view_setting_auto_shrink_images_set(view, prefs_enable_auto_shrink_images_get(prefs)); - ewk_view_setting_scripts_window_open_set(view, prefs_allow_popup_get(prefs)); - view_touch_interface_set(view, prefs_enable_touch_interface_get(prefs)); - window_mouse_enabled_set(win->win, prefs_enable_mouse_cursor_get(prefs)); + ewk_view_setting_enable_scripts_set(view, config_enable_javascript_get(config)); + ewk_view_setting_enable_plugins_set(view, config_enable_plugins_get(config)); + ewk_view_setting_user_agent_set(view, config_user_agent_get(config)); + ewk_view_setting_private_browsing_set(view, config_enable_private_mode_get(config)); + ewk_view_setting_auto_load_images_set(view, config_enable_auto_load_images_get(config)); + ewk_view_setting_auto_shrink_images_set(view, config_enable_auto_shrink_images_get(config)); + 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)); } static void -pref_updated(More_Menu_Preference *p, void *new_value) +conf_updated(More_Menu_Config *mmc, void *new_value) { Evas_Object *chrome, *view; Browser_Window *win; Eina_List *win_iter, *chrome_iter; -#define SET_PREF_TO_ALL_VIEWS(fn,newvalue) \ - EINA_LIST_FOREACH(app.windows, win_iter, win) \ - { \ +#define SET_PREF_TO_ALL_VIEWS(fn,newvalue) \ + EINA_LIST_FOREACH(app.windows, win_iter, win) \ + { \ EINA_LIST_FOREACH(win->chromes, chrome_iter, chrome) \ - { \ - view = evas_object_data_get(chrome, "view"); \ - fn(view, newvalue); \ - } \ + { \ + view = evas_object_data_get(chrome, "view"); \ + fn(view, newvalue); \ + } \ } - switch (p->pref) { - case EVE_PREF_ENABLE_JAVASCRIPT: + switch (mmc->conf) { + case EVE_CONFIG_ENABLE_JAVASCRIPT: { SET_PREF_TO_ALL_VIEWS(ewk_view_setting_enable_scripts_set, *((int *)new_value)); break; } - case EVE_PREF_ENABLE_PLUGINS: + case EVE_CONFIG_ENABLE_PLUGINS: { SET_PREF_TO_ALL_VIEWS(ewk_view_setting_enable_plugins_set, *((int *)new_value)); break; } - case EVE_PREF_USER_AGENT: + case EVE_CONFIG_USER_AGENT: { SET_PREF_TO_ALL_VIEWS(ewk_view_setting_user_agent_set, new_value); break; } - case EVE_PREF_ENABLE_PRIVATE_MODE: + case EVE_CONFIG_ENABLE_PRIVATE_MODE: { SET_PREF_TO_ALL_VIEWS(ewk_view_setting_private_browsing_set, *((int *)new_value)); break; } - case EVE_PREF_AUTO_LOAD_IMAGES: + case EVE_CONFIG_AUTO_LOAD_IMAGES: { SET_PREF_TO_ALL_VIEWS(ewk_view_setting_auto_load_images_set, *((int *)new_value)); break; } - case EVE_PREF_AUTO_SHRINK_IMAGES: + case EVE_CONFIG_AUTO_SHRINK_IMAGES: { SET_PREF_TO_ALL_VIEWS(ewk_view_setting_auto_shrink_images_set, *((int *)new_value)); break; } - case EVE_PREF_POPUP_ALLOW: + case EVE_CONFIG_POPUP_ALLOW: { SET_PREF_TO_ALL_VIEWS(ewk_view_setting_scripts_window_open_set, *((int *)new_value)); break; } - case EVE_PREF_TOUCH_INTERFACE: + case EVE_CONFIG_TOUCH_INTERFACE: { SET_PREF_TO_ALL_VIEWS(view_touch_interface_set, *((int*)new_value)); break; } - case EVE_PREF_MOUSE_CURSOR: + case EVE_CONFIG_MOUSE_CURSOR: { EINA_LIST_FOREACH(app.windows, win_iter, win) { @@ -1108,72 +1108,72 @@ pref_updated(More_Menu_Preference *p, void *new_value) } static void -cb_pref_bool_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__) +cb_config_bool_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__) { - More_Menu_Preference *pref = data; - void (*pref_set)(Prefs *, Eina_Bool); + More_Menu_Config *mmc = data; + void (*conf_set)(Config *, Eina_Bool); - if ((pref_set = pref->pref_set)) + if ((conf_set = mmc->conf_set)) { - pref_set(prefs, elm_toggle_state_get(obj)); - pref_updated(pref, (int[]){ elm_toggle_state_get(obj) }); + conf_set(config, elm_toggle_state_get(obj)); + conf_updated(mmc, (int[]){ elm_toggle_state_get(obj) }); } } static void -cb_pref_int_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__) +cb_config_int_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__) { - More_Menu_Preference *pref = data; - void (*pref_set)(Prefs *, int); + More_Menu_Config *mmc = data; + void (*conf_set)(Config *, int); - if ((pref_set = pref->pref_set)) + if ((conf_set = mmc->conf_set)) { - pref_set(prefs, elm_spinner_value_get(obj)); - pref_updated(pref, (int[]){ elm_spinner_value_get(obj) }); + conf_set(config, elm_spinner_value_get(obj)); + conf_updated(mmc, (int[]){ elm_spinner_value_get(obj) }); } } static void -cb_pref_string_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__) +cb_config_string_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__) { - More_Menu_Preference *pref = data; - void (*pref_set)(Prefs *, const char *); + More_Menu_Config *mmc = data; + void (*conf_set)(Config *, const char *); - if ((pref_set = pref->pref_set)) + if ((conf_set = mmc->conf_set)) { - pref_set(prefs, elm_scrolled_entry_entry_get(obj)); - pref_updated(pref, (void *)elm_scrolled_entry_entry_get(obj)); + conf_set(config, elm_scrolled_entry_entry_get(obj)); + conf_updated(mmc, (void *)elm_scrolled_entry_entry_get(obj)); } } static Evas_Object * -pref_widget_get(Evas_Object *parent, More_Menu_Preference *pref) +config_widget_get(Evas_Object *parent, More_Menu_Config *mmc) { - if (!pref->pref_get) return NULL; + if (!mmc->conf_get) return NULL; - switch (pref->type) { - case PREF_TYPE_CHECKBOX: + switch (mmc->type) { + case CONFIG_TYPE_CHECKBOX: { - Eina_Bool (*pref_get)(Prefs *); + Eina_Bool (*conf_get)(Config *); Evas_Object *toggle = elm_toggle_add(parent); - pref_get = pref->pref_get; - elm_toggle_state_set(toggle, pref_get(prefs)); - evas_object_smart_callback_add(toggle, "changed", cb_pref_bool_changed, pref); + conf_get = mmc->conf_get; + elm_toggle_state_set(toggle, conf_get(config)); + evas_object_smart_callback_add(toggle, "changed", cb_config_bool_changed, mmc); return toggle; } - case PREF_TYPE_SPINNER: + case CONFIG_TYPE_SPINNER: { - int (*pref_get)(Prefs *); + int (*conf_get)(Config *); Evas_Object *spinner = elm_spinner_add(parent); - More_Menu_Preference_Spinner *spinner_params = pref->data; + More_Menu_Config_Spinner *spinner_params = mmc->data; - pref_get = pref->pref_get; + conf_get = mmc->conf_get; elm_spinner_min_max_set(spinner, spinner_params->min, spinner_params->max); if (spinner_params->format) elm_spinner_label_format_set(spinner, spinner_params->format); - elm_spinner_value_set(spinner, pref_get(prefs)); - evas_object_smart_callback_add(spinner, "changed", cb_pref_int_changed, pref); + elm_spinner_value_set(spinner, conf_get(config)); + evas_object_smart_callback_add(spinner, "changed", cb_config_int_changed, mmc); return spinner; } @@ -1218,8 +1218,8 @@ on_list_completely_hidden(void *data, Evas_Object *ed, const char *emission __UN elm_list_item_separator_set(item, EINA_TRUE); break; } - case ITEM_TYPE_PREFERENCE: - end = pref_widget_get(params->list, params->root[i].next); + case ITEM_TYPE_CONFIG: + end = config_widget_get(params->list, params->root[i].next); /* fallthrough */ default: if (!icon && params->root[i].flags & ITEM_FLAG_SELECTED) @@ -1301,11 +1301,11 @@ on_more_item_back_click(void *data, Evas_Object *edje, } static void -callback_menu_prefs_list_set(Browser_Window *win __UNUSED__, More_Menu_Item *i) +callback_menu_config_list_set(Browser_Window *win __UNUSED__, More_Menu_Item *i) { - More_Menu_Preference *p = i->data; - More_Menu_Preference_List *l = p->data; - void (*pref_set)(Prefs *, const char *); + More_Menu_Config *p = i->data; + More_Menu_Config_List *l = p->data; + void (*conf_set)(Config *, const char *); const char *title = NULL; int item; @@ -1313,10 +1313,10 @@ callback_menu_prefs_list_set(Browser_Window *win __UNUSED__, More_Menu_Item *i) { if (!strcmp(l[item].title, i->text)) { - if ((pref_set = p->pref_set)) + if ((conf_set = p->conf_set)) { - pref_set(prefs, l[item].value); - pref_updated(p, (void *)l[item].value); + conf_set(config, l[item].value); + conf_updated(p, (void *)l[item].value); } break; } @@ -1324,25 +1324,25 @@ callback_menu_prefs_list_set(Browser_Window *win __UNUSED__, More_Menu_Item *i) } static More_Menu_Item * -more_menu_prefs_list_create(More_Menu_Item *i, More_Menu_Preference *p) +more_menu_config_list_create(More_Menu_Item *i, More_Menu_Config *p) { - More_Menu_Preference_List *list = p->data; + More_Menu_Config_List *list = p->data; More_Menu_Item *mmi; - const char *(*pref_get)(void *); - const char *preference = NULL; + const char *(*conf_get)(void *); + const char *configuration = NULL; int item, n_items; 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 ((pref_get = p->pref_get)) preference = pref_get(prefs); + 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_prefs_list_set; + mmi[item].next = callback_menu_config_list_set; mmi[item].type = ITEM_TYPE_CALLBACK_NO_HIDE; mmi[item].data = p; - mmi[item].flags = (preference && !strcmp(list[item].value, preference)) ? ITEM_FLAG_SELECTED : ITEM_FLAG_NONE; + mmi[item].flags = (configuration && !strcmp(list[item].value, configuration)) ? ITEM_FLAG_SELECTED : ITEM_FLAG_NONE; mmi[item].flags |= ITEM_FLAG_DYNAMIC; } @@ -1368,17 +1368,17 @@ on_string_ask_cancel_click(void *data, Evas_Object *obj, void *event_info) } static void -more_menu_prefs_string_ask(Evas_Object *parent, More_Menu_Item *item, More_Menu_Preference *pref, Eina_Bool password) +more_menu_config_string_ask(Evas_Object *parent, More_Menu_Item *item, More_Menu_Config *mmc, Eina_Bool password) { Eina_Bool response = EINA_FALSE; Evas_Object *bx_h, *bx_v, *lb; Evas_Object *bt_cancel, *bt_ok; Evas_Object *notify; Evas_Object *entry; - const char *(*pref_get)(Prefs *); - void (*pref_set)(Prefs *, const char *); + const char *(*conf_get)(Config *); + void (*conf_set)(Config *, const char *); - if (!(pref_get = pref->pref_get) || !(pref_set = pref->pref_set)) return; + if (!(conf_get = mmc->conf_get) || !(conf_set = mmc->conf_set)) return; notify = elm_notify_add(parent); elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_CENTER); @@ -1399,7 +1399,7 @@ more_menu_prefs_string_ask(Evas_Object *parent, More_Menu_Item *item, More_Menu_ entry = elm_entry_add(bx_v); elm_entry_password_set(entry, password); elm_entry_single_line_set(entry, EINA_TRUE); - elm_entry_entry_set(entry, pref_get(prefs)); + elm_entry_entry_set(entry, conf_get(config)); elm_box_pack_end(bx_v, entry); evas_object_show(entry); @@ -1431,22 +1431,22 @@ more_menu_prefs_string_ask(Evas_Object *parent, More_Menu_Item *item, More_Menu_ evas_object_hide(notify); if (response == EINA_TRUE) - pref_set(prefs, elm_entry_entry_get(entry)); + conf_set(config, elm_entry_entry_get(entry)); evas_object_del(notify); } static More_Menu_Item * -more_menu_prefs_create(Evas_Object *parent, More_Menu_Item *item, More_Menu_Preference *pref) +more_menu_config_create(Evas_Object *parent, More_Menu_Item *item, More_Menu_Config *config) { - switch (pref->type) { - case PREF_TYPE_LIST: - return more_menu_prefs_list_create(item, pref); - case PREF_TYPE_STRING: - more_menu_prefs_string_ask(parent, item, pref, EINA_FALSE); + switch (config->type) { + case CONFIG_TYPE_LIST: + return more_menu_config_list_create(item, config); + case CONFIG_TYPE_STRING: + more_menu_config_string_ask(parent, item, config, EINA_FALSE); break; - case PREF_TYPE_PASSWORD: - more_menu_prefs_string_ask(parent, item, pref, EINA_TRUE); + case CONFIG_TYPE_PASSWORD: + more_menu_config_string_ask(parent, item, config, EINA_TRUE); break; } @@ -1455,7 +1455,7 @@ more_menu_prefs_create(Evas_Object *parent, More_Menu_Item *item, More_Menu_Pref static void on_more_item_click(void *data, Evas_Object *obj, - void *event_info __UNUSED__) + void *event_info __UNUSED__) { Evas_Object *chrome = evas_object_data_get(obj, "chrome"); Evas_Object *ed = elm_layout_edje_get(chrome); @@ -1489,12 +1489,12 @@ on_more_item_click(void *data, Evas_Object *obj, break; } - case ITEM_TYPE_PREFERENCE: + case ITEM_TYPE_CONFIG: { if (!mmi->next) return; - More_Menu_Item *new_root = more_menu_prefs_create(win->win, mmi, mmi->next); + More_Menu_Item *new_root = more_menu_config_create(win->win, mmi, mmi->next); if (new_root) { win->list_history_titles = eina_list_prepend(win->list_history_titles, old_text); @@ -1615,7 +1615,7 @@ on_action_addtab(void *data, Evas_Object *o __UNUSED__, Evas_Object *ed = elm_layout_edje_get(chrome); edje_object_signal_emit(ed, "tab,item,clicked", ""); - tab_add(win, prefs_home_page_get(prefs)); + tab_add(win, config_home_page_get(config)); } static void @@ -1699,7 +1699,7 @@ on_action_home(void *data, Evas_Object *o __UNUSED__, { Evas_Object *view = data; - ewk_view_uri_set(view, prefs_home_page_get(prefs)); + ewk_view_uri_set(view, config_home_page_get(config)); } static void @@ -1997,7 +1997,7 @@ chrome_add(Browser_Window *win, const char *url) _chrome_state_apply(chrome, view); elm_pager_content_push(win->pager, chrome); - chrome_prefs_apply(chrome); + chrome_config_apply(chrome); return chrome; error_view_create: diff --git a/src/bin/eve_state.c b/src/bin/eve_state.c new file mode 100644 index 0000000..f92d567 --- /dev/null +++ b/src/bin/eve_state.c @@ -0,0 +1,1179 @@ +/* This file has been automatically generated by geneet.py */ +/* DO NOT MODIFY */ + +#include +#include +#include +#include +#include + +#include "eve_state.h" + +struct _Config { + 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; + const char *__eet_filename; +}; + +struct _Hist_Item { + const char * title; + const char * url; + unsigned int visit_count; + double last_visit; +}; + +struct _Hist { + Eina_Hash * items; + const char *__eet_filename; +}; + +struct _Fav_Item { + const char * url; + const char * title; + unsigned int visit_count; +}; + +struct _Fav { + Eina_Hash * items; + const char *__eet_filename; +}; + +struct _Session_Item { + const char * url; + unsigned char focused; + double scroll_x; + double scroll_y; +}; + +struct _Session_Window { + Eina_List * tabs; + unsigned char focused; +}; + +struct _Session { + Eina_List * windows; + const char *__eet_filename; +}; + +static const char CONFIG_ENTRY[] = "config"; +static const char HIST_ITEM_ENTRY[] = "hist_item"; +static const char HIST_ENTRY[] = "hist"; +static const char FAV_ITEM_ENTRY[] = "fav_item"; +static const char FAV_ENTRY[] = "fav"; +static const char SESSION_ITEM_ENTRY[] = "session_item"; +static const char SESSION_WINDOW_ENTRY[] = "session_window"; +static const char SESSION_ENTRY[] = "session"; + +static Eet_Data_Descriptor *_config_descriptor = NULL; +static Eet_Data_Descriptor *_hist_item_descriptor = NULL; +static Eet_Data_Descriptor *_hist_descriptor = NULL; +static Eet_Data_Descriptor *_fav_item_descriptor = NULL; +static Eet_Data_Descriptor *_fav_descriptor = NULL; +static Eet_Data_Descriptor *_session_item_descriptor = NULL; +static Eet_Data_Descriptor *_session_window_descriptor = NULL; +static Eet_Data_Descriptor *_session_descriptor = NULL; + +static inline void +_config_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_config_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Config); + _config_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "allow_popup", allow_popup, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_auto_load_images", enable_auto_load_images, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_auto_shrink_images", enable_auto_shrink_images, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_javascript", enable_javascript, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_mouse_cursor", enable_mouse_cursor, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_plugins", enable_plugins, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_private_mode", enable_private_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "enable_touch_interface", enable_touch_interface, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_config_descriptor, Config, "home_page", home_page, EET_T_STRING); + 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); +} + +static inline void +_config_shutdown(void) +{ + if (!_config_descriptor) return; + eet_data_descriptor_free(_config_descriptor); + _config_descriptor = NULL; +} + +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 = calloc(1, sizeof(Config)); + + if (!config) + { + fprintf(stderr, "ERROR: could not calloc Config\n"); + return NULL; + } + + config->allow_popup = allow_popup; + config->enable_auto_load_images = enable_auto_load_images; + config->enable_auto_shrink_images = enable_auto_shrink_images; + config->enable_javascript = enable_javascript; + config->enable_mouse_cursor = enable_mouse_cursor; + config->enable_plugins = enable_plugins; + config->enable_private_mode = enable_private_mode; + config->enable_touch_interface = enable_touch_interface; + config->home_page = eina_stringshare_add(home_page ? home_page : "http://www.google.com"); + config->proxy = eina_stringshare_add(proxy); + config->restore_state = restore_state; + config->user_agent = eina_stringshare_add(user_agent ? user_agent : "eve"); + + return config; +} + +void +config_free(Config *config) +{ + eina_stringshare_del(config->home_page); + eina_stringshare_del(config->proxy); + eina_stringshare_del(config->user_agent); + free(config); +} + +inline unsigned char +config_allow_popup_get(const Config *config) +{ + return config->allow_popup; +} + +inline void +config_allow_popup_set(Config *config, unsigned char allow_popup) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->allow_popup = allow_popup; +} + +inline unsigned char +config_enable_auto_load_images_get(const Config *config) +{ + return config->enable_auto_load_images; +} + +inline void +config_enable_auto_load_images_set(Config *config, unsigned char enable_auto_load_images) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->enable_auto_load_images = enable_auto_load_images; +} + +inline unsigned char +config_enable_auto_shrink_images_get(const Config *config) +{ + return config->enable_auto_shrink_images; +} + +inline void +config_enable_auto_shrink_images_set(Config *config, unsigned char enable_auto_shrink_images) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->enable_auto_shrink_images = enable_auto_shrink_images; +} + +inline unsigned char +config_enable_javascript_get(const Config *config) +{ + return config->enable_javascript; +} + +inline void +config_enable_javascript_set(Config *config, unsigned char enable_javascript) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->enable_javascript = enable_javascript; +} + +inline unsigned char +config_enable_mouse_cursor_get(const Config *config) +{ + return config->enable_mouse_cursor; +} + +inline void +config_enable_mouse_cursor_set(Config *config, unsigned char enable_mouse_cursor) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->enable_mouse_cursor = enable_mouse_cursor; +} + +inline unsigned char +config_enable_plugins_get(const Config *config) +{ + return config->enable_plugins; +} + +inline void +config_enable_plugins_set(Config *config, unsigned char enable_plugins) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->enable_plugins = enable_plugins; +} + +inline unsigned char +config_enable_private_mode_get(const Config *config) +{ + return config->enable_private_mode; +} + +inline void +config_enable_private_mode_set(Config *config, unsigned char enable_private_mode) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->enable_private_mode = enable_private_mode; +} + +inline unsigned char +config_enable_touch_interface_get(const Config *config) +{ + return config->enable_touch_interface; +} + +inline void +config_enable_touch_interface_set(Config *config, unsigned char enable_touch_interface) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->enable_touch_interface = enable_touch_interface; +} + +inline const char * +config_home_page_get(const Config *config) +{ + return config->home_page; +} + +inline void +config_home_page_set(Config *config, const char *home_page) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + eina_stringshare_replace(&(config->home_page), home_page); +} + +inline const char * +config_proxy_get(const Config *config) +{ + return config->proxy; +} + +inline void +config_proxy_set(Config *config, const char *proxy) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + eina_stringshare_replace(&(config->proxy), proxy); +} + +inline unsigned char +config_restore_state_get(const Config *config) +{ + return config->restore_state; +} + +inline void +config_restore_state_set(Config *config, unsigned char restore_state) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + config->restore_state = restore_state; +} + +inline const char * +config_user_agent_get(const Config *config) +{ + return config->user_agent; +} + +inline void +config_user_agent_set(Config *config, const char *user_agent) +{ + EINA_SAFETY_ON_NULL_RETURN(config); + eina_stringshare_replace(&(config->user_agent), user_agent); +} + +Config * +config_load(const char *filename) +{ + Config *config = NULL; + Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); + return NULL; + } + + config = eet_data_read(ef, _config_descriptor, CONFIG_ENTRY); + if (!config) goto end; + config->__eet_filename = eina_stringshare_add(filename); + +end: + eet_close(ef); + return config; +} + +Eina_Bool +config_save(Config *config, const char *filename) +{ + Eet_File *ef; + Eina_Bool ret; + + if (filename) config->__eet_filename = eina_stringshare_add(filename); + else if (config->__eet_filename) filename = config->__eet_filename; + else return EINA_FALSE; + + ef = eet_open(filename, EET_FILE_MODE_READ_WRITE); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for write\n", filename); + return EINA_FALSE; + } + + ret = !!eet_data_write(ef, _config_descriptor, CONFIG_ENTRY, config, EINA_TRUE); + eet_close(ef); + + return ret; +} + +static inline void +_hist_item_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_hist_item_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Hist_Item); + _hist_item_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "title", title, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "url", url, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "visit_count", visit_count, EET_T_UINT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "last_visit", last_visit, EET_T_DOUBLE); +} + +static inline void +_hist_item_shutdown(void) +{ + if (!_hist_item_descriptor) return; + eet_data_descriptor_free(_hist_item_descriptor); + _hist_item_descriptor = NULL; +} + +Hist_Item * +hist_item_new(const char * title, const char * url, unsigned int visit_count, double last_visit) +{ + Hist_Item *hist_item = calloc(1, sizeof(Hist_Item)); + + if (!hist_item) + { + fprintf(stderr, "ERROR: could not calloc Hist_Item\n"); + return NULL; + } + + hist_item->title = eina_stringshare_add(title ? title : "Untitled"); + hist_item->url = eina_stringshare_add(url ? url : "about:blank"); + hist_item->visit_count = visit_count; + hist_item->last_visit = last_visit; + + return hist_item; +} + +void +hist_item_free(Hist_Item *hist_item) +{ + eina_stringshare_del(hist_item->title); + eina_stringshare_del(hist_item->url); + free(hist_item); +} + +inline const char * +hist_item_title_get(const Hist_Item *hist_item) +{ + return hist_item->title; +} + +inline void +hist_item_title_set(Hist_Item *hist_item, const char *title) +{ + EINA_SAFETY_ON_NULL_RETURN(hist_item); + eina_stringshare_replace(&(hist_item->title), title); +} + +inline const char * +hist_item_url_get(const Hist_Item *hist_item) +{ + return hist_item->url; +} + +inline void +hist_item_url_set(Hist_Item *hist_item, const char *url) +{ + EINA_SAFETY_ON_NULL_RETURN(hist_item); + eina_stringshare_replace(&(hist_item->url), url); +} + +inline unsigned int +hist_item_visit_count_get(const Hist_Item *hist_item) +{ + return hist_item->visit_count; +} + +inline void +hist_item_visit_count_set(Hist_Item *hist_item, unsigned int visit_count) +{ + EINA_SAFETY_ON_NULL_RETURN(hist_item); + hist_item->visit_count = visit_count; +} + +inline double +hist_item_last_visit_get(const Hist_Item *hist_item) +{ + return hist_item->last_visit; +} + +inline void +hist_item_last_visit_set(Hist_Item *hist_item, double last_visit) +{ + EINA_SAFETY_ON_NULL_RETURN(hist_item); + hist_item->last_visit = last_visit; +} + + +static inline void +_hist_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_hist_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Hist); + _hist_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_HASH(_hist_descriptor, Hist, "items", items, _hist_item_descriptor); +} + +static inline void +_hist_shutdown(void) +{ + if (!_hist_descriptor) return; + eet_data_descriptor_free(_hist_descriptor); + _hist_descriptor = NULL; +} + +Hist * +hist_new() +{ + Hist *hist = calloc(1, sizeof(Hist)); + + if (!hist) + { + fprintf(stderr, "ERROR: could not calloc Hist\n"); + return NULL; + } + + hist->items = eina_hash_stringshared_new(EINA_FREE_CB(hist_item_free)); + + return hist; +} + +void +hist_free(Hist *hist) +{ + eina_hash_free(hist->items); + free(hist); +} + +void +hist_items_add(Hist *hist, const char * url, Hist_Item *hist_item) +{ + EINA_SAFETY_ON_NULL_RETURN(hist); + eina_hash_add(hist->items, url, hist_item); +} + +void +hist_items_del(Hist *hist, const char * url) +{ + EINA_SAFETY_ON_NULL_RETURN(hist); + eina_hash_del(hist->items, url, NULL); +} + +inline Hist_Item * +hist_items_get(const Hist *hist, const char * url) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(hist, NULL); + return eina_hash_find(hist->items, url); +} + +inline Eina_Hash * +hist_items_hash_get(const Hist *hist) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(hist, NULL); + return hist->items; +} + +void +hist_items_modify(Hist *hist, const char * key, void *value) +{ + EINA_SAFETY_ON_NULL_RETURN(hist); + eina_hash_modify(hist->items, key, value); +} + +Hist * +hist_load(const char *filename) +{ + Hist *hist = NULL; + Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); + return NULL; + } + + hist = eet_data_read(ef, _hist_descriptor, HIST_ENTRY); + if (!hist) goto end; + hist->__eet_filename = eina_stringshare_add(filename); + + if (!hist->items) hist->items = eina_hash_stringshared_new(EINA_FREE_CB(hist_item_free)); + +end: + eet_close(ef); + return hist; +} + +Eina_Bool +hist_save(Hist *hist, const char *filename) +{ + Eet_File *ef; + Eina_Bool ret; + + if (filename) hist->__eet_filename = eina_stringshare_add(filename); + else if (hist->__eet_filename) filename = hist->__eet_filename; + else return EINA_FALSE; + + ef = eet_open(filename, EET_FILE_MODE_READ_WRITE); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for write\n", filename); + return EINA_FALSE; + } + + ret = !!eet_data_write(ef, _hist_descriptor, HIST_ENTRY, hist, EINA_TRUE); + eet_close(ef); + + return ret; +} + +static inline void +_fav_item_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_fav_item_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Fav_Item); + _fav_item_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_fav_item_descriptor, Fav_Item, "url", url, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_fav_item_descriptor, Fav_Item, "title", title, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_fav_item_descriptor, Fav_Item, "visit_count", visit_count, EET_T_UINT); +} + +static inline void +_fav_item_shutdown(void) +{ + if (!_fav_item_descriptor) return; + eet_data_descriptor_free(_fav_item_descriptor); + _fav_item_descriptor = NULL; +} + +Fav_Item * +fav_item_new(const char * url, const char * title, unsigned int visit_count) +{ + Fav_Item *fav_item = calloc(1, sizeof(Fav_Item)); + + if (!fav_item) + { + fprintf(stderr, "ERROR: could not calloc Fav_Item\n"); + return NULL; + } + + fav_item->url = eina_stringshare_add(url); + fav_item->title = eina_stringshare_add(title); + fav_item->visit_count = visit_count; + + return fav_item; +} + +void +fav_item_free(Fav_Item *fav_item) +{ + eina_stringshare_del(fav_item->url); + eina_stringshare_del(fav_item->title); + free(fav_item); +} + +inline const char * +fav_item_url_get(const Fav_Item *fav_item) +{ + return fav_item->url; +} + +inline void +fav_item_url_set(Fav_Item *fav_item, const char *url) +{ + EINA_SAFETY_ON_NULL_RETURN(fav_item); + eina_stringshare_replace(&(fav_item->url), url); +} + +inline const char * +fav_item_title_get(const Fav_Item *fav_item) +{ + return fav_item->title; +} + +inline void +fav_item_title_set(Fav_Item *fav_item, const char *title) +{ + EINA_SAFETY_ON_NULL_RETURN(fav_item); + eina_stringshare_replace(&(fav_item->title), title); +} + +inline unsigned int +fav_item_visit_count_get(const Fav_Item *fav_item) +{ + return fav_item->visit_count; +} + +inline void +fav_item_visit_count_set(Fav_Item *fav_item, unsigned int visit_count) +{ + EINA_SAFETY_ON_NULL_RETURN(fav_item); + fav_item->visit_count = visit_count; +} + + +static inline void +_fav_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_fav_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Fav); + _fav_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_HASH(_fav_descriptor, Fav, "items", items, _fav_item_descriptor); +} + +static inline void +_fav_shutdown(void) +{ + if (!_fav_descriptor) return; + eet_data_descriptor_free(_fav_descriptor); + _fav_descriptor = NULL; +} + +Fav * +fav_new() +{ + Fav *fav = calloc(1, sizeof(Fav)); + + if (!fav) + { + fprintf(stderr, "ERROR: could not calloc Fav\n"); + return NULL; + } + + fav->items = eina_hash_stringshared_new(EINA_FREE_CB(fav_item_free)); + + return fav; +} + +void +fav_free(Fav *fav) +{ + eina_hash_free(fav->items); + free(fav); +} + +void +fav_items_add(Fav *fav, const char * url, Fav_Item *fav_item) +{ + EINA_SAFETY_ON_NULL_RETURN(fav); + eina_hash_add(fav->items, url, fav_item); +} + +void +fav_items_del(Fav *fav, const char * url) +{ + EINA_SAFETY_ON_NULL_RETURN(fav); + eina_hash_del(fav->items, url, NULL); +} + +inline Fav_Item * +fav_items_get(const Fav *fav, const char * url) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(fav, NULL); + return eina_hash_find(fav->items, url); +} + +inline Eina_Hash * +fav_items_hash_get(const Fav *fav) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(fav, NULL); + return fav->items; +} + +void +fav_items_modify(Fav *fav, const char * key, void *value) +{ + EINA_SAFETY_ON_NULL_RETURN(fav); + eina_hash_modify(fav->items, key, value); +} + +Fav * +fav_load(const char *filename) +{ + Fav *fav = NULL; + Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); + return NULL; + } + + fav = eet_data_read(ef, _fav_descriptor, FAV_ENTRY); + if (!fav) goto end; + fav->__eet_filename = eina_stringshare_add(filename); + + if (!fav->items) fav->items = eina_hash_stringshared_new(EINA_FREE_CB(fav_item_free)); + +end: + eet_close(ef); + return fav; +} + +Eina_Bool +fav_save(Fav *fav, const char *filename) +{ + Eet_File *ef; + Eina_Bool ret; + + if (filename) fav->__eet_filename = eina_stringshare_add(filename); + else if (fav->__eet_filename) filename = fav->__eet_filename; + else return EINA_FALSE; + + ef = eet_open(filename, EET_FILE_MODE_READ_WRITE); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for write\n", filename); + return EINA_FALSE; + } + + ret = !!eet_data_write(ef, _fav_descriptor, FAV_ENTRY, fav, EINA_TRUE); + eet_close(ef); + + return ret; +} + +static inline void +_session_item_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_session_item_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Session_Item); + _session_item_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "url", url, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "focused", focused, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "scroll_x", scroll_x, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_session_item_descriptor, Session_Item, "scroll_y", scroll_y, EET_T_DOUBLE); +} + +static inline void +_session_item_shutdown(void) +{ + if (!_session_item_descriptor) return; + eet_data_descriptor_free(_session_item_descriptor); + _session_item_descriptor = NULL; +} + +Session_Item * +session_item_new(const char * url, unsigned char focused, double scroll_x, double scroll_y) +{ + Session_Item *session_item = calloc(1, sizeof(Session_Item)); + + if (!session_item) + { + fprintf(stderr, "ERROR: could not calloc Session_Item\n"); + return NULL; + } + + session_item->url = eina_stringshare_add(url); + session_item->focused = focused; + session_item->scroll_x = scroll_x; + session_item->scroll_y = scroll_y; + + return session_item; +} + +void +session_item_free(Session_Item *session_item) +{ + eina_stringshare_del(session_item->url); + free(session_item); +} + +inline const char * +session_item_url_get(const Session_Item *session_item) +{ + return session_item->url; +} + +inline void +session_item_url_set(Session_Item *session_item, const char *url) +{ + EINA_SAFETY_ON_NULL_RETURN(session_item); + eina_stringshare_replace(&(session_item->url), url); +} + +inline unsigned char +session_item_focused_get(const Session_Item *session_item) +{ + return session_item->focused; +} + +inline void +session_item_focused_set(Session_Item *session_item, unsigned char focused) +{ + EINA_SAFETY_ON_NULL_RETURN(session_item); + session_item->focused = focused; +} + +inline double +session_item_scroll_x_get(const Session_Item *session_item) +{ + return session_item->scroll_x; +} + +inline void +session_item_scroll_x_set(Session_Item *session_item, double scroll_x) +{ + EINA_SAFETY_ON_NULL_RETURN(session_item); + session_item->scroll_x = scroll_x; +} + +inline double +session_item_scroll_y_get(const Session_Item *session_item) +{ + return session_item->scroll_y; +} + +inline void +session_item_scroll_y_set(Session_Item *session_item, double scroll_y) +{ + EINA_SAFETY_ON_NULL_RETURN(session_item); + session_item->scroll_y = scroll_y; +} + + +static inline void +_session_window_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_session_window_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Session_Window); + _session_window_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_LIST(_session_window_descriptor, Session_Window, "tabs", tabs, _session_item_descriptor); + EET_DATA_DESCRIPTOR_ADD_BASIC(_session_window_descriptor, Session_Window, "focused", focused, EET_T_UCHAR); +} + +static inline void +_session_window_shutdown(void) +{ + if (!_session_window_descriptor) return; + eet_data_descriptor_free(_session_window_descriptor); + _session_window_descriptor = NULL; +} + +Session_Window * +session_window_new(Eina_List * tabs, unsigned char focused) +{ + Session_Window *session_window = calloc(1, sizeof(Session_Window)); + + if (!session_window) + { + fprintf(stderr, "ERROR: could not calloc Session_Window\n"); + return NULL; + } + + session_window->tabs = tabs; + session_window->focused = focused; + + return session_window; +} + +void +session_window_free(Session_Window *session_window) +{ + if (session_window->tabs) + { + Session_Item *tabs_elem; + EINA_LIST_FREE(session_window->tabs, tabs_elem) + session_item_free(tabs_elem); + } + free(session_window); +} + +inline void +session_window_tabs_add(Session_Window *session_window, Session_Item *session_item) +{ + EINA_SAFETY_ON_NULL_RETURN(session_window); + session_window->tabs = eina_list_append(session_window->tabs, session_item); +} + +inline void +session_window_tabs_del(Session_Window *session_window, Session_Item *session_item) +{ + EINA_SAFETY_ON_NULL_RETURN(session_window); + session_window->tabs = eina_list_remove(session_window->tabs, session_item); +} + +inline Session_Item * +session_window_tabs_get(const Session_Window *session_window, unsigned int nth) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(session_window, NULL); + return eina_list_nth(session_window->tabs, nth); +} + +inline unsigned int +session_window_tabs_count(const Session_Window *session_window) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(session_window, 0); + return eina_list_count(session_window->tabs); +} + +void +session_window_tabs_list_clear(Session_Window *session_window) +{ + EINA_SAFETY_ON_NULL_RETURN(session_window); + Session_Item *data; + EINA_LIST_FREE(session_window->tabs, data) session_item_free(data); +} + +inline Eina_List * +session_window_tabs_list_get(const Session_Window *session_window) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(session_window, NULL); + return session_window->tabs; +} + +inline void +session_window_tabs_list_set(Session_Window *session_window, Eina_List *list) +{ + EINA_SAFETY_ON_NULL_RETURN(session_window); + session_window->tabs = list; +} + +inline unsigned char +session_window_focused_get(const Session_Window *session_window) +{ + return session_window->focused; +} + +inline void +session_window_focused_set(Session_Window *session_window, unsigned char focused) +{ + EINA_SAFETY_ON_NULL_RETURN(session_window); + session_window->focused = focused; +} + + +static inline void +_session_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_session_descriptor) return; + + EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Session); + _session_descriptor = eet_data_descriptor_stream_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_LIST(_session_descriptor, Session, "windows", windows, _session_window_descriptor); +} + +static inline void +_session_shutdown(void) +{ + if (!_session_descriptor) return; + eet_data_descriptor_free(_session_descriptor); + _session_descriptor = NULL; +} + +Session * +session_new(Eina_List * windows) +{ + Session *session = calloc(1, sizeof(Session)); + + if (!session) + { + fprintf(stderr, "ERROR: could not calloc Session\n"); + return NULL; + } + + session->windows = windows; + + return session; +} + +void +session_free(Session *session) +{ + if (session->windows) + { + Session_Window *windows_elem; + EINA_LIST_FREE(session->windows, windows_elem) + session_window_free(windows_elem); + } + free(session); +} + +inline void +session_windows_add(Session *session, Session_Window *session_window) +{ + EINA_SAFETY_ON_NULL_RETURN(session); + session->windows = eina_list_append(session->windows, session_window); +} + +inline void +session_windows_del(Session *session, Session_Window *session_window) +{ + EINA_SAFETY_ON_NULL_RETURN(session); + session->windows = eina_list_remove(session->windows, session_window); +} + +inline Session_Window * +session_windows_get(const Session *session, unsigned int nth) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(session, NULL); + return eina_list_nth(session->windows, nth); +} + +inline unsigned int +session_windows_count(const Session *session) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(session, 0); + return eina_list_count(session->windows); +} + +void +session_windows_list_clear(Session *session) +{ + EINA_SAFETY_ON_NULL_RETURN(session); + Session_Window *data; + EINA_LIST_FREE(session->windows, data) session_window_free(data); +} + +inline Eina_List * +session_windows_list_get(const Session *session) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(session, NULL); + return session->windows; +} + +inline void +session_windows_list_set(Session *session, Eina_List *list) +{ + EINA_SAFETY_ON_NULL_RETURN(session); + session->windows = list; +} + +Session * +session_load(const char *filename) +{ + Session *session = NULL; + Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); + return NULL; + } + + session = eet_data_read(ef, _session_descriptor, SESSION_ENTRY); + if (!session) goto end; + session->__eet_filename = eina_stringshare_add(filename); + +end: + eet_close(ef); + return session; +} + +Eina_Bool +session_save(Session *session, const char *filename) +{ + Eet_File *ef; + Eina_Bool ret; + + if (filename) session->__eet_filename = eina_stringshare_add(filename); + else if (session->__eet_filename) filename = session->__eet_filename; + else return EINA_FALSE; + + ef = eet_open(filename, EET_FILE_MODE_READ_WRITE); + if (!ef) + { + fprintf(stderr, "ERROR: could not open '%s' for write\n", filename); + return EINA_FALSE; + } + + ret = !!eet_data_write(ef, _session_descriptor, SESSION_ENTRY, session, EINA_TRUE); + eet_close(ef); + + return ret; +} + +void +eve_state_init(void) +{ + _config_init(); + _hist_item_init(); + _hist_init(); + _fav_item_init(); + _fav_init(); + _session_item_init(); + _session_window_init(); + _session_init(); +} + +void +eve_state_shutdown(void) +{ + _config_shutdown(); + _hist_item_shutdown(); + _hist_shutdown(); + _fav_item_shutdown(); + _fav_shutdown(); + _session_item_shutdown(); + _session_window_shutdown(); + _session_shutdown(); +} + diff --git a/src/bin/eve_state.geneet b/src/bin/eve_state.geneet new file mode 100644 index 0000000..b2563b2 --- /dev/null +++ b/src/bin/eve_state.geneet @@ -0,0 +1,51 @@ +Config { + allow_popup : uchar; + enable_auto_load_images : uchar; + enable_auto_shrink_images : uchar; + enable_javascript : uchar; + enable_mouse_cursor : uchar; + enable_plugins : uchar; + enable_private_mode : uchar; + enable_touch_interface : uchar; + home_page : str default "http://www.google.com"; + proxy : str; + restore_state : uchar; + user_agent : str default "eve"; +} + +Hist_Item { + title : str default "Untitled"; + url : str default "about:blank"; + visit_count : uint; + last_visit : double; +} + +Hist { + items : hash of Hist_Item by url; +} + +Fav_Item { + url : str; + title : str; + visit_count : uint; +} + +Fav { + items : hash of Fav_Item by url; +} + +Session_Item { + url : str; + focused : uchar; + scroll_x : double; + scroll_y : double; +} + +Session_Window { + tabs : list of Session_Item; + focused : uchar; +} + +Session { + windows : list of Session_Window; +} diff --git a/src/bin/eve_state.h b/src/bin/eve_state.h new file mode 100644 index 0000000..0914e9f --- /dev/null +++ b/src/bin/eve_state.h @@ -0,0 +1,147 @@ +/* This file has been automatically generated by geneet.py */ +/* DO NOT MODIFY */ + +#ifndef __EVE_STATE_H__ +#define __EVE_STATE_H__ + +#include +#include + +typedef struct _Config Config; +typedef struct _Hist_Item Hist_Item; +typedef struct _Hist Hist; +typedef struct _Fav_Item Fav_Item; +typedef struct _Fav Fav; +typedef struct _Session_Item Session_Item; +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); +void config_free(Config *config); + +void config_allow_popup_set(Config *config, unsigned char allow_popup); +unsigned char config_allow_popup_get(const Config *config); +void config_enable_auto_load_images_set(Config *config, unsigned char enable_auto_load_images); +unsigned char config_enable_auto_load_images_get(const Config *config); +void config_enable_auto_shrink_images_set(Config *config, unsigned char enable_auto_shrink_images); +unsigned char config_enable_auto_shrink_images_get(const Config *config); +void config_enable_javascript_set(Config *config, unsigned char enable_javascript); +unsigned char config_enable_javascript_get(const Config *config); +void config_enable_mouse_cursor_set(Config *config, unsigned char enable_mouse_cursor); +unsigned char config_enable_mouse_cursor_get(const Config *config); +void config_enable_plugins_set(Config *config, unsigned char enable_plugins); +unsigned char config_enable_plugins_get(const Config *config); +void config_enable_private_mode_set(Config *config, unsigned char enable_private_mode); +unsigned char config_enable_private_mode_get(const Config *config); +void config_enable_touch_interface_set(Config *config, unsigned char enable_touch_interface); +unsigned char config_enable_touch_interface_get(const Config *config); +void config_home_page_set(Config *config, const char * home_page); +const char * config_home_page_get(const Config *config); +void config_proxy_set(Config *config, const char * proxy); +const char * config_proxy_get(const Config *config); +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); + +Config *config_load(const char *filename); +Eina_Bool config_save(Config *config, const char *filename); + +/* Hist_Item */ +Hist_Item *hist_item_new(const char * title, const char * url, unsigned int visit_count, double last_visit); +void hist_item_free(Hist_Item *hist_item); + +void hist_item_title_set(Hist_Item *hist_item, const char * title); +const char * hist_item_title_get(const Hist_Item *hist_item); +void hist_item_url_set(Hist_Item *hist_item, const char * url); +const char * hist_item_url_get(const Hist_Item *hist_item); +void hist_item_visit_count_set(Hist_Item *hist_item, unsigned int visit_count); +unsigned int hist_item_visit_count_get(const Hist_Item *hist_item); +void hist_item_last_visit_set(Hist_Item *hist_item, double last_visit); +double hist_item_last_visit_get(const Hist_Item *hist_item); + +/* Hist */ +Hist *hist_new(); +void hist_free(Hist *hist); + +void hist_items_add(Hist *hist, const char * url, Hist_Item *hist_item); +void hist_items_del(Hist *hist, const char * url); +Hist_Item *hist_items_get(const Hist *hist, const char * key); +Eina_Hash *hist_items_hash_get(const Hist *hist); +void hist_items_modify(Hist *hist, const char * key, void *value); + +Hist *hist_load(const char *filename); +Eina_Bool hist_save(Hist *hist, const char *filename); + +/* Fav_Item */ +Fav_Item *fav_item_new(const char * url, const char * title, unsigned int visit_count); +void fav_item_free(Fav_Item *fav_item); + +void fav_item_url_set(Fav_Item *fav_item, const char * url); +const char * fav_item_url_get(const Fav_Item *fav_item); +void fav_item_title_set(Fav_Item *fav_item, const char * title); +const char * fav_item_title_get(const Fav_Item *fav_item); +void fav_item_visit_count_set(Fav_Item *fav_item, unsigned int visit_count); +unsigned int fav_item_visit_count_get(const Fav_Item *fav_item); + +/* Fav */ +Fav *fav_new(); +void fav_free(Fav *fav); + +void fav_items_add(Fav *fav, const char * url, Fav_Item *fav_item); +void fav_items_del(Fav *fav, const char * url); +Fav_Item *fav_items_get(const Fav *fav, const char * key); +Eina_Hash *fav_items_hash_get(const Fav *fav); +void fav_items_modify(Fav *fav, const char * key, void *value); + +Fav *fav_load(const char *filename); +Eina_Bool fav_save(Fav *fav, const char *filename); + +/* Session_Item */ +Session_Item *session_item_new(const char * url, unsigned char focused, double scroll_x, double scroll_y); +void session_item_free(Session_Item *session_item); + +void session_item_url_set(Session_Item *session_item, const char * url); +const char * session_item_url_get(const Session_Item *session_item); +void session_item_focused_set(Session_Item *session_item, unsigned char focused); +unsigned char session_item_focused_get(const Session_Item *session_item); +void session_item_scroll_x_set(Session_Item *session_item, double scroll_x); +double session_item_scroll_x_get(const Session_Item *session_item); +void session_item_scroll_y_set(Session_Item *session_item, double scroll_y); +double session_item_scroll_y_get(const Session_Item *session_item); + +/* Session_Window */ +Session_Window *session_window_new(Eina_List * tabs, unsigned char focused); +void session_window_free(Session_Window *session_window); + +void session_window_tabs_add(Session_Window *session_window, Session_Item *session_item); +void session_window_tabs_del(Session_Window *session_window, Session_Item *session_item); +Session_Item *session_window_tabs_get(const Session_Window *session_window, unsigned int nth); +unsigned int session_window_tabs_count(const Session_Window *session_window); +Eina_List *session_window_tabs_list_get(const Session_Window *session_window); +void session_window_tabs_list_clear(Session_Window *session_window); +void session_window_tabs_list_set(Session_Window *session_window, Eina_List *list); +void session_window_focused_set(Session_Window *session_window, unsigned char focused); +unsigned char session_window_focused_get(const Session_Window *session_window); + +/* Session */ +Session *session_new(Eina_List * windows); +void session_free(Session *session); + +void session_windows_add(Session *session, Session_Window *session_window); +void session_windows_del(Session *session, Session_Window *session_window); +Session_Window *session_windows_get(const Session *session, unsigned int nth); +unsigned int session_windows_count(const Session *session); +Eina_List *session_windows_list_get(const Session *session); +void session_windows_list_clear(Session *session); +void session_windows_list_set(Session *session, Eina_List *list); + +Session *session_load(const char *filename); +Eina_Bool session_save(Session *session, const char *filename); + +/* Global initializer / shutdown functions */ +void eve_state_init(void); +void eve_state_shutdown(void); + +#endif /* __EVE_STATE_H__ */ diff --git a/src/bin/history.c b/src/bin/history.c deleted file mode 100644 index 20e096f..0000000 --- a/src/bin/history.c +++ /dev/null @@ -1,311 +0,0 @@ -/* This file has been automatically generated by geneet.py */ -/* DO NOT MODIFY */ - -#include -#include -#include -#include -#include - -#include "history.h" - -struct _Hist_Item { - const char * title; - const char * url; - unsigned int visit_count; - double last_visit; -}; - -struct _Hist { - int version; - Eina_Hash * items; - const char *__eet_filename; -}; - -static const char HIST_ITEM_ENTRY[] = "hist_item"; -static const char HIST_ENTRY[] = "hist"; - -static Eet_Data_Descriptor *_hist_item_descriptor = NULL; -static Eet_Data_Descriptor *_hist_descriptor = NULL; - -static inline void -_hist_item_init(void) -{ - Eet_Data_Descriptor_Class eddc; - - if (_hist_item_descriptor) return; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Hist_Item); - _hist_item_descriptor = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "title", title, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "url", url, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "visit_count", visit_count, EET_T_UINT); - EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_item_descriptor, Hist_Item, "last_visit", last_visit, EET_T_DOUBLE); -} - -static inline void -_hist_item_shutdown(void) -{ - if (!_hist_item_descriptor) return; - eet_data_descriptor_free(_hist_item_descriptor); - _hist_item_descriptor = NULL; -} - -Hist_Item * -hist_item_new(const char * title, const char * url, unsigned int visit_count, double last_visit) -{ - Hist_Item *hist_item = calloc(1, sizeof(Hist_Item)); - - if (!hist_item) - { - fprintf(stderr, "ERROR: could not calloc Hist_Item\n"); - return NULL; - } - - hist_item->title = eina_stringshare_add(title ? title : "Untitled"); - hist_item->url = eina_stringshare_add(url ? url : "about:blank"); - hist_item->visit_count = visit_count; - hist_item->last_visit = last_visit; - - return hist_item; -} - -void -hist_item_free(Hist_Item *hist_item) -{ - eina_stringshare_del(hist_item->title); - eina_stringshare_del(hist_item->url); - free(hist_item); -} - -inline const char * -hist_item_title_get(const Hist_Item *hist_item) -{ - return hist_item->title; -} - -inline void -hist_item_title_set(Hist_Item *hist_item, const char *title) -{ - EINA_SAFETY_ON_NULL_RETURN(hist_item); - eina_stringshare_del(hist_item->title); - hist_item->title = eina_stringshare_add(title); -} - -inline const char * -hist_item_url_get(const Hist_Item *hist_item) -{ - return hist_item->url; -} - -inline void -hist_item_url_set(Hist_Item *hist_item, const char *url) -{ - EINA_SAFETY_ON_NULL_RETURN(hist_item); - eina_stringshare_del(hist_item->url); - hist_item->url = eina_stringshare_add(url); -} - -inline unsigned int -hist_item_visit_count_get(const Hist_Item *hist_item) -{ - return hist_item->visit_count; -} - -inline void -hist_item_visit_count_set(Hist_Item *hist_item, unsigned int visit_count) -{ - EINA_SAFETY_ON_NULL_RETURN(hist_item); - hist_item->visit_count = visit_count; -} - -inline double -hist_item_last_visit_get(const Hist_Item *hist_item) -{ - return hist_item->last_visit; -} - -inline void -hist_item_last_visit_set(Hist_Item *hist_item, double last_visit) -{ - EINA_SAFETY_ON_NULL_RETURN(hist_item); - hist_item->last_visit = last_visit; -} - - -static inline void -_hist_init(void) -{ - Eet_Data_Descriptor_Class eddc; - - if (_hist_descriptor) return; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Hist); - _hist_descriptor = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_hist_descriptor, Hist, "version", version, EET_T_INT); - EET_DATA_DESCRIPTOR_ADD_HASH(_hist_descriptor, Hist, "items", items, _hist_item_descriptor); -} - -static inline void -_hist_shutdown(void) -{ - if (!_hist_descriptor) return; - eet_data_descriptor_free(_hist_descriptor); - _hist_descriptor = NULL; -} - -Hist * -hist_new(int version) -{ - Hist *hist = calloc(1, sizeof(Hist)); - - if (!hist) - { - fprintf(stderr, "ERROR: could not calloc Hist\n"); - return NULL; - } - - hist->version = version; - hist->items = eina_hash_stringshared_new(EINA_FREE_CB(hist_item_free)); - - return hist; -} - -void -hist_free(Hist *hist) -{ - eina_hash_free(hist->items); - free(hist); -} - -inline int -hist_version_get(const Hist *hist) -{ - return hist->version; -} - -inline void -hist_version_set(Hist *hist, int version) -{ - EINA_SAFETY_ON_NULL_RETURN(hist); - hist->version = version; -} - -void -hist_items_add(Hist *hist, const char * url, Hist_Item *hist_item) -{ - EINA_SAFETY_ON_NULL_RETURN(hist); - eina_hash_add(hist->items, url, hist_item); -} - -void -hist_items_del(Hist *hist, const char * url) -{ - EINA_SAFETY_ON_NULL_RETURN(hist); - eina_hash_del(hist->items, url, NULL); -} - -inline Hist_Item * -hist_items_get(const Hist *hist, const char * url) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(hist, NULL); - return eina_hash_find(hist->items, url); -} - -inline Eina_Hash * -hist_items_hash_get(const Hist *hist) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(hist, NULL); - return hist->items; -} - -void -hist_items_modify(Hist *hist, const char * key, void *value) -{ - EINA_SAFETY_ON_NULL_RETURN(hist); - eina_hash_modify(hist->items, key, value); -} - -Hist * -hist_load(const char *filename) -{ - Hist *hist; - Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); - if (!ef) - { - fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); - return NULL; - } - - hist = eet_data_read(ef, _hist_descriptor, HIST_ENTRY); - hist->__eet_filename = eina_stringshare_add(filename); - - if (!hist->items) hist->items = eina_hash_stringshared_new(EINA_FREE_CB(hist_item_free)); - - eet_close(ef); - return hist; -} - -Eina_Bool -hist_save(Hist *hist, const char *filename) -{ - char tmp[PATH_MAX]; - Eet_File *ef; - Eina_Bool ret; - unsigned int i, len; - struct stat st; - - if (filename) hist->__eet_filename = eina_stringshare_add(filename); - else if (hist->__eet_filename) filename = hist->__eet_filename; - else return EINA_FALSE; - - len = eina_strlcpy(tmp, filename, sizeof(tmp)); - if (len + 12 >= (int)sizeof(tmp)) - { - fprintf(stderr, "ERROR: filename is too big: %s\n", filename); - return EINA_FALSE; - } - - i = 0; - do - { - snprintf(tmp + len, 12, ".%u", i); - i++; - } - while(stat(tmp, &st) == 0); - - ef = eet_open(tmp, EET_FILE_MODE_WRITE); - if (!ef) - { - fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp); - return EINA_FALSE; - } - - ret = !!eet_data_write(ef, _hist_descriptor, HIST_ENTRY, hist, EINA_TRUE); - eet_close(ef); - - if (ret) - { - unlink(filename); - rename(tmp, filename); - } - - return ret; -} - -void -history_init(void) -{ - _hist_item_init(); - _hist_init(); -} - -void -history_shutdown(void) -{ - _hist_item_shutdown(); - _hist_shutdown(); -} - diff --git a/src/bin/history.h b/src/bin/history.h deleted file mode 100644 index 04472f2..0000000 --- a/src/bin/history.h +++ /dev/null @@ -1,45 +0,0 @@ -/* This file has been automatically generated by geneet.py */ -/* DO NOT MODIFY */ - -#ifndef __HISTORY_H__ -#define __HISTORY_H__ - -#include -#include - -typedef struct _Hist_Item Hist_Item; -typedef struct _Hist Hist; - -/* Hist_Item */ -Hist_Item *hist_item_new(const char * title, const char * url, unsigned int visit_count, double last_visit); -void hist_item_free(Hist_Item *hist_item); - -void hist_item_title_set(Hist_Item *hist_item, const char * title); -const char * hist_item_title_get(const Hist_Item *hist_item); -void hist_item_url_set(Hist_Item *hist_item, const char * url); -const char * hist_item_url_get(const Hist_Item *hist_item); -void hist_item_visit_count_set(Hist_Item *hist_item, unsigned int visit_count); -unsigned int hist_item_visit_count_get(const Hist_Item *hist_item); -void hist_item_last_visit_set(Hist_Item *hist_item, double last_visit); -double hist_item_last_visit_get(const Hist_Item *hist_item); - -/* Hist */ -Hist *hist_new(int version); -void hist_free(Hist *hist); - -void hist_version_set(Hist *hist, int version); -int hist_version_get(const Hist *hist); -void hist_items_add(Hist *hist, const char * url, Hist_Item *hist_item); -void hist_items_del(Hist *hist, const char * url); -Hist_Item *hist_items_get(const Hist *hist, const char * key); -Eina_Hash *hist_items_hash_get(const Hist *hist); -void hist_items_modify(Hist *hist, const char * key, void *value); - -Hist *hist_load(const char *filename); -Eina_Bool hist_save(Hist *hist, const char *filename); - -/* Global initializer / shutdown functions */ -void history_init(void); -void history_shutdown(void); - -#endif /* __HISTORY_H__ */ diff --git a/src/bin/main.c b/src/bin/main.c index c0eb1a6..be9967c 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -11,8 +11,6 @@ #include #ifndef ELM_LIB_QUICKLAUNCH -#include "prefs.h" -#include "favorite.h" #include "private.h" #include @@ -23,9 +21,9 @@ #include "gettext.h" int _log_domain = -1; -Fav *fav = NULL; Hist *hist = NULL; -Prefs *prefs = NULL; +Fav *fav = NULL; +Config *config = NULL; App app; struct Cursor { @@ -234,7 +232,7 @@ add_win(App *app, const char *url) elm_win_title_set(win->win, PACKAGE_STRING); elm_win_rotation_set(win->win, app->rotate); elm_win_fullscreen_set(win->win, app->is_fullscreen); - window_mouse_enabled_set(win->win, prefs_enable_mouse_cursor_get(prefs)); + window_mouse_enabled_set(win->win, config_enable_mouse_cursor_get(config)); win->bg = edje_object_add(evas_object_evas_get(win->win)); if (!win->bg) @@ -425,7 +423,7 @@ state_save(void) Browser_Window *win; Eina_List *win_iter; - if (!prefs_restore_state_get(prefs)) return; + if (!config_restore_state_get(config)) return; prefs_state_list_clear(prefs); EINA_LIST_FOREACH(app.windows, win_iter, win) @@ -528,9 +526,7 @@ elm_main(int argc, char **argv) elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/default.edj"); ewk_init(); - favorite_init(); - history_init(); - preferences_init(); + eve_state_init(); e_dbus_init(); home = getenv("HOME"); @@ -596,23 +592,56 @@ elm_main(int argc, char **argv) BOOL_OPT(plugins); #undef BOOL_OPT - prefs = prefs_new(enable_mouse_cursor, enable_touch_interface, - enable_plugins, - EINA_TRUE, user_agent_str, DEFAULT_URL, NULL, - EINA_FALSE, EINA_TRUE, EINA_FALSE, - EINA_TRUE, EINA_FALSE, NULL); - prefs_save(prefs, path); + 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); + if (!config_save(config, path)) + { + r = -1; + goto end_config; + } + } + + hist = hist_load(path); + if (!hist) + { + hist = hist_new(); + if (!hist_save(hist, path)) + { + r = -1; + goto end_hist; + } + } + + fav = fav_load(path); + if (!fav) + { + fav = fav_new(); + if (!fav_save(fav, path)) + { + r = -1; + goto end_fav; + } } #define BOOL_OPT(opt) \ if (disable_##opt != 0xff) \ { \ - Eina_Bool old = prefs_enable_##opt##_get(prefs); \ + Eina_Bool old = config_enable_##opt##_get(config); \ Eina_Bool cur = !disable_##opt; \ if (old != cur) \ { \ INF("Changed preferences to "#opt"=%hhu", cur); \ - prefs_enable_##opt##_set(prefs, cur); \ + config_enable_##opt##_set(config, cur); \ } \ } BOOL_OPT(mouse_cursor); @@ -622,19 +651,19 @@ elm_main(int argc, char **argv) if (user_agent_option) { - const char *old = prefs_user_agent_get(prefs); + const char *old = config_user_agent_get(config); const char *cur = user_agent_str; if (strcmp(old, cur) != 0) { INF("Changed preferences to user_agent=\"%s\"", cur); - prefs_user_agent_set(prefs, cur); + config_user_agent_set(config, cur); } } if (args < argc) url = argv[args]; else - url = prefs_home_page_get(prefs); + url = config_home_page_get(config); conn = e_dbus_bus_get(DBUS_BUS_SESSION); if (conn) @@ -648,7 +677,8 @@ elm_main(int argc, char **argv) e_dbus_request_name(conn, "mobi.profusion.eve", 0, _cb_dbus_request_name, response); } - if (prefs_restore_state_get(prefs) && prefs_state_count(prefs) > 0) +#if 0 + if (prefs_restore_state_get(prefs) && prefs_state_count(config) > 0) { Eina_List *previous_state = prefs_state_list_get(prefs); Eina_List *state_iter; @@ -665,34 +695,33 @@ elm_main(int argc, char **argv) EINA_LIST_FOREACH(previous_state->next, state_iter, tab) tab_add(win, prefs_opened_tab_address_get(tab)); } - else if (!add_win(&app, url)) + else +#else + if (!add_win(&app, url)) { r = -1; goto end; } +#endif elm_run(); end: - state_save(); - - fav_save(fav, NULL); - fav_free(fav); - + config_save(config, NULL); + config_free(config); +end_config: hist_save(hist, NULL); hist_free(hist); - - prefs_save(prefs, NULL); - prefs_free(prefs); - +end_hist: + fav_save(fav, NULL); + fav_free(fav); +end_fav: if (conn) e_dbus_connection_close(conn); eina_log_domain_unregister(_log_domain); _log_domain = -1; elm_shutdown(); ewk_shutdown(); - favorite_shutdown(); - history_shutdown(); - preferences_shutdown(); + eve_state_shutdown(); e_dbus_shutdown(); return r; } diff --git a/src/bin/prefs.c b/src/bin/prefs.c deleted file mode 100644 index 93d5b5b..0000000 --- a/src/bin/prefs.c +++ /dev/null @@ -1,461 +0,0 @@ -/* This file has been automatically generated by geneet.py */ -/* DO NOT MODIFY */ - -#include -#include -#include -#include -#include - -#include "prefs.h" - -struct _Prefs_Opened_Tab { - const char * address; -}; - -struct _Prefs { - char enable_mouse_cursor; - char enable_touch_interface; - char enable_plugins; - char enable_javascript; - const char * user_agent; - const char * home_page; - const char * proxy; - char enable_private_mode; - char enable_auto_load_images; - char enable_auto_shrink_images; - char allow_popup; - char restore_state; - Eina_List * state; - const char *__eet_filename; -}; - -static const char PREFS_OPENED_TAB_ENTRY[] = "prefs_opened_tab"; -static const char PREFS_ENTRY[] = "prefs"; - -static Eet_Data_Descriptor *_prefs_opened_tab_descriptor = NULL; -static Eet_Data_Descriptor *_prefs_descriptor = NULL; - -static inline void -_prefs_opened_tab_init(void) -{ - Eet_Data_Descriptor_Class eddc; - - if (_prefs_opened_tab_descriptor) return; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Prefs_Opened_Tab); - _prefs_opened_tab_descriptor = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_opened_tab_descriptor, Prefs_Opened_Tab, "address", address, EET_T_STRING); -} - -static inline void -_prefs_opened_tab_shutdown(void) -{ - if (!_prefs_opened_tab_descriptor) return; - eet_data_descriptor_free(_prefs_opened_tab_descriptor); - _prefs_opened_tab_descriptor = NULL; -} - -Prefs_Opened_Tab * -prefs_opened_tab_new(const char * address) -{ - Prefs_Opened_Tab *prefs_opened_tab = calloc(1, sizeof(Prefs_Opened_Tab)); - - if (!prefs_opened_tab) - { - fprintf(stderr, "ERROR: could not calloc Prefs_Opened_Tab\n"); - return NULL; - } - - prefs_opened_tab->address = eina_stringshare_add(address); - - return prefs_opened_tab; -} - -void -prefs_opened_tab_free(Prefs_Opened_Tab *prefs_opened_tab) -{ - eina_stringshare_del(prefs_opened_tab->address); - free(prefs_opened_tab); -} - -inline const char * -prefs_opened_tab_address_get(const Prefs_Opened_Tab *prefs_opened_tab) -{ - return prefs_opened_tab->address; -} - -inline void -prefs_opened_tab_address_set(Prefs_Opened_Tab *prefs_opened_tab, const char *address) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs_opened_tab); - eina_stringshare_del(prefs_opened_tab->address); - prefs_opened_tab->address = eina_stringshare_add(address); -} - - -static inline void -_prefs_init(void) -{ - Eet_Data_Descriptor_Class eddc; - - if (_prefs_descriptor) return; - - EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Prefs); - _prefs_descriptor = eet_data_descriptor_stream_new(&eddc); - - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "enable_mouse_cursor", enable_mouse_cursor, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "enable_touch_interface", enable_touch_interface, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "enable_plugins", enable_plugins, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "enable_javascript", enable_javascript, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "user_agent", user_agent, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "home_page", home_page, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "proxy", proxy, EET_T_STRING); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "enable_private_mode", enable_private_mode, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "enable_auto_load_images", enable_auto_load_images, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "enable_auto_shrink_images", enable_auto_shrink_images, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "allow_popup", allow_popup, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_BASIC(_prefs_descriptor, Prefs, "restore_state", restore_state, EET_T_CHAR); - EET_DATA_DESCRIPTOR_ADD_LIST(_prefs_descriptor, Prefs, "state", state, _prefs_opened_tab_descriptor); -} - -static inline void -_prefs_shutdown(void) -{ - if (!_prefs_descriptor) return; - eet_data_descriptor_free(_prefs_descriptor); - _prefs_descriptor = NULL; -} - -Prefs * -prefs_new(char enable_mouse_cursor, char enable_touch_interface, char enable_plugins, char enable_javascript, const char * user_agent, const char * home_page, const char * proxy, char enable_private_mode, char enable_auto_load_images, char enable_auto_shrink_images, char allow_popup, char restore_state, Eina_List * state) -{ - Prefs *prefs = calloc(1, sizeof(Prefs)); - - if (!prefs) - { - fprintf(stderr, "ERROR: could not calloc Prefs\n"); - return NULL; - } - - prefs->enable_mouse_cursor = enable_mouse_cursor; - prefs->enable_touch_interface = enable_touch_interface; - prefs->enable_plugins = enable_plugins; - prefs->enable_javascript = enable_javascript; - prefs->user_agent = eina_stringshare_add(user_agent ? user_agent : "eve"); - prefs->home_page = eina_stringshare_add(home_page ? home_page : "http://www.google.com"); - prefs->proxy = eina_stringshare_add(proxy); - prefs->enable_private_mode = enable_private_mode; - prefs->enable_auto_load_images = enable_auto_load_images; - prefs->enable_auto_shrink_images = enable_auto_shrink_images; - prefs->allow_popup = allow_popup; - prefs->restore_state = restore_state; - prefs->state = state; - - return prefs; -} - -void -prefs_free(Prefs *prefs) -{ - eina_stringshare_del(prefs->user_agent); - eina_stringshare_del(prefs->home_page); - eina_stringshare_del(prefs->proxy); - if (prefs->state) - { - Prefs_Opened_Tab *state_elem; - EINA_LIST_FREE(prefs->state, state_elem) - prefs_opened_tab_free(state_elem); - } - free(prefs); -} - -inline char -prefs_enable_mouse_cursor_get(const Prefs *prefs) -{ - return prefs->enable_mouse_cursor; -} - -inline void -prefs_enable_mouse_cursor_set(Prefs *prefs, char enable_mouse_cursor) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->enable_mouse_cursor = enable_mouse_cursor; -} - -inline char -prefs_enable_touch_interface_get(const Prefs *prefs) -{ - return prefs->enable_touch_interface; -} - -inline void -prefs_enable_touch_interface_set(Prefs *prefs, char enable_touch_interface) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->enable_touch_interface = enable_touch_interface; -} - -inline char -prefs_enable_plugins_get(const Prefs *prefs) -{ - return prefs->enable_plugins; -} - -inline void -prefs_enable_plugins_set(Prefs *prefs, char enable_plugins) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->enable_plugins = enable_plugins; -} - -inline char -prefs_enable_javascript_get(const Prefs *prefs) -{ - return prefs->enable_javascript; -} - -inline void -prefs_enable_javascript_set(Prefs *prefs, char enable_javascript) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->enable_javascript = enable_javascript; -} - -inline const char * -prefs_user_agent_get(const Prefs *prefs) -{ - return prefs->user_agent; -} - -inline void -prefs_user_agent_set(Prefs *prefs, const char *user_agent) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - eina_stringshare_del(prefs->user_agent); - prefs->user_agent = eina_stringshare_add(user_agent); -} - -inline const char * -prefs_home_page_get(const Prefs *prefs) -{ - return prefs->home_page; -} - -inline void -prefs_home_page_set(Prefs *prefs, const char *home_page) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - eina_stringshare_del(prefs->home_page); - prefs->home_page = eina_stringshare_add(home_page); -} - -inline const char * -prefs_proxy_get(const Prefs *prefs) -{ - return prefs->proxy; -} - -inline void -prefs_proxy_set(Prefs *prefs, const char *proxy) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - eina_stringshare_del(prefs->proxy); - prefs->proxy = eina_stringshare_add(proxy); -} - -inline char -prefs_enable_private_mode_get(const Prefs *prefs) -{ - return prefs->enable_private_mode; -} - -inline void -prefs_enable_private_mode_set(Prefs *prefs, char enable_private_mode) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->enable_private_mode = enable_private_mode; -} - -inline char -prefs_enable_auto_load_images_get(const Prefs *prefs) -{ - return prefs->enable_auto_load_images; -} - -inline void -prefs_enable_auto_load_images_set(Prefs *prefs, char enable_auto_load_images) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->enable_auto_load_images = enable_auto_load_images; -} - -inline char -prefs_enable_auto_shrink_images_get(const Prefs *prefs) -{ - return prefs->enable_auto_shrink_images; -} - -inline void -prefs_enable_auto_shrink_images_set(Prefs *prefs, char enable_auto_shrink_images) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->enable_auto_shrink_images = enable_auto_shrink_images; -} - -inline char -prefs_allow_popup_get(const Prefs *prefs) -{ - return prefs->allow_popup; -} - -inline void -prefs_allow_popup_set(Prefs *prefs, char allow_popup) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->allow_popup = allow_popup; -} - -inline char -prefs_restore_state_get(const Prefs *prefs) -{ - return prefs->restore_state; -} - -inline void -prefs_restore_state_set(Prefs *prefs, char restore_state) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->restore_state = restore_state; -} - -inline void -prefs_state_add(Prefs *prefs, Prefs_Opened_Tab *prefs_opened_tab) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->state = eina_list_append(prefs->state, prefs_opened_tab); -} - -inline void -prefs_state_del(Prefs *prefs, Prefs_Opened_Tab *prefs_opened_tab) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->state = eina_list_remove(prefs->state, prefs_opened_tab); -} - -inline Prefs_Opened_Tab * -prefs_state_get(const Prefs *prefs, unsigned int nth) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(prefs, NULL); - return eina_list_nth(prefs->state, nth); -} - -inline unsigned int -prefs_state_count(const Prefs *prefs) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(prefs, 0); - return eina_list_count(prefs->state); -} - -void -prefs_state_list_clear(Prefs *prefs) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - Prefs_Opened_Tab *data; - EINA_LIST_FREE(prefs->state, data) prefs_opened_tab_free(data); -} - -inline Eina_List * -prefs_state_list_get(const Prefs *prefs) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(prefs, NULL); - return prefs->state; -} - -inline void -prefs_state_list_set(Prefs *prefs, Eina_List *list) -{ - EINA_SAFETY_ON_NULL_RETURN(prefs); - prefs->state = list; -} - -Prefs * -prefs_load(const char *filename) -{ - Prefs *prefs; - Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); - if (!ef) - { - fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); - return NULL; - } - - prefs = eet_data_read(ef, _prefs_descriptor, PREFS_ENTRY); - prefs->__eet_filename = eina_stringshare_add(filename); - - eet_close(ef); - return prefs; -} - -Eina_Bool -prefs_save(Prefs *prefs, const char *filename) -{ - char tmp[PATH_MAX]; - Eet_File *ef; - Eina_Bool ret; - unsigned int i, len; - struct stat st; - - if (filename) prefs->__eet_filename = eina_stringshare_add(filename); - else if (prefs->__eet_filename) filename = prefs->__eet_filename; - else return EINA_FALSE; - - len = eina_strlcpy(tmp, filename, sizeof(tmp)); - if (len + 12 >= (int)sizeof(tmp)) - { - fprintf(stderr, "ERROR: filename is too big: %s\n", filename); - return EINA_FALSE; - } - - i = 0; - do - { - snprintf(tmp + len, 12, ".%u", i); - i++; - } - while(stat(tmp, &st) == 0); - - ef = eet_open(tmp, EET_FILE_MODE_WRITE); - if (!ef) - { - fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp); - return EINA_FALSE; - } - - ret = !!eet_data_write(ef, _prefs_descriptor, PREFS_ENTRY, prefs, EINA_TRUE); - eet_close(ef); - - if (ret) - { - unlink(filename); - rename(tmp, filename); - } - - return ret; -} - -void -preferences_init(void) -{ - _prefs_opened_tab_init(); - _prefs_init(); -} - -void -preferences_shutdown(void) -{ - _prefs_opened_tab_shutdown(); - _prefs_shutdown(); -} - diff --git a/src/bin/prefs.h b/src/bin/prefs.h deleted file mode 100644 index f8dc178..0000000 --- a/src/bin/prefs.h +++ /dev/null @@ -1,63 +0,0 @@ -/* This file has been automatically generated by geneet.py */ -/* DO NOT MODIFY */ - -#ifndef __PREFERENCES_H__ -#define __PREFERENCES_H__ - -#include -#include - -typedef struct _Prefs_Opened_Tab Prefs_Opened_Tab; -typedef struct _Prefs Prefs; - -/* Prefs_Opened_Tab */ -Prefs_Opened_Tab *prefs_opened_tab_new(const char * address); -void prefs_opened_tab_free(Prefs_Opened_Tab *prefs_opened_tab); - -void prefs_opened_tab_address_set(Prefs_Opened_Tab *prefs_opened_tab, const char * address); -const char * prefs_opened_tab_address_get(const Prefs_Opened_Tab *prefs_opened_tab); - -/* Prefs */ -Prefs *prefs_new(char enable_mouse_cursor, char enable_touch_interface, char enable_plugins, char enable_javascript, const char * user_agent, const char * home_page, const char * proxy, char enable_private_mode, char enable_auto_load_images, char enable_auto_shrink_images, char allow_popup, char restore_state, Eina_List * state); -void prefs_free(Prefs *prefs); - -void prefs_enable_mouse_cursor_set(Prefs *prefs, char enable_mouse_cursor); -char prefs_enable_mouse_cursor_get(const Prefs *prefs); -void prefs_enable_touch_interface_set(Prefs *prefs, char enable_touch_interface); -char prefs_enable_touch_interface_get(const Prefs *prefs); -void prefs_enable_plugins_set(Prefs *prefs, char enable_plugins); -char prefs_enable_plugins_get(const Prefs *prefs); -void prefs_enable_javascript_set(Prefs *prefs, char enable_javascript); -char prefs_enable_javascript_get(const Prefs *prefs); -void prefs_user_agent_set(Prefs *prefs, const char * user_agent); -const char * prefs_user_agent_get(const Prefs *prefs); -void prefs_home_page_set(Prefs *prefs, const char * home_page); -const char * prefs_home_page_get(const Prefs *prefs); -void prefs_proxy_set(Prefs *prefs, const char * proxy); -const char * prefs_proxy_get(const Prefs *prefs); -void prefs_enable_private_mode_set(Prefs *prefs, char enable_private_mode); -char prefs_enable_private_mode_get(const Prefs *prefs); -void prefs_enable_auto_load_images_set(Prefs *prefs, char enable_auto_load_images); -char prefs_enable_auto_load_images_get(const Prefs *prefs); -void prefs_enable_auto_shrink_images_set(Prefs *prefs, char enable_auto_shrink_images); -char prefs_enable_auto_shrink_images_get(const Prefs *prefs); -void prefs_allow_popup_set(Prefs *prefs, char allow_popup); -char prefs_allow_popup_get(const Prefs *prefs); -void prefs_restore_state_set(Prefs *prefs, char restore_state); -char prefs_restore_state_get(const Prefs *prefs); -void prefs_state_add(Prefs *prefs, Prefs_Opened_Tab *prefs_opened_tab); -void prefs_state_del(Prefs *prefs, Prefs_Opened_Tab *prefs_opened_tab); -Prefs_Opened_Tab *prefs_state_get(const Prefs *prefs, unsigned int nth); -unsigned int prefs_state_count(const Prefs *prefs); -Eina_List *prefs_state_list_get(const Prefs *prefs); -void prefs_state_list_clear(Prefs *prefs); -void prefs_state_list_set(Prefs *prefs, Eina_List *list); - -Prefs *prefs_load(const char *filename); -Eina_Bool prefs_save(Prefs *prefs, const char *filename); - -/* Global initializer / shutdown functions */ -void preferences_init(void); -void preferences_shutdown(void); - -#endif /* __PREFERENCES_H__ */ diff --git a/src/bin/private.h b/src/bin/private.h index c5a5d7a..3b5c3c6 100644 --- a/src/bin/private.h +++ b/src/bin/private.h @@ -8,18 +8,16 @@ #include #include -#include "prefs.h" -#include "favorite.h" -#include "history.h" +#include "eve_state.h" typedef struct _App App; typedef struct _Browser_Window Browser_Window; typedef struct _View_Zoom_Interactive View_Zoom_Interactive; extern int _log_domain; -extern Fav *fav; extern Hist *hist; -extern Prefs *prefs; +extern Fav *fav; +extern Config *config; extern App app; #define CRITICAL(...) EINA_LOG_DOM_CRIT(_log_domain, __VA_ARGS__)