[elm_genlist] added edit mode style set class
authorSeunggyun Kim <sgyun.kim@samsung.com>
Thu, 9 Sep 2010 16:37:08 +0000 (01:37 +0900)
committerSeunggyun Kim <sgyun.kim@samsung.com>
Thu, 9 Sep 2010 16:37:08 +0000 (01:37 +0900)
src/lib/Elementary.h.in
src/lib/elm_genlist.c

index d879c85..1ce09f9 100644 (file)
@@ -1192,6 +1192,8 @@ extern "C" {
         GenlistInsertNewFunc insert_new;
         GenlistMoveFunc move;
         GenlistItemSelectedFunc item_selected;
+        const char *item_style;
+        const char *select_all_item_style;
      };
    EAPI Evas_Object      *elm_genlist_add(Evas_Object *parent);
    EAPI Elm_Genlist_Item *elm_genlist_item_append(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item_Flags flags, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *func_data);
index f9c7472..aca68ae 100755 (executable)
@@ -1724,7 +1724,7 @@ _hide_delete_confirm_object (void *data, Evas_Object *obj, const char *emission,
 static void
 _remove_item_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
 {
-  const char *del_icon_part, *del_conf_style;
+  const char *del_conf_style;
   Elm_Genlist_Item *it = data;
   if(_edit_mode_reset( it->wd ))
      return;
@@ -1848,7 +1848,6 @@ static void
 _reorder_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
 {
   Elm_Genlist_Item *it = data;
-  Evas_Event_Mouse_Up *ev = event_info;
   
   Item_Block *itb;
    EINA_INLIST_FOREACH(it->wd->blocks, itb)
@@ -1950,8 +1949,6 @@ _select_all_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *even
    Widget_Data *wd = it->wd;
    if (!wd) return;
 
-   Eina_List *realized_list = elm_genlist_realized_items_get(wd->obj);
-
        if(!wd->selct_all) 
                edje_object_signal_emit(it->base, "elm,state,del_confirm", "elm");
        else
@@ -2010,6 +2007,8 @@ _edit_controls_eval( Elm_Genlist_Item *it )
     it->pad_left = 0;
     it->pad_right = 0;
     Evas_Object *icon;
+    char buf[1024];
+
     if( it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE && !it->edit_obj )
       return;
 
@@ -2028,7 +2027,21 @@ _edit_controls_eval( Elm_Genlist_Item *it )
               _elm_config->scale);
         evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
         elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
-        _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
+        if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
+        else strncpy(buf, "item", sizeof(buf));
+        if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
+        // if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
+        strncat(buf, "/", sizeof(buf) - strlen(buf));
+        
+        if(it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default")) 
+          {
+             strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
+             _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", buf, elm_widget_style_get(it->wd->obj));
+          }
+        else
+          {
+             _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
+          }
 
         edje_object_signal_callback_add(it->edit_obj, "elm,action,edit,reset",
               "elm", _edit_mode_reset, it);
@@ -2066,13 +2079,18 @@ _edit_controls_eval( Elm_Genlist_Item *it )
         else
           edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
 
+        edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
+              "elm", _remove_item_cb );
+        edje_object_signal_callback_del(it->edit_obj, "elm,action,hide,del_confirm",
+              "elm", _hide_delete_confirm_object );
+    
         edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
               "elm", _remove_item_cb, it);
 
         edje_object_signal_callback_add(it->edit_obj, "elm,action,hide,del_confirm",
               "elm", _hide_delete_confirm_object, it );
         it->pad_left += pad;
-    evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
+        evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
                    _reorder_mouse_down, it);
       }
     else
@@ -2099,6 +2117,13 @@ _edit_controls_eval( Elm_Genlist_Item *it )
           {
              reorder_icon = edje_object_part_object_get(it->edit_obj, reorder_part );
 
+             evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
+                   _reorder_mouse_down);
+             evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
+                   _reorder_mouse_up);
+             evas_object_event_callback_del(it->edit_obj, EVAS_CALLBACK_MOUSE_MOVE,
+                   _reorder_mouse_move);
+         
              evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_DOWN,
                    _reorder_mouse_down, it);
              evas_object_event_callback_add(it->edit_obj, EVAS_CALLBACK_MOUSE_UP,
@@ -4763,7 +4788,10 @@ elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *e
 
    if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
      {
-       itc.item_style = "select_all";
+      if(edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
+         itc.item_style = edit_class->select_all_item_style;
+      else
+                       itc.item_style = "select_all";
        itc.func.label_get = NULL;
        itc.func.icon_get = NULL;
        itc.func.del = NULL;
@@ -4825,22 +4853,32 @@ elm_genlist_item_expanded_depth_get(Elm_Genlist_Item *it)
 EAPI void
 elm_genlist_edit_selected_items_del(Evas_Object *obj)
 {
-   Elm_Genlist_Item *it;
-   Eina_List *l, *realized_list;
-   Item_Block *itb;
+  Elm_Genlist_Item *it;
+   Eina_List *l;
+   Item_Block *itb = NULL;
 
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-
+   if(!wd->blocks) return;
+   
    EINA_INLIST_FOREACH(wd->blocks, itb)
      {
-       if (itb->realized)
+       if(!wd->blocks) break;
+       
+       if (itb && itb->realized)
          {
             EINA_LIST_FOREACH(itb->items, l, it)
               {
                  if (it->delete_check)
-                   elm_genlist_item_del( it );
+                   {
+             if(!wd->selct_all) 
+             {
+                       itb->wd->minh -= it->h;
+                       itb->wd->select_all_minh -= it->h;
+             }
+                      elm_genlist_item_del( it );
+                   }
               }
          }
      }