diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 16c40eb66..f02c490f3 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -316,6 +316,38 @@ static Evas_List *_e_fm2_list = NULL; static Evas_List *_e_fm2_fop_list = NULL; /* externally accessible functions */ +EAPI E_Fm2_Custom_File * +e_fm2_custom_file_get(const char *path) +{ + /* get any custom info for the path in our metadata - if non exists, + * return NULL. This may mean loading upa chunk of metadata off disk + * on demand and caching it */ + return NULL; +} + +EAPI void +e_fm2_custom_file_set(const char *path, E_Fm2_Custom_File *cf) +{ + /* set custom metadata for a file path - save it to the metadata (or queue it) */ +} + +EAPI void e_fm2_custom_file_del(const char *path) +{ + /* delete a custom metadata entry for a path - save changes (or queue it) */ +} + +EAPI void e_fm2_custom_file_rename(const char *path, const char *new_path) +{ + /* rename file path a to file paht b in the metadata - if the path exists */ +} + +EAPI void e_fm2_custom_file_flush(void) +{ + /* free any loaded custom file data, sync changes to disk etc. */ +} + +/***/ + EAPI int e_fm2_init(void) { @@ -959,7 +991,26 @@ e_fm2_icon_get(Evas *evas, const char *realpath, } else { - if (ici->mime) + if (ici->icon_type == 1) + { + if (ici->pseudo_link) + snprintf(buf, sizeof(buf), "%s/%s", ici->pseudo_dir, ici->file); + else + snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file); + + oic = e_thumb_icon_add(evas); + e_thumb_icon_file_set(oic, buf, NULL); + e_thumb_icon_size_set(oic, 128, 128); + if (gen_func) evas_object_smart_callback_add(oic, + "e_thumb_gen", + gen_func, data); + if (!ic) + e_thumb_icon_begin(oic); + else + _e_fm2_icon_thumb(ic, oic, force_gen); + if (type_ret) *type_ret = "THUMB"; + } + else if (ici->mime) { const char *icon; @@ -1355,7 +1406,10 @@ _e_fm2_scan_stop(Evas_Object *obj) { sd->busy_count--; if (sd->busy_count == 0) - edje_object_signal_emit(sd->overlay, "e,state,busy,stop", "e"); + { + edje_object_signal_emit(sd->overlay, "e,state,busy,stop", "e"); + e_fm2_custom_file_flush(); + } } /* stop the scan idler, the sort timer and free the queue */ if (sd->dir) @@ -1898,8 +1952,10 @@ _e_fm2_icon_fill(E_Fm2_Icon *ic) Evas_Object *obj, *obj2; char buf[4096], *lnk; const char *mime; + E_Fm2_Custom_File *cf; snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file); + cf = e_fm2_custom_file_get(buf); lnk = ecore_file_readlink(buf); if (stat(buf, &(ic->info.statinfo)) == -1) { @@ -1952,6 +2008,21 @@ _e_fm2_icon_fill(E_Fm2_Icon *ic) if ((e_util_glob_case_match(ic->info.file, "*.desktop")) || (e_util_glob_case_match(ic->info.file, "*.directory"))) _e_fm2_icon_desktop_load(ic); + + if (cf) + { + if (cf->icon.valid) + { + if (cf->icon.icon) + { + if (ic->info.icon) evas_stringshare_del(ic->info.icon); + ic->info.icon = NULL; + ic->info.icon = evas_stringshare_add(cf->icon.icon); + } + ic->info.icon_type = cf->icon.type; + } + } + evas_event_freeze(evas_object_evas_get(ic->sd->obj)); edje_freeze(); switch (ic->sd->config->view.mode) @@ -4232,6 +4303,7 @@ _e_fm2_smart_del(Evas_Object *obj) if (sd->drop_handler) e_drop_handler_del(sd->drop_handler); _e_fm2_list = evas_list_remove(_e_fm2_list, sd->obj); free(sd); + e_fm2_custom_file_flush(); } static void @@ -4959,6 +5031,7 @@ _e_fm2_file_rename_yes_cb(char *text, void *data) e_dialog_show(dialog); return; } + e_fm2_custom_file_rename(oldpath, newpath); _e_fm2_live_file_del(ic->sd->obj, ic->info.file); _e_fm2_live_file_add(ic->sd->obj, text, NULL, 0); // evas_stringshare_del(ic->info.file); @@ -5623,6 +5696,7 @@ _e_fm2_fop_process(E_Fm2_Fop *fop) snprintf(buf, sizeof(buf), "%s/%s", fi->fop->dir, fi->file); if (ecore_file_unlink(buf)) { + e_fm2_custom_file_del(buf); if ((fi->fop->obj) && (!strchr(fi->file, '/'))) _e_fm2_live_file_del(fi->fop->obj, fi->file); } @@ -5664,6 +5738,7 @@ _e_fm2_fop_process(E_Fm2_Fop *fop) { if (ecore_file_mv(fi->file, fi->file2)) { + e_fm2_custom_file_rename(fi->file, fi->file2); if ((fi->fop->obj) && (fi->file_add)) _e_fm2_live_file_add(fi->fop->obj, fi->file, fi->file3, fi->after); diff --git a/src/bin/e_fm.h b/src/bin/e_fm.h index 4a5b049d9..5c5cd9c20 100644 --- a/src/bin/e_fm.h +++ b/src/bin/e_fm.h @@ -25,9 +25,10 @@ typedef enum _E_Fm2_Menu_Flags E_FM2_MENU_NO_RENAME = (1 << 5) } E_Fm2_Menu_Flags; -typedef struct _E_Fm2_Config E_Fm2_Config; -typedef struct _E_Fm2_Icon E_Fm2_Icon; -typedef struct _E_Fm2_Icon_Info E_Fm2_Icon_Info; +typedef struct _E_Fm2_Config E_Fm2_Config; +typedef struct _E_Fm2_Icon E_Fm2_Icon; +typedef struct _E_Fm2_Icon_Info E_Fm2_Icon_Info; +typedef struct _E_Fm2_Custom_File E_Fm2_Custom_File; #else #ifndef E_FM_H @@ -102,12 +103,35 @@ struct _E_Fm2_Icon_Info const char *real_link; const char *pseudo_dir; struct stat statinfo; + unsigned char icon_type; unsigned char mount : 1; unsigned char pseudo_link : 1; unsigned char deleted : 1; unsigned char broken_link : 1; }; +struct _E_Fm2_Custom_File +{ + struct { + int x, y, w, h; + int res_w, res_h; + unsigned char valid; + } geom; + struct { + int type; + const char *icon; + unsigned char valid; + } icon; + const char *label; + /* FIXME: this will have more added */ +}; + +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_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 int e_fm2_init(void); EAPI int e_fm2_shutdown(void); EAPI Evas_Object *e_fm2_add(Evas *evas); diff --git a/src/bin/e_fm_prop.c b/src/bin/e_fm_prop.c index 11bcf881d..bb8e98cc6 100644 --- a/src/bin/e_fm_prop.c +++ b/src/bin/e_fm_prop.c @@ -68,8 +68,12 @@ struct _E_Config_Dialog_Data int owner_write; int others_read; int others_write; + int picon_type; + int picon_mime; + int picon_changed; int icon_type; int icon_mime; + char *icon; /*- ADVANCED -*/ }; @@ -87,8 +91,10 @@ e_fm_prop_file(E_Container *con, E_Fm2_Icon_Info *fi) v->free_cfdata = _free_data; v->basic.apply_cfdata = _basic_apply_data; v->basic.create_widgets = _basic_create_widgets; -// v->advanced.apply_cfdata = _advanced_apply_data; -// v->advanced.create_widgets = _advanced_create_widgets; +#if 0 + v->advanced.apply_cfdata = _advanced_apply_data; + v->advanced.create_widgets = _advanced_create_widgets; +#endif /* create config diaolg for NULL object/data */ cfd = e_config_dialog_new(con, _("File Properties"), @@ -139,6 +145,7 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) E_FREE(cfdata->mod_date); E_FREE(cfdata->mime); E_FREE(cfdata->owner); + E_FREE(cfdata->icon); free(cfdata); } @@ -149,6 +156,8 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) char buf[4096]; int fperm = 0; + snprintf(buf, sizeof(buf), "%s/%s", + e_fm2_real_path_get(cfdata->fi->fm), cfdata->fi->file); if (((cfdata->fi->statinfo.st_mode & S_IRUSR) && (cfdata->owner_read)) || ((!cfdata->fi->statinfo.st_mode & S_IRUSR) && (!cfdata->owner_read))) fperm = 1; @@ -161,13 +170,57 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) if (((cfdata->fi->statinfo.st_mode & S_IWOTH) && (cfdata->others_write)) || ((!cfdata->fi->statinfo.st_mode & S_IWOTH) && (!cfdata->others_write))) fperm = 1; - snprintf(buf, sizeof(buf), "%s/%s", - e_fm2_real_path_get(cfdata->fi->fm), cfdata->fi->file); if (fperm) { - /* FIXME: modify st_mode */ - chmod(buf, cfdata->fi->statinfo.st_mode); + mode_t pmode; + + pmode = cfdata->fi->statinfo.st_mode; + if (cfdata->owner_read) cfdata->fi->statinfo.st_mode |= S_IRUSR; + else cfdata->fi->statinfo.st_mode &= ~S_IRUSR; + if (cfdata->owner_write) cfdata->fi->statinfo.st_mode |= S_IWUSR; + else cfdata->fi->statinfo.st_mode &= ~S_IWUSR; + if (cfdata->others_read) cfdata->fi->statinfo.st_mode |= S_IROTH; + else cfdata->fi->statinfo.st_mode &= ~S_IROTH; + if (cfdata->others_write) cfdata->fi->statinfo.st_mode |= S_IWOTH; + else cfdata->fi->statinfo.st_mode &= ~S_IWOTH; + if (chmod(buf, cfdata->fi->statinfo.st_mode) == -1) + { + /* FIXME: error dialog */ + cfdata->fi->statinfo.st_mode = pmode; + } } + if ((cfdata->picon_type != cfdata->icon_type) || + (cfdata->picon_mime != cfdata->icon_mime) || + (cfdata->picon_changed)) + { + if (cfdata->icon_mime) /* modify mimetype */ + { + if (!cfdata->picon_mime) /* remove previous custom icon info */ + e_fm2_custom_file_del(buf); + /* FIXME: modify mime info */ + } + else /* custom for this file */ + { + E_Fm2_Custom_File *cf, cf0; + + cf = e_fm2_custom_file_get(buf); + if (!cf) + { + memset(cf, 0, sizeof(E_Fm2_Custom_File)); + cf = &cf0; + } + cf->icon.type = cfdata->icon_type; + if (cf->icon.icon) + evas_stringshare_del(cf->icon.icon); + cf->icon.icon = NULL; + if (cfdata->icon) + cf->icon.icon = evas_stringshare_add(cfdata->icon); + cf->icon.valid = 1; + e_fm2_custom_file_set(buf, &cf); + } + e_fm2_all_icons_update(); + } + return 1; /* Apply was OK */ } @@ -204,7 +257,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_entry_readonly_set(ob, 1); e_widget_table_object_append(ot, ob, 1, 0, 1, 1, 1, 0, 1, 0); - ob = e_widget_label_add(evas, _("Size:")); + ob = e_widget_label_add(evas, _("Size:")); e_widget_table_object_append(ot, ob, 0, 1, 1, 1, 1, 0, 1, 0); ob = e_widget_entry_add(evas, &(cfdata->size)); e_widget_min_size_set(ob, 140, -1); @@ -289,6 +342,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf } else cfdata->icon_type = 0; + cfdata->picon_type = cfdata->icon_type; rg = e_widget_radio_group_new(&cfdata->icon_type); ob = e_widget_radio_add(evas, _("Default"), 0, rg); @@ -304,6 +358,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf cfdata->icon_mime = 1; if ((cfdata->fi->icon) || ((itype) && (!strcmp(itype, "DESKTOP")))) cfdata->icon_mime = 0; + cfdata->picon_mime = cfdata->icon_mime; ob = e_widget_check_add(evas, _("Use this icon for all files of this type"), &(cfdata->icon_mime)); e_widget_frametable_object_append(ot, ob, 0, 3, 2, 1, 1, 1, 1, 1);