forked from enlightenment/edi
Remove the extra callback, we can just make type a required parameter that can be null
This commit is contained in:
parent
0365a65263
commit
d8e430285a
|
@ -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);
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ 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,
|
||||
typedef void (*edi_filepanel_item_clicked_cb)(const char *path,
|
||||
const char *type);
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
if (type == NULL)
|
||||
INF("Opening %s", path);
|
||||
edi_mainview_open_path(path);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_open_type_cb(const char *path, const char *type)
|
||||
{
|
||||
else
|
||||
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);
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue