New elm widget exported to edje: bubble.
authorGustavo Lima Chaves <glima@profusion.mobi>
Mon, 29 Mar 2010 17:19:35 +0000 (17:19 +0000)
committerGustavo Lima Chaves <glima@profusion.mobi>
Mon, 29 Mar 2010 17:19:35 +0000 (17:19 +0000)
SVN revision: 47559

data/edje_externals/Makefile.am
data/edje_externals/ico_bubble.png [new file with mode: 0644]
data/edje_externals/icons.edc
src/edje_externals/Makefile.am
src/edje_externals/elm.c
src/edje_externals/elm_bubble.c [new file with mode: 0644]
src/edje_externals/modules.inc
src/edje_externals/private.h
src/lib/Elementary.h.in
src/lib/elm_bubble.c

index 3f05020..1d55767 100644 (file)
@@ -9,6 +9,7 @@ files_DATA = icons.edj
 
 EXTRA_DIST = \
 icons.edc \
+ico_bubble.png \
 ico_button.png \
 ico_check.png \
 ico_radio.png \
diff --git a/data/edje_externals/ico_bubble.png b/data/edje_externals/ico_bubble.png
new file mode 100644 (file)
index 0000000..e2df401
Binary files /dev/null and b/data/edje_externals/ico_bubble.png differ
index 0d9ba73..45d2048 100644 (file)
@@ -10,6 +10,7 @@ collections { group { name: "ico_"_name;                     \
                image.normal: "ico_"_name".png";             \
 }}}}}
 
+ICON("bubble")
 ICON("button")
 ICON("check")
 ICON("radio")
index d39f857..37f3717 100644 (file)
@@ -24,14 +24,15 @@ pkgdir = $(libdir)/edje
 pkg_LTLIBRARIES = elm.la
 
 elm_la_SOURCES = private.h \
-                               modules.inc \
-                               elm.c \
-                               elm_button.c \
-                               elm_check.c \
-                               elm_radio.c \
-                               elm_scrolled_entry.c \
-                               elm_slider.c \
-                               elm_toggle.c
+modules.inc \
+elm.c \
+elm_bubble.c \
+elm_button.c \
+elm_check.c \
+elm_radio.c \
+elm_scrolled_entry.c \
+elm_slider.c \
+elm_toggle.c
 
 elm_la_LIBADD = $(top_builddir)/src/lib/libelementary.la
 elm_la_LDFLAGS = $(all_libraries) -no-undefined @lt_enable_auto_import@ -module -avoid-version -shared -fPIC
index 608649d..b56ed96 100644 (file)
@@ -132,6 +132,31 @@ external_common_icon_param_parse(Evas_Object **icon, Evas_Object *obj, const Ein
    *icon = external_common_param_icon_get(obj, p);
 }
 
+Evas_Object *
+external_common_param_edje_object_get(Evas_Object *obj, const Edje_External_Param *p)
+{
+   Evas_Object *edje, *parent_widget, *ret;
+   const char *file;
+
+   if ((!p) || (!p->s) || (p->type != EDJE_EXTERNAL_PARAM_TYPE_STRING))
+       return NULL;
+
+   edje = evas_object_smart_parent_get(obj);
+   edje_object_file_get(edje, &file, NULL);
+
+   parent_widget = elm_widget_parent_widget_get(obj);
+   if (!parent_widget)
+     parent_widget = edje;
+
+   ret = edje_object_add(evas_object_evas_get(parent_widget));
+
+   if (edje_object_file_set(ret, file, p->s))
+     return ret;
+
+   evas_object_del(ret);
+   return NULL;
+}
+
 void
 external_common_params_free(void *params)
 {
diff --git a/src/edje_externals/elm_bubble.c b/src/edje_externals/elm_bubble.c
new file mode 100644 (file)
index 0000000..380e07c
--- /dev/null
@@ -0,0 +1,160 @@
+#include "private.h"
+
+typedef struct _Elm_Params_Bubble
+{
+   Elm_Params base;
+   Evas_Object *icon;
+   const char *info;
+   Evas_Object *content; /* part name whose obj is to be set as content */
+} Elm_Params_Bubble;
+
+static void
+external_bubble_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
+{
+   const Elm_Params_Bubble *p;
+
+   if (to_params) p = to_params;
+   else if (from_params) p = from_params;
+   else return;
+
+   if (p->base.label) elm_bubble_label_set(obj, p->base.label);
+   if (p->icon) elm_bubble_icon_set(obj, p->icon);
+   if (p->info) elm_bubble_info_set(obj, p->info);
+   if (p->content) elm_bubble_content_set(obj, p->content);
+}
+
+static Eina_Bool
+external_bubble_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
+{
+   if (!strcmp(param->name, "label"))
+     {
+       if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
+         {
+            elm_bubble_label_set(obj, param->s);
+            return EINA_TRUE;
+         }
+     }
+   else if (!strcmp(param->name, "icon"))
+     {
+       if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
+         {
+            Evas_Object *icon = external_common_param_icon_get(obj, param);
+            if (icon)
+              {
+                 elm_bubble_icon_set(obj, icon);
+                 return EINA_TRUE;
+              }
+         }
+     }
+   else if (!strcmp(param->name, "info"))
+     {
+       if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
+         {
+            elm_bubble_info_set(obj, param->s);
+            return EINA_TRUE;
+         }
+     }
+   else if (!strcmp(param->name, "content"))
+     {
+       if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
+         {
+            Evas_Object *content = \
+              external_common_param_edje_object_get(obj, param);
+            if (content)
+              {
+                 elm_bubble_content_set(obj, content);
+                 return EINA_TRUE;
+              }
+         }
+     }
+
+   ERR("unknown parameter '%s' of type '%s'",
+       param->name, edje_external_param_type_str(param->type));
+
+   return EINA_FALSE;
+}
+
+static Eina_Bool
+external_bubble_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
+{
+   if (!strcmp(param->name, "label"))
+     {
+       if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
+         {
+            param->s = elm_bubble_label_get(obj);
+            return EINA_TRUE;
+         }
+     }
+   else if (!strcmp(param->name, "icon"))
+     {
+       /* not easy to get icon name back from live object */
+       return EINA_FALSE;
+     }
+   else if (!strcmp(param->name, "info"))
+     {
+       if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
+         {
+            param->s = elm_bubble_info_get(obj);
+            return EINA_TRUE;
+         }
+     }
+   else if (!strcmp(param->name, "content"))
+     {
+       /* not easy to get content name back from live object */
+       return EINA_FALSE;
+     }
+
+   ERR("unknown parameter '%s' of type '%s'",
+       param->name, edje_external_param_type_str(param->type));
+
+   return EINA_FALSE;
+}
+
+static void *
+external_bubble_params_parse(void *data, Evas_Object *obj, const Eina_List *params)
+{
+   Elm_Params_Bubble *mem;
+   Edje_External_Param *param;
+   const Eina_List *l;
+
+   mem = external_common_params_parse(Elm_Params_Bubble, data, obj, params);
+   if (!mem)
+     return NULL;
+
+   external_common_icon_param_parse(&mem->icon, obj, params);
+
+   EINA_LIST_FOREACH(params, l, param)
+     {
+       if (!strcmp(param->name, "info"))
+         mem->info = eina_stringshare_add(param->s);
+       else if (!strcmp(param->name, "content"))
+         mem->content = external_common_param_edje_object_get(obj, param);
+     }
+
+   return mem;
+}
+
+ static void
+external_bubble_params_free(void *params)
+{
+   Elm_Params_Bubble *mem = params;
+
+   if (mem->icon)
+     evas_object_del(mem->icon);
+   if (mem->content)
+     evas_object_del(mem->content);
+   if (mem->info)
+     eina_stringshare_del(mem->info);
+   external_common_params_free(params);
+}
+
+static Edje_External_Param_Info external_bubble_params[] = {
+   DEFINE_EXTERNAL_COMMON_PARAMS,
+   EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
+   EDJE_EXTERNAL_PARAM_INFO_STRING("info"),
+   EDJE_EXTERNAL_PARAM_INFO_STRING("content"),
+   EDJE_EXTERNAL_PARAM_INFO_SENTINEL
+};
+
+DEFINE_EXTERNAL_ICON_ADD(bubble, "bubble");
+DEFINE_EXTERNAL_TYPE_SIMPLE(bubble, "Bubble");
index 50a9f63..40bd25c 100644 (file)
@@ -1,3 +1,4 @@
+DEFINE_TYPE(bubble)
 DEFINE_TYPE(button)
 DEFINE_TYPE(check)
 DEFINE_TYPE(radio)
index 4bdc26d..45591b1 100644 (file)
@@ -14,6 +14,7 @@ const char *external_translate(void *data, const char *orig);
 void external_common_params_free(void *params);
 void *external_common_params_parse_internal(size_t params_size, void *data, Evas_Object *obj, const Eina_List *params);
 Evas_Object *external_common_param_icon_get(Evas_Object *obj, const Edje_External_Param *param);
+Evas_Object *external_common_param_edje_object_get(Evas_Object *obj, const Edje_External_Param *p);
 void external_common_icon_param_parse(Evas_Object **icon, Evas_Object *obj, const Eina_List *params);
 #define external_common_params_parse(type, data, obj, params)   \
     external_common_params_parse_internal(sizeof(type), data, obj, params)
index 916c213..352c3e2 100644 (file)
@@ -694,6 +694,8 @@ extern "C" {
    EAPI void         elm_bubble_label_set(Evas_Object *obj, const char *label);
    EAPI const char  *elm_bubble_label_get(const Evas_Object *obj);
    EAPI void         elm_bubble_info_set(Evas_Object *obj, const char *info);
+   EAPI const char  *elm_bubble_info_get(const Evas_Object *obj);
+
    EAPI void         elm_bubble_content_set(Evas_Object *obj, Evas_Object *content);
    EAPI void         elm_bubble_icon_set(Evas_Object *obj, Evas_Object *icon);
    EAPI Evas_Object *elm_bubble_icon_get(const Evas_Object *obj);
index e9ed0ec..c4386a5 100644 (file)
@@ -169,6 +169,29 @@ elm_bubble_info_set(Evas_Object *obj, const char *info)
    edje_object_part_text_set(wd->bbl, "elm.info", info);
    _sizing_eval(obj);
 }
+
+/**
+ * Get the info of the bubble
+ *
+ * @param obj The given evas pointer
+ *
+ * @return The "info" string of the bubble
+ *
+ * This function gets the text set to be displayed at the top right of
+ * the bubble.
+ *
+ * @ingroup Bubble
+ *
+ */
+EAPI const char *
+elm_bubble_info_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   return wd->info;
+}
+
 /**
  * Set the text to be showed in the bubble
  *