summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2016-07-29 19:26:21 -0300
committerLarry Jr <larry.olj@gmail.com>2016-07-29 19:26:21 -0300
commitd5761bf03eacb49ca99983c021e4878f2bd72344 (patch)
treeb5d72b5c80e732e02e2aa3300d19c1a7b23fee63
parent84464fd1031664d191e75b86aeab614d0be8caee (diff)
elementary, elm_layout added model_connect signal emitdevs/felipealmeida/model_connect_lastdevs/felipealmeida/layout_connect
-rw-r--r--src/examples/elementary/layout_model_connect.c12
-rw-r--r--src/lib/elementary/elm_layout.c30
2 files changed, 40 insertions, 2 deletions
diff --git a/src/examples/elementary/layout_model_connect.c b/src/examples/elementary/layout_model_connect.c
index 6f78e6f7a6..38884bfe05 100644
--- a/src/examples/elementary/layout_model_connect.c
+++ b/src/examples/elementary/layout_model_connect.c
@@ -78,6 +78,16 @@ _label_init(Evas_Object *win, Evas_Object *box, const char *text)
78 return widget; 78 return widget;
79} 79}
80 80
81
82static void
83_signal_cb(void *data,
84 Evas_Object *obj EINA_UNUSED,
85 const char *emission,
86 const char *source)
87{
88 printf(">> Signal callback emission='%s' source='%s'\n", emission, source);
89}
90
81EAPI_MAIN int 91EAPI_MAIN int
82elm_main(int argc, char **argv) 92elm_main(int argc, char **argv)
83{ 93{
@@ -136,6 +146,8 @@ elm_main(int argc, char **argv)
136 elm_box_pack_end(bxr, priv->bt); 146 elm_box_pack_end(bxr, priv->bt);
137 elm_object_text_set(priv->bt, "update model"); 147 elm_object_text_set(priv->bt, "update model");
138 evas_object_smart_callback_add(priv->bt, "clicked", _update_cb, priv); 148 evas_object_smart_callback_add(priv->bt, "clicked", _update_cb, priv);
149 edje_obj_signal_callback_add(priv->bt, "test*" , "*", _signal_cb, priv);
150 efl_ui_model_connect(priv->bt, "signal/test-%v", "size");
139 evas_object_show(priv->bt); 151 evas_object_show(priv->bt);
140 152
141 /* Image widget */ 153 /* Image widget */
diff --git a/src/lib/elementary/elm_layout.c b/src/lib/elementary/elm_layout.c
index df660dd7da..ff9cc298cd 100644
--- a/src/lib/elementary/elm_layout.c
+++ b/src/lib/elementary/elm_layout.c
@@ -28,6 +28,8 @@ static const char SIG_THEME_CHANGED[] = "theme,changed";
28const char SIG_LAYOUT_FOCUSED[] = "focused"; 28const char SIG_LAYOUT_FOCUSED[] = "focused";
29const char SIG_LAYOUT_UNFOCUSED[] = "unfocused"; 29const char SIG_LAYOUT_UNFOCUSED[] = "unfocused";
30 30
31const char SIGNAL_PREFIX[] = "signal/";
32
31/* smart callbacks coming from elm layout objects: */ 33/* smart callbacks coming from elm layout objects: */
32static const Evas_Smart_Cb_Description _smart_callbacks[] = { 34static const Evas_Smart_Cb_Description _smart_callbacks[] = {
33 {SIG_THEME_CHANGED, ""}, 35 {SIG_THEME_CHANGED, ""},
@@ -1961,6 +1963,30 @@ _prop_promise_error_cb(void* data, Eina_Error err EINA_UNUSED)
1961} 1963}
1962 1964
1963static void 1965static void
1966_view_update(Elm_Layout_Smart_Data *pd, const char *name, const char *property)
1967{
1968 const char *source;
1969 Eina_Strbuf *buf;
1970
1971 if (strncmp(SIGNAL_PREFIX, name, sizeof(SIGNAL_PREFIX) -1) != 0)
1972 {
1973 elm_layout_text_set(pd->obj, name, property);
1974 return;
1975 }
1976
1977 ELM_WIDGET_DATA_GET_OR_RETURN(pd->obj, wd);
1978 source = eo_class_name_get(eo_class_get(pd->model));
1979
1980 buf = eina_strbuf_new();
1981 eina_strbuf_append(buf, name);
1982 eina_strbuf_remove(buf, 0, sizeof(SIGNAL_PREFIX)-1);
1983 eina_strbuf_replace_all(buf, "%v", property);
1984
1985 edje_object_signal_emit(wd->resize_obj, eina_strbuf_string_get(buf), source);
1986 eina_strbuf_free(buf);
1987}
1988
1989static void
1964_prop_promise_then_cb(void* data, void* values) 1990_prop_promise_then_cb(void* data, void* values)
1965{ 1991{
1966 Elm_Layout_Sub_Property_Promise *sub_pp = data; 1992 Elm_Layout_Sub_Property_Promise *sub_pp = data;
@@ -1980,12 +2006,12 @@ _prop_promise_then_cb(void* data, void* values)
1980 if (vtype == EINA_VALUE_TYPE_STRING || vtype == EINA_VALUE_TYPE_STRINGSHARE) 2006 if (vtype == EINA_VALUE_TYPE_STRING || vtype == EINA_VALUE_TYPE_STRINGSHARE)
1981 { 2007 {
1982 eina_value_get(value, &text); 2008 eina_value_get(value, &text);
1983 elm_layout_text_set(pd->obj, name, text); 2009 _view_update(pd, name, text);
1984 } 2010 }
1985 else 2011 else
1986 { 2012 {
1987 text = eina_value_to_string(value); 2013 text = eina_value_to_string(value);
1988 elm_layout_text_set(pd->obj, name, text); 2014 _view_update(pd, name, text);
1989 free(text); 2015 free(text);
1990 } 2016 }
1991 eina_stringshare_del(name); 2017 eina_stringshare_del(name);