From d8e430285a3f8007da1568b765fee620331caaeb Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 26 Feb 2014 08:17:44 +0000 Subject: [PATCH] Remove the extra callback, we can just make type a required parameter that can be null --- src/bin/edi_filepanel.c | 13 +++++-------- src/bin/edi_filepanel.h | 10 +++------- src/bin/edi_main.c | 17 +++++++---------- src/bin/edi_mainview.c | 25 +++++++------------------ src/bin/edi_mainview.h | 13 ++----------- 5 files changed, 24 insertions(+), 54 deletions(-) diff --git a/src/bin/edi_filepanel.c b/src/bin/edi_filepanel.c index f0f9a52..cf88e58 100644 --- a/src/bin/edi_filepanel.c +++ b/src/bin/edi_filepanel.c @@ -15,7 +15,6 @@ static Elm_Genlist_Item_Class itc, itc2; static Evas_Object *list; static edi_filepanel_item_clicked_cb _open_cb; -static edi_filepanel_item_type_clicked_cb _open_type_cb; static Evas_Object *menu, *_main_win; static const char *_menu_cb_path; @@ -30,7 +29,7 @@ _item_menu_open_cb(Elm_Object_Item *it EINA_UNUSED, Evas_Object *obj EINA_UNUSED if (ecore_file_is_dir(_menu_cb_path)) return; - _open_cb(_menu_cb_path); + _open_cb(_menu_cb_path, NULL); } static void @@ -50,14 +49,14 @@ static void _item_menu_open_as_text_cb(Elm_Object_Item *it EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - _open_type_cb(_menu_cb_path, "text"); + _open_cb(_menu_cb_path, "text"); } static void _item_menu_open_as_image_cb(Elm_Object_Item *it EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - _open_type_cb(_menu_cb_path, "image"); + _open_cb(_menu_cb_path, "image"); } static void @@ -147,7 +146,7 @@ _item_sel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED const char *path = data; if (!ecore_file_is_dir(path)) - _open_cb(path); + _open_cb(path, NULL); } static Evas_Object * @@ -329,8 +328,7 @@ _populate(Evas_Object *obj, void edi_filepanel_add(Evas_Object *parent, Evas_Object *win, - const char *path, edi_filepanel_item_clicked_cb cb, - edi_filepanel_item_type_clicked_cb type_cb) + const char *path, edi_filepanel_item_clicked_cb cb) { list = elm_genlist_add(parent); evas_object_size_hint_min_set(list, 100, -1); @@ -358,7 +356,6 @@ edi_filepanel_add(Evas_Object *parent, Evas_Object *win, itc2.func.del = _item_del; _open_cb = cb; - _open_type_cb = type_cb; _main_win = win; _populate(list, path, NULL, NULL); diff --git a/src/bin/edi_filepanel.h b/src/bin/edi_filepanel.h index fe98fa1..d1a41d2 100644 --- a/src/bin/edi_filepanel.h +++ b/src/bin/edi_filepanel.h @@ -12,10 +12,8 @@ extern "C" { * @brief These routines are used for managing the Edi file panel. */ -typedef void (*edi_filepanel_item_clicked_cb)(const char *path); - -typedef void (*edi_filepanel_item_type_clicked_cb)(const char *path, - const char *type); +typedef void (*edi_filepanel_item_clicked_cb)(const char *path, + const char *type); /** * @brief UI management functions. @@ -34,13 +32,11 @@ typedef void (*edi_filepanel_item_type_clicked_cb)(const char *path, * @param win The main window of the application. * @param path The project path being opened. * @param cb A callback to inform the app a file should be opened. - * @param type_cb A callback to inform the app a file should be opened with a specified type. * * @ingroup UI */ void edi_filepanel_add(Evas_Object *parent, Evas_Object *win, - const char *path, edi_filepanel_item_clicked_cb cb, - edi_filepanel_item_type_clicked_cb type_cb); + const char *path, edi_filepanel_item_clicked_cb cb); /** * @} diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c index 039bf62..73f6fea 100644 --- a/src/bin/edi_main.c +++ b/src/bin/edi_main.c @@ -29,17 +29,14 @@ _edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info } static void -_edi_file_open_cb(const char *path) +_edi_file_open_cb(const char *path, const char *type) { - INF("Opening %s", path); - edi_mainview_open_path(path); -} + if (type == NULL) + INF("Opening %s", path); + else + INF("Opening %s as %s", path, type); -static void -_edi_file_open_type_cb(const char *path, const char *type) -{ - INF("Opening %s as %s", path, type); - edi_mainview_open_path_type(path, type); + edi_mainview_open_path(path, type); } static Evas_Object * @@ -82,7 +79,7 @@ edi_content_setup(Evas_Object *win, const char *path) evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(panel); - edi_filepanel_add(panel, win, path, _edi_file_open_cb, _edi_file_open_type_cb); + edi_filepanel_add(panel, win, path, _edi_file_open_cb); elm_object_part_content_set(panes, "left", panel); elm_panes_content_left_size_set(panes, 0.2); diff --git a/src/bin/edi_mainview.c b/src/bin/edi_mainview.c index 238efbc..16b7d3f 100644 --- a/src/bin/edi_mainview.c +++ b/src/bin/edi_mainview.c @@ -109,7 +109,7 @@ _edi_mainview_open_stat_done(void *data, Eio_File *handler EINA_UNUSED, const Ei } EAPI void -edi_mainview_open_path_type(const char *path, const char *type) +edi_mainview_open_path(const char *path, const char *type) { Elm_Object_Item *it; @@ -120,7 +120,12 @@ edi_mainview_open_path_type(const char *path, const char *type) return; } - if (!strcmp(type, "text")) + if (type == NULL) + { + eio_file_direct_stat(path, _edi_mainview_open_stat_done, dummy, + eina_stringshare_add(path)); + } + else if (!strcmp(type, "text")) { _edi_mainview_open_file_text(path); } @@ -130,22 +135,6 @@ edi_mainview_open_path_type(const char *path, const char *type) } } -EAPI void -edi_mainview_open_path(const char *path) -{ - Elm_Object_Item *it; - - it = _get_item_for_path(path); - if (it) - { - elm_naviframe_item_promote(it); - return; - } - - eio_file_direct_stat(path, _edi_mainview_open_stat_done, dummy, - eina_stringshare_add(path)); -} - EAPI void edi_mainview_save() { diff --git a/src/bin/edi_mainview.h b/src/bin/edi_mainview.h index 821a622..9966631 100644 --- a/src/bin/edi_mainview.h +++ b/src/bin/edi_mainview.h @@ -44,25 +44,16 @@ EAPI void edi_mainview_add(Evas_Object *parent); * */ -/** - * Open the file at path for editing. - * - * @param path The absolute path of the file to open. - * - * @ingroup Content - */ -EAPI void edi_mainview_open_path(const char *path); - /** * Open the file at path for editing using the type specified. * Supported types are "text" and "image". * * @param path The absolute path of the file to open. - * @param type The requested type to use when opening the file + * @param type The requested type to use when opening the file or NULL for auto-detect * * @ingroup Content */ -EAPI void edi_mainview_open_path_type(const char *path, const char *type); +EAPI void edi_mainview_open_path(const char *path, const char *type); /** * Save the current file.