From: Enlightenment S. <no-...@en...> - 2010-11-11 21:43:22
|
Log: enki : add button add a library Author: watchwolf Date: 2010-11-11 13:43:15 -0800 (Thu, 11 Nov 2010) New Revision: 54482 Modified: trunk/enki/data/themes/default/default.edc trunk/enki/data/themes/default/libraries.edc trunk/enki/data/themes/default/main_page.edc trunk/enki/src/bin/main_menu.c Modified: trunk/enki/data/themes/default/default.edc =================================================================== --- trunk/enki/data/themes/default/default.edc 2010-11-11 21:28:24 UTC (rev 54481) +++ trunk/enki/data/themes/default/default.edc 2010-11-11 21:43:15 UTC (rev 54482) @@ -157,8 +157,8 @@ color: 0 0 0 255; rel1.to: "shadow"; rel2.to: "shadow"; - rel1.relative: 0.01 0.01; - rel2.relative: 0.99 0.99; + rel1.relative: 0.05 0.05; + rel2.relative: 0.95 0.95; } } part { Modified: trunk/enki/data/themes/default/libraries.edc =================================================================== --- trunk/enki/data/themes/default/libraries.edc 2010-11-11 21:28:24 UTC (rev 54481) +++ trunk/enki/data/themes/default/libraries.edc 2010-11-11 21:43:15 UTC (rev 54482) @@ -2,52 +2,17 @@ //gengrid("object.main_menu.libraries") //TODO need elm gengrid edje external -group { - name : "object.main_menu.libraries"; - parts { - part { - name: "object.main_menu.libraries"; - type: SWALLOW; - description { - state : "default" 0.0; - } - } - } -} -button("object.main_menu.bt_new_library", "New Library", "folder") - group { name : "libraries"; parts { part { - name: "libraries"; - type: BOX; + name: "object.main_menu.libraries"; + type: SWALLOW; description { state : "default" 0.0; - box { - layout: "vertical"; - } } - box { - items { - item { - type: GROUP; - source: "object.main_menu.libraries"; - name: "libraries"; - align: -1 -1; - weight: 1 1; - } - item { - type: GROUP; - source: "object.main_menu.bt_new_library"; - name: "bt_new_library"; - align: -1 1; - weight: 1 0; - } - } - } } } } Modified: trunk/enki/data/themes/default/main_page.edc =================================================================== --- trunk/enki/data/themes/default/main_page.edc 2010-11-11 21:28:24 UTC (rev 54481) +++ trunk/enki/data/themes/default/main_page.edc 2010-11-11 21:43:15 UTC (rev 54482) @@ -4,8 +4,7 @@ parts { //libraries - alias: "object.main_menu.bt_new_library" "panes[right]:menu[libraries]:libraries[bt_new_library]:object.main_menu.bt_new_library"; - alias: "object.main_menu.list_libraries" "panes[right]:menu[libraries]:libraries[libraries]:object.main_menu.libraries"; + alias: "object.main_menu.list_libraries" "panes[right]:menu[libraries]:object.main_menu.libraries"; // //map Modified: trunk/enki/src/bin/main_menu.c =================================================================== --- trunk/enki/src/bin/main_menu.c 2010-11-11 21:28:24 UTC (rev 54481) +++ trunk/enki/src/bin/main_menu.c 2010-11-11 21:43:15 UTC (rev 54482) @@ -5,7 +5,6 @@ static Evas_Object *inwin = NULL; static Evas_Object *libraries_list; -static Evas_Object *bt_new_library; static Evas_Object *bt_import; static Evas_Object *bt_slideshow; static Evas_Object *bt_del_bg; @@ -18,7 +17,7 @@ static Evas_Object* _library_icon_get(void *data, Evas_Object *obj, const char *part); static void _library_select(void *data, Evas_Object *obj, void *event_info); -static void _new_library_cb(void *data, Evas_Object *obj, void *event_info); +static void _new_library(); static void _new_library_done_cb(void *data, Evas_Object *obj, void *event_info); static void _slideshow_cb(void *data, Evas_Object *obj, void *event_info); @@ -32,6 +31,7 @@ typedef struct { + Eina_Bool is_new_library; const char *path; Enlil_Photo *photo; } Library; @@ -46,8 +46,6 @@ libraries_list = elm_gengrid_add(edje); elm_gengrid_item_size_set(libraries_list, 256, 256); edje_object_part_swallow(edje, "object.main_menu.list_libraries", libraries_list); - bt_new_library = edje_object_part_external_object_get(edje, "object.main_menu.bt_new_library"); - evas_object_smart_callback_add(bt_new_library, "clicked", _new_library_cb, NULL); itc_grid.func.label_get = _library_get; itc_grid.func.del = _library_del; @@ -87,7 +85,6 @@ void main_menu_loading_disable_set(Eina_Bool disabled) { - elm_object_disabled_set(bt_new_library, disabled); elm_object_disabled_set(libraries_list, disabled); elm_object_disabled_set(bt_import, disabled); elm_object_disabled_set(bt_album_new, disabled); @@ -96,14 +93,12 @@ void main_menu_sync_disable_set(Eina_Bool disabled) { - elm_object_disabled_set(bt_new_library, disabled); elm_object_disabled_set(libraries_list, disabled); } void main_menu_noroot_disabled_set(Eina_Bool disabled) { main_menu_loading_disable_set(disabled); - elm_object_disabled_set(bt_new_library, EINA_FALSE); elm_object_disabled_set(libraries_list, EINA_FALSE); elm_object_disabled_set(bt_del_bg, disabled); } @@ -114,9 +109,18 @@ Eina_List *list = enlil_root_eet_path_load(); elm_gengrid_clear(libraries_list); + + // + Library *lib = calloc(1, sizeof(Library)); + lib->is_new_library = EINA_TRUE; + lib->path = eina_stringshare_add("New Library"); + elm_gengrid_item_append(libraries_list, &itc_grid, lib, _library_select, NULL); + // + EINA_LIST_FREE(list, string) { Library *lib = calloc(1, sizeof(Library)); + lib->is_new_library = EINA_FALSE; lib->path = eina_stringshare_add(string->string); lib->photo = enlil_photo_new(); Enlil_Photo_Data *photo_data = calloc(1, sizeof(Enlil_Photo_Data)); @@ -140,7 +144,8 @@ { Library *lib = data; EINA_STRINGSHARE_DEL(lib->path); - enlil_photo_free(&(lib->photo)); + if(lib->photo) + enlil_photo_free(&(lib->photo)); FREE(lib); } @@ -148,6 +153,14 @@ { const char *s = NULL; Library *lib = data; + + if(lib->is_new_library) + { + Evas_Object *icon = elm_icon_add(obj); + elm_icon_standard_set(icon, "add"); + return icon; + } + Enlil_Photo *photo = enlil_root_first_photo_get(lib->path); if(!photo) @@ -185,11 +198,19 @@ static void _library_select(void *data, Evas_Object *obj, void *event_info) { Library *lib = elm_gengrid_item_data_get(elm_gengrid_selected_item_get(obj)); - root_set(lib->path); - select_list_photo(); + + if(lib->is_new_library) + { + _new_library(); + } + else + { + root_set(lib->path); + select_list_photo(); + } } -static void _new_library_cb(void *data, Evas_Object *obj, void *event_info) +static void _new_library() { Evas_Object *fs, *vbox; |