From c2a1c49ab2042f559b28e840e54feb8494888e0e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 23 Mar 2016 12:56:14 -0700 Subject: elementary: move all legacy files to their expected new location. --- src/modules/elementary/Makefile.am | 10 + src/modules/elementary/access_output/Makefile.am | 22 + src/modules/elementary/access_output/mod.c | 137 +++ .../elementary/datetime_input_ctxpopup/Makefile.am | 23 + .../datetime_input_ctxpopup.c | 398 +++++++ src/modules/elementary/prefs/Makefile.am | 56 + src/modules/elementary/prefs/elm_button.c | 72 ++ src/modules/elementary/prefs/elm_check.c | 99 ++ src/modules/elementary/prefs/elm_datetime.c | 100 ++ src/modules/elementary/prefs/elm_entry.c | 283 +++++ src/modules/elementary/prefs/elm_horizontal_box.c | 99 ++ .../elementary/prefs/elm_horizontal_frame.c | 118 ++ src/modules/elementary/prefs/elm_label.c | 37 + src/modules/elementary/prefs/elm_prefs_swallow.edc | 15 + src/modules/elementary/prefs/elm_separator.c | 59 + src/modules/elementary/prefs/elm_slider.c | 124 +++ src/modules/elementary/prefs/elm_spinner.c | 124 +++ src/modules/elementary/prefs/elm_swallow.c | 63 ++ src/modules/elementary/prefs/elm_vertical_box.c | 99 ++ src/modules/elementary/prefs/elm_vertical_frame.c | 117 ++ src/modules/elementary/prefs/item_widgets.inc | 9 + src/modules/elementary/prefs/page_widgets.inc | 4 + src/modules/elementary/prefs/prefs_iface.c | 287 +++++ src/modules/elementary/prefs/private.h | 127 +++ src/modules/elementary/test_entry/Makefile.am | 22 + src/modules/elementary/test_entry/mod.c | 51 + src/modules/elementary/test_map/Makefile.am | 22 + src/modules/elementary/test_map/mod.c | 103 ++ src/modules/elementary/web/Makefile.am | 6 + src/modules/elementary/web/none/.gitignore | 1 + src/modules/elementary/web/none/Makefile.am | 40 + src/modules/elementary/web/none/elm_web_none.c | 359 ++++++ src/modules/elementary/web/none/elm_web_none.eo | 51 + src/modules/elementary/web/webkit2/.gitignore | 1 + src/modules/elementary/web/webkit2/Makefile.am | 42 + .../elementary/web/webkit2/elm_web_webkit2.c | 1157 ++++++++++++++++++++ .../elementary/web/webkit2/elm_web_webkit2.eo | 53 + 37 files changed, 4390 insertions(+) create mode 100644 src/modules/elementary/Makefile.am create mode 100644 src/modules/elementary/access_output/Makefile.am create mode 100644 src/modules/elementary/access_output/mod.c create mode 100644 src/modules/elementary/datetime_input_ctxpopup/Makefile.am create mode 100644 src/modules/elementary/datetime_input_ctxpopup/datetime_input_ctxpopup.c create mode 100644 src/modules/elementary/prefs/Makefile.am create mode 100644 src/modules/elementary/prefs/elm_button.c create mode 100644 src/modules/elementary/prefs/elm_check.c create mode 100644 src/modules/elementary/prefs/elm_datetime.c create mode 100644 src/modules/elementary/prefs/elm_entry.c create mode 100644 src/modules/elementary/prefs/elm_horizontal_box.c create mode 100644 src/modules/elementary/prefs/elm_horizontal_frame.c create mode 100644 src/modules/elementary/prefs/elm_label.c create mode 100644 src/modules/elementary/prefs/elm_prefs_swallow.edc create mode 100644 src/modules/elementary/prefs/elm_separator.c create mode 100644 src/modules/elementary/prefs/elm_slider.c create mode 100644 src/modules/elementary/prefs/elm_spinner.c create mode 100644 src/modules/elementary/prefs/elm_swallow.c create mode 100644 src/modules/elementary/prefs/elm_vertical_box.c create mode 100644 src/modules/elementary/prefs/elm_vertical_frame.c create mode 100644 src/modules/elementary/prefs/item_widgets.inc create mode 100644 src/modules/elementary/prefs/page_widgets.inc create mode 100644 src/modules/elementary/prefs/prefs_iface.c create mode 100644 src/modules/elementary/prefs/private.h create mode 100644 src/modules/elementary/test_entry/Makefile.am create mode 100644 src/modules/elementary/test_entry/mod.c create mode 100644 src/modules/elementary/test_map/Makefile.am create mode 100644 src/modules/elementary/test_map/mod.c create mode 100644 src/modules/elementary/web/Makefile.am create mode 100644 src/modules/elementary/web/none/.gitignore create mode 100644 src/modules/elementary/web/none/Makefile.am create mode 100644 src/modules/elementary/web/none/elm_web_none.c create mode 100644 src/modules/elementary/web/none/elm_web_none.eo create mode 100644 src/modules/elementary/web/webkit2/.gitignore create mode 100644 src/modules/elementary/web/webkit2/Makefile.am create mode 100644 src/modules/elementary/web/webkit2/elm_web_webkit2.c create mode 100644 src/modules/elementary/web/webkit2/elm_web_webkit2.eo (limited to 'src/modules/elementary') diff --git a/src/modules/elementary/Makefile.am b/src/modules/elementary/Makefile.am new file mode 100644 index 0000000000..8ad4392dbd --- /dev/null +++ b/src/modules/elementary/Makefile.am @@ -0,0 +1,10 @@ +AUTOMAKE_OPTIONS = 1.4 foreign +MAINTAINERCLEANFILES = Makefile.in + +SUBDIRS = \ +prefs \ +test_entry \ +test_map \ +access_output \ +datetime_input_ctxpopup \ +web diff --git a/src/modules/elementary/access_output/Makefile.am b/src/modules/elementary/access_output/Makefile.am new file mode 100644 index 0000000000..941348ea35 --- /dev/null +++ b/src/modules/elementary/access_output/Makefile.am @@ -0,0 +1,22 @@ + +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-I. \ +-I$(top_builddir) \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DELEMENTARY_BUILD \ +@ELEMENTARY_CFLAGS@ + +pkgdir = $(pkglibdir)/modules/access_output/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la + +module_la_SOURCES = mod.c + +module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la +module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ +module_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/src/modules/elementary/access_output/mod.c b/src/modules/elementary/access_output/mod.c new file mode 100644 index 0000000000..0dff159885 --- /dev/null +++ b/src/modules/elementary/access_output/mod.c @@ -0,0 +1,137 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include + +/* to enable this module +export ELM_MODULES="access_output>access/api" +export ELM_ACCESS_MODE=1 + */ + +static void (*cb_func) (void *data); +static void *cb_data; +static Ecore_Exe *espeak = NULL; +static Ecore_Event_Handler *exe_exit_handler = NULL; +static char *tmpf = NULL; +static int tmpfd = -1; + +static Eina_Bool +_exe_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +{ + Ecore_Exe_Event_Del *ev = event; + + if ((espeak) && (ev->exe == espeak)) + { + if (tmpf) + { + unlink(tmpf); + free(tmpf); + tmpf = NULL; + close(tmpfd); + } + espeak = NULL; + if (cb_func) cb_func(cb_data); + } + return ECORE_CALLBACK_RENEW; +} + +// module api funcs needed +EAPI int +elm_modapi_init(void *m EINA_UNUSED) +{ + exe_exit_handler = + ecore_event_handler_add(ECORE_EXE_EVENT_DEL, + _exe_del, NULL); + return 1; // succeed always +} + +EAPI int +elm_modapi_shutdown(void *m EINA_UNUSED) +{ + if (exe_exit_handler) + { + ecore_event_handler_del(exe_exit_handler); + exe_exit_handler = NULL; + } + return 1; // succeed always +} + +// module fucns for the specific module type +EAPI void +out_read(const char *txt) +{ + if (!tmpf) + { + char buf[PATH_MAX]; + mode_t cur_umask; + + snprintf(buf, sizeof(buf), "/tmp/.elm-speak-XXXXXX"); + cur_umask = umask(S_IRWXO | S_IRWXG); + tmpfd = mkstemp(buf); + umask(cur_umask); + if (tmpfd >= 0) tmpf = strdup(buf); + else return; + } + if (write(tmpfd, txt, strlen(txt)) < 0) perror("write to tmpfile (espeak)"); +} + +EAPI void +out_read_done(void) +{ + char buf[PATH_MAX]; + + if (espeak) + { + ecore_exe_interrupt(espeak); + espeak = NULL; + } + if (tmpf) + { + // FIXME: espeak supporets -v XX for voice locale. should provide this + // based on actual lang/locale + close(tmpfd); + snprintf(buf, sizeof(buf), "espeak -p 2 -s 120 -k 10 -m -f %s", tmpf); + espeak = ecore_exe_pipe_run(buf, + ECORE_EXE_NOT_LEADER, + NULL); + } +} + +EAPI void +out_cancel(void) +{ + if (espeak) + { + ecore_exe_interrupt(espeak); + espeak = NULL; + } + if (tmpf) + { + unlink(tmpf); + free(tmpf); + tmpf = NULL; + close(tmpfd); + } +} + +EAPI void +out_done_callback_set(void (*func) (void *data), const void *data) +{ + cb_func = func; + cb_data = (void *)data; +} + +static Eina_Bool +_module_init(void) +{ + return EINA_TRUE; +} + +static void +_module_shutdown(void) +{ +} + +EINA_MODULE_INIT(_module_init); +EINA_MODULE_SHUTDOWN(_module_shutdown); diff --git a/src/modules/elementary/datetime_input_ctxpopup/Makefile.am b/src/modules/elementary/datetime_input_ctxpopup/Makefile.am new file mode 100644 index 0000000000..3f1350eb08 --- /dev/null +++ b/src/modules/elementary/datetime_input_ctxpopup/Makefile.am @@ -0,0 +1,23 @@ + +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-DELM_INTERNAL_API_ARGESFSDFEFC=1 \ +-I. \ +-I$(top_builddir) \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DELEMENTARY_BUILD \ +@ELEMENTARY_CFLAGS@ + +pkgdir = $(pkglibdir)/modules/datetime_input_ctxpopup/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la + +module_la_SOURCES = datetime_input_ctxpopup.c + +module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la +module_la_LDFLAGS = -no-undefined -module -avoid-version +module_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/src/modules/elementary/datetime_input_ctxpopup/datetime_input_ctxpopup.c b/src/modules/elementary/datetime_input_ctxpopup/datetime_input_ctxpopup.c new file mode 100644 index 0000000000..198f095a28 --- /dev/null +++ b/src/modules/elementary/datetime_input_ctxpopup/datetime_input_ctxpopup.c @@ -0,0 +1,398 @@ +#ifdef HAVE_CONFIG_H +#include "elementary_config.h" +#endif + +#include +#include "elm_widget.h" +#include "elm_widget_datetime.h" + +#define DATETIME_FIELD_COUNT 6 +#define FIELD_FORMAT_LEN 3 +#define DISKSELECTOR_MIN_ITEMS 4 +#define BUFF_SIZE 1024 + +typedef struct _Ctxpopup_Module_Data Ctxpopup_Module_Data; +typedef struct _DiskItem_Data DiskItem_Data; + +struct _Ctxpopup_Module_Data +{ + Elm_Datetime_Module_Data mod_data; + Evas_Object *ctxpopup; +}; + +struct _DiskItem_Data +{ + Ctxpopup_Module_Data *ctx_mod; + Elm_Datetime_Field_Type sel_field_type; + unsigned int sel_field_value; +}; + +static void +_diskselector_item_free_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + free(data); +} + +static Eina_Bool +_ctxpopup_dismissed_cb(void *data, const Eo_Event *event) +{ + Ctxpopup_Module_Data *ctx_mod; + ctx_mod = (Ctxpopup_Module_Data *)data; + evas_object_del(event->obj); + ctx_mod->ctxpopup = NULL; + + return EINA_TRUE; +} + +static void +_datetime_resize_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Ctxpopup_Module_Data *ctx_mod; + + ctx_mod = (Ctxpopup_Module_Data *)data; + if (!ctx_mod || !ctx_mod->ctxpopup) return; + + evas_object_hide(ctx_mod->ctxpopup); +} + +static void +_datetime_move_cb(void *data, Evas *e EINA_UNUSED,Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Ctxpopup_Module_Data *ctx_mod; + + ctx_mod = (Ctxpopup_Module_Data *)data; + if (!ctx_mod || !ctx_mod->ctxpopup) return; + + evas_object_hide(ctx_mod->ctxpopup); +} + +static void +_field_value_set(struct tm *tim, Elm_Datetime_Field_Type field_type, int val) +{ + if (field_type >= (DATETIME_FIELD_COUNT - 1)) return; + + int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour, &tim->tm_min }; + *timearr[field_type] = val; +} + +static int +_field_value_get(struct tm *tim, Elm_Datetime_Field_Type field_type) +{ + if (field_type >= (DATETIME_FIELD_COUNT - 1)) return -1; + + int *timearr[]= { &tim->tm_year, &tim->tm_mon, &tim->tm_mday, &tim->tm_hour, &tim->tm_min }; + return (*timearr[field_type]); +} + +static Eina_Bool +_diskselector_cb(void *data EINA_UNUSED, const Eo_Event *event) +{ + DiskItem_Data *disk_data; + struct tm curr_time; + const char *fmt; + + disk_data = (DiskItem_Data *)elm_object_item_data_get(event->event_info); + if (!disk_data || !(disk_data->ctx_mod)) return EINA_FALSE; + + elm_datetime_value_get(disk_data->ctx_mod->mod_data.base, &curr_time); + fmt = disk_data->ctx_mod->mod_data.field_format_get(disk_data->ctx_mod->mod_data.base, disk_data->sel_field_type); + if ((disk_data->sel_field_type == ELM_DATETIME_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) || + (!strncmp(fmt, "%l", FIELD_FORMAT_LEN))) && (curr_time.tm_hour >= 12)) + disk_data->sel_field_value += 12; + _field_value_set(&curr_time, disk_data->sel_field_type, disk_data->sel_field_value); + elm_datetime_value_set(disk_data->ctx_mod->mod_data.base, &curr_time); + evas_object_hide(disk_data->ctx_mod->ctxpopup); + + return EINA_TRUE; +} + +static Eina_Bool +_ampm_clicked_cb(void *data, const Eo_Event *event EINA_UNUSED) +{ + Ctxpopup_Module_Data *ctx_mod; + struct tm curr_time; + + ctx_mod = (Ctxpopup_Module_Data *)data; + if (!ctx_mod) return EINA_FALSE; + + elm_datetime_value_get(ctx_mod->mod_data.base, &curr_time); + if (curr_time.tm_hour >= 12) curr_time.tm_hour -= 12; + else curr_time.tm_hour += 12; + elm_datetime_value_set(ctx_mod->mod_data.base, &curr_time); + return EINA_TRUE; +} + +static Eina_Bool +_field_clicked_cb(void *data, const Eo_Event *event) +{ + Ctxpopup_Module_Data *ctx_mod; + Evas_Object *diskselector; + Elm_Object_Item *item; + DiskItem_Data *disk_data; + Elm_Datetime_Field_Type field_type; + time_t t; + struct tm time1; + char buf[BUFF_SIZE], label[BUFF_SIZE]; + const char *fmt; + int idx, min, max, val; + unsigned int display_item_num, text_len = 0; + Evas_Coord x = 0, y = 0, w = 0, h = 0, width; + + ctx_mod = (Ctxpopup_Module_Data *)data; + if (!ctx_mod) return EINA_FALSE; + + snprintf(buf, sizeof(buf), "datetime/%s", elm_object_style_get(event->obj)); + + ctx_mod->ctxpopup = elm_ctxpopup_add(event->obj); + elm_object_style_set(ctx_mod->ctxpopup, buf); + elm_ctxpopup_horizontal_set(ctx_mod->ctxpopup, EINA_TRUE); + evas_object_size_hint_weight_set(ctx_mod->ctxpopup, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(ctx_mod->ctxpopup, EVAS_HINT_FILL, 0.5); + eo_event_callback_add + (ctx_mod->ctxpopup, ELM_CTXPOPUP_EVENT_DISMISSED, _ctxpopup_dismissed_cb, ctx_mod); + elm_ctxpopup_hover_parent_set(ctx_mod->ctxpopup, elm_widget_top_get(event->obj)); + + diskselector = elm_diskselector_add(elm_widget_top_get(ctx_mod->mod_data.base)); + eo_event_callback_add + (diskselector, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _diskselector_cb, NULL); + elm_object_style_set(diskselector, buf); + elm_object_content_set(ctx_mod->ctxpopup, diskselector); + + t = time(NULL); + localtime_r(&t, &time1); + + field_type = (Elm_Datetime_Field_Type )evas_object_data_get(event->obj, "_field_type"); + fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type); + elm_datetime_value_get(ctx_mod->mod_data.base, &time1); + val = _field_value_get(&time1, field_type); + ctx_mod->mod_data.field_limit_get(ctx_mod->mod_data.base, field_type, &min, &max); + + time1.tm_mday = 1; // To avoid month wrapping, set the first day of the month to start with. + + if ((field_type == ELM_DATETIME_HOUR) && ((!strncmp(fmt, "%I", FIELD_FORMAT_LEN)) || + (!strncmp(fmt, "%l", FIELD_FORMAT_LEN)))) + { + if (max >= 12) max -= 12; + if (val >= 12) val -= 12; + if (min >= 12) min -= 12; + } + for (idx = min; idx <= max; idx++) + { + _field_value_set(&time1, field_type, idx); + strftime(label, BUFF_SIZE, fmt, &time1); + if (strlen(label) > text_len) text_len = strlen(label); + if (idx == val) + { + item = elm_diskselector_item_append(diskselector, label, NULL, NULL, NULL); + elm_diskselector_item_selected_set(item, EINA_TRUE); + } + else + { + disk_data = (DiskItem_Data *) malloc (sizeof(DiskItem_Data)); + disk_data->ctx_mod = ctx_mod; + disk_data->sel_field_type = field_type; + disk_data->sel_field_value = idx; + item = elm_diskselector_item_append(diskselector, label, NULL, NULL, disk_data); + elm_object_item_del_cb_set(item, _diskselector_item_free_cb); + } + } + elm_diskselector_side_text_max_length_set(diskselector, text_len); + + evas_object_geometry_get(event->obj, &x, &y, &w, &h); + evas_object_geometry_get(elm_widget_top_get(ctx_mod->mod_data.base), NULL, NULL, &width, NULL); + evas_object_size_hint_min_set(ctx_mod->ctxpopup, width, -1); + display_item_num = width / (w + elm_config_finger_size_get()); + // always display even number of items to avoid autoselection + if (display_item_num % 2) display_item_num -= 1; + if (display_item_num < DISKSELECTOR_MIN_ITEMS) + display_item_num = DISKSELECTOR_MIN_ITEMS; + elm_diskselector_display_item_num_set(diskselector, display_item_num); + elm_diskselector_round_enabled_set(diskselector, EINA_TRUE); + + elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_DOWN, + ELM_CTXPOPUP_DIRECTION_UP, -1, -1); + evas_object_move(ctx_mod->ctxpopup, (x+w/2), (y+h)); + + // if the direction of Ctxpopup is upwards, move it to the top of datetime + if (elm_ctxpopup_direction_get(ctx_mod->ctxpopup) == ELM_CTXPOPUP_DIRECTION_UP) + { + elm_ctxpopup_direction_priority_set(ctx_mod->ctxpopup, ELM_CTXPOPUP_DIRECTION_UP, + ELM_CTXPOPUP_DIRECTION_DOWN, -1, -1); + evas_object_move(ctx_mod->ctxpopup, (x + w / 2), y); + } + evas_object_show(ctx_mod->ctxpopup); + return EINA_TRUE; +} + +static void +_access_set(Evas_Object *obj, Elm_Datetime_Field_Type field_type) +{ + const char* type = NULL; + + switch (field_type) + { + case ELM_DATETIME_YEAR: + type = "datetime field, year"; + break; + + case ELM_DATETIME_MONTH: + type = "datetime field, month"; + break; + + case ELM_DATETIME_DATE: + type = "datetime field, date"; + break; + + case ELM_DATETIME_HOUR: + type = "datetime field, hour"; + break; + + case ELM_DATETIME_MINUTE: + type = "datetime field, minute"; + break; + + case ELM_DATETIME_AMPM: + type = "datetime field, AM PM"; + break; + + default: + break; + } + + _elm_access_text_set + (_elm_access_info_get(obj), ELM_ACCESS_TYPE, type); + _elm_access_callback_set + (_elm_access_info_get(obj), ELM_ACCESS_STATE, NULL, NULL); +} + +// module funcs for the specific module type +EAPI void +field_value_display(Elm_Datetime_Module_Data *module_data, Evas_Object *obj) +{ + Ctxpopup_Module_Data *ctx_mod; + Elm_Datetime_Field_Type field_type; + struct tm tim; + char buf[BUFF_SIZE]; + const char *fmt; + + ctx_mod = (Ctxpopup_Module_Data *)module_data; + if (!ctx_mod || !obj) return; + + elm_datetime_value_get(ctx_mod->mod_data.base, &tim); + field_type = (Elm_Datetime_Field_Type )evas_object_data_get(obj, "_field_type"); + fmt = ctx_mod->mod_data.field_format_get(ctx_mod->mod_data.base, field_type); + buf[0] = 0; + strftime(buf, sizeof(buf), fmt, &tim); + if ((!buf[0]) && ((!strcmp(fmt, "%p")) || (!strcmp(fmt, "%P")))) + { + // yes BUFF_SIZE is more than 2 bytes! + if (tim.tm_hour < 12) strcpy(buf, "AM"); + else strcpy(buf, "PM"); + } + elm_object_text_set(obj, buf); +} + +EAPI Evas_Object * +field_create(Elm_Datetime_Module_Data *module_data, Elm_Datetime_Field_Type field_type) +{ + Ctxpopup_Module_Data *ctx_mod; + Evas_Object *field_obj; + + ctx_mod = (Ctxpopup_Module_Data *)module_data; + if (!ctx_mod) return NULL; + + if (field_type == ELM_DATETIME_AMPM) + { + field_obj = elm_button_add(ctx_mod->mod_data.base); + eo_event_callback_add + (field_obj, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _ampm_clicked_cb, ctx_mod); + } + else + { + field_obj = elm_entry_add(ctx_mod->mod_data.base); + elm_entry_single_line_set(field_obj, EINA_TRUE); + elm_entry_editable_set(field_obj, EINA_FALSE); + elm_entry_input_panel_enabled_set(field_obj, EINA_FALSE); + elm_entry_context_menu_disabled_set(field_obj, EINA_TRUE); + eo_event_callback_add + (field_obj, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _field_clicked_cb, ctx_mod); + } + evas_object_data_set(field_obj, "_field_type", (void *)field_type); + + // ACCESS + _access_set(field_obj, field_type); + + return field_obj; +} + +EAPI Elm_Datetime_Module_Data * +obj_hook(Evas_Object *obj) +{ + Ctxpopup_Module_Data *ctx_mod; + ctx_mod = calloc(1, sizeof(Ctxpopup_Module_Data)); + if (!ctx_mod) return NULL; + + evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, + _datetime_resize_cb, ctx_mod); + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, + _datetime_move_cb, ctx_mod); + + return ((Elm_Datetime_Module_Data*)ctx_mod); +} + +EAPI void +obj_unhook(Elm_Datetime_Module_Data *module_data) +{ + Ctxpopup_Module_Data *ctx_mod; + + ctx_mod = (Ctxpopup_Module_Data *)module_data; + if (!ctx_mod) return; + + if (ctx_mod->ctxpopup) + evas_object_del(ctx_mod->ctxpopup); + + free(ctx_mod); + ctx_mod = NULL; +} + +EAPI void +obj_hide(Elm_Datetime_Module_Data *module_data) +{ + Ctxpopup_Module_Data *ctx_mod; + + ctx_mod = (Ctxpopup_Module_Data *)module_data; + if (!ctx_mod) return; + + if (ctx_mod->ctxpopup) + evas_object_hide(ctx_mod->ctxpopup); +} + +// module api funcs needed +EAPI int +elm_modapi_init(void *m EINA_UNUSED) +{ + return 1; // succeed always +} + +EAPI int +elm_modapi_shutdown(void *m EINA_UNUSED) +{ + return 1; // succeed always +} + +static Eina_Bool +_module_init(void) +{ + return EINA_TRUE; +} + +static void +_module_shutdown(void) +{ +} + +EINA_MODULE_INIT(_module_init); +EINA_MODULE_SHUTDOWN(_module_shutdown); diff --git a/src/modules/elementary/prefs/Makefile.am b/src/modules/elementary/prefs/Makefile.am new file mode 100644 index 0000000000..d7280cb137 --- /dev/null +++ b/src/modules/elementary/prefs/Makefile.am @@ -0,0 +1,56 @@ +MAINTAINERCLEANFILES = Makefile.in + +include ../../../Makefile_Elm_Helpers.am + +EXTRA_DIST = \ +elm_prefs_swallow.edc + +filesdir = $(pkglibdir)/modules/prefs/$(MODULE_ARCH) +files_DATA = elm_prefs_swallow.edj + +elm_prefs_swallow.edj: Makefile elm_prefs_swallow.edc + $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) \ + $(top_srcdir)/src/modules/prefs/elm_prefs_swallow.edc \ + $(top_builddir)/src/modules/prefs/elm_prefs_swallow.edj + +AM_CPPFLAGS = \ +-DELM_INTERNAL_API_ARGESFSDFEFC=1 \ +-I. \ +-I$(top_builddir) \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \ +-DLOCALE_DIR=\"$(localedir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DELEMENTARY_BUILD \ +@ELEMENTARY_CFLAGS@ + +pkgdir = $(pkglibdir)/modules/prefs/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la + +module_la_SOURCES = \ +private.h \ +item_widgets.inc \ +page_widgets.inc \ +prefs_iface.c \ +elm_button.c \ +elm_check.c \ +elm_datetime.c \ +elm_entry.c \ +elm_label.c \ +elm_separator.c \ +elm_slider.c \ +elm_spinner.c \ +elm_swallow.c \ +elm_vertical_box.c \ +elm_horizontal_box.c \ +elm_vertical_frame.c \ +elm_horizontal_frame.c + +module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la +module_la_LDFLAGS = -no-undefined -module -avoid-version +module_la_LIBTOOLFLAGS = --tag=disable-static + +clean-local: + rm -f *.edj diff --git a/src/modules/elementary/prefs/elm_button.c b/src/modules/elementary/prefs/elm_button.c new file mode 100644 index 0000000000..4cccfb181a --- /dev/null +++ b/src/modules/elementary/prefs/elm_button.c @@ -0,0 +1,72 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_ACTION, + ELM_PREFS_TYPE_RESET, + ELM_PREFS_TYPE_SAVE, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Eina_Bool +_item_changed_cb(void *data, const Eo_Event *event) +{ + Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data; + + prefs_it_changed_cb(event->obj); + return EINA_TRUE; +} + +static Evas_Object * +elm_prefs_button_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type EINA_UNUSED, + const Elm_Prefs_Item_Spec spec EINA_UNUSED, + Elm_Prefs_Item_Changed_Cb cb) +{ + Evas_Object *obj = elm_button_add(prefs); + + eo_event_callback_add + (obj, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _item_changed_cb, cb); + + return obj; +} + +static Eina_Bool +elm_prefs_button_label_set(Evas_Object *obj, + const char *label) +{ + return elm_layout_text_set(obj, NULL, label); +} + +static Eina_Bool +elm_prefs_button_icon_set(Evas_Object *obj, + const char *icon) +{ + Evas_Object *ic = elm_icon_add(obj); + Eina_Bool ret; + + if (!elm_icon_standard_set(ic, icon)) goto err; + + elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); + + ret = elm_layout_content_set(obj, "icon", ic); + if (!ret) goto err; + + return ret; + +err: + evas_object_del(ic); + return EINA_FALSE; +} + +PREFS_ITEM_WIDGET_ADD(button, + supported_types, + NULL, + NULL, + NULL, + elm_prefs_button_label_set, + elm_prefs_button_icon_set, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_check.c b/src/modules/elementary/prefs/elm_check.c new file mode 100644 index 0000000000..2b02d0dde3 --- /dev/null +++ b/src/modules/elementary/prefs/elm_check.c @@ -0,0 +1,99 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_BOOL, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Eina_Bool +_item_changed_cb(void *data, const Eo_Event *event) +{ + Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data; + + prefs_it_changed_cb(event->obj); + return EINA_TRUE; +} + +static Evas_Object * +elm_prefs_check_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type EINA_UNUSED, + const Elm_Prefs_Item_Spec spec, + Elm_Prefs_Item_Changed_Cb cb) +{ + Evas_Object *obj = elm_check_add(prefs); + + eo_event_callback_add + (obj, ELM_CHECK_EVENT_CHANGED, _item_changed_cb, cb); + elm_check_state_set(obj, spec.b.def); + + return obj; +} + +static Eina_Bool +elm_prefs_check_value_set(Evas_Object *obj, + Eina_Value *value) +{ + Eina_Bool val; + + if (eina_value_type_get(value) != EINA_VALUE_TYPE_UCHAR) return EINA_FALSE; + + eina_value_get(value, &val); + elm_check_state_set(obj, val); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_check_value_get(Evas_Object *obj, + Eina_Value *value) +{ + Eina_Bool val; + + val = elm_check_state_get(obj); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_UCHAR)) return EINA_FALSE; + if (!eina_value_set(value, val)) return EINA_FALSE; + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_check_label_set(Evas_Object *obj, + const char *label) +{ + return elm_layout_text_set(obj, NULL, label); +} + +static Eina_Bool +elm_prefs_check_icon_set(Evas_Object *obj, + const char *icon) +{ + Evas_Object *ic = elm_icon_add(obj); + Eina_Bool ret; + + if (!elm_icon_standard_set(ic, icon)) goto err; + + elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); + + ret = elm_layout_content_set(obj, "icon", ic); + if (!ret) goto err; + + return ret; + +err: + evas_object_del(ic); + return EINA_FALSE; +} + +PREFS_ITEM_WIDGET_ADD(check, + supported_types, + elm_prefs_check_value_set, + elm_prefs_check_value_get, + NULL, + elm_prefs_check_label_set, + elm_prefs_check_icon_set, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_datetime.c b/src/modules/elementary/prefs/elm_datetime.c new file mode 100644 index 0000000000..86b4729d68 --- /dev/null +++ b/src/modules/elementary/prefs/elm_datetime.c @@ -0,0 +1,100 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_DATE, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Eina_Bool +_item_changed_cb(void *data, const Eo_Event *event) +{ + Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data; + + prefs_it_changed_cb(event->obj); + return EINA_TRUE; +} + +static Evas_Object * +elm_prefs_datetime_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type EINA_UNUSED, + const Elm_Prefs_Item_Spec spec, + Elm_Prefs_Item_Changed_Cb cb) +{ + Evas_Object *obj = elm_datetime_add(prefs); + struct tm t; + + memset(&t, 0, sizeof t); + + elm_datetime_field_visible_set(obj, ELM_DATETIME_HOUR, EINA_FALSE); + elm_datetime_field_visible_set(obj, ELM_DATETIME_MINUTE, EINA_FALSE); + elm_datetime_field_visible_set(obj, ELM_DATETIME_AMPM, EINA_FALSE); + + eo_event_callback_add + (obj, ELM_DATETIME_EVENT_CHANGED, _item_changed_cb, cb); + + t.tm_year = spec.d.min.y - 1900; + t.tm_mon = spec.d.min.m - 1; + t.tm_mday = spec.d.min.d; + + elm_datetime_value_min_set(obj, &t); + + t.tm_year = spec.d.max.y - 1900; + t.tm_mon = spec.d.max.m - 1; + t.tm_mday = spec.d.max.d; + + elm_datetime_value_max_set(obj, &t); + + return obj; +} + +static Eina_Bool +elm_prefs_datetime_value_set(Evas_Object *obj, + Eina_Value *value) +{ + struct timeval val; + struct tm *t; + time_t gmt; + + if (eina_value_type_get(value) != EINA_VALUE_TYPE_TIMEVAL) + return EINA_FALSE; + + eina_value_get(value, &val); + gmt = val.tv_sec; + t = gmtime(&gmt); + + if (elm_datetime_value_set(obj, t)) return EINA_TRUE; + + return EINA_FALSE; +} + +static Eina_Bool +elm_prefs_datetime_value_get(Evas_Object *obj, + Eina_Value *value) +{ + struct timeval val; + struct tm t; + + memset(&val, 0, sizeof val); + + if (!elm_datetime_value_get(obj, &t)) return EINA_FALSE; + + val.tv_sec = mktime(&t); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_TIMEVAL)) return EINA_FALSE; + if (!eina_value_set(value, val)) return EINA_FALSE; + + return EINA_TRUE; +} + +PREFS_ITEM_WIDGET_ADD(datetime, + supported_types, + elm_prefs_datetime_value_set, + elm_prefs_datetime_value_get, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_entry.c b/src/modules/elementary/prefs/elm_entry.c new file mode 100644 index 0000000000..9bd0dcc57a --- /dev/null +++ b/src/modules/elementary/prefs/elm_entry.c @@ -0,0 +1,283 @@ +#include "private.h" +#include "elm_widget.h" +#include +#include + +#define BLINK_INTERVAL 0.1 + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_TEXT, + ELM_PREFS_TYPE_TEXTAREA, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Eina_Bool +_color_change_do(void *data) +{ + Evas_Object *obj = data; + int color; + + color = (int)(uintptr_t)evas_object_data_get(obj, "current_color"); + switch (color) + { + case 0: + evas_object_data_set(obj, "current_color", (void *)1); + evas_object_color_set(obj, 255, 0, 0, 255); /* 1st red */ + goto renew; + + case 1: + evas_object_data_set(obj, "current_color", (void *)2); + evas_object_color_set(obj, 255, 255, 255, 255); /* 2nd white */ + goto renew; + + case 2: + evas_object_data_set(obj, "current_color", (void *)3); + evas_object_color_set(obj, 255, 0, 0, 255); /* 2nd red */ + goto renew; + + case 3: + default: + evas_object_data_set(obj, "current_color", (void *)0); + evas_object_color_set(obj, 255, 255, 255, 255); /* back to white */ + goto end; + } + +renew: + return ECORE_CALLBACK_RENEW; + +end: + evas_object_data_del(obj, "timer"); + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool +elm_prefs_entry_value_validate(Evas_Object *obj) +{ + Ecore_Timer *timer; + const char *val; + regex_t *regex; + size_t min; + + val = elm_entry_entry_get(obj); + if (!val) return EINA_FALSE; + + regex = evas_object_data_get(obj, "accept_regex"); + if (regex) + { + if (regexec(regex, val, 0, NULL, 0)) goto mismatch; + } + + regex = evas_object_data_get(obj, "deny_regex"); + if (regex) + { + /* we want tokens *out* of the deny language */ + if (!regexec(regex, val, 0, NULL, 0)) goto mismatch; + } + + min = (size_t) evas_object_data_get(obj, "min_size"); + if (min) + { + if (strlen(val) < min) goto mismatch; + } + + return EINA_TRUE; + +mismatch: + evas_object_color_set(obj, 255, 0, 0, 255); + + timer = evas_object_data_get(obj, "timer"); + if (timer) ecore_timer_del(timer); + + evas_object_data_set + (obj, "timer", ecore_timer_add(BLINK_INTERVAL, _color_change_do, obj)); + + return EINA_FALSE; +} + +static Eina_Bool +_item_changed_cb(void *data, const Eo_Event *event) +{ + Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data; + + prefs_it_changed_cb(event->obj); + return EINA_TRUE; +} + +static void +_entry_del_cb(void *data EINA_UNUSED, + Evas *evas EINA_UNUSED, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + regex_t *regex; + Ecore_Timer *timer; + + regex = evas_object_data_del(obj, "accept_regex"); + if (regex) regfree(regex); + + regex = evas_object_data_del(obj, "deny_regex"); + if (regex) regfree(regex); + + timer = evas_object_data_del(obj, "timer"); + if (timer) ecore_timer_del(timer); + + evas_object_data_del(obj, "min_size"); +} + +static Evas_Object * +elm_prefs_entry_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Spec spec, + Elm_Prefs_Item_Changed_Cb cb) +{ + Evas_Object *obj = elm_entry_add(prefs); + regex_t *regex = NULL; + char buf[256]; + + Elm_Entry_Filter_Limit_Size limit = { + .max_char_count = spec.s.length.max + }; + + evas_object_data_set(obj, "prefs_type", (void *)type); + + /* FIXME: have this warning animation on the theme, later */ + + /* 0: orig. white; 1: 1st red; 2: 2nd white; 3: 2o red */ + evas_object_data_set(obj, "current_color", 0); + + /* FIXME: is it worth to ERR with the item's name, too, here? */ + + eo_event_callback_add + (obj, ELM_ENTRY_EVENT_ACTIVATED, _item_changed_cb, cb); + eo_event_callback_add + (obj, ELM_WIDGET_EVENT_UNFOCUSED, _item_changed_cb, cb); + if (spec.s.accept) + { + int ret; + + regex = calloc(1, sizeof(regex_t)); + ret = regcomp(regex, spec.s.accept, REG_EXTENDED | REG_NOSUB); + + if (ret) + { + regerror(ret, regex, buf, sizeof(buf)); + regfree(regex); + ERR("bad regular expression (%s) on item's 'accept' tag (%s)." + " Because of that, the 'accept' tag will be dropped for the " + "item.", spec.s.accept, buf); + } + else + evas_object_data_set(obj, "accept_regex", regex); + } + + if (spec.s.deny) + { + int ret; + + regex = calloc(1, sizeof(regex_t)); + ret = regcomp(regex, spec.s.deny, REG_EXTENDED | REG_NOSUB); + + if (ret) + { + regerror(ret, regex, buf, sizeof(buf)); + regfree(regex); + ERR("bad regular expression (%s) on item's 'deny' tag (%s)." + " Because of that, the 'deny' tag will be dropped for the " + "item.", spec.s.deny, buf); + } + else + evas_object_data_set(obj, "deny_regex", regex); + } + + if (spec.s.length.min) /* zero makes no sense */ + { + size_t min = (size_t) spec.s.length.min; + evas_object_data_set(obj, "min_size", (void *) min); + } + + evas_object_event_callback_add + (obj, EVAS_CALLBACK_DEL, _entry_del_cb, NULL); + + elm_entry_scrollable_set(obj, EINA_TRUE); + + if (type == ELM_PREFS_TYPE_TEXT) + elm_entry_single_line_set(obj, EINA_TRUE); + + elm_entry_markup_filter_append(obj, elm_entry_filter_limit_size, &limit); + elm_layout_text_set(obj, NULL, spec.s.placeholder); + + regfree(regex); + return obj; +} + +/* already expects an EINA_VALUE_TYPE_STRINGSHARE one */ +static Eina_Bool +elm_prefs_entry_value_set(Evas_Object *obj, + Eina_Value *value) +{ + const char *val; + + eina_value_get(value, &val); + + return elm_layout_text_set(obj, NULL, val); +} + +static Eina_Bool +elm_prefs_entry_value_get(Evas_Object *obj, + Eina_Value *value) +{ + const char *val; + + val = elm_layout_text_get(obj, NULL); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_STRINGSHARE)) + return EINA_FALSE; + if (!eina_value_set(value, val)) return EINA_FALSE; + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_entry_icon_set(Evas_Object *obj, + const char *icon) +{ + Evas_Object *ic = elm_icon_add(obj); + + elm_icon_standard_set(ic, icon); + + return elm_layout_content_set(obj, "icon", ic); +} + +static Eina_Bool +elm_prefs_entry_editable_set(Evas_Object *obj, + Eina_Bool editable) +{ + elm_entry_editable_set(obj, editable); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_entry_editable_get(Evas_Object *obj) +{ + return elm_entry_editable_get(obj); +} + +static Eina_Bool +elm_prefs_entry_expand_want(Evas_Object *obj EINA_UNUSED) +{ + return EINA_TRUE; +} + +PREFS_ITEM_WIDGET_ADD(entry, + supported_types, + elm_prefs_entry_value_set, + elm_prefs_entry_value_get, + elm_prefs_entry_value_validate, + NULL, + elm_prefs_entry_icon_set, + elm_prefs_entry_editable_set, + elm_prefs_entry_editable_get, + elm_prefs_entry_expand_want); diff --git a/src/modules/elementary/prefs/elm_horizontal_box.c b/src/modules/elementary/prefs/elm_horizontal_box.c new file mode 100644 index 0000000000..5bf58b4f20 --- /dev/null +++ b/src/modules/elementary/prefs/elm_horizontal_box.c @@ -0,0 +1,99 @@ +#include "private.h" + +static Evas_Object * +elm_prefs_horizontal_box_add(const Elm_Prefs_Page_Iface *iface EINA_UNUSED, + Evas_Object *prefs) +{ + Evas_Object *obj = elm_box_add(prefs); + + elm_box_horizontal_set(obj, EINA_TRUE); + + return obj; +} + +static Eina_Bool +elm_prefs_horizontal_box_item_pack(Evas_Object *obj, + Evas_Object *it, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l; + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 1.0, 0.5); + + elm_prefs_horizontal_page_common_pack(it, obj, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_horizontal_box_item_unpack(Evas_Object *obj, + Evas_Object *it) +{ + /* back to defaults */ + evas_object_size_hint_align_set(it, 0.5, 0.5); + evas_object_size_hint_weight_set(it, 0.0, 0.0); + + elm_prefs_page_common_unpack(it, obj); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_horizontal_box_item_pack_before(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_before, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l; + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 1.0, 0.5); + + elm_prefs_horizontal_page_common_pack_before(it, it_before, obj, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_horizontal_box_item_pack_after(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_after, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l; + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 1.0, 0.5); + + elm_prefs_horizontal_page_common_pack_after(it, it_after, obj, iface); + + return EINA_TRUE; +} + +PREFS_PAGE_WIDGET_ADD(horizontal_box, + NULL, + NULL, + NULL, + elm_prefs_horizontal_box_item_pack, + elm_prefs_horizontal_box_item_unpack, + elm_prefs_horizontal_box_item_pack_before, + elm_prefs_horizontal_box_item_pack_after); diff --git a/src/modules/elementary/prefs/elm_horizontal_frame.c b/src/modules/elementary/prefs/elm_horizontal_frame.c new file mode 100644 index 0000000000..b848e3dea1 --- /dev/null +++ b/src/modules/elementary/prefs/elm_horizontal_frame.c @@ -0,0 +1,118 @@ +#include "private.h" + +static Evas_Object * +elm_prefs_horizontal_frame_add(const Elm_Prefs_Page_Iface *iface EINA_UNUSED, + Evas_Object *prefs) +{ + Evas_Object *bx, *obj = elm_frame_add(prefs); + + bx = elm_box_add(obj); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_box_horizontal_set(bx, EINA_TRUE); + + elm_layout_content_set(obj, NULL, bx); + + evas_object_data_set(obj, "bx_container", bx); + + return obj; +} + +static Eina_Bool +elm_prefs_horizontal_frame_title_set(Evas_Object *obj, + const char *title) +{ + elm_layout_text_set(obj, NULL, title); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_horizontal_frame_item_pack(Evas_Object *obj, + Evas_Object *it, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container"); + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 1.0, 0.5); + + elm_prefs_horizontal_page_common_pack(it, bx, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_horizontal_frame_item_unpack(Evas_Object *obj, + Evas_Object *it) +{ + Evas_Object *bx = evas_object_data_get(obj, "bx_container"); + + /* back to defaults */ + evas_object_size_hint_align_set(it, 0.5, 0.5); + evas_object_size_hint_weight_set(it, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_prefs_page_common_unpack(it, bx); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_horizontal_frame_item_pack_before(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_before, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container"); + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 1.0, 0.5); + + elm_prefs_horizontal_page_common_pack_before(it, it_before, bx, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_horizontal_frame_item_pack_after(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_after, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container"); + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_FALSE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 1.0, 0.5); + + elm_prefs_horizontal_page_common_pack_after(it, it_after, bx, iface); + + return EINA_TRUE; +} + +PREFS_PAGE_WIDGET_ADD(horizontal_frame, + elm_prefs_horizontal_frame_title_set, + NULL, + NULL, + elm_prefs_horizontal_frame_item_pack, + elm_prefs_horizontal_frame_item_unpack, + elm_prefs_horizontal_frame_item_pack_before, + elm_prefs_horizontal_frame_item_pack_after); diff --git a/src/modules/elementary/prefs/elm_label.c b/src/modules/elementary/prefs/elm_label.c new file mode 100644 index 0000000000..8ea7e66a9e --- /dev/null +++ b/src/modules/elementary/prefs/elm_label.c @@ -0,0 +1,37 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_LABEL, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Evas_Object * +elm_prefs_label_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type EINA_UNUSED, + const Elm_Prefs_Item_Spec spec EINA_UNUSED, + Elm_Prefs_Item_Changed_Cb it_changed_cb EINA_UNUSED) +{ + Evas_Object *obj = elm_label_add(prefs); + + return obj; +} + +static Eina_Bool +elm_prefs_label_label_set(Evas_Object *obj, + const char *label) +{ + return elm_layout_text_set(obj, NULL, label); +} + +PREFS_ITEM_WIDGET_ADD(label, + supported_types, + NULL, + NULL, + NULL, + elm_prefs_label_label_set, + NULL, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_prefs_swallow.edc b/src/modules/elementary/prefs/elm_prefs_swallow.edc new file mode 100644 index 0000000000..730d0c1777 --- /dev/null +++ b/src/modules/elementary/prefs/elm_prefs_swallow.edc @@ -0,0 +1,15 @@ +collections { + group { + name: "elm_prefs_swallow"; + + parts { + part { + name: "content"; + type: SWALLOW; + + description { + } + } + } + } +} diff --git a/src/modules/elementary/prefs/elm_separator.c b/src/modules/elementary/prefs/elm_separator.c new file mode 100644 index 0000000000..1d72a4b6a0 --- /dev/null +++ b/src/modules/elementary/prefs/elm_separator.c @@ -0,0 +1,59 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_SEPARATOR, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Evas_Object * +elm_prefs_separator_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type EINA_UNUSED, + const Elm_Prefs_Item_Spec spec EINA_UNUSED, + Elm_Prefs_Item_Changed_Cb cb EINA_UNUSED) +{ + Evas_Object *obj = elm_separator_add(prefs); + + return obj; +} + +static Eina_Bool +elm_prefs_separator_value_set(Evas_Object *obj, + Eina_Value *value) +{ + Eina_Bool val; + + if (eina_value_type_get(value) != EINA_VALUE_TYPE_UCHAR) + return EINA_FALSE; + + eina_value_get(value, &val); + elm_separator_horizontal_set(obj, val); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_separator_value_get(Evas_Object *obj, + Eina_Value *value) +{ + Eina_Bool val = elm_separator_horizontal_get(obj); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_UCHAR)) + return EINA_FALSE; + + if (!eina_value_set(value, val)) return EINA_FALSE; + + return EINA_TRUE; +} + +PREFS_ITEM_WIDGET_ADD(separator, + supported_types, + elm_prefs_separator_value_set, + elm_prefs_separator_value_get, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_slider.c b/src/modules/elementary/prefs/elm_slider.c new file mode 100644 index 0000000000..e03a1e1646 --- /dev/null +++ b/src/modules/elementary/prefs/elm_slider.c @@ -0,0 +1,124 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_INT, + ELM_PREFS_TYPE_FLOAT, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Eina_Bool +_item_changed_cb(void *data, const Eo_Event *event) +{ + Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data; + + prefs_it_changed_cb(event->obj); + return EINA_TRUE; +} + +static Evas_Object * +elm_prefs_slider_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Spec spec, + Elm_Prefs_Item_Changed_Cb cb) +{ + Evas_Object *obj = elm_slider_add(prefs); + + evas_object_data_set(obj, "prefs_type", (void *)type); + + eo_event_callback_add + (obj, ELM_SLIDER_EVENT_CHANGED, _item_changed_cb, cb); + if (type == ELM_PREFS_TYPE_INT) + { + elm_slider_unit_format_set(obj, "%1.0f"); + elm_slider_indicator_format_set(obj, "%1.0f"); + elm_slider_min_max_set(obj, spec.i.min, spec.i.max); + elm_slider_value_set(obj, spec.i.def); + } + else if (type == ELM_PREFS_TYPE_FLOAT) + { + elm_slider_unit_format_set(obj, "%1.2f"); + elm_slider_indicator_format_set(obj, "%1.2f"); + elm_slider_min_max_set(obj, spec.f.min, spec.f.max); + elm_slider_value_set(obj, spec.f.def); + } + + return obj; +} + +static Eina_Bool +elm_prefs_slider_value_set(Evas_Object *obj, + Eina_Value *value) +{ + union + { + int i; + float f; + } val; + + Elm_Prefs_Item_Type pt = + (Elm_Prefs_Item_Type)evas_object_data_get(obj, "prefs_type"); + + const Eina_Value_Type *vt = eina_value_type_get(value); + if (!vt) return EINA_FALSE; + + if ((pt == ELM_PREFS_TYPE_INT) && (vt == EINA_VALUE_TYPE_INT)) + { + eina_value_get(value, &(val.i)); + elm_slider_value_set(obj, val.i); + } + else if ((pt == ELM_PREFS_TYPE_FLOAT) && (vt == EINA_VALUE_TYPE_FLOAT)) + { + eina_value_get(value, &(val.f)); + elm_slider_value_set(obj, val.f); + } + else + return EINA_FALSE; + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_slider_value_get(Evas_Object *obj, + Eina_Value *value) +{ + union + { + int i; + float f; + } val; + + Elm_Prefs_Item_Type pt = + (Elm_Prefs_Item_Type)evas_object_data_get(obj, "prefs_type"); + + if (pt == ELM_PREFS_TYPE_INT) + { + val.i = elm_slider_value_get(obj); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_INT)) return EINA_FALSE; + if (!eina_value_set(value, val.i)) return EINA_FALSE; + } + else if (pt == ELM_PREFS_TYPE_FLOAT) + { + val.f = elm_slider_value_get(obj); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_FLOAT)) return EINA_FALSE; + if (!eina_value_set(value, val.f)) return EINA_FALSE; + } + else + return EINA_FALSE; + + return EINA_TRUE; +} + +PREFS_ITEM_WIDGET_ADD(slider, + supported_types, + elm_prefs_slider_value_set, + elm_prefs_slider_value_get, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_spinner.c b/src/modules/elementary/prefs/elm_spinner.c new file mode 100644 index 0000000000..51903fed90 --- /dev/null +++ b/src/modules/elementary/prefs/elm_spinner.c @@ -0,0 +1,124 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_INT, + ELM_PREFS_TYPE_FLOAT, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Eina_Bool +_item_changed_cb(void *data, const Eo_Event *event) +{ + Elm_Prefs_Item_Changed_Cb prefs_it_changed_cb = data; + + prefs_it_changed_cb(event->obj); + return EINA_TRUE; +} + +static Evas_Object * +elm_prefs_spinner_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Spec spec, + Elm_Prefs_Item_Changed_Cb cb) +{ + Evas_Object *obj = elm_spinner_add(prefs); + + evas_object_data_set(obj, "prefs_type", (void *)type); + + eo_event_callback_add + (obj, ELM_SPINNER_EVENT_CHANGED, _item_changed_cb, cb); + + if (type == ELM_PREFS_TYPE_INT) + { + elm_spinner_step_set(obj, 1.0); + elm_spinner_min_max_set(obj, spec.i.min, spec.i.max); + elm_spinner_value_set(obj, spec.i.def); + } + else if (type == ELM_PREFS_TYPE_FLOAT) + { + elm_spinner_label_format_set(obj, "%1.2f"); + elm_spinner_step_set(obj, 0.1); + elm_spinner_min_max_set(obj, spec.f.min, spec.f.max); + elm_spinner_value_set(obj, spec.f.def); + } + + return obj; +} + +static Eina_Bool +elm_prefs_spinner_value_set(Evas_Object *obj, + Eina_Value *value) +{ + union + { + int i; + float f; + } val; + + Elm_Prefs_Item_Type pt = + (Elm_Prefs_Item_Type) evas_object_data_get(obj, "prefs_type"); + + const Eina_Value_Type *vt = eina_value_type_get(value); + if (!vt) return EINA_FALSE; + + if ((pt == ELM_PREFS_TYPE_INT) && (vt == EINA_VALUE_TYPE_INT)) + { + eina_value_get(value, &(val.i)); + elm_spinner_value_set(obj, val.i); + } + else if ((pt == ELM_PREFS_TYPE_FLOAT) && (vt == EINA_VALUE_TYPE_FLOAT)) + { + eina_value_get(value, &(val.f)); + elm_spinner_value_set(obj, val.f); + } + else + return EINA_FALSE; + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_spinner_value_get(Evas_Object *obj, + Eina_Value *value) +{ + union + { + int i; + float f; + } val; + + Elm_Prefs_Item_Type pt = + (Elm_Prefs_Item_Type) evas_object_data_get(obj, "prefs_type"); + + if (pt == ELM_PREFS_TYPE_INT) + { + val.i = elm_spinner_value_get(obj); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_INT)) return EINA_FALSE; + if (!eina_value_set(value, val.i)) return EINA_FALSE; + } + else if (pt == ELM_PREFS_TYPE_FLOAT) + { + val.f = elm_spinner_value_get(obj); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_FLOAT)) return EINA_FALSE; + if (!eina_value_set(value, val.f)) return EINA_FALSE; + } + else + return EINA_FALSE; + + return EINA_TRUE; +} + +PREFS_ITEM_WIDGET_ADD(spinner, + supported_types, + elm_prefs_spinner_value_set, + elm_prefs_spinner_value_get, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_swallow.c b/src/modules/elementary/prefs/elm_swallow.c new file mode 100644 index 0000000000..e5ea11d624 --- /dev/null +++ b/src/modules/elementary/prefs/elm_swallow.c @@ -0,0 +1,63 @@ +#include "private.h" + +static Elm_Prefs_Item_Type supported_types[] = +{ + ELM_PREFS_TYPE_SWALLOW, + ELM_PREFS_TYPE_UNKNOWN +}; + +static Evas_Object * +elm_prefs_swallow_add(const Elm_Prefs_Item_Iface *iface EINA_UNUSED, + Evas_Object *prefs, + const Elm_Prefs_Item_Type type EINA_UNUSED, + const Elm_Prefs_Item_Spec spec EINA_UNUSED, + Elm_Prefs_Item_Changed_Cb cb EINA_UNUSED) +{ + Evas_Object *obj = elm_layout_add(prefs); + char layout_edj[PATH_MAX]; + + snprintf(layout_edj, sizeof(layout_edj), "%s/elementary/modules/prefs/%s/elm_prefs_swallow.edj", elm_app_lib_dir_get(), MODULE_ARCH); + + elm_layout_file_set(obj, layout_edj, "elm_prefs_swallow"); + + return obj; +} + +static Eina_Bool +elm_prefs_swallow_swallow(Evas_Object *obj, + Eina_Value *value) +{ + Evas_Object *subobj; + + if (eina_value_type_get(value) != EINA_VALUE_TYPE_UINT64 || + !eina_value_get(value, &subobj)) + return EINA_FALSE; + + elm_layout_content_set(obj, "content", subobj); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_swallow_unswallow(Evas_Object *obj, + Eina_Value *value) +{ + Evas_Object *subobj = elm_layout_content_unset(obj, "content"); + + if (!eina_value_setup(value, EINA_VALUE_TYPE_UINT64) || + !eina_value_set(value, subobj)) + return EINA_FALSE; + + return EINA_TRUE; +} + +PREFS_ITEM_WIDGET_ADD(swallow, + supported_types, + elm_prefs_swallow_swallow, + elm_prefs_swallow_unswallow, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); diff --git a/src/modules/elementary/prefs/elm_vertical_box.c b/src/modules/elementary/prefs/elm_vertical_box.c new file mode 100644 index 0000000000..c7ffa0854a --- /dev/null +++ b/src/modules/elementary/prefs/elm_vertical_box.c @@ -0,0 +1,99 @@ +#include "private.h" + +static Evas_Object * +elm_prefs_vertical_box_add(const Elm_Prefs_Page_Iface *iface EINA_UNUSED, + Evas_Object *prefs) +{ + Evas_Object *obj = elm_box_add(prefs); + + elm_box_horizontal_set(obj, EINA_FALSE); + + return obj; +} + +static Eina_Bool +elm_prefs_vertical_box_item_pack(Evas_Object *obj, + Evas_Object *it, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l; + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 0.0, 1.0); + + elm_prefs_vertical_page_common_pack(it, obj, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_vertical_box_item_unpack(Evas_Object *obj, + Evas_Object *it) +{ + /* back to defaults */ + evas_object_size_hint_align_set(it, 0.5, 0.5); + evas_object_size_hint_weight_set(it, 0.0, 0.0); + + elm_prefs_page_common_unpack(it, obj); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_vertical_box_item_pack_before(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_before, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l; + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 0.0, 1.0); + + elm_prefs_vertical_page_common_pack_before(it, it_before, obj, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_vertical_box_item_pack_after(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_after, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l; + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 0.0, 1.0); + + elm_prefs_vertical_page_common_pack_after(it, it_after, obj, iface); + + return EINA_TRUE; +} + +PREFS_PAGE_WIDGET_ADD(vertical_box, + NULL, + NULL, + NULL, + elm_prefs_vertical_box_item_pack, + elm_prefs_vertical_box_item_unpack, + elm_prefs_vertical_box_item_pack_before, + elm_prefs_vertical_box_item_pack_after); diff --git a/src/modules/elementary/prefs/elm_vertical_frame.c b/src/modules/elementary/prefs/elm_vertical_frame.c new file mode 100644 index 0000000000..0df2a4a685 --- /dev/null +++ b/src/modules/elementary/prefs/elm_vertical_frame.c @@ -0,0 +1,117 @@ +#include "private.h" + +static Evas_Object * +elm_prefs_vertical_frame_add(const Elm_Prefs_Page_Iface *iface EINA_UNUSED, + Evas_Object *prefs) +{ + Evas_Object *bx, *obj = elm_frame_add(prefs); + + bx = elm_box_add(obj); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + elm_layout_content_set(obj, NULL, bx); + + evas_object_data_set(obj, "bx_container", bx); + + return obj; +} + +static Eina_Bool +elm_prefs_vertical_frame_title_set(Evas_Object *obj, + const char *title) +{ + elm_layout_text_set(obj, NULL, title); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_vertical_frame_item_pack(Evas_Object *obj, + Evas_Object *it, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container"); + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 0.0, 1.0); + + elm_prefs_vertical_page_common_pack(it, bx, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_vertical_frame_item_unpack(Evas_Object *obj, + Evas_Object *it) +{ + Evas_Object *bx = evas_object_data_get(obj, "bx_container"); + + /* back to defaults */ + evas_object_size_hint_align_set(it, 0.5, 0.5); + evas_object_size_hint_weight_set(it, 0.0, 0.0); + + elm_prefs_page_common_unpack(it, bx); + + return EINA_TRUE; +} + + +static Eina_Bool +elm_prefs_vertical_frame_item_pack_before(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_before, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container"); + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 0.0, 1.0); + + elm_prefs_vertical_page_common_pack_before(it, it_before, bx, iface); + + return EINA_TRUE; +} + +static Eina_Bool +elm_prefs_vertical_frame_item_pack_after(Evas_Object *obj, + Evas_Object *it, + Evas_Object *it_after, + const Elm_Prefs_Item_Type type, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container"); + + if ((type == ELM_PREFS_TYPE_SEPARATOR) && + (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE))) + return EINA_FALSE; + + l = evas_object_data_get(it, "label_widget"); + if (l) + evas_object_size_hint_align_set(l, 0.0, 1.0); + + elm_prefs_vertical_page_common_pack_after(it, it_after, bx, iface); + + return EINA_TRUE; +} + +PREFS_PAGE_WIDGET_ADD(vertical_frame, + elm_prefs_vertical_frame_title_set, + NULL, + NULL, + elm_prefs_vertical_frame_item_pack, + elm_prefs_vertical_frame_item_unpack, + elm_prefs_vertical_frame_item_pack_before, + elm_prefs_vertical_frame_item_pack_after); diff --git a/src/modules/elementary/prefs/item_widgets.inc b/src/modules/elementary/prefs/item_widgets.inc new file mode 100644 index 0000000000..1c0ce66239 --- /dev/null +++ b/src/modules/elementary/prefs/item_widgets.inc @@ -0,0 +1,9 @@ +PREFS_ADD(button) +PREFS_ADD(check) +PREFS_ADD(datetime) +PREFS_ADD(entry) +PREFS_ADD(label) +PREFS_ADD(separator) +PREFS_ADD(slider) +PREFS_ADD(spinner) +PREFS_ADD(swallow) diff --git a/src/modules/elementary/prefs/page_widgets.inc b/src/modules/elementary/prefs/page_widgets.inc new file mode 100644 index 0000000000..2bf3c1cbbb --- /dev/null +++ b/src/modules/elementary/prefs/page_widgets.inc @@ -0,0 +1,4 @@ +PREFS_ADD(vertical_box) +PREFS_ADD(horizontal_box) +PREFS_ADD(vertical_frame) +PREFS_ADD(horizontal_frame) diff --git a/src/modules/elementary/prefs/prefs_iface.c b/src/modules/elementary/prefs/prefs_iface.c new file mode 100644 index 0000000000..1150fcbd2f --- /dev/null +++ b/src/modules/elementary/prefs/prefs_iface.c @@ -0,0 +1,287 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include "Elementary.h" +#include "private.h" + +/* including declaration of each prefs item implementation iface struct */ +#define PREFS_ADD(w_name) \ + extern const Elm_Prefs_Item_Iface prefs_##w_name##_impl; + +#include "item_widgets.inc" + +#undef PREFS_ADD + +int _elm_prefs_log_dom = -1; + +/* now building on array of those, to be put on a hash for lookup */ +static Elm_Prefs_Item_Iface_Info _elm_prefs_item_widgets[] = +{ +#define PREFS_ADD(w_name) \ + {"elm/" #w_name, &prefs_##w_name##_impl}, + +#include "item_widgets.inc" + +#undef PREFS_ADD + {NULL, NULL} +}; + +/* including declaration of each prefs page implementation iface struct */ +#define PREFS_ADD(w_name) \ + extern const Elm_Prefs_Page_Iface prefs_##w_name##_impl; + +#include "page_widgets.inc" + +#undef PREFS_ADD + +/* now building on array of those, to be put on a hash for lookup */ +static Elm_Prefs_Page_Iface_Info _elm_prefs_page_widgets[] = +{ +#define PREFS_ADD(w_name) \ + {"elm/" #w_name, &prefs_##w_name##_impl}, + +#include "page_widgets.inc" + +#undef PREFS_ADD + {NULL, NULL} +}; + +Eina_Bool +elm_prefs_page_item_value_set(Evas_Object *it, + const Elm_Prefs_Item_Iface *iface, + Eina_Bool val) +{ + Eina_Value value; + + if (!iface->value_set) return EINA_FALSE; + + if ((!eina_value_setup(&value, EINA_VALUE_TYPE_UCHAR)) || + (!eina_value_set(&value, val))) + return EINA_FALSE; + + return iface->value_set(it, &value); +} + +static Evas_Object * +_elm_prefs_page_box_add(Evas_Object *obj, + Evas_Object *it) +{ + Evas_Object *sbx; + double align_x, align_y; + + evas_object_size_hint_align_get(it, &align_x, &align_y); + + sbx = elm_box_add(obj); + elm_box_horizontal_set(sbx, EINA_TRUE); + evas_object_size_hint_weight_set(sbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(sbx, align_x, align_y); + evas_object_data_set(obj, "sub_box", sbx); + evas_object_show(sbx); + + return sbx; +} + +static void +_elm_prefs_page_item_hints_set(Evas_Object *it, + const Elm_Prefs_Item_Iface *iface) +{ + if (iface && iface->expand_want && iface->expand_want(it)) + evas_object_size_hint_align_set(it, EVAS_HINT_FILL, EVAS_HINT_FILL); + + evas_object_size_hint_weight_set(it, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); +} + +static void +_elm_prefs_page_pack_setup(Evas_Object *it, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *i, *sbx; + + _elm_prefs_page_item_hints_set(it, iface); + + l = evas_object_data_get(it, "label_widget"); + i = evas_object_data_get(it, "icon_widget"); + if (i) + { + sbx = _elm_prefs_page_box_add(obj, it); + elm_box_pack_end(obj, sbx); + + evas_object_size_hint_align_set(it, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_align_set(i, 0.0, EVAS_HINT_FILL); + elm_box_pack_end(sbx, i); + elm_box_pack_end(sbx, it); + + if (l) elm_box_pack_before(obj, l, sbx); + } + else + { + elm_box_pack_end(obj, it); + if (l) elm_box_pack_before(obj, l, it); + } +} + +static void +_elm_prefs_page_pack_before_setup(Evas_Object *it, + Evas_Object *it_before, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *i, *sbx; + + _elm_prefs_page_item_hints_set(it, iface); + + l = evas_object_data_get(it, "label_widget"); + i = evas_object_data_get(it, "icon_widget"); + if (i) + { + sbx = _elm_prefs_page_box_add(obj, it); + elm_box_pack_before(obj, sbx, it_before); + + evas_object_size_hint_align_set(i, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(sbx, i); + elm_box_pack_end(sbx, it); + + if (l) elm_box_pack_before(obj, l, sbx); + } + else + { + elm_box_pack_before(obj, it, it_before); + if (l) elm_box_pack_before(obj, l, it); + } +} + +static void +_elm_prefs_page_pack_after_setup(Evas_Object *it, + Evas_Object *it_after, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + Evas_Object *l, *i, *sbx; + + _elm_prefs_page_item_hints_set(it, iface); + + l = evas_object_data_get(it, "label_widget"); + i = evas_object_data_get(it, "icon_widget"); + if (i) + { + sbx = _elm_prefs_page_box_add(obj, it); + elm_box_pack_after(obj, sbx, it_after); + + evas_object_size_hint_align_set(i, EVAS_HINT_FILL, 0.5); + elm_box_pack_end(sbx, i); + elm_box_pack_end(sbx, it); + + if (l) elm_box_pack_before(obj, l, sbx); + } + else + { + elm_box_pack_after(obj, it, it_after); + if (l) elm_box_pack_before(obj, l, it); + } +} + +void +elm_prefs_horizontal_page_common_pack(Evas_Object *it, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + evas_object_size_hint_align_set(it, 0.5, EVAS_HINT_FILL); + _elm_prefs_page_pack_setup(it, obj, iface); +} + +void +elm_prefs_horizontal_page_common_pack_before(Evas_Object *it, + Evas_Object *it_before, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + evas_object_size_hint_align_set(it, 0.5, EVAS_HINT_FILL); + _elm_prefs_page_pack_before_setup(it, it_before, obj, iface); +} + +void +elm_prefs_horizontal_page_common_pack_after(Evas_Object *it, + Evas_Object *it_after, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + evas_object_size_hint_align_set(it, 0.5, EVAS_HINT_FILL); + _elm_prefs_page_pack_after_setup(it, it_after, obj, iface); +} + +void +elm_prefs_vertical_page_common_pack(Evas_Object *it, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + evas_object_size_hint_align_set(it, EVAS_HINT_FILL, 0.5); + _elm_prefs_page_pack_setup(it, obj, iface); +} + +void +elm_prefs_vertical_page_common_pack_before(Evas_Object *it, + Evas_Object *it_before, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + evas_object_size_hint_align_set(it, EVAS_HINT_FILL, 0.5); + _elm_prefs_page_pack_before_setup(it, it_before, obj, iface); +} + +void +elm_prefs_vertical_page_common_pack_after(Evas_Object *it, + Evas_Object *it_after, + Evas_Object *obj, + const Elm_Prefs_Item_Iface *iface) +{ + evas_object_size_hint_align_set(it, EVAS_HINT_FILL, 0.5); + _elm_prefs_page_pack_after_setup(it, it_after, obj, iface); +} + +void +elm_prefs_page_common_unpack(Evas_Object *it, + Evas_Object *obj) +{ + Evas_Object *l, *i, *sbx; + + l = evas_object_data_get(it, "label_widget"); + if (l) elm_box_unpack(obj, l); + + sbx = evas_object_data_get(it, "sub_box"); + i = evas_object_data_get(it, "icon_widget"); + + if (i && sbx) + { + elm_box_unpack_all(sbx); + elm_box_unpack(obj, sbx); + evas_object_del(sbx); + } + else + elm_box_unpack(obj, it); +} + +EAPI int +elm_modapi_init(void *m EINA_UNUSED) +{ + _elm_prefs_log_dom = eina_log_domain_register + ("elm-prefs", EINA_COLOR_YELLOW); + + elm_prefs_item_iface_register(_elm_prefs_item_widgets); + elm_prefs_page_iface_register(_elm_prefs_page_widgets); + + return 1; // succeed always +} + +EAPI int +elm_modapi_shutdown(void *m EINA_UNUSED) +{ + elm_prefs_item_iface_unregister(_elm_prefs_item_widgets); + elm_prefs_page_iface_unregister(_elm_prefs_page_widgets); + + if (_elm_prefs_log_dom >= 0) eina_log_domain_unregister(_elm_prefs_log_dom); + _elm_prefs_log_dom = -1; + + return 1; // succeed always +} diff --git a/src/modules/elementary/prefs/private.h b/src/modules/elementary/prefs/private.h new file mode 100644 index 0000000000..f65370bedf --- /dev/null +++ b/src/modules/elementary/prefs/private.h @@ -0,0 +1,127 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#include "Elementary.h" + +#undef CRI +#undef ERR +#undef WRN +#undef INF +#undef DBG + +#define CRI(...) EINA_LOG_DOM_CRIT(_elm_prefs_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR (_elm_prefs_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_elm_prefs_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_elm_prefs_log_dom, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG (_elm_prefs_log_dom, __VA_ARGS__) + +extern int _elm_prefs_log_dom; + +#define PREFS_ITEM_WIDGET_ADD(_w_name, \ + _types, \ + _value_set_fn, \ + _value_get_fn, \ + _value_validate_fn, \ + _label_set_fn, \ + _icon_set_fn, \ + _editable_set_fn, \ + _editable_get_fn, \ + _expand_want_fn) \ + static Evas_Object * \ + _prefs_##_w_name##_add(const Elm_Prefs_Item_Iface * iface, \ + Evas_Object * prefs, \ + const Elm_Prefs_Item_Type type, \ + const Elm_Prefs_Item_Spec spec, \ + Elm_Prefs_Item_Changed_Cb it_changed_cb) \ + { \ + Evas_Object *obj = \ + elm_prefs_##_w_name##_add(iface, prefs, type, spec, it_changed_cb); \ + if (!obj) return NULL; \ + if (!elm_prefs_item_widget_common_add(prefs, obj)) \ + { \ + evas_object_del(obj); \ + return NULL; \ + } \ + \ + return obj; \ + } \ + \ + const Elm_Prefs_Item_Iface prefs_##_w_name##_impl = \ + { \ + .abi_version = ELM_PREFS_ITEM_IFACE_ABI_VERSION, \ + .add = _prefs_##_w_name##_add, \ + .types = _types, \ + .value_set = _value_set_fn, \ + .value_get = _value_get_fn, \ + .value_validate = _value_validate_fn, \ + .label_set = _label_set_fn, \ + .icon_set = _icon_set_fn, \ + .editable_set = _editable_set_fn, \ + .editable_get = _editable_get_fn, \ + .expand_want = _expand_want_fn \ + } + +#define PREFS_PAGE_WIDGET_ADD(_w_name, \ + _title_set_fn, \ + _sub_title_set_fn, \ + _icon_set_fn, \ + _item_pack_fn, \ + _item_unpack_fn, \ + _item_pack_before_fn, \ + _item_pack_after_fn) \ + static Evas_Object * \ + _prefs_##_w_name##_add(const Elm_Prefs_Page_Iface * iface, \ + Evas_Object * prefs) \ + { \ + Evas_Object *obj = \ + elm_prefs_##_w_name##_add(iface, prefs); \ + if (!obj) return NULL; \ + if (!elm_prefs_page_widget_common_add(prefs, obj)) \ + { \ + evas_object_del(obj); \ + return NULL; \ + } \ + \ + return obj; \ + } \ + \ + const Elm_Prefs_Page_Iface prefs_##_w_name##_impl = \ + { \ + .abi_version = ELM_PREFS_PAGE_IFACE_ABI_VERSION, \ + .add = _prefs_##_w_name##_add, \ + .title_set = _title_set_fn, \ + .sub_title_set = _sub_title_set_fn, \ + .icon_set = _icon_set_fn, \ + .item_pack = _item_pack_fn, \ + .item_unpack = _item_unpack_fn, \ + .item_pack_before = _item_pack_before_fn, \ + .item_pack_after = _item_pack_after_fn \ + } + +Eina_Bool elm_prefs_page_item_value_set(Evas_Object *it, + const Elm_Prefs_Item_Iface *iface, + Eina_Bool val); +void elm_prefs_horizontal_page_common_pack(Evas_Object *, + Evas_Object *, + const Elm_Prefs_Item_Iface *); +void elm_prefs_horizontal_page_common_pack_before(Evas_Object *, + Evas_Object *, + Evas_Object *, + const Elm_Prefs_Item_Iface *); +void elm_prefs_horizontal_page_common_pack_after(Evas_Object *, + Evas_Object *, + Evas_Object *, + const Elm_Prefs_Item_Iface *); +void elm_prefs_vertical_page_common_pack(Evas_Object *, + Evas_Object *, + const Elm_Prefs_Item_Iface *); +void elm_prefs_vertical_page_common_pack_before(Evas_Object *, + Evas_Object *, + Evas_Object *, + const Elm_Prefs_Item_Iface *); +void elm_prefs_vertical_page_common_pack_after(Evas_Object *, + Evas_Object *, + Evas_Object *, + const Elm_Prefs_Item_Iface *); +void elm_prefs_page_common_unpack(Evas_Object *, + Evas_Object *); diff --git a/src/modules/elementary/test_entry/Makefile.am b/src/modules/elementary/test_entry/Makefile.am new file mode 100644 index 0000000000..a791506efa --- /dev/null +++ b/src/modules/elementary/test_entry/Makefile.am @@ -0,0 +1,22 @@ + +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-I. \ +-I$(top_builddir) \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DELEMENTARY_BUILD \ +@ELEMENTARY_CFLAGS@ + +pkgdir = $(pkglibdir)/modules/test_entry/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la + +module_la_SOURCES = mod.c + +module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la +module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ +module_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/src/modules/elementary/test_entry/mod.c b/src/modules/elementary/test_entry/mod.c new file mode 100644 index 0000000000..d2d5171af2 --- /dev/null +++ b/src/modules/elementary/test_entry/mod.c @@ -0,0 +1,51 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include + +// module api funcs needed +EAPI int +elm_modapi_init(void *m EINA_UNUSED) +{ + return 1; // succeed always +} + +EAPI int +elm_modapi_shutdown(void *m EINA_UNUSED) +{ + return 1; // succeed always +} + +// module fucns for the specific module type +EAPI void +obj_hook(Evas_Object *obj) +{ + printf("hook: %p\n", obj); +} + +EAPI void +obj_unhook(Evas_Object *obj) +{ + printf("unhook: %p\n", obj); +} + +EAPI void +obj_longpress(Evas_Object *obj) +{ + printf("longpress: %p\n", obj); +} + +static Eina_Bool +_module_init(void) +{ + return EINA_TRUE; +} + +static void +_module_shutdown(void) +{ +} + +EINA_MODULE_INIT(_module_init); +EINA_MODULE_SHUTDOWN(_module_shutdown); diff --git a/src/modules/elementary/test_map/Makefile.am b/src/modules/elementary/test_map/Makefile.am new file mode 100644 index 0000000000..14e7cc2747 --- /dev/null +++ b/src/modules/elementary/test_map/Makefile.am @@ -0,0 +1,22 @@ + +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-I. \ +-I$(top_builddir) \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DELEMENTARY_BUILD \ +@ELEMENTARY_CFLAGS@ + +pkgdir = $(pkglibdir)/modules/test_map/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la + +module_la_SOURCES = mod.c + +module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la +module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ +module_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/src/modules/elementary/test_map/mod.c b/src/modules/elementary/test_map/mod.c new file mode 100644 index 0000000000..df300f7ffe --- /dev/null +++ b/src/modules/elementary/test_map/mod.c @@ -0,0 +1,103 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include "Elementary.h" +#include "elm_widget_map.h" +#include + +EAPI Eina_Stringshare * +map_module_source_name_get(void) +{ + return eina_stringshare_add("test_map"); +} + +EAPI int +map_module_tile_zoom_min_get(void) +{ + return 0; +} + +EAPI int +map_module_tile_zoom_max_get(void) +{ + return 18; +} + +EAPI char * +map_module_tile_url_get(Evas_Object *obj EINA_UNUSED, int x, int y, int zoom) +{ + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png", + zoom, x, y); + return strdup(buf); +} + +EAPI char * +map_module_route_source_get(void) +{ + return NULL; +} + +EAPI void +map_module_route_source_parse(Elm_Map_Route *r EINA_UNUSED) +{ + return; +} + +EAPI char * +map_module_route_url_get(Evas_Object *obj EINA_UNUSED, const char *type_name EINA_UNUSED, int method EINA_UNUSED, double flon EINA_UNUSED, double flat EINA_UNUSED, double tlon EINA_UNUSED, double tlat EINA_UNUSED) +{ + return strdup(""); +} + +EAPI char * +map_module_name_url_get(Evas_Object *obj EINA_UNUSED, int method EINA_UNUSED, const char *name EINA_UNUSED, double lon EINA_UNUSED, double lat EINA_UNUSED) +{ + return strdup(""); +} + +EAPI void +map_module_name_source_parse(Elm_Map_Name *n EINA_UNUSED) +{ + return; +} + +EAPI void +map_module_name_list_source_parse(Elm_Map_Name_List *nl EINA_UNUSED) +{ + return; +} + +EAPI Eina_Bool +map_module_tile_geo_to_coord(const Evas_Object *obj EINA_UNUSED, int zoom EINA_UNUSED, double lon EINA_UNUSED, double lat EINA_UNUSED, int size EINA_UNUSED, int *x EINA_UNUSED, int *y EINA_UNUSED) +{ + return EINA_FALSE; +} + +EAPI Eina_Bool +map_module_tile_coord_to_geo(const Evas_Object *obj EINA_UNUSED, int zoom EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int size EINA_UNUSED, double *lon EINA_UNUSED, double *lat EINA_UNUSED) +{ + return EINA_FALSE; +} + +EAPI double +map_module_tile_scale_get(const Evas_Object *obj EINA_UNUSED, double lon EINA_UNUSED, double lat EINA_UNUSED, int zoom EINA_UNUSED) +{ + return 0; +} + +static Eina_Bool +_module_init(void) +{ + return EINA_TRUE; +} + +static void +_module_shutdown(void) +{ +} + +EINA_MODULE_INIT(_module_init); +EINA_MODULE_SHUTDOWN(_module_shutdown); + diff --git a/src/modules/elementary/web/Makefile.am b/src/modules/elementary/web/Makefile.am new file mode 100644 index 0000000000..9b7287b741 --- /dev/null +++ b/src/modules/elementary/web/Makefile.am @@ -0,0 +1,6 @@ +AUTOMAKE_OPTIONS = 1.4 foreign +MAINTAINERCLEANFILES = Makefile.in + +SUBDIRS = \ +none \ +webkit2 diff --git a/src/modules/elementary/web/none/.gitignore b/src/modules/elementary/web/none/.gitignore new file mode 100644 index 0000000000..2ed3a40b69 --- /dev/null +++ b/src/modules/elementary/web/none/.gitignore @@ -0,0 +1 @@ +*.eo.* diff --git a/src/modules/elementary/web/none/Makefile.am b/src/modules/elementary/web/none/Makefile.am new file mode 100644 index 0000000000..f3a0f11dd1 --- /dev/null +++ b/src/modules/elementary/web/none/Makefile.am @@ -0,0 +1,40 @@ +AUTOMAKE_OPTIONS = 1.4 foreign +MAINTAINERCLEANFILES = Makefile.in + +CLEANFILES = + +EOLIAN_FLAGS = @DEPS_EOLIAN_FLAGS@ \ + -I$(top_srcdir)/src/lib + +include $(top_srcdir)/Makefile_Eolian_Helper.am + +AM_CPPFLAGS = \ +-DELM_INTERNAL_API_ARGESFSDFEFC=1 \ +-DMODULES_PATH=\"$(pkglibdir)/modules\" \ +-I. \ +-I$(top_builddir) \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/imported \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \ +-DLOCALE_DIR=\"$(localedir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DICON_DIR=\"$(datadir)/icons\" \ +-DELM_TOP_BUILD_DIR=\"$(top_builddir)\" \ +-DELEMENTARY_BUILD \ +@ELEMENTARY_CFLAGS@ + +pkgdir = $(pkglibdir)/modules/web/none/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la + +BUILT_SOURCES = elm_web_none.eo.h elm_web_none.eo.c + +module_la_SOURCES = elm_web_none.c elm_web_none.eo.h +module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la +module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ +module_la_LIBTOOLFLAGS = --tag=disable-static + +EXTRA_DIST = elm_web_none.eo + + diff --git a/src/modules/elementary/web/none/elm_web_none.c b/src/modules/elementary/web/none/elm_web_none.c new file mode 100644 index 0000000000..e98cfe8771 --- /dev/null +++ b/src/modules/elementary/web/none/elm_web_none.c @@ -0,0 +1,359 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED + +#include + +#include "elm_priv.h" +#include "elm_widget_web.h" +#include "elm_web_none.eo.h" + +#define MY_CLASS ELM_WEB_CLASS + +#define MY_CLASS_NAME "Elm_Web_None" + +typedef struct _Elm_Web_None_Data Elm_Web_None_Data; +struct _Elm_Web_None_Data +{ +}; + +static int _none_log_dom = -1; + +#undef CRI +#undef ERR +#undef WRN +#undef INF +#undef DBG +#define CRI(...) EINA_LOG_DOM_CRIT(_none_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_none_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_none_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_none_log_dom, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG(_none_log_dom, __VA_ARGS__) + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_tab_propagate_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static void +_elm_web_none_elm_web_tab_propagate_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED, Eina_Bool propagate EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_evas_object_smart_add(Eo *obj, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + Evas_Object *resize_obj; + + resize_obj = elm_label_add(obj); + elm_object_text_set(resize_obj, "WebKit not supported!"); + elm_widget_resize_object_set(obj, resize_obj, EINA_TRUE); + + evas_obj_smart_add(eo_super(obj, MY_CLASS)); + elm_widget_sub_object_parent_add(obj); +} + +EOLIAN static Evas_Object* +_elm_web_none_elm_web_webkit_view_get(Eo *obj, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + (void)obj; + ERR("Elementary not compiled with EWebKit support."); + return NULL; +} + +EOLIAN static void +_elm_web_none_elm_web_window_create_hook_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED, Elm_Web_Window_Open func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_dialog_alert_hook_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED, Elm_Web_Dialog_Alert func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_dialog_confirm_hook_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED, Elm_Web_Dialog_Confirm func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_dialog_prompt_hook_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED, Elm_Web_Dialog_Prompt func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_dialog_file_selector_hook_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, Elm_Web_Dialog_File_Selector func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_console_message_hook_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, Elm_Web_Console_Message func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_useragent_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, const char *user_agent EINA_UNUSED) +{ +} + +EOLIAN static const char* +_elm_web_none_elm_web_useragent_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return NULL; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_url_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, const char *url EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static const char* +_elm_web_none_elm_web_url_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return NULL; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_html_string_load(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, const char *html EINA_UNUSED, const char *base_url EINA_UNUSED, const char *unreachable_url EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static const char* +_elm_web_none_elm_web_title_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return NULL; +} + +EOLIAN static void +_elm_web_none_elm_web_bg_color_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, int r EINA_UNUSED, int g EINA_UNUSED, int b EINA_UNUSED, int a EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_bg_color_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, int *r, int *g, int *b, int *a) +{ + if (r) *r = 0; + if (g) *g = 0; + if (b) *b = 0; + if (a) *a = 0; +} + +EOLIAN static const char* +_elm_web_none_elm_web_selection_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return NULL; +} + +EOLIAN static void +_elm_web_none_elm_web_popup_selected_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, int idx EINA_UNUSED) +{ +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_popup_destroy(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_text_search(const Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, const char *string EINA_UNUSED, Eina_Bool case_sensitive EINA_UNUSED, Eina_Bool forward EINA_UNUSED, Eina_Bool wrap EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static unsigned int +_elm_web_none_elm_web_text_matches_mark(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, const char *string EINA_UNUSED, Eina_Bool case_sensitive EINA_UNUSED, Eina_Bool highlight EINA_UNUSED, unsigned int limit EINA_UNUSED) +{ + return 0; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_text_matches_unmark_all(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_text_matches_highlight_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, Eina_Bool highlight EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_text_matches_highlight_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static double +_elm_web_none_elm_web_load_progress_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return -1.0; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_stop(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_reload(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_reload_full(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_back(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_forward(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_navigate(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, int steps EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_back_possible_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_forward_possible_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_navigate_possible_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, int steps EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_history_enabled_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static void +_elm_web_none_elm_web_history_enabled_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, Eina_Bool enable EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_zoom_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, double zoom EINA_UNUSED) +{ +} + +EOLIAN static double +_elm_web_none_elm_web_zoom_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return -1; +} + +EOLIAN static void +_elm_web_none_elm_web_zoom_mode_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, Elm_Web_Zoom_Mode mode EINA_UNUSED) +{ +} + +EOLIAN static Elm_Web_Zoom_Mode +_elm_web_none_elm_web_zoom_mode_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED) +{ + return ELM_WEB_ZOOM_MODE_LAST; +} + +EOLIAN static void +_elm_web_none_elm_web_region_show(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_region_bring_in(Eo *obj EINA_UNUSED, Elm_Web_None_Data *_pd EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_none_elm_web_inwin_mode_set(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED, Eina_Bool value EINA_UNUSED) +{ +} + +EOLIAN static Eina_Bool +_elm_web_none_elm_web_inwin_mode_get(Eo *obj EINA_UNUSED, Elm_Web_None_Data *sd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EAPI void +ewm_window_features_ref(Elm_Web_Window_Features *wf EINA_UNUSED) +{ +} + +EAPI void +ewm_window_features_unref(Elm_Web_Window_Features *wf EINA_UNUSED) +{ +} + +EAPI Eina_Bool +ewm_window_features_property_get(const Elm_Web_Window_Features *wf EINA_UNUSED, + Elm_Web_Window_Feature_Flag flag EINA_UNUSED) +{ + return EINA_FALSE; +} + +EAPI void +ewm_window_features_region_get(const Elm_Web_Window_Features *wf EINA_UNUSED, + Evas_Coord *x, + Evas_Coord *y, + Evas_Coord *w, + Evas_Coord *h) +{ + if (x) *x = 0; + if (y) *y = 0; + if (w) *w = 0; + if (h) *h = 0; +} + +EAPI void +ewm_unneed_web(void) +{ +} + +EAPI Eina_Bool +ewm_need_web(void) +{ + if (_none_log_dom == -1) + _none_log_dom = eina_log_domain_register("elm_none", EINA_COLOR_LIGHTBLUE); + return EINA_TRUE; +} + +EAPI const Eo_Class * +ewm_class_get(void) +{ + return elm_web_none_class_get(); +} + +#undef ELM_WEB_CLASS +#define ELM_WEB_CLASS elm_web_class_get() + +#include "elm_web_none.eo.c" diff --git a/src/modules/elementary/web/none/elm_web_none.eo b/src/modules/elementary/web/none/elm_web_none.eo new file mode 100644 index 0000000000..6fc7c9b508 --- /dev/null +++ b/src/modules/elementary/web/none/elm_web_none.eo @@ -0,0 +1,51 @@ +class Elm.Web.None (Elm.Web) +{ + implements { + Evas.Object_Smart.add; + Elm.Web.tab_propagate.get; + Elm.Web.tab_propagate.set; + Elm.Web.webkit_view.get; + Elm.Web.window_create_hook.set; + Elm.Web.dialog_alert_hook.set; + Elm.Web.dialog_confirm_hook.set; + Elm.Web.dialog_prompt_hook.set; + Elm.Web.dialog_file_selector_hook.set; + Elm.Web.console_message_hook.set; + Elm.Web.useragent.set; + Elm.Web.useragent.get; + Elm.Web.url.set; + Elm.Web.url.get; + Elm.Web.html_string_load; + Elm.Web.title.get; + Elm.Web.bg_color.set; + Elm.Web.bg_color.get; + Elm.Web.selection.get; + Elm.Web.popup_selected.set; + Elm.Web.popup_destroy; + Elm.Web.text_search; + Elm.Web.text_matches_mark; + Elm.Web.text_matches_unmark_all; + Elm.Web.text_matches_highlight.set; + Elm.Web.text_matches_highlight.get; + Elm.Web.load_progress.get; + Elm.Web.stop; + Elm.Web.reload; + Elm.Web.reload_full; + Elm.Web.back; + Elm.Web.forward; + Elm.Web.navigate; + Elm.Web.back_possible.get; + Elm.Web.forward_possible.get; + Elm.Web.navigate_possible_get; + Elm.Web.history_enabled.get; + Elm.Web.history_enabled.set; + Elm.Web.zoom.set; + Elm.Web.zoom.get; + Elm.Web.zoom_mode.set; + Elm.Web.zoom_mode.get; + Elm.Web.region_show; + Elm.Web.region_bring_in; + Elm.Web.inwin_mode.set; + Elm.Web.inwin_mode.get; + } +} diff --git a/src/modules/elementary/web/webkit2/.gitignore b/src/modules/elementary/web/webkit2/.gitignore new file mode 100644 index 0000000000..2ed3a40b69 --- /dev/null +++ b/src/modules/elementary/web/webkit2/.gitignore @@ -0,0 +1 @@ +*.eo.* diff --git a/src/modules/elementary/web/webkit2/Makefile.am b/src/modules/elementary/web/webkit2/Makefile.am new file mode 100644 index 0000000000..d34cdcd94a --- /dev/null +++ b/src/modules/elementary/web/webkit2/Makefile.am @@ -0,0 +1,42 @@ +AUTOMAKE_OPTIONS = 1.4 foreign +MAINTAINERCLEANFILES = Makefile.in + +CLEANFILES = + +EOLIAN_FLAGS = @DEPS_EOLIAN_FLAGS@ \ + -I$(top_srcdir)/src/lib + +include $(top_srcdir)/Makefile_Eolian_Helper.am + +AM_CPPFLAGS = \ +-DELM_INTERNAL_API_ARGESFSDFEFC=1 \ +-DMODULES_PATH=\"$(pkglibdir)/modules\" \ +-I. \ +-I$(top_builddir) \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/imported \ +-I$(top_srcdir)/src/lib \ +-I$(top_builddir)/src/lib \ +-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" \ +-DLOCALE_DIR=\"$(localedir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DICON_DIR=\"$(datadir)/icons\" \ +-DELM_TOP_BUILD_DIR=\"$(top_builddir)\" \ +-DELEMENTARY_BUILD \ +@ELEMENTARY_CFLAGS@ \ +@EWEBKIT2_CFLAGS@ + +if HAVE_EWEBKIT2 +pkgdir = $(pkglibdir)/modules/web/webkit2/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la + +BUILT_SOURCES = elm_web_webkit2.eo.h elm_web_webkit2.eo.c + +module_la_SOURCES = elm_web_webkit2.c elm_web_webkit2.eo.h +module_la_LIBADD = @ELEMENTARY_LIBS@ $(top_builddir)/src/lib/libelementary.la @EWEBKIT2_LIBS@ +module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ +module_la_LIBTOOLFLAGS = --tag=disable-static +endif + +EXTRA_DIST = elm_web_webkit2.eo + diff --git a/src/modules/elementary/web/webkit2/elm_web_webkit2.c b/src/modules/elementary/web/webkit2/elm_web_webkit2.c new file mode 100644 index 0000000000..3c898343fc --- /dev/null +++ b/src/modules/elementary/web/webkit2/elm_web_webkit2.c @@ -0,0 +1,1157 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED + +#include + +#include "elm_priv.h" +#include "elm_widget_web.h" +#include "elm_web_webkit2.eo.h" + +#include + +#define MY_CLASS ELM_WEB_WEBKIT2_CLASS + +#define MY_CLASS_NAME "Elm_Web_Webkit2" + +#define ELM_WEB_WEBKIT2_DATA_GET(o, sd) \ + Elm_Web_Webkit2_Data * sd = eo_data_scope_get(o, ELM_WEB_WEBKIT2_CLASS) + +#define ELM_WEB_WEBKIT2_DATA_GET_OR_RETURN(o, ptr) \ + ELM_WEB_WEBKIT2_DATA_GET(o, ptr); \ + if (EINA_UNLIKELY(!ptr)) \ + { \ + CRI("No widget data for object %p (%s)", \ + o, evas_object_type_get(o)); \ + return; \ + } + +#define ELM_WEB_WEBKIT2_DATA_GET_OR_RETURN_VAL(o, ptr, val) \ + ELM_WEB_WEBKIT2_DATA_GET(o, ptr); \ + if (EINA_UNLIKELY(!ptr)) \ + { \ + CRI("No widget data for object %p (%s)", \ + o, evas_object_type_get(o)); \ + return val; \ + } + +#define ELM_WEB_WEBKIT2_CHECK(obj) \ + if (EINA_UNLIKELY(!eo_isa((obj), ELM_WEB_WEBKIT2_CLASS))) \ + return + +typedef struct _Elm_Web_Webkit2_Data Elm_Web_Webkit2_Data; +struct _Elm_Web_Webkit2_Data +{ + struct + { + Elm_Web_Window_Open window_create; + void *window_create_data; + Elm_Web_Dialog_Alert alert; + void *alert_data; + Elm_Web_Dialog_Confirm confirm; + void *confirm_data; + Elm_Web_Dialog_Prompt prompt; + void *prompt_data; + Elm_Web_Dialog_File_Selector file_selector; + void *file_selector_data; + Elm_Web_Console_Message console_message; + void *console_message_data; + } hook; + + Elm_Win_Keyboard_Mode input_method; + + struct + { + Elm_Web_Zoom_Mode mode; + float current; + float min, max; + Eina_Bool no_anim; + Ecore_Timer *timer; + } zoom; + + struct + { + struct + { + int x, y; + } start, end; + Ecore_Animator *animator; + } bring_in; + + Eina_Bool tab_propagate : 1; + Eina_Bool inwin_mode : 1; +}; + +typedef struct _View_Smart_Data View_Smart_Data; +struct _View_Smart_Data +{ + Ewk_View_Smart_Data base; + struct + { + Evas_Event_Mouse_Down event; + Evas_Coord x, y; + unsigned int move_count; + Ecore_Timer *longpress_timer; + Ecore_Animator *pan_anim; + } mouse; +}; + +enum Dialog_Type +{ + DIALOG_ALERT, + DIALOG_CONFIRM, + DIALOG_PROMPT, + DIALOG_FILE_SELECTOR +}; + +typedef struct _Dialog_Data Dialog_Data; +struct _Dialog_Data +{ + enum Dialog_Type type; + + Evas_Object *dialog; + Evas_Object *box; + Evas_Object *bt_ok, *bt_cancel; + Evas_Object *entry; + Evas_Object *file_sel; + + Eina_Bool *response; + const char **entry_value; + Eina_List **selected_files; +}; + +static Ewk_View_Smart_Class _ewk_view_parent_sc = + EWK_VIEW_SMART_CLASS_INIT_NULL; + +static int _webkit2_log_dom = -1; + +#undef CRI +#undef ERR +#undef WRN +#undef INF +#undef DBG +#define CRI(...) EINA_LOG_DOM_CRIT(_webkit2_log_dom, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_webkit2_log_dom, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_webkit2_log_dom, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_webkit2_log_dom, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG(_webkit2_log_dom, __VA_ARGS__) + +static void +_view_smart_add(Evas_Object *obj) +{ + View_Smart_Data *sd; + + sd = calloc(1, sizeof(View_Smart_Data)); + evas_object_smart_data_set(obj, sd); + + _ewk_view_parent_sc.sc.add(obj); +} + +static void +_view_smart_del(Evas_Object *obj) +{ + _ewk_view_parent_sc.sc.del(obj); +} + +static Evas_Object * +_view_smart_window_create(Ewk_View_Smart_Data *vsd, + const Ewk_Window_Features *window_features) +{ + Evas_Object *new; + Evas_Object *obj = evas_object_smart_parent_get(vsd->self); + + ELM_WEB_WEBKIT2_DATA_GET_OR_RETURN_VAL(obj, sd, NULL); + + if (!sd->hook.window_create) return NULL; + + new = sd->hook.window_create + (sd->hook.window_create_data, obj, EINA_TRUE, + (const Elm_Web_Window_Features *)window_features); + if (new) return elm_web_webkit_view_get(new); + + return NULL; +} + +static void +_view_smart_window_close(Ewk_View_Smart_Data *sd) +{ + Evas_Object *obj = evas_object_smart_parent_get(sd->self); + + ELM_WEB_WEBKIT2_CHECK(obj); + + eo_event_callback_call(obj, ELM_WEB_EVENT_WINDOWS_CLOSE_REQUEST, NULL); +} + +static void +_popup_item_selected(void *data, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Elm_Object_Item *list_it = elm_list_selected_item_get(obj); + const Eina_List *itr, *list = elm_list_items_get(obj); + Ewk_Popup_Menu *menu = data; + int i = 0; + void *d; + + EINA_LIST_FOREACH(list, itr, d) + { + if (d == list_it) + break; + + i++; + } + + ewk_popup_menu_selected_index_set(menu, i); + ewk_popup_menu_close(menu); + + evas_object_del(evas_object_data_get(obj, "_notify")); +} + +static Eina_Bool +_popup_dismiss_cb(void *data, const Eo_Event *event) +{ + ewk_popup_menu_close(data); + evas_object_del(event->obj); + return EINA_TRUE; +} + +static Eina_Bool +_view_smart_popup_menu_show(Ewk_View_Smart_Data *sd, + Eina_Rectangle r, + Ewk_Text_Direction dir EINA_UNUSED, + double scale EINA_UNUSED, + Ewk_Popup_Menu *menu) +{ + Evas_Object *notify, *list, *grid, *win; + const Eina_List* items = ewk_popup_menu_items_get(menu); + Evas_Object *obj = evas_object_smart_parent_get(sd->self); + int h, ww, wh; + + Elm_Object_Item *lit; + Eina_Bool disabled; + const char *txt; + Ewk_Popup_Menu_Item *it; + const Eina_List *itr; + + Evas_Object *popup = evas_object_data_get(sd->self, "_select_popup"); + if (popup) evas_object_del(popup); + + win = elm_widget_top_get(obj); + + notify = elm_notify_add(win); + elm_notify_allow_events_set(notify, EINA_FALSE); + elm_notify_align_set(notify, 0.5, 1.0); + + list = elm_list_add(notify); + evas_object_data_set(list, "_notify", notify); + elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_scroller_bounce_set(list, EINA_FALSE, EINA_FALSE); + elm_list_mode_set(list, ELM_LIST_EXPAND); + evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(list); + + EINA_LIST_FOREACH(items, itr, it) + { + switch (ewk_popup_menu_item_type_get(it)) + { + case EWK_POPUP_MENU_SEPARATOR: + // TODO: + break; + case EWK_POPUP_MENU_ITEM: + txt = ewk_popup_menu_item_text_get(it); + if (ewk_popup_menu_item_is_label_get(it)) + { + lit = elm_list_item_append(list, txt, NULL, NULL, NULL, NULL); + disabled = EINA_TRUE; + } + else + { + lit = elm_list_item_append(list, txt, NULL, NULL, _popup_item_selected, menu); + disabled = !ewk_popup_menu_item_enabled_get(it); + } + + elm_object_item_disabled_set(lit, disabled); + break; + default: + break; + } + } + elm_list_go(list); + + grid = elm_grid_add(win); + elm_grid_size_set(grid, 1, 1); + elm_grid_pack(grid, list, 0, 0, 1, 1); + evas_object_geometry_get(win, NULL, NULL, &ww, &wh); + + //FIXME: it should be the real height of items in the list. + h = r.h * eina_list_count(items); + evas_object_size_hint_min_set(grid, ww, h < wh / 2 ? h : wh / 2); + elm_object_content_set(notify, grid); + evas_object_show(grid); + + evas_object_show(notify); + + evas_object_data_set(sd->self, "_select_popup", notify); + + eo_event_callback_add + (notify, ELM_NOTIFY_EVENT_BLOCK_CLICKED, _popup_dismiss_cb, menu); + + return EINA_TRUE; +} + +static Eina_Bool +_view_smart_popup_menu_hide(Ewk_View_Smart_Data *sd) +{ + Evas_Object *popup = evas_object_data_get(sd->self, "_select_popup"); + if (!popup) return EINA_FALSE; + + evas_object_del(popup); + evas_object_data_del(sd->self, "_select_popup"); + + return EINA_TRUE; +} + +static Eina_Bool +_fullscreen_accept(void *data, const Eo_Event *event EINA_UNUSED) +{ + Evas_Object *ewk = data; + evas_object_del(evas_object_data_get(ewk, "_fullscreen_permission_popup")); + + return EINA_TRUE; +} + +static Eina_Bool +_fullscreen_deny(void *data, const Eo_Event *event EINA_UNUSED) +{ + Evas_Object *ewk = data; + ewk_view_fullscreen_exit(ewk); + evas_object_del(evas_object_data_get(ewk, "_fullscreen_permission_popup")); + + return EINA_TRUE; +} + +static Eina_Bool +_view_smart_fullscreen_enter(Ewk_View_Smart_Data *sd, Ewk_Security_Origin *origin) +{ + Evas_Object *btn, *popup, *top; + const char *host; + char buffer[2048]; + + Evas_Object *obj = evas_object_smart_parent_get(sd->self); + + ELM_WEB_WEBKIT2_CHECK(obj) EINA_FALSE; + + top = elm_widget_top_get(obj); + elm_win_fullscreen_set(top, EINA_TRUE); + + popup = elm_popup_add(top); + elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + host = ewk_security_origin_host_get(origin); + snprintf(buffer, sizeof(buffer), "%s is now fullscreen.
Press ESC at any time to exit fullscreen,
Allow fullscreen?
", host); + elm_object_text_set(popup, buffer); + + btn = elm_button_add(popup); + elm_object_text_set(btn, "Accept"); + elm_object_part_content_set(popup, "button1", btn); + eo_event_callback_add + (btn, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _fullscreen_accept, sd->self); + + btn = elm_button_add(popup); + elm_object_text_set(btn, "Deny"); + elm_object_part_content_set(popup, "button2", btn); + eo_event_callback_add + (btn, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _fullscreen_deny, sd->self); + + evas_object_data_set(sd->self, "_fullscreen_permission_popup", popup); + evas_object_show(popup); + + return EINA_TRUE; +} + +static Eina_Bool +_view_smart_fullscreen_exit(Ewk_View_Smart_Data *sd) +{ + Evas_Object *obj = evas_object_smart_parent_get(sd->self); + + ELM_WEB_WEBKIT2_CHECK(obj) EINA_FALSE; + + Evas_Object *top = elm_widget_top_get(obj); + elm_win_fullscreen_set(top, EINA_FALSE); + + return EINA_TRUE; +} + +static Eina_Bool +_bt_close(void *data, const Eo_Event *event) +{ + Dialog_Data *d = data; + + if (d->type == DIALOG_ALERT) goto end; + + *d->response = (event->obj == d->bt_ok); + if (d->type == DIALOG_CONFIRM) goto end; + + if (d->type == DIALOG_PROMPT) + *d->entry_value = strdup(elm_entry_entry_get(d->entry)); + +end: + evas_object_del(d->dialog); + free(d); + + return EINA_TRUE; +} + +static Dialog_Data * +_dialog_new(Evas_Object *web, Eina_Bool inwin_mode) +{ + Dialog_Data *d; + + d = calloc(1, sizeof(Dialog_Data)); + if (!d) return NULL; + + if (!web || inwin_mode) + { + Evas_Object *bg; + + d->dialog = elm_win_add(NULL, "elm-web-popup", ELM_WIN_DIALOG_BASIC); + eo_event_callback_add + (d->dialog, ELM_WIN_EVENT_DELETE_REQUEST, _bt_close, d); + + bg = elm_bg_add(d->dialog); + evas_object_size_hint_weight_set + (bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(d->dialog, bg); + evas_object_show(bg); + + d->box = elm_box_add(d->dialog); + evas_object_size_hint_weight_set + (d->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(d->dialog, d->box); + evas_object_show(d->box); + } + else + { + Evas_Object *win = elm_widget_top_get(web); + + d->dialog = elm_win_inwin_add(win); + elm_object_style_set(d->dialog, "minimal"); + evas_object_size_hint_weight_set + (d->dialog, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + d->box = elm_box_add(win); + evas_object_size_hint_weight_set + (d->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_inwin_content_set(d->dialog, d->box); + evas_object_show(d->box); + } + + return d; +} + +static void +_dialog_ok_cancel_buttons_add(Dialog_Data *dialog_data) +{ + Evas_Object *bx, *bt; + bx = elm_box_add(dialog_data->box); + elm_box_horizontal_set(bx, EINA_TRUE); + elm_box_pack_end(dialog_data->box, bx); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(bx); + + dialog_data->bt_cancel = bt = elm_button_add(bx); + elm_object_text_set(bt, "Cancel"); + elm_box_pack_end(bx, bt); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + eo_event_callback_add + (bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _bt_close, dialog_data); + evas_object_show(bt); + + dialog_data->bt_ok = bt = elm_button_add(bx); + elm_object_text_set(bt, "Ok"); + elm_box_pack_end(bx, bt); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + eo_event_callback_add + (bt, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _bt_close, dialog_data); + evas_object_show(bt); +} + +static void +_dialog_del_cb(void *data EINA_UNUSED, + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + ecore_main_loop_quit(); +} + +static void +_exec_dialog(Evas_Object *dialog) +{ + evas_object_event_callback_add + (dialog, EVAS_CALLBACK_DEL, _dialog_del_cb, NULL); + ecore_main_loop_begin(); +} + +static void +_view_smart_run_javascript_alert(Ewk_View_Smart_Data *vsd, const char *message) +{ + Evas_Object *obj = evas_object_smart_parent_get(vsd->self); + Evas_Object *dialog = NULL; + + ELM_WEB_WEBKIT2_DATA_GET_OR_RETURN(obj, sd); + + if (sd->hook.alert) + dialog = sd->hook.alert(sd->hook.alert_data, obj, message); + else + { + Evas_Object *lb; + Dialog_Data *dialog_data = _dialog_new(obj, sd->inwin_mode); + dialog_data->type = DIALOG_ALERT; + dialog = dialog_data->dialog; + + lb = elm_label_add(dialog_data->box); + elm_object_text_set(lb, message); + elm_box_pack_end(dialog_data->box, lb); + evas_object_show(lb); + + dialog_data->bt_ok = elm_button_add(dialog_data->box); + elm_object_text_set(dialog_data->bt_ok, "Close"); + elm_box_pack_end(dialog_data->box, dialog_data->bt_ok); + evas_object_size_hint_align_set + (dialog_data->bt_ok, EVAS_HINT_FILL, EVAS_HINT_FILL); + eo_event_callback_add + (dialog_data->bt_ok, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _bt_close, dialog_data); + evas_object_show(dialog_data->bt_ok); + + evas_object_show(dialog); + } + + if (dialog) _exec_dialog(dialog); +} + +static Eina_Bool +_view_smart_run_javascript_confirm(Ewk_View_Smart_Data *vsd, const char *message) +{ + Evas_Object *obj = evas_object_smart_parent_get(vsd->self); + Eina_Bool response = EINA_FALSE; + Evas_Object *dialog = NULL; + + ELM_WEB_WEBKIT2_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE); + + if (sd->hook.confirm) + dialog = sd->hook.confirm(sd->hook.confirm_data, obj, message, &response); + else + { + Evas_Object *lb; + Dialog_Data *dialog_data = _dialog_new(obj, sd->inwin_mode); + dialog_data->type = DIALOG_CONFIRM; + dialog_data->response = &response; + dialog = dialog_data->dialog; + + lb = elm_label_add(dialog_data->box); + elm_object_text_set(lb, message); + elm_box_pack_end(dialog_data->box, lb); + evas_object_show(lb); + + _dialog_ok_cancel_buttons_add(dialog_data); + + evas_object_show(dialog); + } + + if (dialog) _exec_dialog(dialog); + + return response; +} + +static const char * +_view_smart_run_javascript_prompt(Ewk_View_Smart_Data *vsd, const char *message, const char *default_value) +{ + Evas_Object *obj = evas_object_smart_parent_get(vsd->self); + Eina_Bool response = EINA_FALSE; + Evas_Object *dialog = NULL; + char *value = NULL; + const char *ret; + + ELM_WEB_WEBKIT2_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE); + + if (sd->hook.prompt) + dialog = sd->hook.prompt(sd->hook.prompt_data, obj, message, default_value, (const char**)&value, &response); + else + { + Evas_Object *lb, *entry; + Dialog_Data *dialog_data = _dialog_new(obj, sd->inwin_mode); + dialog_data->type = DIALOG_PROMPT; + dialog_data->response = &response; + dialog_data->entry_value = (const char**)&value; + dialog = dialog_data->dialog; + + lb = elm_label_add(dialog_data->box); + elm_object_text_set(lb, message); + elm_box_pack_end(dialog_data->box, lb); + evas_object_show(lb); + + dialog_data->entry = entry = elm_entry_add(dialog_data->box); + elm_entry_single_line_set(entry, EINA_TRUE); + elm_entry_scrollable_set(entry, EINA_TRUE); + elm_entry_entry_set(entry, default_value); + evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_box_pack_end(dialog_data->box, entry); + evas_object_show(entry); + + _dialog_ok_cancel_buttons_add(dialog_data); + + evas_object_show(dialog); + } + + if (dialog) _exec_dialog(dialog); + + if (!value) return NULL; + + ret = eina_stringshare_add(value); + free(value); + return ret; +} + +/** + * Creates a new view object given the parent. + * + * @param parent object to use as parent. + * + * @return newly added Evas_Object or @c NULL on errors. + */ +Evas_Object * +_view_add(Evas_Object *parent) +{ + Evas *canvas = evas_object_evas_get(parent); + static Evas_Smart *smart = NULL; + Evas_Object *view; + + if (!smart) + { + static Ewk_View_Smart_Class api = + EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("EWK_View_Elementary"); + + ewk_view_smart_class_set(&api); + ewk_view_smart_class_set(&_ewk_view_parent_sc); + + // TODO: check every api method and provide overrides with hooks! + // TODO: hooks should provide extension points + // TODO: extension should have some kind of "default implementation", + // TODO: that can be replaced or controlled by hooks. + // TODO: ie: run_javascript_alert() should present an elm_win + // TODO: by default, but user could override it to show as inwin. + api.sc.add = _view_smart_add; + api.sc.del = _view_smart_del; + api.window_create = _view_smart_window_create; + api.window_close = _view_smart_window_close; + api.popup_menu_show = _view_smart_popup_menu_show; + api.popup_menu_hide = _view_smart_popup_menu_hide; + api.fullscreen_enter = _view_smart_fullscreen_enter; + api.fullscreen_exit = _view_smart_fullscreen_exit; + api.run_javascript_alert = _view_smart_run_javascript_alert; + api.run_javascript_confirm = _view_smart_run_javascript_confirm; + api.run_javascript_prompt = _view_smart_run_javascript_prompt; + + smart = evas_smart_class_new(&api.sc); + if (!smart) + { + CRI("Could not create smart class"); + return NULL; + } + } + + view = ewk_view_smart_add(canvas, smart, ewk_context_default_get(), ewk_page_group_create(0)); + if (!view) + { + ERR("Could not create smart object object for view"); + return NULL; + } + + return view; +} + +static Eina_Bool +_view_smart_url_changed_cb(void *data, const Eo_Event *event) +{ + eo_event_callback_call(data, ELM_WEB_EVENT_URI_CHANGED, event->event_info); + eo_event_callback_call(data, ELM_WEB_EVENT_URL_CHANGED, event->event_info); + + return EINA_TRUE; +} + +static void +_view_smart_callback_proxy(Evas_Object *view, Evas_Object *parent) +{ + eo_event_callback_add + (view, ELM_WEB_EVENT_URL_CHANGED, _view_smart_url_changed_cb, parent); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_widget_on_focus(Eo *obj, Elm_Web_Webkit2_Data *sd, Elm_Object_Item *item EINA_UNUSED) +{ + Evas_Object *top; + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_TRUE); + Eina_Bool int_ret = EINA_FALSE; + + int_ret = elm_obj_widget_on_focus(eo_super(obj, MY_CLASS), NULL); + if (!int_ret) return EINA_TRUE; + + top = elm_widget_top_get(obj); + + if (elm_object_focus_get(obj)) + { + evas_object_focus_set(wd->resize_obj, EINA_TRUE); + if (top) elm_win_keyboard_mode_set(top, sd->input_method); + } + else + { + evas_object_focus_set(wd->resize_obj, EINA_FALSE); + if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF); + } + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_tab_propagate_get(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd) +{ + return sd->tab_propagate; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_tab_propagate_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd, Eina_Bool propagate) +{ + sd->tab_propagate = propagate; +} + +EOLIAN static void +_elm_web_webkit2_evas_object_smart_add(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + Evas_Object *resize_obj; + + resize_obj = _view_add(obj); + elm_widget_resize_object_set(obj, resize_obj, EINA_TRUE); + + evas_obj_smart_add(eo_super(obj, MY_CLASS)); + elm_widget_sub_object_parent_add(obj); + + //TODO: need a way to change theme + ewk_view_theme_set(resize_obj, WEBKIT_DATADIR "/themes/default.edj"); + + _view_smart_callback_proxy(resize_obj, obj); + elm_widget_can_focus_set(obj, EINA_TRUE); +} + +EOLIAN static void +_elm_web_webkit2_evas_object_smart_del(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + evas_obj_smart_del(eo_super(obj, MY_CLASS)); +} + +EOLIAN static Evas_Object* +_elm_web_webkit2_elm_web_webkit_view_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + return wd->resize_obj; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_window_create_hook_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd, Elm_Web_Window_Open func, void *data) +{ + sd->hook.window_create = func; + sd->hook.window_create_data = data; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_dialog_alert_hook_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd, Elm_Web_Dialog_Alert func, void *data) +{ + sd->hook.alert = func; + sd->hook.alert_data = data; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_dialog_confirm_hook_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd, Elm_Web_Dialog_Confirm func, void *data) +{ + sd->hook.confirm = func; + sd->hook.confirm_data = data; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_dialog_prompt_hook_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd, Elm_Web_Dialog_Prompt func, void *data) +{ + sd->hook.prompt = func; + sd->hook.prompt_data = data; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_dialog_file_selector_hook_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, Elm_Web_Dialog_File_Selector func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_webkit2_elm_web_console_message_hook_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, Elm_Web_Console_Message func EINA_UNUSED, void *data EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_webkit2_elm_web_useragent_set(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, const char *user_agent) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + ewk_view_user_agent_set(wd->resize_obj, user_agent); +} + +EOLIAN static const char* +_elm_web_webkit2_elm_web_useragent_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + + return ewk_view_user_agent_get(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_url_set(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, const char *url) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + return ewk_view_url_set(wd->resize_obj, url); +} + +EOLIAN static const char* +_elm_web_webkit2_elm_web_url_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + return ewk_view_url_get(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_html_string_load(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, const char *html, const char *base_url, const char *unreachable_url) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_html_string_load(wd->resize_obj, + html, base_url, unreachable_url); +} + +EOLIAN static const char* +_elm_web_webkit2_elm_web_title_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + return ewk_view_title_get(wd->resize_obj); +} + +EOLIAN static void +_elm_web_webkit2_elm_web_bg_color_set(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, int r, int g, int b, int a) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + ewk_view_bg_color_set(wd->resize_obj, r, g, b, a); +} + +EOLIAN static void +_elm_web_webkit2_elm_web_bg_color_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, int *r, int *g, int *b, int *a) +{ + if (r) *r = 0; + if (g) *g = 0; + if (b) *b = 0; + if (a) *a = 0; + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + ewk_view_bg_color_get(wd->resize_obj, r, g, b, a); +} + +EOLIAN static const char* +_elm_web_webkit2_elm_web_selection_get(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + return NULL; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_popup_selected_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, int idx EINA_UNUSED) +{ +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_popup_destroy(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_text_search(const Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, const char *string EINA_UNUSED, Eina_Bool case_sensitive EINA_UNUSED, Eina_Bool forward EINA_UNUSED, Eina_Bool wrap EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static unsigned int +_elm_web_webkit2_elm_web_text_matches_mark(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, const char *string EINA_UNUSED, Eina_Bool case_sensitive EINA_UNUSED, Eina_Bool highlight EINA_UNUSED, unsigned int limit EINA_UNUSED) +{ + return 0; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_text_matches_unmark_all(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_text_matches_highlight_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, Eina_Bool highlight EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_text_matches_highlight_get(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static double +_elm_web_webkit2_elm_web_load_progress_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, -1.0); + + return ewk_view_load_progress_get(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_stop(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_stop(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_reload(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_reload(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_reload_full(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_reload_bypass_cache(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_back(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_back(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_forward(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_forward(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_navigate(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, int steps) +{ + Ewk_Back_Forward_List *history; + Ewk_Back_Forward_List_Item *item = NULL; + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + history = ewk_view_back_forward_list_get(wd->resize_obj); + if (history) + { + item = ewk_back_forward_list_item_at_index_get(history, steps); + if (item) return ewk_view_navigate_to(wd->resize_obj, item); + } + + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_back_possible_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_back_possible(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_forward_possible_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + return ewk_view_forward_possible(wd->resize_obj); +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_navigate_possible_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, int steps) +{ + Ewk_Back_Forward_List *history; + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + + history = ewk_view_back_forward_list_get(wd->resize_obj); + if (history && ewk_back_forward_list_item_at_index_get(history, steps)) + return EINA_TRUE; + return EINA_FALSE; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_history_enabled_get(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + return EINA_FALSE; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_history_enabled_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, Eina_Bool enable EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_webkit2_elm_web_zoom_set(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, double zoom) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + + ewk_view_page_zoom_set(wd->resize_obj, zoom); +} + +EOLIAN static double +_elm_web_webkit2_elm_web_zoom_get(Eo *obj, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, -1); + + return ewk_view_page_zoom_get(wd->resize_obj); +} + +EOLIAN static void +_elm_web_webkit2_elm_web_zoom_mode_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, Elm_Web_Zoom_Mode mode EINA_UNUSED) +{ +} + +EOLIAN static Elm_Web_Zoom_Mode +_elm_web_webkit2_elm_web_zoom_mode_get(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED) +{ + return ELM_WEB_ZOOM_MODE_LAST; +} + +EOLIAN static void +_elm_web_webkit2_elm_web_region_show(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_webkit2_elm_web_region_bring_in(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *_pd EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED) +{ +} + +EOLIAN static void +_elm_web_webkit2_elm_web_inwin_mode_set(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd, Eina_Bool value) +{ + sd->inwin_mode = value; +} + +EOLIAN static Eina_Bool +_elm_web_webkit2_elm_web_inwin_mode_get(Eo *obj EINA_UNUSED, Elm_Web_Webkit2_Data *sd) +{ + return sd->inwin_mode; +} + +EAPI void +ewm_web_window_features_ref(Elm_Web_Window_Features *wf) +{ + ewk_object_ref((Ewk_Object *)wf); +} + +EAPI void +ewm_web_window_features_unref(Elm_Web_Window_Features *wf) +{ + ewk_object_unref((Ewk_Object *)wf); +} + +EAPI Eina_Bool +ewm_web_window_features_property_get(const Elm_Web_Window_Features *wf, + Elm_Web_Window_Feature_Flag flag) +{ + const Ewk_Window_Features *ewf = (const Ewk_Window_Features *)wf; + switch (flag) + { + case ELM_WEB_WINDOW_FEATURE_TOOLBAR: + return ewk_window_features_toolbar_visible_get(ewf); + + case ELM_WEB_WINDOW_FEATURE_STATUSBAR: + return ewk_window_features_statusbar_visible_get(ewf); + + case ELM_WEB_WINDOW_FEATURE_SCROLLBARS: + return ewk_window_features_scrollbars_visible_get(ewf); + + case ELM_WEB_WINDOW_FEATURE_MENUBAR: + return ewk_window_features_menubar_visible_get(ewf); + + case ELM_WEB_WINDOW_FEATURE_LOCATIONBAR: + return ewk_window_features_locationbar_visible_get(ewf); + + case ELM_WEB_WINDOW_FEATURE_FULLSCREEN: + return ewk_window_features_fullscreen_get(ewf); + } + + return EINA_FALSE; +} + +EAPI void +ewm_web_window_features_region_get(const Elm_Web_Window_Features *wf, + Evas_Coord *x, + Evas_Coord *y, + Evas_Coord *w, + Evas_Coord *h) +{ + ewk_window_features_geometry_get + ((const Ewk_Window_Features *)wf, x, y, w, h); +} + +static Eina_Bool _elm_need_web = EINA_FALSE; + +EAPI void +ewm_unneed_web(void) +{ + if (!_elm_need_web) return; + _elm_need_web = EINA_FALSE; + ewk_shutdown(); +} + +EAPI Eina_Bool +ewm_need_web(void) +{ + if (_elm_need_web) return EINA_TRUE; + _elm_need_web = EINA_TRUE; + ewk_init(); + + if (_webkit2_log_dom == -1) + _webkit2_log_dom = eina_log_domain_register("elm_webkit2", EINA_COLOR_LIGHTBLUE); + return EINA_TRUE; +} + +EAPI const Eo_Class * +ewm_class_get(void) +{ + return elm_web_webkit2_class_get(); +} + +#undef ELM_WEB_CLASS +#define ELM_WEB_CLASS elm_web_class_get() + +#include "elm_web_webkit2.eo.c" diff --git a/src/modules/elementary/web/webkit2/elm_web_webkit2.eo b/src/modules/elementary/web/webkit2/elm_web_webkit2.eo new file mode 100644 index 0000000000..a0dad4a83a --- /dev/null +++ b/src/modules/elementary/web/webkit2/elm_web_webkit2.eo @@ -0,0 +1,53 @@ +class Elm.Web.Webkit2 (Elm.Web) +{ + implements { + Evas.Object_Smart.add; + Evas.Object_Smart.del; + Elm.Widget.on_focus; + Elm.Web.tab_propagate.get; + Elm.Web.tab_propagate.set; + Elm.Web.webkit_view.get; + Elm.Web.window_create_hook.set; + Elm.Web.dialog_alert_hook.set; + Elm.Web.dialog_confirm_hook.set; + Elm.Web.dialog_prompt_hook.set; + Elm.Web.dialog_file_selector_hook.set; + Elm.Web.console_message_hook.set; + Elm.Web.useragent.set; + Elm.Web.useragent.get; + Elm.Web.url.set; + Elm.Web.url.get; + Elm.Web.html_string_load; + Elm.Web.title.get; + Elm.Web.bg_color.set; + Elm.Web.bg_color.get; + Elm.Web.selection.get; + Elm.Web.popup_selected.set; + Elm.Web.popup_destroy; + Elm.Web.text_search; + Elm.Web.text_matches_mark; + Elm.Web.text_matches_unmark_all; + Elm.Web.text_matches_highlight.set; + Elm.Web.text_matches_highlight.get; + Elm.Web.load_progress.get; + Elm.Web.stop; + Elm.Web.reload; + Elm.Web.reload_full; + Elm.Web.back; + Elm.Web.forward; + Elm.Web.navigate; + Elm.Web.back_possible.get; + Elm.Web.forward_possible.get; + Elm.Web.navigate_possible_get; + Elm.Web.history_enabled.get; + Elm.Web.history_enabled.set; + Elm.Web.zoom.set; + Elm.Web.zoom.get; + Elm.Web.zoom_mode.set; + Elm.Web.zoom_mode.get; + Elm.Web.region_show; + Elm.Web.region_bring_in; + Elm.Web.inwin_mode.set; + Elm.Web.inwin_mode.get; + } +} -- cgit v1.2.1