aboutsummaryrefslogtreecommitdiffstats
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
parentelementary: efl_ui_image added "key" in model_connect (diff)
downloadefl-d5761bf03eacb49ca99983c021e4878f2bd72344.tar.gz
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)
return widget;
}
+
+static void
+_signal_cb(void *data,
+ Evas_Object *obj EINA_UNUSED,
+ const char *emission,
+ const char *source)
+{
+ printf(">> Signal callback emission='%s' source='%s'\n", emission, source);
+}
+
EAPI_MAIN int
elm_main(int argc, char **argv)
{
@@ -136,6 +146,8 @@ elm_main(int argc, char **argv)
elm_box_pack_end(bxr, priv->bt);
elm_object_text_set(priv->bt, "update model");
evas_object_smart_callback_add(priv->bt, "clicked", _update_cb, priv);
+ edje_obj_signal_callback_add(priv->bt, "test*" , "*", _signal_cb, priv);
+ efl_ui_model_connect(priv->bt, "signal/test-%v", "size");
evas_object_show(priv->bt);
/* 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";
const char SIG_LAYOUT_FOCUSED[] = "focused";
const char SIG_LAYOUT_UNFOCUSED[] = "unfocused";
+const char SIGNAL_PREFIX[] = "signal/";
+
/* smart callbacks coming from elm layout objects: */
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
{SIG_THEME_CHANGED, ""},
@@ -1961,6 +1963,30 @@ _prop_promise_error_cb(void* data, Eina_Error err EINA_UNUSED)
}
static void
+_view_update(Elm_Layout_Smart_Data *pd, const char *name, const char *property)
+{
+ const char *source;
+ Eina_Strbuf *buf;
+
+ if (strncmp(SIGNAL_PREFIX, name, sizeof(SIGNAL_PREFIX) -1) != 0)
+ {
+ elm_layout_text_set(pd->obj, name, property);
+ return;
+ }
+
+ ELM_WIDGET_DATA_GET_OR_RETURN(pd->obj, wd);
+ source = eo_class_name_get(eo_class_get(pd->model));
+
+ buf = eina_strbuf_new();
+ eina_strbuf_append(buf, name);
+ eina_strbuf_remove(buf, 0, sizeof(SIGNAL_PREFIX)-1);
+ eina_strbuf_replace_all(buf, "%v", property);
+
+ edje_object_signal_emit(wd->resize_obj, eina_strbuf_string_get(buf), source);
+ eina_strbuf_free(buf);
+}
+
+static void
_prop_promise_then_cb(void* data, void* values)
{
Elm_Layout_Sub_Property_Promise *sub_pp = data;
@@ -1980,12 +2006,12 @@ _prop_promise_then_cb(void* data, void* values)
if (vtype == EINA_VALUE_TYPE_STRING || vtype == EINA_VALUE_TYPE_STRINGSHARE)
{
eina_value_get(value, &text);
- elm_layout_text_set(pd->obj, name, text);
+ _view_update(pd, name, text);
}
else
{
text = eina_value_to_string(value);
- elm_layout_text_set(pd->obj, name, text);
+ _view_update(pd, name, text);
free(text);
}
eina_stringshare_del(name);