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 Elm_Genlist_Item_Class itc, itc2;
|
||||||
static Evas_Object *list;
|
static Evas_Object *list;
|
||||||
static edi_filepanel_item_clicked_cb _open_cb;
|
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 Evas_Object *menu, *_main_win;
|
||||||
static const char *_menu_cb_path;
|
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))
|
if (ecore_file_is_dir(_menu_cb_path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_open_cb(_menu_cb_path);
|
_open_cb(_menu_cb_path, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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,
|
_item_menu_open_as_text_cb(Elm_Object_Item *it EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
_open_type_cb(_menu_cb_path, "text");
|
_open_cb(_menu_cb_path, "text");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_item_menu_open_as_image_cb(Elm_Object_Item *it EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
_item_menu_open_as_image_cb(Elm_Object_Item *it EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
_open_type_cb(_menu_cb_path, "image");
|
_open_cb(_menu_cb_path, "image");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -147,7 +146,7 @@ _item_sel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED
|
||||||
const char *path = data;
|
const char *path = data;
|
||||||
|
|
||||||
if (!ecore_file_is_dir(path))
|
if (!ecore_file_is_dir(path))
|
||||||
_open_cb(path);
|
_open_cb(path, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
|
@ -329,8 +328,7 @@ _populate(Evas_Object *obj,
|
||||||
|
|
||||||
void
|
void
|
||||||
edi_filepanel_add(Evas_Object *parent, Evas_Object *win,
|
edi_filepanel_add(Evas_Object *parent, Evas_Object *win,
|
||||||
const char *path, edi_filepanel_item_clicked_cb cb,
|
const char *path, edi_filepanel_item_clicked_cb cb)
|
||||||
edi_filepanel_item_type_clicked_cb type_cb)
|
|
||||||
{
|
{
|
||||||
list = elm_genlist_add(parent);
|
list = elm_genlist_add(parent);
|
||||||
evas_object_size_hint_min_set(list, 100, -1);
|
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;
|
itc2.func.del = _item_del;
|
||||||
|
|
||||||
_open_cb = cb;
|
_open_cb = cb;
|
||||||
_open_type_cb = type_cb;
|
|
||||||
_main_win = win;
|
_main_win = win;
|
||||||
_populate(list, path, NULL, NULL);
|
_populate(list, path, NULL, NULL);
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,8 @@ extern "C" {
|
||||||
* @brief These routines are used for managing the Edi file panel.
|
* @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_clicked_cb)(const char *path,
|
||||||
|
const char *type);
|
||||||
typedef void (*edi_filepanel_item_type_clicked_cb)(const char *path,
|
|
||||||
const char *type);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UI management functions.
|
* @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 win The main window of the application.
|
||||||
* @param path The project path being opened.
|
* @param path The project path being opened.
|
||||||
* @param cb A callback to inform the app a file should be 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
|
* @ingroup UI
|
||||||
*/
|
*/
|
||||||
void edi_filepanel_add(Evas_Object *parent, Evas_Object *win,
|
void edi_filepanel_add(Evas_Object *parent, Evas_Object *win,
|
||||||
const char *path, edi_filepanel_item_clicked_cb cb,
|
const char *path, edi_filepanel_item_clicked_cb cb);
|
||||||
edi_filepanel_item_type_clicked_cb type_cb);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|
|
@ -29,17 +29,14 @@ _edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_edi_file_open_cb(const char *path)
|
_edi_file_open_cb(const char *path, const char *type)
|
||||||
{
|
{
|
||||||
INF("Opening %s", path);
|
if (type == NULL)
|
||||||
edi_mainview_open_path(path);
|
INF("Opening %s", path);
|
||||||
}
|
else
|
||||||
|
INF("Opening %s as %s", path, type);
|
||||||
|
|
||||||
static void
|
edi_mainview_open_path(path, type);
|
||||||
_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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
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_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
evas_object_show(panel);
|
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_object_part_content_set(panes, "left", panel);
|
||||||
elm_panes_content_left_size_set(panes, 0.2);
|
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
|
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;
|
Elm_Object_Item *it;
|
||||||
|
|
||||||
|
@ -120,7 +120,12 @@ edi_mainview_open_path_type(const char *path, const char *type)
|
||||||
return;
|
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);
|
_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
|
EAPI void
|
||||||
edi_mainview_save()
|
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.
|
* Open the file at path for editing using the type specified.
|
||||||
* Supported types are "text" and "image".
|
* Supported types are "text" and "image".
|
||||||
*
|
*
|
||||||
* @param path The absolute path of the file to open.
|
* @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
|
* @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.
|
* Save the current file.
|
||||||
|
|
Loading…
Reference in New Issue