From 813a78ea78acd50fe68887fe35a6370674b1b103 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 13 Sep 2010 08:44:09 +0900 Subject: [PATCH] [entry] add autoperiod API --- src/lib/Elementary.h.in | 6 ++- src/lib/elc_scrolled_entry.c | 22 +++++++++- src/lib/elm_config.c | 98 +++++++++++++++++++++++++++++++++++--------- src/lib/elm_entry.c | 31 +++++++++++++- src/lib/elm_priv.h | 2 + 5 files changed, 133 insertions(+), 26 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 396f8e0..5b4ba14 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -830,7 +830,8 @@ extern "C" { EAPI void elm_entry_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a); EAPI void elm_entry_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis); - EAPI void elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool on); + EAPI void elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap); + EAPI void elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod); EAPI void elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on); EAPI void elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled); EAPI void elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout); @@ -1734,7 +1735,8 @@ extern "C" { EAPI void elm_scrolled_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled); EAPI void elm_scrolled_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout); EAPI Ecore_IMF_Context *elm_scrolled_entry_imf_context_get(Evas_Object *obj); - EAPI void elm_scrolled_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool on); + EAPI void elm_scrolled_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap); + EAPI void elm_scrolled_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod); EAPI Evas_Object *elm_conformant_add(Evas_Object *parent); EAPI void elm_conformant_content_set(Evas_Object *obj, Evas_Object *content); diff --git a/src/lib/elc_scrolled_entry.c b/src/lib/elc_scrolled_entry.c index ce0fa4e..cfc254a 100644 --- a/src/lib/elc_scrolled_entry.c +++ b/src/lib/elc_scrolled_entry.c @@ -1063,12 +1063,30 @@ elm_scrolled_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layo * @ingroup Scrolled_Entry */ EAPI void -elm_scrolled_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool on) +elm_scrolled_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd || !wd->entry) return; - elm_entry_autocapitalization_set(wd->entry, on); + elm_entry_autocapitalization_set(wd->entry, autocap); +} + +/** + * Set whether scrolled entry should support auto period + * + * @param obj The entry object + * @param on If true, scrolled entry suports auto period. + * + * @ingroup Scrolled_Entry + */ +EAPI void +elm_scrolled_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd || !wd->entry) return; + + elm_entry_autoperiod_set(wd->entry, autoperiod); } diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c index 7763cdd..466f05a 100644 --- a/src/lib/elm_config.c +++ b/src/lib/elm_config.c @@ -35,7 +35,9 @@ static const char *_atom_names[ATOM_COUNT] = "ENLIGHTENMENT_THEME", "ENLIGHTENMENT_PROFILE", "ENLIGHTENMENT_CONFIG", - "ENLIGHTENMENT_INPUT_PANEL" + "ENLIGHTENMENT_INPUT_PANEL", + "ENLIGHTENMENT_AUTOCAPITAL", + "ENLIGHTENMENT_AUTOPERIOD", }; #define ATOM_E_SCALE 0 #define ATOM_E_FINGER_SIZE 1 @@ -43,6 +45,8 @@ static const char *_atom_names[ATOM_COUNT] = #define ATOM_E_PROFILE 3 #define ATOM_E_CONFIG 4 #define ATOM_E_INPUT_PANEL 5 +#define ATOM_E_AUTOCAPITAL 6 +#define ATOM_E_AUTOPERIOD 7 static Eina_Bool _prop_config_get(void); static Eina_Bool _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev); @@ -168,11 +172,6 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) } } } - else if (((_atom_config > 0) && (event->atom == _atom_config)) || - (event->atom == _atom[ATOM_E_CONFIG])) - { - _prop_config_get(); - } else if (event->atom == _atom[ATOM_E_INPUT_PANEL]) { unsigned int val = 0; @@ -183,8 +182,36 @@ _prop_change(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) { edje_input_panel_enabled_set(val); } - } + } + else if (event->atom == _atom[ATOM_E_AUTOCAPITAL]) + { + unsigned int val = 0; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + edje_autocapitalization_set(val); + } + } + else if (event->atom == _atom[ATOM_E_AUTOPERIOD]) + { + unsigned int val = 0; + + if (ecore_x_window_prop_card32_get(event->win, + event->atom, + &val, 1) > 0) + { + edje_autoperiod_set(val); + } + } + else if (((_atom_config > 0) && (event->atom == _atom_config)) || + (event->atom == _atom[ATOM_E_CONFIG])) + { + _prop_config_get(); + } } + return ECORE_CALLBACK_PASS_ON; } #endif @@ -522,6 +549,12 @@ _env_get(void) s = getenv("ELM_INPUT_PANEL"); if (s) _elm_config->input_panel_enable = atoi(s); + + s = getenv("ELM_AUTOCAPITAL"); + if (s) _elm_config->autocapital = atoi(s); + + s = getenv("ELM_AUTOPERIOD"); + if (s) _elm_config->autoperiod = atoi(s); } void @@ -620,19 +653,42 @@ _elm_config_sub_init(void) if (changed) _prop_config_get(); } } - if (!getenv("ELM_INPUT_PANEL")) - { - if (ecore_x_window_prop_card32_get(_root_1st, - _atom[ATOM_E_INPUT_PANEL], - &val, 1) > 0) - { - if (val > 0) - { - _elm_config->input_panel_enable = val; - } - } - } - + if (!getenv("ELM_INPUT_PANEL")) + { + if (ecore_x_window_prop_card32_get(_root_1st, + _atom[ATOM_E_INPUT_PANEL], + &val, 1) > 0) + { + if (val > 0) + { + _elm_config->input_panel_enable = val; + } + } + } + if (!getenv("ELM_AUTOCAPITAL")) + { + if (ecore_x_window_prop_card32_get(_root_1st, + _atom[ATOM_E_AUTOCAPITAL], + &val, 1) > 0) + { + if (val > 0) + { + _elm_config->autocapital = val; + } + } + } + if (!getenv("ELM_AUTOPERIOD")) + { + if (ecore_x_window_prop_card32_get(_root_1st, + _atom[ATOM_E_AUTOPERIOD], + &val, 1) > 0) + { + if (val > 0) + { + _elm_config->autoperiod = val; + } + } + } #endif } } @@ -663,3 +719,5 @@ _elm_config_shutdown(void) } _desc_shutdown(); } + +/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index 13b6280..a70172e 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -137,6 +137,7 @@ struct _Widget_Data Eina_Bool input_panel_enable : 1; Eina_Bool autocapitalize : 1; Elm_Input_Panel_Layout input_panel_layout; + Eina_Bool autoperiod : 1; }; struct _Elm_Entry_Item_Provider @@ -284,6 +285,7 @@ _theme_hook(Evas_Object *obj) eina_stringshare_del(t); edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale); edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize); +// edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod); edje_object_part_text_input_panel_enabled_set(wd->ent, "elm.text", wd->input_panel_enable); ic = edje_object_part_text_imf_context_get(wd->ent, "elm.text"); @@ -1938,6 +1940,8 @@ elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line) t = eina_stringshare_add(elm_entry_entry_get(obj)); _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj)); elm_entry_entry_set(obj, t); + edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize); +// edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod); ic = elm_entry_imf_context_get(obj); if (ic) { @@ -2865,7 +2869,7 @@ elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on) * @ingroup Entry */ EAPI void -elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool on) +elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); @@ -2874,12 +2878,35 @@ elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool on) if (wd->password) wd->autocapitalize = EINA_FALSE; else - wd->autocapitalize = on; + wd->autocapitalize = autocap; edje_object_part_text_autocapitalization_set(wd->ent, "elm.text", wd->autocapitalize); } /** + * Set whether entry should support auto period + * + * @param obj The entry object + * @param on If true, entry suports auto period. + * + * @ingroup Entry + */ +EAPI void +elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + if (wd->password) + wd->autoperiod = EINA_FALSE; + else + wd->autoperiod = autoperiod; + +// edje_object_part_text_autoperiod_set(wd->ent, "elm.text", wd->autoperiod); +} + +/** * Set the font size on the entry object * * @param obj The entry object diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index 6eaf759..02fa57f 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -78,6 +78,8 @@ struct _Elm_Config const char *theme; const char *modules; int input_panel_enable; + int autocapital; + int autoperiod; }; typedef struct _Elm_Module Elm_Module; -- 2.7.4