Add a callback when a new directory is selected : "directory,changed".

SVN revision: 52193
This commit is contained in:
Nicolas Aguirre 2010-09-13 17:02:32 +00:00
parent ea18ee503b
commit bd1ed51ead
3 changed files with 26 additions and 2 deletions

View File

@ -44,6 +44,7 @@ Evas_Object *ephoto_create_thumb_browser(Evas_Object *parent, const char *direct
void ephoto_populate_thumbnails(Evas_Object *obj); void ephoto_populate_thumbnails(Evas_Object *obj);
/* smart callbacks called: /* smart callbacks called:
* "selected" - an item in the thumb browser is selected. The selected file is passed as event_info argument. * "selected" - an item in the thumb browser is selected. The selected file is passed as event_info argument.
* "directory,changed" - the user selected a new directory. The selected directory is passed as event_info argument.
*/ */
typedef enum _Ephoto_State Ephoto_State; typedef enum _Ephoto_State Ephoto_State;
@ -68,6 +69,7 @@ struct _Ephoto
Evas_Object *thumb_browser; Evas_Object *thumb_browser;
Eina_List *images; Eina_List *images;
Ephoto_State state; Ephoto_State state;
const char *cur_directory;
}; };
typedef struct _Ephoto Ephoto; typedef struct _Ephoto Ephoto;

View File

@ -7,17 +7,21 @@ Ephoto *em;
static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info); static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info); static void _ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_thumb_browser_selected_cb(void *data, Evas_Object *obj, void *event_info); static void _ephoto_thumb_browser_selected_cb(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_thumb_browser_directory_changed_cb(void *data, Evas_Object *obj, void *event_info);
/* Objects Callbacks */ /* Objects Callbacks */
static void static void
_ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info) _ephoto_flow_browser_delete_cb(void *data, Evas_Object *obj, void *event_info)
{ {
em->thumb_browser = ephoto_create_thumb_browser(em->layout, NULL/*ecore_file_dir_get(ef->cur_image)*/); em->thumb_browser = ephoto_create_thumb_browser(em->layout, em->cur_directory);
elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser); elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser);
evas_object_smart_callback_add(em->thumb_browser, evas_object_smart_callback_add(em->thumb_browser,
"selected", "selected",
_ephoto_thumb_browser_selected_cb, _ephoto_thumb_browser_selected_cb,
NULL); NULL);
evas_object_smart_callback_add(em->thumb_browser,
"directory,changed",
_ephoto_thumb_browser_directory_changed_cb,
NULL);
em->state = EPHOTO_STATE_THUMB; em->state = EPHOTO_STATE_THUMB;
} }
@ -37,6 +41,16 @@ _ephoto_thumb_browser_selected_cb(void *data, Evas_Object *obj, void *event_info
em->state = EPHOTO_STATE_FLOW; em->state = EPHOTO_STATE_FLOW;
} }
static void
_ephoto_thumb_browser_directory_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
const char *dir = event_info;
eina_stringshare_del(em->cur_directory);
em->cur_directory = eina_stringshare_add(dir);
printf("Directory changed : %s\n", em->cur_directory);
}
/*Create the main ephoto window*/ /*Create the main ephoto window*/
void void
ephoto_create_main_window(const char *directory, const char *image) ephoto_create_main_window(const char *directory, const char *image)
@ -77,6 +91,7 @@ ephoto_create_main_window(const char *directory, const char *image)
{ {
em->flow_browser = ephoto_create_flow_browser(em->layout); em->flow_browser = ephoto_create_flow_browser(em->layout);
ephoto_flow_browser_image_set(em->flow_browser, image); ephoto_flow_browser_image_set(em->flow_browser, image);
em->cur_directory = eina_stringshare_add(ecore_file_dir_get(image));
eina_stringshare_del(image); eina_stringshare_del(image);
elm_layout_content_set(em->layout, "ephoto.content.swallow", em->flow_browser); elm_layout_content_set(em->layout, "ephoto.content.swallow", em->flow_browser);
evas_object_smart_callback_add(em->flow_browser, evas_object_smart_callback_add(em->flow_browser,
@ -88,12 +103,17 @@ ephoto_create_main_window(const char *directory, const char *image)
else else
{ {
em->thumb_browser = ephoto_create_thumb_browser(em->layout, directory); em->thumb_browser = ephoto_create_thumb_browser(em->layout, directory);
em->cur_directory = eina_stringshare_add(directory);
evas_object_show(em->thumb_browser); evas_object_show(em->thumb_browser);
elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser); elm_layout_content_set(em->layout, "ephoto.content.swallow", em->thumb_browser);
evas_object_smart_callback_add(em->thumb_browser, evas_object_smart_callback_add(em->thumb_browser,
"selected", "selected",
_ephoto_thumb_browser_selected_cb, _ephoto_thumb_browser_selected_cb,
NULL); NULL);
evas_object_smart_callback_add(em->thumb_browser,
"directory,changed",
_ephoto_thumb_browser_directory_changed_cb,
NULL);
em->state = EPHOTO_STATE_THUMB; em->state = EPHOTO_STATE_THUMB;
} }

View File

@ -455,6 +455,8 @@ _ephoto_directory_chosen(void *data, Evas_Object *obj, void *event_info)
elm_win_title_set(em->win, "Ephoto"); elm_win_title_set(em->win, "Ephoto");
} }
} }
printf("before callback\n");
evas_object_smart_callback_call(tb->layout, "directory,changed", tb->current_directory);
evas_object_del(tb->fsel_win); evas_object_del(tb->fsel_win);
elm_toolbar_item_unselect_all(tb->toolbar); elm_toolbar_item_unselect_all(tb->toolbar);