diff options
author | codewarrior <codewarrior> | 2005-10-26 00:19:52 +0000 |
---|---|---|
committer | codewarrior <codewarrior@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2005-10-26 00:19:52 +0000 |
commit | 3d4aa3f39c94a7b84e6e160fa7e596a5efc5895c (patch) | |
tree | 89e634af68f751147b237428956981a5414c5563 | |
parent | 66b3b98d70739835f723893ce7c114c0304fab98 (diff) | |
download | enlightenment-3d4aa3f39c94a7b84e6e160fa7e596a5efc5895c.tar.gz |
- add fileselector capability to efm
- add image browsing and choosing to internal eap editor
- allow e_widget to delete a sub object
SVN revision: 17961
-rw-r--r-- | src/bin/e_eap_editor.c | 65 | ||||
-rw-r--r-- | src/bin/e_eap_editor.h | 3 | ||||
-rw-r--r-- | src/bin/e_fileman.c | 19 | ||||
-rw-r--r-- | src/bin/e_fileman.h | 6 | ||||
-rw-r--r-- | src/bin/e_fileman_smart.c | 35 | ||||
-rw-r--r-- | src/bin/e_fileman_smart.h | 3 | ||||
-rw-r--r-- | src/bin/e_widget.c | 11 | ||||
-rw-r--r-- | src/bin/e_widget.h | 1 | ||||
-rw-r--r-- | src/bin/e_widget_image.c | 2 |
9 files changed, 131 insertions, 14 deletions
diff --git a/src/bin/e_eap_editor.c b/src/bin/e_eap_editor.c index e7a16f04dd..23a5a9e888 100644 --- a/src/bin/e_eap_editor.c +++ b/src/bin/e_eap_editor.c @@ -6,7 +6,8 @@ static void _e_eap_edit_save_cb(void *data, E_Dialog *dia); static void _e_eap_edit_cancel_cb(void *data, E_Dialog *dia); static void _e_eap_edit_browse_cb(void *data1, void *data2); static void _e_eap_edit_free(E_App_Edit *app); - +static void _e_eap_edit_selector_cb(E_Fileman *fileman, char *file, void *data); + #define IFDUP(src, dst) if(src) dst = strdup(src); else dst = NULL /* externally accessible functions */ @@ -15,7 +16,7 @@ e_eap_edit_show(E_Container *con, E_App *a) { E_Manager *man; E_App_Edit *app; - Evas_Object *o, *ol, *img; + Evas_Object *o, *ol; app = E_OBJECT_ALLOC(E_App_Edit, E_EAP_EDIT_TYPE, _e_eap_edit_free); if (!app) return NULL; @@ -47,16 +48,18 @@ e_eap_edit_show(E_Container *con, E_App *a) if(a->path) { - img = edje_object_add(app->evas); - edje_object_file_set(img, a->path, "icon"); + app->img = edje_object_add(app->evas); + edje_object_file_set(app->img, a->path, "icon"); + } else { - img = edje_object_add(app->evas); - e_theme_edje_object_set(img, "base/theme/icons/enlightenment/e", "icons/enlightenment/e"); + app->img = edje_object_add(app->evas); + e_theme_edje_object_set(app->img, "base/theme/icons/enlightenment/e", "icons/enlightenment/e"); } - - e_widget_table_object_append(o, e_widget_image_add_from_object(app->evas, img, 48, 48), + + app->img_widget = e_widget_image_add_from_object(app->evas, app->img, 48, 48); + e_widget_table_object_append(o, app->img_widget, 0, 0, 1, 1, 1, 1, 1, 1); @@ -212,6 +215,8 @@ _e_eap_edit_save_cb(void *data, E_Dialog *dia) IFDUP(editor->data.iclass, eap->icon_class); IFDUP(editor->data.path, eap->path); IFDUP(editor->data.image, eap->image); + + printf("image is: %s\n", eap->image); printf("eap path: %s\n", eap->path); @@ -228,7 +233,49 @@ _e_eap_edit_cancel_cb(void *data, E_Dialog *dia) static void _e_eap_edit_browse_cb(void *data1, void *data2) -{} +{ + E_Fileman *fileman; + E_App_Edit *editor; + + editor = data1; + fileman = e_fileman_new (editor->dia->win->container); + e_fileman_selector_enable(fileman, _e_eap_edit_selector_cb, editor); + e_win_resize(fileman->win, 640, 300); + e_fileman_show (fileman); +} + +/* need to make sure we can load the image */ +static void +_e_eap_edit_selector_cb(E_Fileman *fileman, char *file, void *data) +{ + E_App_Edit *editor; + char *ext; + Evas_Object *img; + + ext = strrchr(file, '.'); + if(!ext) + return; + if(strcasecmp(ext, ".png") && strcasecmp(ext, ".jpg") && + strcasecmp(ext, ".jpeg")) + return; + + editor = data; + E_FREE(editor->eap->image); + editor->data.image = strdup(file); + e_widget_sub_object_del(editor->img_widget, editor->img); + evas_object_del(editor->img); + editor->img = evas_object_image_add(editor->evas); + evas_object_image_file_set(editor->img, file, NULL); + evas_object_image_fill_set(editor->img, 0, 0, 48, 48); + evas_object_resize(editor->img, 48, 48); + evas_object_show(editor->img); + e_widget_resize_object_set(editor->img_widget, editor->img); + e_widget_sub_object_add(editor->img_widget, editor->img); + e_widget_min_size_set(editor->img_widget, 48, 48); + e_widget_change(editor->img_widget); + + e_object_del(fileman); +} static void _e_eap_edit_free(E_App_Edit *app) { diff --git a/src/bin/e_eap_editor.h b/src/bin/e_eap_editor.h index 574b3ec2ce..85918d02f5 100644 --- a/src/bin/e_eap_editor.h +++ b/src/bin/e_eap_editor.h @@ -18,6 +18,9 @@ struct _E_App_Edit E_Dialog *dia; E_App *eap; + + Evas_Object *img; + Evas_Object *img_widget; struct { char *image; diff --git a/src/bin/e_fileman.c b/src/bin/e_fileman.c index cff21ad6e9..dd50b2c7e7 100644 --- a/src/bin/e_fileman.c +++ b/src/bin/e_fileman.c @@ -24,6 +24,7 @@ static int _e_fileman_dir_change_cb(void *data, int type, void *event); static int _e_fileman_mouse_wheel_cb(void *data, int type, void *event); static void _e_fileman_resize_cb(E_Win *win); static void _e_fileman_delete_cb(E_Win *win); +static void _e_fileman_selector_cb(Evas_Object *object, char *file, void *data); static void _e_fileman_vscrollbar_show_cb(void *data, Evas *e, Evas_Object *obj, void *ev); static void _e_fileman_vscrollbar_hide_cb(void *data, Evas *e, Evas_Object *obj, void *ev); static void _e_fileman_free(E_Fileman *fileman); @@ -114,6 +115,14 @@ e_fileman_new(E_Container *con) } void +e_fileman_selector_enable(E_Fileman *fileman, void (*func)(E_Fileman *fileman, char *file, void *data), void *data) +{ + fileman->selector.func = func; + fileman->selector.data = data; + e_fm_selector_enable(fileman->smart, _e_fileman_selector_cb, fileman); +} + +void e_fileman_show(E_Fileman *fileman) { if (!fileman) return; @@ -276,6 +285,16 @@ _e_fileman_mouse_wheel_cb(void *data, int type, void *event) return 1; } +static void +_e_fileman_selector_cb(Evas_Object *object, char *file, void *data) +{ + E_Fileman *fileman; + + fileman = data; + fileman->selector.func(fileman, file, fileman->selector.data); + //e_object_del(E_OBJECT(fileman)); +} + static void _e_fileman_vscrollbar_show_cb(void *data, Evas *e, Evas_Object *obj, void *ev) { diff --git a/src/bin/e_fileman.h b/src/bin/e_fileman.h index c6b05fb874..01de3dbfb4 100644 --- a/src/bin/e_fileman.h +++ b/src/bin/e_fileman.h @@ -30,11 +30,17 @@ struct _E_Fileman int swallowed; Evas_List *event_handlers; + + struct { + void (*func)(E_Fileman *fileman, char *file, void *data); + void *data; + } selector; }; EAPI E_Fileman *e_fileman_new(E_Container *con); EAPI void e_fileman_show(E_Fileman *fileman); EAPI void e_fileman_hide(E_Fileman *fileman); +EAPI void e_fileman_selector_enable(E_Fileman *fileman, void (*func)(E_Fileman *fileman, char *file, void *data), void *data); #endif #endif diff --git a/src/bin/e_fileman_smart.c b/src/bin/e_fileman_smart.c index e1d3d40062..7d1107a795 100644 --- a/src/bin/e_fileman_smart.c +++ b/src/bin/e_fileman_smart.c @@ -136,6 +136,10 @@ struct _E_Fm_Smart_Data int frozen; double position; + int is_selector; + void (*selector_func) (Evas_Object *object, char *file, void *data); + void *selector_data; + Evas_Coord x, y, w, h; struct { @@ -238,6 +242,8 @@ static void _e_fm_drop_done_cb (E_Drag *drag, int dropped); static int _e_fm_files_sort_name_cb (void *d1, void *d2); static int _e_fm_files_sort_modtime_cb (void *d1, void *d2); +static void _e_fm_selector_send_file (E_Fm_Icon *icon); + static Ecore_Event_Handler *e_fm_mouse_up_handler = NULL; static double e_fm_grab_time = 0; static Evas_Smart *e_fm_smart = NULL; @@ -421,6 +427,19 @@ e_fm_thaw(Evas_Object *object) return sd->frozen; } +void +e_fm_selector_enable(Evas_Object *object, void (*func)(Evas_Object *object, char *file, void *data), void *data) +{ + E_Fm_Smart_Data *sd; + + if ((!object) || !(sd = evas_object_smart_data_get(object))) + return; + + sd->is_selector = 1; + sd->selector_func = func; + sd->selector_data = data; +} + /* local subsystem functions */ static void @@ -440,7 +459,7 @@ _e_fm_smart_add(Evas_Object *object) sd->evas = evas_object_evas_get(object); sd->frozen = 0; - + sd->is_selector = 0; sd->bg = evas_object_rectangle_add(sd->evas); // this should become an edje evas_object_color_set(sd->bg, 0, 0, 0, 0); evas_object_show(sd->bg); @@ -1909,7 +1928,13 @@ _e_fm_icon_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info else if (icon->file->type == E_FM_FILE_TYPE_FILE && (ev->flags == EVAS_BUTTON_DOUBLE_CLICK)) { icon->sd->drag.start = 0; - + + if(icon->sd->is_selector) + { + _e_fm_selector_send_file(icon); + return; + } + if ((!e_fm_file_assoc_exec(icon->file)) && (e_fm_file_can_exec(icon->file))) e_fm_file_exec(icon->file); @@ -2287,3 +2312,9 @@ _e_fm_files_sort_modtime_cb(void *d1, void *d2) return (e1->file->mtime > e2->file->mtime); } + +static void +_e_fm_selector_send_file(E_Fm_Icon *icon) +{ + icon->sd->selector_func(icon->sd->object, strdup(icon->file->path), icon->sd->selector_data); +} diff --git a/src/bin/e_fileman_smart.h b/src/bin/e_fileman_smart.h index 57ff240372..619ffd91e2 100644 --- a/src/bin/e_fileman_smart.h +++ b/src/bin/e_fileman_smart.h @@ -37,7 +37,8 @@ EAPI void e_fm_geometry_virtual_get(Evas_Object *object, Evas_C EAPI void e_fm_reconfigure_callback_add(Evas_Object *object, void (*func)(void *data, Evas_Object *obj, E_Event_Fm_Reconfigure *ev), void *data); EAPI int e_fm_freeze(Evas_Object *freeze); EAPI int e_fm_thaw(Evas_Object *freeze); - +EAPI void e_fm_selector_enable(Evas_Object *object, void (*func)(Evas_Object *object, char *file, void *data), void *data); + extern int E_EVENT_FM_RECONFIGURE; extern int E_EVENT_FM_DIRECTORY_CHANGE; #endif diff --git a/src/bin/e_widget.c b/src/bin/e_widget.c index 9aa054f91e..fb2f1fd8bd 100644 --- a/src/bin/e_widget.c +++ b/src/bin/e_widget.c @@ -150,6 +150,17 @@ e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj) } void +e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj) +{ + API_ENTRY return; + sd->subobjs = evas_list_remove(sd->subobjs, sobj); + if (!sd->child_can_focus) + { + if (e_widget_can_focus_get(sobj)) sd->child_can_focus = 0; + } +} + +void e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj) { API_ENTRY return; diff --git a/src/bin/e_widget.h b/src/bin/e_widget.h index a5a27701da..db4d88eb13 100644 --- a/src/bin/e_widget.h +++ b/src/bin/e_widget.h @@ -18,6 +18,7 @@ EAPI void *e_widget_data_get(Evas_Object *obj); EAPI void e_widget_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh); EAPI void e_widget_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh); EAPI void e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj); +EAPI void e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj); EAPI void e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj); EAPI void e_widget_can_focus_set(Evas_Object *obj, int can_focus); EAPI int e_widget_can_focus_get(Evas_Object *obj); diff --git a/src/bin/e_widget_image.c b/src/bin/e_widget_image.c index 3751865915..562098d015 100644 --- a/src/bin/e_widget_image.c +++ b/src/bin/e_widget_image.c @@ -41,5 +41,3 @@ e_widget_image_add_from_file(Evas *evas, char *file, int minw, int minh) return obj; } - - |