forked from enlightenment/enlightenment
e_fm: remember directory settings.
e_fm2_custom_file now remembers directory settings, it will save position on screen (horizontal and vertical pan percentage), view mode, icon size, if to remember ordering and if it should show hidden files. There is a menu option to remove these settings and inherit settings from parent. SVN revision: 39031
This commit is contained in:
parent
b6e158989f
commit
815441ef2e
196
src/bin/e_fm.c
196
src/bin/e_fm.c
|
@ -76,6 +76,7 @@ struct _E_Fm2_Smart_Data
|
|||
unsigned char typebuf_visible : 1;
|
||||
unsigned char show_hidden_files : 1;
|
||||
unsigned char listing : 1;
|
||||
unsigned char inherited_dir_props : 1;
|
||||
signed char view_mode; /* -1 = unset */
|
||||
signed short icon_size; /* -1 = unset */
|
||||
|
||||
|
@ -206,6 +207,9 @@ static void _e_fm2_icons_free(Evas_Object *obj);
|
|||
static void _e_fm2_regions_eval(Evas_Object *obj);
|
||||
static void _e_fm2_config_free(E_Fm2_Config *cfg);
|
||||
|
||||
static void _e_fm2_dir_load_props(E_Fm2_Smart_Data *sd);
|
||||
static void _e_fm2_dir_save_props(E_Fm2_Smart_Data *sd);
|
||||
|
||||
static Evas_Object *_e_fm2_file_fm2_find(const char *file);
|
||||
static E_Fm2_Icon *_e_fm2_icon_find(Evas_Object *obj, const char *file);
|
||||
static const char *_e_fm2_uri_escape(const char *path);
|
||||
|
@ -286,6 +290,7 @@ static void _e_fm2_menu_post_cb(void *data, E_Menu *m);
|
|||
static void _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp);
|
||||
static void _e_fm2_icon_menu_post_cb(void *data, E_Menu *m);
|
||||
static void _e_fm2_icon_menu_item_cb(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_fm2_toggle_inherit_dir_props(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_fm2_view_menu_pre(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_fm2_view_menu_grid_icons_cb(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _e_fm2_view_menu_custom_icons_cb(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
|
@ -590,6 +595,8 @@ e_fm2_path_set(Evas_Object *obj, const char *dev, const char *path)
|
|||
_e_fm2_icons_free(obj);
|
||||
edje_object_part_text_set(sd->overlay, "e.text.busy_label", "");
|
||||
|
||||
_e_fm2_dir_load_props(sd);
|
||||
|
||||
/* If the path change from a mountpoint to something else, we fake-unmount */
|
||||
if (sd->mount && sd->mount->mount_point
|
||||
&& strncmp(sd->mount->mount_point, sd->realpath,
|
||||
|
@ -720,6 +727,126 @@ e_fm2_path_get(Evas_Object *obj, const char **dev, const char **path)
|
|||
if (path) *path = sd->path;
|
||||
}
|
||||
|
||||
static E_Fm2_Custom_File *
|
||||
_e_fm2_dir_load_props_from_parent(const char *path)
|
||||
{
|
||||
E_Fm2_Custom_File *cf;
|
||||
char *parent;
|
||||
|
||||
if ((!path) || (path[0] == '\0') || (strcmp(path, "/") == 0))
|
||||
return NULL;
|
||||
|
||||
parent = ecore_file_dir_get(path);
|
||||
cf = e_fm2_custom_file_get(parent);
|
||||
if ((cf) && (cf->dir) && (cf->dir->prop.in_use))
|
||||
{
|
||||
free(parent);
|
||||
return cf;
|
||||
}
|
||||
|
||||
cf = _e_fm2_dir_load_props_from_parent(parent);
|
||||
free(parent);
|
||||
return cf;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm2_dir_load_props(E_Fm2_Smart_Data *sd)
|
||||
{
|
||||
E_Fm2_Custom_File *cf;
|
||||
|
||||
cf = e_fm2_custom_file_get(sd->realpath);
|
||||
if ((cf) && (cf->dir))
|
||||
{
|
||||
Evas_Coord x, y;
|
||||
|
||||
if (sd->max.w - sd->w > 0)
|
||||
x = (sd->max.w - sd->w) * cf->dir->pos.x;
|
||||
else
|
||||
x = 0;
|
||||
|
||||
if (sd->max.h - sd->h > 0)
|
||||
y = (sd->max.h - sd->h) * cf->dir->pos.y;
|
||||
else
|
||||
y = 0;
|
||||
|
||||
e_fm2_pan_set(sd->obj, x, y);
|
||||
|
||||
if (cf->dir->prop.in_use)
|
||||
{
|
||||
sd->view_mode = cf->dir->prop.view_mode;
|
||||
sd->icon_size = cf->dir->prop.icon_size;
|
||||
sd->order_file = !!cf->dir->prop.order_file;
|
||||
sd->show_hidden_files = !!cf->dir->prop.show_hidden_files;
|
||||
sd->inherited_dir_props = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sd->pos.x = 0;
|
||||
sd->pos.y = 0;
|
||||
}
|
||||
|
||||
sd->inherited_dir_props = 1;
|
||||
|
||||
cf = _e_fm2_dir_load_props_from_parent(sd->realpath);
|
||||
if ((cf) && (cf->dir) && (cf->dir->prop.in_use))
|
||||
{
|
||||
sd->view_mode = cf->dir->prop.view_mode;
|
||||
sd->icon_size = cf->dir->prop.icon_size;
|
||||
sd->order_file = !!cf->dir->prop.order_file;
|
||||
sd->show_hidden_files = !!cf->dir->prop.show_hidden_files;
|
||||
}
|
||||
else
|
||||
{
|
||||
sd->view_mode = -1;
|
||||
sd->icon_size = -1;
|
||||
sd->order_file = 0;
|
||||
sd->show_hidden_files = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm2_dir_save_props(E_Fm2_Smart_Data *sd)
|
||||
{
|
||||
E_Fm2_Custom_File *cf, cf0;
|
||||
E_Fm2_Custom_Dir dir0;
|
||||
|
||||
cf = e_fm2_custom_file_get(sd->realpath);
|
||||
if (!cf)
|
||||
{
|
||||
cf = &cf0;
|
||||
memset(cf, 0, sizeof(*cf));
|
||||
cf->dir = &dir0;
|
||||
}
|
||||
else if (!cf->dir)
|
||||
{
|
||||
E_Fm2_Custom_File *cf2 = cf;
|
||||
cf = &cf0;
|
||||
memcpy(cf, cf2, sizeof(*cf2));
|
||||
cf->dir = &dir0;
|
||||
}
|
||||
|
||||
if (sd->max.w - sd->w > 0)
|
||||
cf->dir->pos.x = sd->pos.x / (double)(sd->max.w - sd->w);
|
||||
else
|
||||
cf->dir->pos.x = 0.0;
|
||||
|
||||
if (sd->max.h - sd->h)
|
||||
cf->dir->pos.y = sd->pos.y / (double)(sd->max.h - sd->h);
|
||||
else
|
||||
cf->dir->pos.y = 0.0;
|
||||
|
||||
cf->dir->prop.icon_size = sd->icon_size;
|
||||
cf->dir->prop.view_mode = sd->view_mode;
|
||||
cf->dir->prop.order_file = sd->order_file;
|
||||
cf->dir->prop.show_hidden_files = sd->show_hidden_files;
|
||||
cf->dir->prop.in_use = !sd->inherited_dir_props;
|
||||
|
||||
e_fm2_custom_file_set(sd->realpath, cf);
|
||||
e_fm2_custom_file_flush();
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_refresh(Evas_Object *obj)
|
||||
{
|
||||
|
@ -730,6 +857,8 @@ e_fm2_refresh(Evas_Object *obj)
|
|||
if (!evas_object_type_get(obj)) return; // safety
|
||||
if (strcmp(evas_object_type_get(obj), "e_fm")) return; // safety
|
||||
|
||||
_e_fm2_dir_save_props(sd);
|
||||
|
||||
_e_fm2_queue_free(obj);
|
||||
_e_fm2_regions_free(obj);
|
||||
_e_fm2_icons_free(obj);
|
||||
|
@ -5942,6 +6071,7 @@ _e_fm2_cb_scroll_job(void *data)
|
|||
_e_fm2_obj_icons_place(sd);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas_object_evas_get(sd->obj));
|
||||
_e_fm2_dir_save_props(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6022,6 +6152,17 @@ _e_fm2_cb_resize_job(void *data)
|
|||
sd->iconlist_changed = 0;
|
||||
sd->pw = sd->w;
|
||||
sd->ph = sd->h;
|
||||
|
||||
if ((sd->max.w > 0) && (sd->max.h > 0) && (sd->w > 0) && (sd->h > 0))
|
||||
{
|
||||
E_Fm2_Custom_File *cf = e_fm2_custom_file_get(sd->realpath);
|
||||
if ((cf) && (cf->dir))
|
||||
{
|
||||
sd->pos.x = cf->dir->pos.x * (sd->max.w - sd->w);
|
||||
sd->pos.y = cf->dir->pos.y * (sd->max.h - sd->h);
|
||||
evas_object_smart_callback_call(sd->obj, "pan_changed", NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -6432,6 +6573,18 @@ _e_fm2_menu(Evas_Object *obj, unsigned int timestamp)
|
|||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_separator_set(mi, 1);
|
||||
}
|
||||
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_INHERIT_PARENT))
|
||||
{
|
||||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_label_set(mi, _("Inherit parent settings"));
|
||||
e_menu_item_icon_edje_set(mi,
|
||||
e_theme_edje_file_get("base/theme/fileman",
|
||||
"e/fileman/default/button/inherit"),
|
||||
"e/fileman/default/button/inherit");
|
||||
e_menu_item_check_set(mi, 1);
|
||||
e_menu_item_toggle_set(mi, sd->inherited_dir_props);
|
||||
e_menu_item_callback_set(mi, _e_fm2_toggle_inherit_dir_props, sd);
|
||||
}
|
||||
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_VIEW_MENU))
|
||||
{
|
||||
mi = e_menu_item_new(mn);
|
||||
|
@ -6589,6 +6742,18 @@ _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp)
|
|||
e_menu_item_separator_set(mi, 1);
|
||||
}
|
||||
|
||||
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_INHERIT_PARENT))
|
||||
{
|
||||
mi = e_menu_item_new(mn);
|
||||
e_menu_item_label_set(mi, _("Inherit parent settings"));
|
||||
e_menu_item_icon_edje_set(mi,
|
||||
e_theme_edje_file_get("base/theme/fileman",
|
||||
"e/fileman/default/button/inherit"),
|
||||
"e/fileman/default/button/inherit");
|
||||
e_menu_item_check_set(mi, 1);
|
||||
e_menu_item_toggle_set(mi, sd->inherited_dir_props);
|
||||
e_menu_item_callback_set(mi, _e_fm2_toggle_inherit_dir_props, sd);
|
||||
}
|
||||
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_VIEW_MENU))
|
||||
{
|
||||
mi = e_menu_item_new(mn);
|
||||
|
@ -6947,9 +7112,10 @@ _e_fm2_view_menu_icon_size_change(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
struct e_fm2_view_menu_icon_size_data *d = data;
|
||||
short current_size = _e_fm2_icon_w_get(d->sd);
|
||||
d->sd->icon_size = d->size;
|
||||
d->sd->inherited_dir_props = 0;
|
||||
if (current_size == d->size)
|
||||
return;
|
||||
e_fm2_refresh(d->sd->obj);
|
||||
_e_fm2_refresh(d->sd, m, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6966,11 +7132,12 @@ _e_fm2_view_menu_icon_size_use_default(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
sd->icon_size = -1;
|
||||
|
||||
new = _e_fm2_icon_w_get(sd);
|
||||
sd->inherited_dir_props = 0;
|
||||
|
||||
if (new == old)
|
||||
return;
|
||||
|
||||
e_fm2_refresh(sd->obj);
|
||||
_e_fm2_refresh(sd, m, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -7027,6 +7194,17 @@ _e_fm2_view_menu_icon_size_pre(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
e_menu_item_callback_set(mi, _e_fm2_view_menu_icon_size_use_default, sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm2_toggle_inherit_dir_props(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
E_Fm2_Smart_Data *sd = data;
|
||||
|
||||
sd->inherited_dir_props = !sd->inherited_dir_props;
|
||||
_e_fm2_dir_save_props(sd);
|
||||
_e_fm2_dir_load_props(sd);
|
||||
_e_fm2_refresh(sd, m, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm2_view_menu_pre(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
|
@ -7101,10 +7279,11 @@ _e_fm2_view_menu_grid_icons_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
|
||||
old = _e_fm2_view_mode_get(sd);
|
||||
sd->view_mode = E_FM2_VIEW_MODE_GRID_ICONS;
|
||||
sd->inherited_dir_props = 0;
|
||||
if (old == E_FM2_VIEW_MODE_GRID_ICONS)
|
||||
return;
|
||||
|
||||
e_fm2_refresh(sd->obj);
|
||||
_e_fm2_refresh(sd, m, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -7115,10 +7294,11 @@ _e_fm2_view_menu_custom_icons_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
|
||||
old = _e_fm2_view_mode_get(sd);
|
||||
sd->view_mode = E_FM2_VIEW_MODE_CUSTOM_ICONS;
|
||||
sd->inherited_dir_props = 0;
|
||||
if (old == E_FM2_VIEW_MODE_CUSTOM_ICONS)
|
||||
return;
|
||||
|
||||
e_fm2_refresh(sd->obj);
|
||||
_e_fm2_refresh(sd, m, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -7129,10 +7309,11 @@ _e_fm2_view_menu_list_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
|
||||
old = _e_fm2_view_mode_get(sd);
|
||||
sd->view_mode = E_FM2_VIEW_MODE_LIST;
|
||||
sd->inherited_dir_props = 0;
|
||||
if (old == E_FM2_VIEW_MODE_LIST)
|
||||
return;
|
||||
|
||||
e_fm2_refresh(sd->obj);
|
||||
_e_fm2_refresh(sd, m, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -7149,11 +7330,12 @@ _e_fm2_view_menu_use_default_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
sd->view_mode = -1;
|
||||
|
||||
new = _e_fm2_view_mode_get(sd);
|
||||
sd->inherited_dir_props = 0;
|
||||
|
||||
if (new == old)
|
||||
return;
|
||||
|
||||
e_fm2_refresh(sd->obj);
|
||||
_e_fm2_refresh(sd, m, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -7177,6 +7359,7 @@ _e_fm2_toggle_hidden_files(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
else
|
||||
sd->show_hidden_files = 1;
|
||||
|
||||
sd->inherited_dir_props = 0;
|
||||
_e_fm2_refresh(data, m, mi);
|
||||
}
|
||||
|
||||
|
@ -7201,6 +7384,7 @@ _e_fm2_toggle_ordering(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
f = fopen(buf, "w");
|
||||
if (f) fclose(f);
|
||||
}
|
||||
sd->inherited_dir_props = 0;
|
||||
_e_fm2_refresh(data, m, mi);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ typedef enum _E_Fm2_Menu_Flags
|
|||
E_FM2_MENU_NO_CUT = (1 << 6),
|
||||
E_FM2_MENU_NO_COPY = (1 << 7),
|
||||
E_FM2_MENU_NO_PASTE = (1 << 8),
|
||||
E_FM2_MENU_NO_VIEW_MENU = (1 << 9)
|
||||
E_FM2_MENU_NO_VIEW_MENU = (1 << 9),
|
||||
E_FM2_MENU_NO_INHERIT_PARENT = (1 << 10)
|
||||
} E_Fm2_Menu_Flags;
|
||||
|
||||
typedef struct _E_Fm2_Config E_Fm2_Config;
|
||||
|
|
|
@ -17,8 +17,10 @@ static void _e_fm2_custom_file_cb_defer_save(void *data);
|
|||
static E_Powersave_Deferred_Action*_e_fm2_flush_defer = NULL;
|
||||
static Eet_File *_e_fm2_custom_file = NULL;
|
||||
static Eet_Data_Descriptor *_e_fm2_custom_file_edd = NULL;
|
||||
static Eet_Data_Descriptor *_e_fm2_custom_dir_edd = NULL;
|
||||
static Eina_Hash *_e_fm2_custom_hash = NULL;
|
||||
static int _e_fm2_custom_writes = 0;
|
||||
static int _e_fm2_custom_init = 0;
|
||||
|
||||
/* FIXME: this uses a flat path key for custom file info. this is fine as
|
||||
* long as we only expect a limited number of custom info nodes. if we
|
||||
|
@ -31,7 +33,12 @@ EAPI int
|
|||
e_fm2_custom_file_init(void)
|
||||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
|
||||
|
||||
_e_fm2_custom_init++;
|
||||
if (_e_fm2_custom_init > 1) return _e_fm2_custom_init;
|
||||
|
||||
_e_fm2_custom_hash = eina_hash_string_superfast_new(NULL);
|
||||
|
||||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
|
||||
eddc.func.mem_alloc = NULL;
|
||||
eddc.func.mem_free = NULL;
|
||||
|
@ -45,10 +52,21 @@ e_fm2_custom_file_init(void)
|
|||
(void (*) (void *, int (*) (void *, const char *, void *, void *), void *))
|
||||
eina_hash_foreach;
|
||||
eddc.func.hash_add = (void* (*) (void *, const char *, void *)) eet_eina_hash_add_alloc;
|
||||
eddc.func.hash_free = (void (*) (Eina_Hash *)) eina_hash_free;
|
||||
eddc.func.hash_free = (void (*) (void *)) eina_hash_free;
|
||||
eddc.name = "e_fm_custom_file";
|
||||
eddc.size = sizeof(E_Fm2_Custom_File);
|
||||
|
||||
_e_fm2_custom_dir_edd = eet_data_descriptor2_new(&eddc);
|
||||
#define DAT(x, y, z) EET_DATA_DESCRIPTOR_ADD_BASIC(_e_fm2_custom_dir_edd, E_Fm2_Custom_Dir, x, y, z)
|
||||
DAT("pos.x", pos.x, EET_T_DOUBLE);
|
||||
DAT("pos.y", pos.y, EET_T_DOUBLE);
|
||||
DAT("prop.icon_size", prop.icon_size, EET_T_SHORT);
|
||||
DAT("prop.view_mode", prop.view_mode, EET_T_CHAR);
|
||||
DAT("prop.order_file", prop.order_file, EET_T_UCHAR);
|
||||
DAT("prop.show_hidden_files", prop.show_hidden_files, EET_T_UCHAR);
|
||||
DAT("prop.in_use", prop.in_use, EET_T_UCHAR);
|
||||
#undef DAT
|
||||
|
||||
_e_fm2_custom_file_edd = eet_data_descriptor2_new(&eddc);
|
||||
#define DAT(x, y, z) EET_DATA_DESCRIPTOR_ADD_BASIC(_e_fm2_custom_file_edd, E_Fm2_Custom_File, x, y, z)
|
||||
DAT("g.x", geom.x, EET_T_INT);
|
||||
|
@ -65,19 +83,29 @@ e_fm2_custom_file_init(void)
|
|||
DAT("i.v", icon.valid, EET_T_UCHAR);
|
||||
|
||||
DAT("l", label, EET_T_STRING);
|
||||
|
||||
|
||||
#undef DAT
|
||||
|
||||
EET_DATA_DESCRIPTOR_ADD_SUB(_e_fm2_custom_file_edd, E_Fm2_Custom_File, "dir",
|
||||
dir, _e_fm2_custom_dir_edd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_custom_file_shutdown(void)
|
||||
{
|
||||
_e_fm2_custom_init--;
|
||||
if (_e_fm2_custom_init != 0) return;
|
||||
|
||||
_e_fm2_custom_file_info_save();
|
||||
_e_fm2_custom_file_info_free();
|
||||
if (_e_fm2_flush_defer) e_powersave_deferred_action_del(_e_fm2_flush_defer);
|
||||
_e_fm2_flush_defer = NULL;
|
||||
eet_data_descriptor_free(_e_fm2_custom_file_edd);
|
||||
_e_fm2_custom_file_edd = NULL;
|
||||
eet_data_descriptor_free(_e_fm2_custom_dir_edd);
|
||||
_e_fm2_custom_dir_edd = NULL;
|
||||
}
|
||||
|
||||
EAPI E_Fm2_Custom_File *
|
||||
|
@ -92,27 +120,75 @@ e_fm2_custom_file_get(const char *path)
|
|||
return cf;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_custom_file_set(const char *path, E_Fm2_Custom_File *cf)
|
||||
static void
|
||||
_e_fm2_custom_dir_del(E_Fm2_Custom_Dir *dir)
|
||||
{
|
||||
free(dir);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm2_custom_file_del(E_Fm2_Custom_File *cf)
|
||||
{
|
||||
if (!cf) return;
|
||||
|
||||
eina_stringshare_del(cf->icon.icon);
|
||||
eina_stringshare_del(cf->label);
|
||||
_e_fm2_custom_dir_del(cf->dir);
|
||||
free(cf);
|
||||
}
|
||||
|
||||
static E_Fm2_Custom_Dir *
|
||||
_e_fm2_custom_dir_dup(const E_Fm2_Custom_Dir *dir)
|
||||
{
|
||||
E_Fm2_Custom_Dir *copy;
|
||||
|
||||
if (!dir) return NULL;
|
||||
|
||||
copy = calloc(1, sizeof(*copy));
|
||||
if (!copy) return NULL;
|
||||
|
||||
memcpy(copy, dir, sizeof(*copy));
|
||||
return copy;
|
||||
}
|
||||
|
||||
EAPI E_Fm2_Custom_File *
|
||||
e_fm2_custom_file_dup(const E_Fm2_Custom_File *cf)
|
||||
{
|
||||
E_Fm2_Custom_File *copy;
|
||||
|
||||
if (!cf) return NULL;
|
||||
|
||||
copy = calloc(1, sizeof(*copy));
|
||||
if (!copy) return NULL;
|
||||
|
||||
memcpy(copy, cf, sizeof(*copy));
|
||||
copy->icon.icon = eina_stringshare_add(cf->icon.icon);
|
||||
copy->label = eina_stringshare_add(cf->label);
|
||||
copy->dir = _e_fm2_custom_dir_dup(cf->dir);
|
||||
return copy;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_fm2_custom_file_set(const char *path, const E_Fm2_Custom_File *cf)
|
||||
{
|
||||
E_Fm2_Custom_File *cf1;
|
||||
_e_fm2_custom_file_info_load();
|
||||
if (!_e_fm2_custom_file) return;
|
||||
if (_e_fm2_flush_defer) e_fm2_custom_file_flush();
|
||||
if (eina_hash_find(_e_fm2_custom_hash, path) != cf)
|
||||
{
|
||||
E_Fm2_Custom_File *cf2;
|
||||
|
||||
cf2 = calloc(1, sizeof(E_Fm2_Custom_File));
|
||||
cf1 = eina_hash_find(_e_fm2_custom_hash, path);
|
||||
if ((cf1 != cf) || ((cf1) && (cf) && (cf1->dir != cf->dir)))
|
||||
{
|
||||
E_Fm2_Custom_File *cf2 = e_fm2_custom_file_dup(cf);
|
||||
if (cf2)
|
||||
{
|
||||
memcpy(cf2, cf, sizeof(E_Fm2_Custom_File));
|
||||
if (cf->icon.icon)
|
||||
cf2->icon.icon = eina_stringshare_add(cf->icon.icon);
|
||||
if (cf->label)
|
||||
cf2->label = eina_stringshare_add(cf->label);
|
||||
if (!_e_fm2_custom_hash)
|
||||
_e_fm2_custom_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(_e_fm2_custom_hash, path, cf2);
|
||||
if (cf1)
|
||||
{
|
||||
eina_hash_modify(_e_fm2_custom_hash, path, cf2);
|
||||
_e_fm2_custom_file_del(cf1);
|
||||
}
|
||||
else
|
||||
eina_hash_add(_e_fm2_custom_hash, path, cf2);
|
||||
}
|
||||
}
|
||||
_e_fm2_custom_writes = 1;
|
||||
|
@ -137,9 +213,7 @@ e_fm2_custom_file_del(const char *path)
|
|||
if (cf2)
|
||||
{
|
||||
eina_hash_del(_e_fm2_custom_hash, l->data, cf2);
|
||||
if (cf2->icon.icon) eina_stringshare_del(cf2->icon.icon);
|
||||
if (cf2->label) eina_stringshare_del(cf2->label);
|
||||
free(cf2);
|
||||
_e_fm2_custom_file_del(cf2);
|
||||
}
|
||||
}
|
||||
eina_list_free(list);
|
||||
|
@ -162,11 +236,7 @@ e_fm2_custom_file_rename(const char *path, const char *new_path)
|
|||
eina_hash_del(_e_fm2_custom_hash, path, cf2);
|
||||
cf = eina_hash_find(_e_fm2_custom_hash, new_path);
|
||||
if (cf)
|
||||
{
|
||||
if (cf->icon.icon) eina_stringshare_del(cf->icon.icon);
|
||||
if (cf->label) eina_stringshare_del(cf->label);
|
||||
free(cf);
|
||||
}
|
||||
_e_fm2_custom_file_del(cf);
|
||||
eina_hash_add(_e_fm2_custom_hash, new_path, cf2);
|
||||
}
|
||||
list = _e_fm2_custom_hash_key_base_list(_e_fm2_custom_hash, path);
|
||||
|
@ -184,11 +254,7 @@ e_fm2_custom_file_rename(const char *path, const char *new_path)
|
|||
eina_hash_del(_e_fm2_custom_hash, l->data, cf2);
|
||||
cf = eina_hash_find(_e_fm2_custom_hash, buf);
|
||||
if (cf)
|
||||
{
|
||||
if (cf->icon.icon) eina_stringshare_del(cf->icon.icon);
|
||||
if (cf->label) eina_stringshare_del(cf->label);
|
||||
free(cf);
|
||||
}
|
||||
_e_fm2_custom_file_del(cf);
|
||||
eina_hash_add(_e_fm2_custom_hash, buf, cf2);
|
||||
}
|
||||
}
|
||||
|
@ -270,12 +336,7 @@ _e_fm2_custom_hash_key_sub_list(const Eina_Hash *hash, const void *str)
|
|||
static Eina_Bool
|
||||
_e_fm2_custom_file_hash_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata)
|
||||
{
|
||||
E_Fm2_Custom_File *cf;
|
||||
|
||||
cf = data;
|
||||
if (cf->icon.icon) eina_stringshare_del(cf->icon.icon);
|
||||
if (cf->label) eina_stringshare_del(cf->label);
|
||||
free(cf);
|
||||
_e_fm2_custom_file_del(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -317,12 +378,7 @@ _e_fm2_custom_file_info_load(void)
|
|||
cf = eet_data_read(_e_fm2_custom_file,
|
||||
_e_fm2_custom_file_edd, list[i]);
|
||||
if (cf)
|
||||
{
|
||||
if (!_e_fm2_custom_hash)
|
||||
_e_fm2_custom_hash =
|
||||
eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(_e_fm2_custom_hash, list[i], cf);
|
||||
}
|
||||
eina_hash_add(_e_fm2_custom_hash, list[i], cf);
|
||||
}
|
||||
free(list);
|
||||
}
|
||||
|
@ -372,7 +428,7 @@ _e_fm2_custom_file_info_free(void)
|
|||
eina_hash_foreach(_e_fm2_custom_hash,
|
||||
_e_fm2_custom_file_hash_foreach, NULL);
|
||||
eina_hash_free(_e_fm2_custom_hash);
|
||||
_e_fm2_custom_hash = NULL;
|
||||
_e_fm2_custom_hash = eina_hash_string_superfast_new(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,26 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Fm2_Custom_File E_Fm2_Custom_File;
|
||||
typedef struct _E_Fm2_Custom_Dir E_Fm2_Custom_Dir;
|
||||
|
||||
#else
|
||||
#ifndef E_FM_CUSTOM_H
|
||||
#define E_FM_CUSTOM_H
|
||||
|
||||
struct _E_Fm2_Custom_Dir
|
||||
{
|
||||
struct {
|
||||
double x, y;
|
||||
} pos;
|
||||
struct {
|
||||
signed short icon_size; /* -1 = unset */
|
||||
signed char view_mode; /* -1 = unset */
|
||||
unsigned char order_file;
|
||||
unsigned char show_hidden_files;
|
||||
unsigned char in_use;
|
||||
} prop;
|
||||
};
|
||||
|
||||
struct _E_Fm2_Custom_File
|
||||
{
|
||||
struct {
|
||||
|
@ -23,16 +38,19 @@ struct _E_Fm2_Custom_File
|
|||
unsigned char valid;
|
||||
} icon;
|
||||
const char *label;
|
||||
E_Fm2_Custom_Dir *dir;
|
||||
/* FIXME: this will have more added */
|
||||
};
|
||||
|
||||
EAPI int e_fm2_custom_file_init(void);
|
||||
EAPI void e_fm2_custom_file_shutdown(void);
|
||||
EAPI E_Fm2_Custom_File *e_fm2_custom_file_get(const char *path);
|
||||
EAPI void e_fm2_custom_file_set(const char *path, E_Fm2_Custom_File *cf);
|
||||
EAPI void e_fm2_custom_file_set(const char *path, const E_Fm2_Custom_File *cf);
|
||||
EAPI void e_fm2_custom_file_del(const char *path);
|
||||
EAPI void e_fm2_custom_file_rename(const char *path, const char *new_path);
|
||||
EAPI void e_fm2_custom_file_flush(void);
|
||||
|
||||
EAPI E_Fm2_Custom_File *e_fm2_custom_file_dup(const E_Fm2_Custom_File *cf);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue