elm elm_object: Fixed part content set hooks.
authorseoz <seoz@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 29 Mar 2012 11:09:40 +0000 (11:09 +0000)
committerseoz <seoz@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 29 Mar 2012 11:09:40 +0000 (11:09 +0000)
 1. delete old content object
 2. check whether new content object is same as old content object
 3. added some doxygen description.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@69743 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elc_ctxpopup.c
src/lib/elc_hoversel.c
src/lib/elc_player.c
src/lib/elc_popup.c
src/lib/elm_bg.c
src/lib/elm_entry.c
src/lib/elm_object.h

index 61b57c3..31f57a8 100644 (file)
@@ -774,13 +774,11 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
    Evas_Coord min_w = -1, min_h = -1;
-
    Widget_Data *wd;
-
    if ((part) && (strcmp(part, "default"))) return;
-
    wd = elm_widget_data_get(obj);
    if ((!wd) || (!content)) return;
+   if (content == wd->content) return;
 
    //TODO: wd->list
    if (wd->content) evas_object_del(wd->content);
index 63012df..fb07d78 100644 (file)
@@ -280,6 +280,7 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
+
    elm_object_part_content_set(wd->btn, part, content);
 }
 
index a6ef91c..aef28ce 100644 (file)
@@ -464,12 +464,14 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
    if (part && strcmp(part, "video")) return;
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
-
+   if (!wd) return;
    double pos, length;
    Eina_Bool seekable;
 
    if (!_elm_video_check(content)) return;
+   if (wd->video == content) return;
 
+   if (wd->video) evas_object_del(wd->video);
    _cleanup_callback(wd);
 
    wd->video = content;
@@ -542,6 +544,7 @@ elm_player_add(Evas_Object *parent)
    elm_widget_can_focus_set(obj, EINA_TRUE);
    elm_widget_event_hook_set(obj, _event_hook);
    elm_widget_content_set_hook_set(obj, _content_set_hook);
+   /* TODO: add content_unset and content_get hook */
 
    wd->layout = edje_object_add(e);
    _elm_theme_object_set(obj, wd->layout, "player", "base", "default");
index d1e21cc..43d51d2 100644 (file)
@@ -699,11 +699,8 @@ _title_icon_set(Evas_Object *obj, Evas_Object *icon)
    if (!wd) return;
    if (wd->title_icon == icon) return;
    title_visibility_old = (wd->title_text) || (wd->title_icon);
-   if (wd->title_icon)
-     {
-        evas_object_del(wd->title_icon);
-        wd->title_icon = NULL;
-     }
+   if (wd->title_icon) evas_object_del(wd->title_icon);
+
    wd->title_icon = icon;
    title_visibility_current = (wd->title_text) || (wd->title_icon);
    elm_object_part_content_set(wd->base, "elm.swallow.title.icon",
index 79400c2..df29d5b 100644 (file)
@@ -122,19 +122,16 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
 {
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd;
-
    if (part && strcmp(part, "overlay")) return;
-
    wd = elm_widget_data_get(obj);
    if (!wd) return;
-   if (wd->overlay)
-     {
-        evas_object_del(wd->overlay);
-        wd->overlay = NULL;
-     }
+
+   if (content == wd->overlay) return;
+   if (wd->overlay) evas_object_del(wd->overlay);
+
+   wd->overlay = content;
    if (content)
      {
-        wd->overlay = content;
         edje_object_part_swallow(wd->base, "elm.swallow.content", content);
         elm_widget_sub_object_add(obj, content);
      }
index ebbef48..8df66ba 100644 (file)
@@ -855,6 +855,7 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    Evas_Object *edje;
+   Evas_Object *prev_content;
    if ((!wd) || (!content)) return;
 
    if (wd->scroll)
@@ -862,23 +863,20 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
    else
       edje = wd->ent;
 
-   /* Delete the currently swallowed object */
-   Evas_Object *cswallow;
-
    if (!part || !strcmp(part, "icon"))
      {
-        cswallow = edje_object_part_swallow_get(edje, "elm.swallow.icon");
+        prev_content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
         edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
      }
    else if (!strcmp(part, "end"))
      {
-        cswallow = edje_object_part_swallow_get(edje, "elm.swallow.end");
+        prev_content = edje_object_part_swallow_get(edje, "elm.swallow.end");
         edje_object_signal_emit(edje, "elm,action,show,end", "elm");
      }
    else
-     cswallow = edje_object_part_swallow_get(edje, part);
+     prev_content = edje_object_part_swallow_get(edje, part);
 
-   if (cswallow) evas_object_del(cswallow);
+   if (prev_content) evas_object_del(prev_content);
 
    evas_event_freeze(evas_object_evas_get(obj));
    elm_widget_sub_object_add(obj, content);
index 033c243..68a863d 100644 (file)
@@ -35,6 +35,10 @@ EAPI const char                  *elm_object_part_text_get(const Evas_Object *ob
  * @param part The content part name to set (NULL for the default content)
  * @param content The new content of the object
  *
+ * This sets a new object to a widget as a content object. If any object was
+ * already set as a content object in the same part, previous object will be
+ * deleted automatically.
+ *
  * @note Elementary objects may have many contents
  *
  * @ingroup General