From 557a0c1f98764aba876069444d9c06103695a93d Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 3 Apr 2009 21:52:01 +0000 Subject: [PATCH] couple of changes and addition. * list: export label and base object for items * list: per-item delete function, cleanup associated data. * list: clear. * couple of functions return success or failure. * win: sticky, lower and raise SVN revision: 39845 --- legacy/elementary/src/lib/Elementary.h.in | 14 ++++++++--- legacy/elementary/src/lib/elm_icon.c | 16 +++++++------ legacy/elementary/src/lib/elm_layout.c | 8 ++++--- legacy/elementary/src/lib/elm_list.c | 29 +++++++++++++++++++++++ legacy/elementary/src/lib/elm_photo.c | 6 +++-- legacy/elementary/src/lib/elm_win.c | 27 ++++++++++++++++++++- legacy/elementary/src/lib/els_icon.c | 17 ++++++++----- legacy/elementary/src/lib/els_icon.h | 4 ++-- 8 files changed, 97 insertions(+), 24 deletions(-) diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 7b14ea19b8..c2aba668f8 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -203,6 +203,8 @@ extern "C" { EAPI void elm_win_title_set(Evas_Object *obj, const char *title); EAPI void elm_win_autodel_set(Evas_Object *obj, Evas_Bool autodel); EAPI void elm_win_activate(Evas_Object *obj); + EAPI void elm_win_lower(Evas_Object *obj); + EAPI void elm_win_raise(Evas_Object *obj); EAPI void elm_win_borderless_set(Evas_Object *obj, Evas_Bool borderless); EAPI void elm_win_shaped_set(Evas_Object *obj, Evas_Bool shaped); EAPI void elm_win_alpha_set(Evas_Object *obj, Evas_Bool alpha); @@ -212,6 +214,8 @@ extern "C" { EAPI void elm_win_iconified_set(Evas_Object *obj, Evas_Bool iconified); EAPI void elm_win_layer_set(Evas_Object *obj, int layer); EAPI void elm_win_rotation_set(Evas_Object *obj, int rotation); + EAPI void elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky); + /*... * ecore_x_icccm_hints_set -> accepts_focus (add to ecore_evas) * ecore_x_icccm_hints_set -> window_group (add to ecore_evas) @@ -251,7 +255,7 @@ extern "C" { */ EAPI Evas_Object *elm_icon_add(Evas_Object *parent); - EAPI void elm_icon_file_set(Evas_Object *obj, const char *file, const char *group); + EAPI Eina_Bool elm_icon_file_set(Evas_Object *obj, const char *file, const char *group); EAPI void elm_icon_standard_set(Evas_Object *obj, const char *name); EAPI void elm_icon_smooth_set(Evas_Object *obj, Evas_Bool smooth); EAPI void elm_icon_no_scale_set(Evas_Object *obj, Evas_Bool no_scale); @@ -341,7 +345,7 @@ extern "C" { */ EAPI Evas_Object *elm_layout_add(Evas_Object *parent); - EAPI void elm_layout_file_set(Evas_Object *obj, const char *file, const char *group); + EAPI Eina_Bool elm_layout_file_set(Evas_Object *obj, const char *file, const char *group); EAPI void elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content); EAPI Evas_Object *elm_layout_edje_get(const Evas_Object *obj); /* smart callbacks called: @@ -472,7 +476,7 @@ extern "C" { */ EAPI Evas_Object *elm_photo_add(Evas_Object *parent); - EAPI void elm_photo_file_set(Evas_Object *obj, const char *file); + EAPI Eina_Bool elm_photo_file_set(Evas_Object *obj, const char *file); EAPI void elm_photo_size_set(Evas_Object *obj, int size); /* smart callbacks called: * "clicked" - the user clicked the icon @@ -522,6 +526,7 @@ extern "C" { EAPI Elm_List_Item *elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data); EAPI Elm_List_Item *elm_list_item_insert_before(Evas_Object *obj, Elm_List_Item *before, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data); EAPI Elm_List_Item *elm_list_item_insert_after(Evas_Object *obj, Elm_List_Item *after, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data); + EAPI void elm_list_clear(Evas_Object *obj); EAPI void elm_list_go(Evas_Object *obj); EAPI void elm_list_multi_select_set(Evas_Object *obj, Evas_Bool multi); EAPI void elm_list_horizontal_mode_set(Evas_Object *obj, Elm_List_Mode mode); @@ -531,9 +536,12 @@ extern "C" { EAPI void elm_list_item_selected_set(Elm_List_Item *item, Evas_Bool selected); EAPI void elm_list_item_show(Elm_List_Item *item); EAPI void elm_list_item_del(Elm_List_Item *item); + EAPI void elm_list_item_del_cb_set(Elm_List_Item *item, void (*func)(void *data, Evas_Object *obj, void *event_info)); EAPI const void *elm_list_item_data_get(const Elm_List_Item *item); EAPI Evas_Object *elm_list_item_icon_get(const Elm_List_Item *item); EAPI Evas_Object *elm_list_item_end_get(const Elm_List_Item *item); + EAPI Evas_Object *elm_list_item_base_get(const Elm_List_Item *item); + EAPI const char *elm_list_item_label_get(const Elm_List_Item *item); /* smart callbacks called: * "clicked" - when the user double-clicked an item * "selected" - when the user selected an item diff --git a/legacy/elementary/src/lib/elm_icon.c b/legacy/elementary/src/lib/elm_icon.c index d776102cc4..dd9a33d5b0 100644 --- a/legacy/elementary/src/lib/elm_icon.c +++ b/legacy/elementary/src/lib/elm_icon.c @@ -106,21 +106,23 @@ elm_icon_add(Evas_Object *parent) return obj; } -EAPI void +EAPI Eina_Bool elm_icon_file_set(Evas_Object *obj, const char *file, const char *group) { Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; + Eina_Bool ret; + if (!wd) return 0; const char *p; - - if (!file) return; + + if (!file) return 0; if (wd->stdicon) eina_stringshare_del(wd->stdicon); wd->stdicon = NULL; if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj"))) - _els_smart_icon_file_edje_set(wd->img, file, group); - else - _els_smart_icon_file_key_set(wd->img, file, group); + ret = _els_smart_icon_file_edje_set(wd->img, file, group); + else + ret = _els_smart_icon_file_key_set(wd->img, file, group); _sizing_eval(obj); + return ret; } EAPI void diff --git a/legacy/elementary/src/lib/elm_layout.c b/legacy/elementary/src/lib/elm_layout.c index 519df365c8..2949d0bd89 100644 --- a/legacy/elementary/src/lib/elm_layout.c +++ b/legacy/elementary/src/lib/elm_layout.c @@ -115,12 +115,14 @@ elm_layout_add(Evas_Object *parent) return obj; } -EAPI void +EAPI Eina_Bool elm_layout_file_set(Evas_Object *obj, const char *file, const char *group) { Widget_Data *wd = elm_widget_data_get(obj); - edje_object_file_set(wd->lay, file, group); - _sizing_eval(obj); + Eina_Bool ret = edje_object_file_set(wd->lay, file, group); + if (ret) + _sizing_eval(obj); + return ret; } EAPI void diff --git a/legacy/elementary/src/lib/elm_list.c b/legacy/elementary/src/lib/elm_list.c index 6b4b7b9598..a590ad0b60 100644 --- a/legacy/elementary/src/lib/elm_list.c +++ b/legacy/elementary/src/lib/elm_list.c @@ -21,6 +21,7 @@ struct _Elm_List_Item const char *label; Evas_Object *icon, *end; void (*func) (void *data, Evas_Object *obj, void *event_info); + void (*del_cb) (void *data, Evas_Object *obj, void *event_info); const void *data; Evas_Bool even : 1; Evas_Bool is_even : 1; @@ -45,6 +46,7 @@ _del_hook(Evas_Object *obj) Elm_List_Item *it; EINA_LIST_FREE(wd->items, it) { + if (it->del_cb) it->del_cb((void *)it->data, it->obj, it); eina_stringshare_del(it->label); if (!it->fixed) { @@ -414,6 +416,14 @@ elm_list_item_insert_after(Evas_Object *obj, Elm_List_Item *after, const char *l return it; } +EAPI void +elm_list_clear(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + while (wd->items) + elm_list_item_del(wd->items->data); +} + EAPI void elm_list_go(Evas_Object *obj) { @@ -500,6 +510,7 @@ EAPI void elm_list_item_del(Elm_List_Item *it) { Widget_Data *wd = elm_widget_data_get(it->obj); + if (it->del_cb) it->del_cb((void *)it->data, it->obj, it); if (it->selected) _item_unselect(it); wd->items = eina_list_remove(wd->items, it); eina_stringshare_del(it->label); @@ -509,6 +520,12 @@ elm_list_item_del(Elm_List_Item *it) free(it); } +EAPI void +elm_list_item_del_cb_set(Elm_List_Item *it, void (*func)(void *data, Evas_Object *obj, void *event_info)) +{ + it->del_cb = func; +} + EAPI const void * elm_list_item_data_get(const Elm_List_Item *it) { @@ -528,3 +545,15 @@ elm_list_item_end_get(const Elm_List_Item *it) if (it->dummy_end) return NULL; return it->end; } + +EAPI Evas_Object * +elm_list_item_base_get(const Elm_List_Item *it) +{ + return it->base; +} + +EAPI const char * +elm_list_item_label_get(const Elm_List_Item *it) +{ + return it->label; +} diff --git a/legacy/elementary/src/lib/elm_photo.c b/legacy/elementary/src/lib/elm_photo.c index 27989db954..184b02f3a7 100644 --- a/legacy/elementary/src/lib/elm_photo.c +++ b/legacy/elementary/src/lib/elm_photo.c @@ -93,12 +93,14 @@ elm_photo_add(Evas_Object *parent) return obj; } -EAPI void +EAPI Eina_Bool elm_photo_file_set(Evas_Object *obj, const char *file) { Widget_Data *wd = elm_widget_data_get(obj); - _els_smart_icon_file_key_set(wd->img, file, NULL); + if (!_els_smart_icon_file_key_set(wd->img, file, NULL)) + return 0; _sizing_eval(obj); + return 1; } EAPI void diff --git a/legacy/elementary/src/lib/elm_win.c b/legacy/elementary/src/lib/elm_win.c index 1cea349de1..e72850869d 100644 --- a/legacy/elementary/src/lib/elm_win.c +++ b/legacy/elementary/src/lib/elm_win.c @@ -130,7 +130,7 @@ _elm_win_xwindow_get(Elm_Win *win) if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee); break; case ELM_SOFTWARE_WIN32: - if (win->ee) win->xwin = (int)ecore_evas_win32_window_get(win->ee); + if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee); break; default: break; @@ -404,6 +404,22 @@ elm_win_activate(Evas_Object *obj) ecore_evas_activate(win->ee); } +EAPI void +elm_win_lower(Evas_Object *obj) +{ + Elm_Win *win = elm_widget_data_get(obj); + if (!win) return; + ecore_evas_lower(win->ee); +} + +EAPI void +elm_win_raise(Evas_Object *obj) +{ + Elm_Win *win = elm_widget_data_get(obj); + if (!win) return; + ecore_evas_raise(win->ee); +} + EAPI void elm_win_borderless_set(Evas_Object *obj, Evas_Bool borderless) { @@ -507,6 +523,15 @@ elm_win_rotation_set(Evas_Object *obj, int rotation) _elm_win_xwin_update(win); } +EAPI void +elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky) +{ + Elm_Win *win = elm_widget_data_get(obj); + if (!win) return; + ecore_evas_sticky_set(win->ee, sticky); + _elm_win_xwin_update(win); +} + EAPI void elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode) { diff --git a/legacy/elementary/src/lib/els_icon.c b/legacy/elementary/src/lib/els_icon.c index 55410ee7b1..f9b565a207 100644 --- a/legacy/elementary/src/lib/els_icon.c +++ b/legacy/elementary/src/lib/els_icon.c @@ -38,33 +38,38 @@ _els_smart_icon_add(Evas *evas) return evas_object_smart_add(evas, _e_smart); } -void +Eina_Bool _els_smart_icon_file_key_set(Evas_Object *obj, const char *file, const char *key) { Smart_Data *sd; sd = evas_object_smart_data_get(obj); - if (!sd) return; + if (!sd) return 0; /* smart code here */ if (sd->size != 0) evas_object_image_load_size_set(sd->obj, sd->size, sd->size); evas_object_image_file_set(sd->obj, file, key); + if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE) + return 0; _smart_reconfigure(sd); + return 1; } -void +Eina_Bool _els_smart_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part) { Smart_Data *sd; - + sd = evas_object_smart_data_get(obj); - if (!sd) return; + if (!sd) return 0; /* smart code here */ if (sd->obj) evas_object_del(sd->obj); sd->obj = edje_object_add(evas_object_evas_get(obj)); - edje_object_file_set(sd->obj, file, part); evas_object_smart_member_add(sd->obj, obj); + if (!edje_object_file_set(sd->obj, file, part)) + return 0; _smart_reconfigure(sd); + return 1; } void diff --git a/legacy/elementary/src/lib/els_icon.h b/legacy/elementary/src/lib/els_icon.h index 74cdb12fe2..e88e2d1db5 100644 --- a/legacy/elementary/src/lib/els_icon.h +++ b/legacy/elementary/src/lib/els_icon.h @@ -1,6 +1,6 @@ Evas_Object *_els_smart_icon_add (Evas *evas); -void _els_smart_icon_file_key_set (Evas_Object *obj, const char *file, const char *key); -void _els_smart_icon_file_edje_set (Evas_Object *obj, const char *file, const char *part); +Eina_Bool _els_smart_icon_file_key_set (Evas_Object *obj, const char *file, const char *key); +Eina_Bool _els_smart_icon_file_edje_set (Evas_Object *obj, const char *file, const char *part); void _els_smart_icon_smooth_scale_set (Evas_Object *obj, int smooth); void _els_smart_icon_size_get (Evas_Object *obj, int *w, int *h); void _els_smart_icon_fill_inside_set (Evas_Object *obj, int fill_inside);