parent
12e9497d94
commit
38679d522c
|
@ -9,10 +9,40 @@
|
|||
# define D(x) ((void) 0)
|
||||
#endif
|
||||
|
||||
typedef struct _E_Fm_Assoc_App E_Fm_Assoc_App;
|
||||
struct _E_Fm_Assoc_App
|
||||
{
|
||||
char *mime;
|
||||
char *app;
|
||||
};
|
||||
|
||||
/* local subsystem functions */
|
||||
static void _e_fm_file_free(E_Fm_File *file);
|
||||
|
||||
/* TODO Make init and shutdown func that populates the assoc */
|
||||
static E_Config_DD *assoc_app_edd;
|
||||
static Evas_List *assoc_apps;
|
||||
|
||||
#if 0
|
||||
{
|
||||
E_Fm_Assoc_App *assoc;
|
||||
|
||||
assoc = E_NEW(E_Fm_Assoc_App, 1);
|
||||
assoc->mime = (char*)E_NEW(char *, 5);
|
||||
snprintf(assoc->mime, 5, "%s", ".jpg");
|
||||
assoc->app = (char*)E_NEW(char *, 7);
|
||||
snprintf(assoc->app, 7, "gqview");
|
||||
sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
|
||||
|
||||
assoc = E_NEW(E_Fm_Assoc_App, 1);
|
||||
assoc->mime = (char*)E_NEW(char *, 5);
|
||||
snprintf(assoc->mime, 5, "%s", ".png");
|
||||
assoc->app = (char*)E_NEW(char *, 7);
|
||||
snprintf(assoc->app, 7, "gqview");
|
||||
sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* externally accessible functions */
|
||||
E_Fm_File *
|
||||
e_fm_file_new(const char *filename)
|
||||
|
@ -143,12 +173,12 @@ e_fm_file_can_preview(E_Fm_File *file)
|
|||
|
||||
D(("e_fm_file_can_preview: (%s) (%p)\n", file->name, file));
|
||||
for (i = 0; i < sizeof(file->preview_funcs); i++)
|
||||
{
|
||||
E_Fm_File_Preview_Function func;
|
||||
func = file->preview_funcs[i];
|
||||
if(func(file))
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
E_Fm_File_Preview_Function func;
|
||||
func = file->preview_funcs[i];
|
||||
if (func(file))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -167,8 +197,8 @@ e_fm_file_is_image(E_Fm_File *file)
|
|||
if (!ext) return 0;
|
||||
|
||||
D(("e_fm_file_is_image: (%p)\n", file));
|
||||
return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png"))
|
||||
|| (!strcasecmp(ext, ".jpeg"));
|
||||
return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png")) ||
|
||||
(!strcasecmp(ext, ".jpeg"));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -183,20 +213,22 @@ e_fm_file_is_etheme(E_Fm_File *file)
|
|||
ext = strrchr(file->name, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
if(strcasecmp(ext, ".edj"))
|
||||
if (strcasecmp(ext, ".edj"))
|
||||
return 0;
|
||||
|
||||
val = 0;
|
||||
groups = edje_file_collection_list(file->path);
|
||||
if(!groups)
|
||||
if (!groups)
|
||||
return 0;
|
||||
|
||||
for (l = groups; l; l = l->next)
|
||||
if(!strcmp(l->data, "widgets/border/default/border"))
|
||||
{
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (!strcmp(l->data, "widgets/border/default/border"))
|
||||
{
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
edje_file_collection_list_free(groups);
|
||||
return val;
|
||||
}
|
||||
|
@ -213,20 +245,22 @@ e_fm_file_is_ebg(E_Fm_File *file)
|
|||
ext = strrchr(file->name, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
if(strcasecmp(ext, ".edj"))
|
||||
if (strcasecmp(ext, ".edj"))
|
||||
return 0;
|
||||
|
||||
val = 0;
|
||||
groups = edje_file_collection_list(file->path);
|
||||
if(!groups)
|
||||
if (!groups)
|
||||
return 0;
|
||||
|
||||
for (l = groups; l; l = l->next)
|
||||
if(!strcmp(l->data, "desktop/background"))
|
||||
{
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (!strcmp(l->data, "desktop/background"))
|
||||
{
|
||||
val = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
edje_file_collection_list_free(groups);
|
||||
return val;
|
||||
}
|
||||
|
@ -242,15 +276,15 @@ e_fm_file_is_eap(E_Fm_File *file)
|
|||
ext = strrchr(file->name, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
if(strcasecmp(ext, ".eap"))
|
||||
if (strcasecmp(ext, ".eap"))
|
||||
return 0;
|
||||
|
||||
app = e_app_new(file->path, 0);
|
||||
if(!app)
|
||||
{
|
||||
e_object_unref(E_OBJECT(app));
|
||||
return 0;
|
||||
}
|
||||
if (!app)
|
||||
{
|
||||
e_object_unref(E_OBJECT(app));
|
||||
return 0;
|
||||
}
|
||||
e_object_unref(E_OBJECT(app));
|
||||
return 1;
|
||||
}
|
||||
|
@ -259,23 +293,22 @@ int
|
|||
e_fm_file_can_exec(E_Fm_File *file)
|
||||
{
|
||||
char *ext;
|
||||
char *fullname;
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if(ext)
|
||||
{
|
||||
if(!strcasecmp(ext, ".eap"))
|
||||
{
|
||||
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (ext)
|
||||
{
|
||||
if (!strcasecmp(ext, ".eap"))
|
||||
{
|
||||
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(ecore_file_can_exec(file->path))
|
||||
{
|
||||
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
if (ecore_file_can_exec(file->path))
|
||||
{
|
||||
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
D(("e_fm_file_can_exec: false (%p) (%s)\n", file, file->name));
|
||||
return 0;
|
||||
|
@ -287,26 +320,25 @@ e_fm_file_exec(E_Fm_File *file)
|
|||
Ecore_Exe *exe;
|
||||
char *ext;
|
||||
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if(ext)
|
||||
{
|
||||
if(!strcasecmp(ext, ".eap"))
|
||||
{
|
||||
E_App *e_app;
|
||||
Ecore_Exe *exe;
|
||||
if (ext)
|
||||
{
|
||||
if (!strcasecmp(ext, ".eap"))
|
||||
{
|
||||
E_App *e_app;
|
||||
Ecore_Exe *exe;
|
||||
|
||||
e_app = e_app_new(file->path, NULL);
|
||||
e_app = e_app_new(file->path, 0);
|
||||
|
||||
if(!e_app) return;
|
||||
if (!e_app) return 0;
|
||||
|
||||
exe = ecore_exe_run(e_app->exe, NULL);
|
||||
if (exe) ecore_exe_free(exe);
|
||||
e_object_unref(E_OBJECT(e_app));
|
||||
D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
exe = ecore_exe_run(e_app->exe, NULL);
|
||||
if (exe) ecore_exe_free(exe);
|
||||
e_object_unref(E_OBJECT(e_app));
|
||||
D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
exe = ecore_exe_run(file->path, NULL);
|
||||
if (!exe)
|
||||
|
@ -327,6 +359,55 @@ e_fm_file_exec(E_Fm_File *file)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
e_fm_file_assoc_set(E_Fm_File *file, const char *assoc)
|
||||
{
|
||||
/* TODO */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
e_fm_file_assoc_exec(E_Fm_File *file)
|
||||
{
|
||||
char app[PATH_MAX * 2];
|
||||
Evas_List *l;
|
||||
E_Fm_Assoc_App *assoc;
|
||||
Ecore_Exe *exe;
|
||||
|
||||
for (l = assoc_apps; l; l = l->next)
|
||||
{
|
||||
char *ext;
|
||||
|
||||
assoc = l->data;
|
||||
ext = strrchr(file->path, '.');
|
||||
if ((ext) && (!strcasecmp(ext, assoc->mime)))
|
||||
break;
|
||||
assoc = NULL;
|
||||
}
|
||||
|
||||
if (!assoc) return 0;
|
||||
|
||||
snprintf(app, PATH_MAX * 2, "%s %s", assoc->app, file->path);
|
||||
exe = ecore_exe_run(app, NULL);
|
||||
|
||||
if (!exe)
|
||||
{
|
||||
e_error_dialog_show(_("Run Error"),
|
||||
_("Enlightenment was unable fork a child process:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"),
|
||||
app);
|
||||
D(("e_fm_assoc_exec: fail (%s)\n", app));
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* ecore_exe_tag_set(exe, "E/app");
|
||||
*/
|
||||
D(("e_fm_assoc_exec: ok (%s)\n", app));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_fm_file_free(E_Fm_File *file)
|
||||
|
|
|
@ -62,6 +62,7 @@ EAPI int e_fm_file_is_image (E_Fm_File *file);
|
|||
EAPI int e_fm_file_is_etheme (E_Fm_File *file);
|
||||
EAPI int e_fm_file_is_ebg (E_Fm_File *file);
|
||||
EAPI int e_fm_file_is_eap (E_Fm_File *file);
|
||||
EAPI int e_fm_file_can_exec (E_Fm_File *file);
|
||||
EAPI int e_fm_file_exec (E_Fm_File *file);
|
||||
EAPI int e_fm_file_assoc_set (E_Fm_File *file, const char *assoc);
|
||||
EAPI int e_fm_file_assoc_exec (E_Fm_File *file);
|
||||
|
|
|
@ -57,9 +57,6 @@ static Evas_List *event_handlers = NULL;
|
|||
int
|
||||
e_fm_icon_init(void)
|
||||
{
|
||||
char *homedir;
|
||||
char path[PATH_MAX];
|
||||
|
||||
event_handlers = evas_list_append(event_handlers,
|
||||
ecore_event_handler_add(ECORE_EVENT_EXE_EXIT,
|
||||
_e_fm_icon_thumb_cb_exe_exit,
|
||||
|
@ -442,12 +439,12 @@ _e_fm_icon_icon_mime_get(E_Smart_Data *sd)
|
|||
|
||||
ext = strdup(ext);
|
||||
ext2 = ext;
|
||||
for(;*ext2;ext2++)
|
||||
*ext2 = (unsigned char)tolower((unsigned char)*ext2);
|
||||
for (; *ext2; ext2++)
|
||||
*ext2 = tolower(*ext2);
|
||||
|
||||
snprintf(part, PATH_MAX, "fileman/icons/%s", (ext + 1));
|
||||
|
||||
if(!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part))
|
||||
if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part))
|
||||
e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "fileman/icons/file");
|
||||
|
||||
free(ext);
|
||||
|
@ -494,12 +491,11 @@ _e_fm_icon_thumb_cb_exe_exit(void *data, int type, void *event)
|
|||
sd = thumb_files->data;
|
||||
thumb_files = evas_list_remove_list(thumb_files, thumb_files);
|
||||
|
||||
ext = strrchr(sd->file->name, ".");
|
||||
if(ext)
|
||||
if(strcasecmp(ext, ".eap"))
|
||||
ext = NULL;
|
||||
ext = strrchr(sd->file->name, '.');
|
||||
if ((ext) && (strcasecmp(ext, ".eap")))
|
||||
ext = NULL;
|
||||
|
||||
if (ecore_file_exists(sd->thumb_path) || ext)
|
||||
if ((ext) || (ecore_file_exists(sd->thumb_path)))
|
||||
{
|
||||
if (sd->image_object) evas_object_del(sd->image_object);
|
||||
sd->image_object = e_thumb_evas_object_get(sd->file->path,
|
||||
|
|
|
@ -70,7 +70,6 @@ struct _E_Fm_Config
|
|||
{
|
||||
int width;
|
||||
int height;
|
||||
Evas_List *apps;
|
||||
};
|
||||
|
||||
struct _E_Fm_Icon
|
||||
|
@ -172,7 +171,6 @@ struct _E_Fm_Smart_Data
|
|||
|
||||
struct {
|
||||
E_Config_DD *main_edd;
|
||||
E_Config_DD *assoc_app_edd;
|
||||
E_Fm_Config *main;
|
||||
} conf;
|
||||
};
|
||||
|
@ -244,10 +242,6 @@ static Ecore_Event_Handler *e_fm_mouse_up_handler = NULL;
|
|||
static double e_fm_grab_time = 0;
|
||||
static Evas_Smart *e_fm_smart = NULL;
|
||||
|
||||
|
||||
/* dummy for now */
|
||||
static int dummy_val;
|
||||
|
||||
/* externally accessible functions */
|
||||
int
|
||||
e_fm_init(void)
|
||||
|
@ -401,7 +395,7 @@ e_fm_freeze(Evas_Object *object)
|
|||
E_Fm_Smart_Data *sd;
|
||||
|
||||
if ((!object) || !(sd = evas_object_smart_data_get(object)))
|
||||
return;
|
||||
return -1;
|
||||
|
||||
sd->frozen++;
|
||||
evas_event_freeze(sd->evas);
|
||||
|
@ -415,9 +409,9 @@ e_fm_thaw(Evas_Object *object)
|
|||
E_Fm_Smart_Data *sd;
|
||||
|
||||
if ((!object) || !(sd = evas_object_smart_data_get(object)))
|
||||
return;
|
||||
return -1;
|
||||
|
||||
if(!sd->frozen) return 0;
|
||||
if (!sd->frozen) return 0;
|
||||
|
||||
sd->frozen--;
|
||||
evas_event_thaw(sd->evas);
|
||||
|
@ -506,53 +500,22 @@ _e_fm_smart_add(Evas_Object *object)
|
|||
sd->position = 0.0;
|
||||
|
||||
sd->conf.main_edd = E_CONFIG_DD_NEW("E_Fm_Config", E_Fm_Config);
|
||||
sd->conf.assoc_app_edd = E_CONFIG_DD_NEW("E_Fm_Assoc_App",E_Fm_Assoc_App);
|
||||
|
||||
#undef T
|
||||
#undef DD
|
||||
#define T E_Fm_Assoc_App
|
||||
#define DD sd->conf.assoc_app_edd
|
||||
E_CONFIG_VAL(DD, T, mime, STR);
|
||||
E_CONFIG_VAL(DD, T, app, STR);
|
||||
#undef T
|
||||
#undef DD
|
||||
#define T E_Fm_Config
|
||||
#define DD sd->conf.main_edd
|
||||
E_CONFIG_VAL(DD, T, width, INT);
|
||||
E_CONFIG_VAL(DD, T, height, INT);
|
||||
E_CONFIG_LIST(DD, T, apps, sd->conf.assoc_app_edd);
|
||||
|
||||
sd->conf.main = e_config_domain_load("efm", sd->conf.main_edd);
|
||||
if(!sd->conf.main)
|
||||
{
|
||||
/* no saved config */
|
||||
sd->conf.main = E_NEW(E_Fm_Config, 1);
|
||||
sd->conf.main->width = 640;
|
||||
sd->conf.main->height = 480;
|
||||
sd->conf.main->apps = NULL;
|
||||
|
||||
|
||||
/* some test values not meant for everyone */
|
||||
|
||||
{
|
||||
E_Fm_Assoc_App *assoc;
|
||||
|
||||
assoc = E_NEW(E_Fm_Assoc_App, 1);
|
||||
assoc->mime = (char*)E_NEW(char *, 5);
|
||||
snprintf(assoc->mime, 5, "%s", ".jpg");
|
||||
assoc->app = (char*)E_NEW(char *, 7);
|
||||
snprintf(assoc->app, 7, "gqview");
|
||||
sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
|
||||
|
||||
assoc = E_NEW(E_Fm_Assoc_App, 1);
|
||||
assoc->mime = (char*)E_NEW(char *, 5);
|
||||
snprintf(assoc->mime, 5, "%s", ".png");
|
||||
assoc->app = (char*)E_NEW(char *, 7);
|
||||
snprintf(assoc->app, 7, "gqview");
|
||||
sd->conf.main->apps = evas_list_append(sd->conf.main->apps, assoc);
|
||||
}
|
||||
|
||||
}
|
||||
if (!sd->conf.main)
|
||||
{
|
||||
/* no saved config */
|
||||
sd->conf.main = E_NEW(E_Fm_Config, 1);
|
||||
sd->conf.main->width = 640;
|
||||
sd->conf.main->height = 480;
|
||||
}
|
||||
|
||||
evas_object_smart_data_set(object, sd);
|
||||
|
||||
|
@ -564,7 +527,6 @@ static void
|
|||
_e_fm_smart_del(Evas_Object *object)
|
||||
{
|
||||
E_Fm_Smart_Data *sd;
|
||||
Evas_List *l;
|
||||
|
||||
if ((!object) || !(sd = evas_object_smart_data_get(object)))
|
||||
return;
|
||||
|
@ -804,7 +766,7 @@ _e_fm_file_menu_open(void *data, E_Menu *m, E_Menu_Item *mi)
|
|||
_e_fm_dir_set(icon->sd, icon->file->path);
|
||||
break;
|
||||
case E_FM_FILE_TYPE_FILE:
|
||||
if ((!e_fm_assoc_exec(icon->sd, icon->file->path) && (e_fm_file_can_exec(icon->file))))
|
||||
if ((!e_fm_file_assoc_exec(icon->file) && (e_fm_file_can_exec(icon->file))))
|
||||
e_fm_file_exec(icon->file);
|
||||
break;
|
||||
default:
|
||||
|
@ -967,46 +929,49 @@ _e_fm_icon_prop_create_data(E_Config_Dialog *cfd)
|
|||
E_Fm_Icon_CFData *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Fm_Icon_CFData, 1);
|
||||
if (!cfdata) return NULL;
|
||||
cfdata->icon = cfd->data;
|
||||
_e_fm_icon_prop_fill_data(cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_prop_free_data(E_Config_Dialog *cfd, E_Fm_Icon_CFData *cfdata)
|
||||
_e_fm_icon_prop_free_data(E_Config_Dialog *cfd, void *data)
|
||||
{
|
||||
free(cfdata);
|
||||
free(data);
|
||||
}
|
||||
|
||||
static int
|
||||
_e_fm_icon_prop_basic_apply_data(E_Config_Dialog *cfd, E_Fm_Icon_CFData *cfdata)
|
||||
_e_fm_icon_prop_basic_apply_data(E_Config_Dialog *cfd, void *data)
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
E_Fm_Icon_CFData *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
icon = cfdata->icon;
|
||||
|
||||
switch(cfdata->readwrite)
|
||||
{
|
||||
case 0:
|
||||
D(("_e_fm_icon_prop_basic_apply_data: read (%s)\n", icon->file->name));
|
||||
icon->file->mode |= (S_IRGRP | S_IROTH);
|
||||
icon->file->mode &= (~S_IWGRP & ~S_IWOTH);
|
||||
break;
|
||||
case 1:
|
||||
D(("_e_fm_icon_prop_basic_apply_data: write (%s)\n", icon->file->name));
|
||||
icon->file->mode |= (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
break;
|
||||
case 2:
|
||||
D(("_e_fm_icon_prop_basic_apply_data: hide (%s)\n", icon->file->name));
|
||||
icon->file->mode &= (~S_IRGRP & ~S_IROTH & ~S_IWGRP & ~S_IWOTH);
|
||||
break;
|
||||
}
|
||||
switch (cfdata->readwrite)
|
||||
{
|
||||
case 0:
|
||||
D(("_e_fm_icon_prop_basic_apply_data: read (%s)\n", icon->file->name));
|
||||
icon->file->mode |= (S_IRGRP | S_IROTH);
|
||||
icon->file->mode &= (~S_IWGRP & ~S_IWOTH);
|
||||
break;
|
||||
case 1:
|
||||
D(("_e_fm_icon_prop_basic_apply_data: write (%s)\n", icon->file->name));
|
||||
icon->file->mode |= (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
break;
|
||||
case 2:
|
||||
D(("_e_fm_icon_prop_basic_apply_data: hide (%s)\n", icon->file->name));
|
||||
icon->file->mode &= (~S_IRGRP & ~S_IROTH & ~S_IWGRP & ~S_IWOTH);
|
||||
break;
|
||||
}
|
||||
|
||||
if(cfdata->protect)
|
||||
{
|
||||
D(("_e_fm_icon_prop_basic_apply_data: protect (%s)\n", icon->file->name));
|
||||
icon->file->mode &= (~S_IWUSR & ~S_IWGRP & ~S_IWOTH);
|
||||
}
|
||||
if (cfdata->protect)
|
||||
{
|
||||
D(("_e_fm_icon_prop_basic_apply_data: protect (%s)\n", icon->file->name));
|
||||
icon->file->mode &= (~S_IWUSR & ~S_IWGRP & ~S_IWOTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
D(("_e_fm_icon_prop_basic_apply_data: unprotect (%s)\n", icon->file->name));
|
||||
|
@ -1019,10 +984,12 @@ _e_fm_icon_prop_basic_apply_data(E_Config_Dialog *cfd, E_Fm_Icon_CFData *cfdata)
|
|||
}
|
||||
|
||||
static int
|
||||
_e_fm_icon_prop_advanced_apply_data(E_Config_Dialog *cfd, E_Fm_Icon_CFData *cfdata)
|
||||
_e_fm_icon_prop_advanced_apply_data(E_Config_Dialog *cfd, void *data)
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
E_Fm_Icon_CFData *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
icon = cfdata->icon;
|
||||
|
||||
if(cfdata->user.r)
|
||||
|
@ -1070,40 +1037,33 @@ _e_fm_icon_prop_advanced_apply_data(E_Config_Dialog *cfd, E_Fm_Icon_CFData *cfda
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_e_fm_icon_prop_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Fm_Icon_CFData *cfdata)
|
||||
_e_fm_icon_prop_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, void *data)
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
E_Win *win;
|
||||
Evas_Object *table;
|
||||
Evas_Object *name;
|
||||
Evas_Coord w, h;
|
||||
E_Fm_Icon_CFData *cfdata;
|
||||
struct group *grp;
|
||||
struct passwd *usr;
|
||||
struct tm *t;
|
||||
char *fullname;
|
||||
char *size, *username, *groupname, *lastaccess, *lastmod, *permissions;
|
||||
char text[512];
|
||||
E_Dialog *dia;
|
||||
Evas_Object *o, *ol, *hb;
|
||||
Evas_Coord mw, mh;
|
||||
Evas_Object *o, *ol;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
cfdata = data;
|
||||
icon = cfdata->icon;
|
||||
|
||||
_e_fm_icon_prop_fill_data(cfdata);
|
||||
|
||||
size = E_NEW(char, 64);
|
||||
snprintf(size, 64, "%d", icon->file->size / 1024);
|
||||
snprintf(size, 64, "%ld", icon->file->size / 1024);
|
||||
|
||||
username = E_NEW(char, 128); // max length of username?
|
||||
usr = getpwuid(icon->file->owner);
|
||||
snprintf(username, 128, "%s", usr->pw_name);
|
||||
//free(usr);
|
||||
|
||||
groupname = E_NEW(char, 128); // max length of group?
|
||||
grp = getgrgid(icon->file->group);
|
||||
snprintf(groupname, 128, "%s", grp->gr_name);
|
||||
//free(grp);
|
||||
|
||||
t = gmtime(&icon->file->atime);
|
||||
lastaccess = E_NEW(char, 128);
|
||||
|
@ -1175,16 +1135,17 @@ _e_fm_icon_prop_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Fm_Icon
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_e_fm_icon_prop_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Fm_Icon_CFData *cfdata)
|
||||
_e_fm_icon_prop_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, void *data)
|
||||
{
|
||||
Evas_Object *o, *ob, *of;
|
||||
E_Radio_Group *rg;
|
||||
E_Fm_Icon *icon;
|
||||
E_Fm_Icon_CFData *cfdata;
|
||||
struct group *grp;
|
||||
struct passwd *usr;
|
||||
struct tm *t;
|
||||
char *lastaccess, *lastmod;
|
||||
|
||||
cfdata = data;
|
||||
icon = cfdata->icon;
|
||||
|
||||
_e_fm_icon_prop_fill_data(cfdata);
|
||||
|
@ -1353,48 +1314,45 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
|
|||
|
||||
/* Get special prev dir */
|
||||
if (strcmp(sd->dir, "/"))
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
char path[PATH_MAX];
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
char path[PATH_MAX];
|
||||
|
||||
icon = E_NEW(E_Fm_Icon, 1);
|
||||
if (icon)
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s/..", sd->dir);
|
||||
icon->file = e_fm_file_new(path);
|
||||
icon->file->mode = 0040000;
|
||||
icon->file->type = E_FM_FILE_TYPE_DIRECTORY;
|
||||
icon->icon_object = e_fm_icon_add(sd->evas);
|
||||
icon->sd = sd;
|
||||
e_fm_icon_file_set(icon->icon_object, icon->file);
|
||||
sd->files = evas_list_prepend(sd->files, icon);
|
||||
}
|
||||
}
|
||||
icon = E_NEW(E_Fm_Icon, 1);
|
||||
if (icon)
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s/..", sd->dir);
|
||||
icon->file = e_fm_file_new(path);
|
||||
icon->file->mode = 0040000;
|
||||
icon->file->type = E_FM_FILE_TYPE_DIRECTORY;
|
||||
icon->icon_object = e_fm_icon_add(sd->evas);
|
||||
icon->sd = sd;
|
||||
e_fm_icon_file_set(icon->icon_object, icon->file);
|
||||
sd->files = evas_list_prepend(sd->files, icon);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add icons to layout */
|
||||
e_icon_layout_freeze(sd->layout);
|
||||
for (l = sd->files; l; l = l->next)
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
Evas_Coord icon_w, icon_h;
|
||||
|
||||
icon = l->data;
|
||||
icon = l->data;
|
||||
|
||||
{
|
||||
Evas_Coord icon_w, icon_h;
|
||||
evas_object_resize(icon->icon_object, sd->icon_info.w, sd->icon_info.h);
|
||||
evas_object_show(icon->icon_object);
|
||||
evas_object_geometry_get(icon->icon_object, NULL, NULL, &icon_w, &icon_h);
|
||||
D(("_e_fm_dir_set: Icon, w=%d h=%d\n", icon_w, icon_h));
|
||||
|
||||
evas_object_resize(icon->icon_object, sd->icon_info.w, sd->icon_info.h);
|
||||
evas_object_show(icon->icon_object);
|
||||
evas_object_geometry_get(icon->icon_object, NULL, NULL, &icon_w, &icon_h);
|
||||
D(("_e_fm_dir_set: Icon, w=%d h=%d\n", icon_w, icon_h));
|
||||
}
|
||||
e_icon_layout_pack(sd->layout, icon->icon_object);
|
||||
|
||||
e_icon_layout_pack(sd->layout, icon->icon_object);
|
||||
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fm_icon_mouse_down_cb, icon);
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_fm_icon_mouse_up_cb, icon);
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_IN, _e_fm_icon_mouse_in_cb, icon);
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_OUT, _e_fm_icon_mouse_out_cb, icon);
|
||||
}
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fm_icon_mouse_down_cb, icon);
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_fm_icon_mouse_up_cb, icon);
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_IN, _e_fm_icon_mouse_in_cb, icon);
|
||||
evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_OUT, _e_fm_icon_mouse_out_cb, icon);
|
||||
}
|
||||
e_icon_layout_thaw(sd->layout);
|
||||
|
||||
/* Draw layout */
|
||||
|
@ -1403,26 +1361,26 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
|
|||
/* raise dir change event */
|
||||
ev = E_NEW(E_Event_Fm_Directory_Change, 1);
|
||||
if (ev)
|
||||
{
|
||||
ev->object = sd->object;
|
||||
ev->w = sd->max.w;
|
||||
ev->h = sd->max.h;
|
||||
ecore_event_add(E_EVENT_FM_DIRECTORY_CHANGE, ev, NULL, NULL);
|
||||
}
|
||||
{
|
||||
ev->object = sd->object;
|
||||
ev->w = sd->max.w;
|
||||
ev->h = sd->max.h;
|
||||
ecore_event_add(E_EVENT_FM_DIRECTORY_CHANGE, ev, NULL, NULL);
|
||||
}
|
||||
|
||||
if(sd->frozen)
|
||||
if (sd->frozen)
|
||||
return;
|
||||
|
||||
/* raise reconfigure event */
|
||||
ev = E_NEW(E_Event_Fm_Reconfigure, 1);
|
||||
if (ev)
|
||||
{
|
||||
e_icon_layout_virtual_size_get(sd->layout, &sd->max.w, &sd->max.h);
|
||||
ev->object = sd->object;
|
||||
ev->w = sd->max.w;
|
||||
ev->h = sd->max.h;
|
||||
ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
|
||||
}
|
||||
{
|
||||
e_icon_layout_virtual_size_get(sd->layout, &sd->max.w, &sd->max.h);
|
||||
ev->object = sd->object;
|
||||
ev->w = sd->max.w;
|
||||
ev->h = sd->max.h;
|
||||
ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static Evas_List *
|
||||
|
@ -1912,9 +1870,9 @@ _e_fm_icon_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info
|
|||
{
|
||||
icon->sd->drag.start = 0;
|
||||
|
||||
if(!e_fm_assoc_exec(icon->sd, icon->file->path))
|
||||
if (e_fm_file_can_exec(icon->file))
|
||||
e_fm_file_exec(icon->file);
|
||||
if ((!e_fm_file_assoc_exec(icon->file)) &&
|
||||
(e_fm_file_can_exec(icon->file)))
|
||||
e_fm_file_exec(icon->file);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2104,7 +2062,6 @@ _e_fm_win_mouse_move_cb(void *data, int type, void *event)
|
|||
Evas_Coord x, y, w, h;
|
||||
int cx, cy;
|
||||
char data[PATH_MAX];
|
||||
const char *path = NULL, *part = NULL;
|
||||
const char *drop_types[] = { "text/uri-list" };
|
||||
|
||||
snprintf(data, sizeof(data), "file://%s", icon->file->path);
|
||||
|
@ -2120,26 +2077,6 @@ _e_fm_win_mouse_move_cb(void *data, int type, void *event)
|
|||
e_fm_icon_title_set(o, "");
|
||||
evas_object_resize(o, w, h);
|
||||
|
||||
/* This shouldnt be needed anymore
|
||||
edje_object_file_get(icon->icon_object, &path, &part);
|
||||
if ((path) && (part))
|
||||
{
|
||||
o = edje_object_add(drag->evas);
|
||||
edje_object_file_set(o, path, part);
|
||||
}
|
||||
else
|
||||
{
|
||||
int iw, ih;
|
||||
|
||||
o = evas_object_image_add(drag->evas);
|
||||
evas_object_image_size_get(icon->icon_object, &iw, &ih);
|
||||
evas_object_image_size_set(o, iw, ih);
|
||||
evas_object_image_data_copy_set(o, evas_object_image_data_get(icon->icon_object, 0));
|
||||
evas_object_image_data_update_add(o, 0, 0, iw, ih);
|
||||
evas_object_image_fill_set(o, 0, 0, iw, ih);
|
||||
evas_object_resize(o, iw, ih);
|
||||
}
|
||||
*/
|
||||
if (!o)
|
||||
{
|
||||
// FIXME: fallback icon for drag
|
||||
|
@ -2310,47 +2247,3 @@ _e_fm_files_sort_modtime_cb(void *d1, void *d2)
|
|||
|
||||
return (e1->file->mtime > e2->file->mtime);
|
||||
}
|
||||
|
||||
/* associations / mime type functions */
|
||||
int
|
||||
e_fm_assoc_exec( E_Fm_Smart_Data *sd, char *file)
|
||||
{
|
||||
char app[PATH_MAX * 2];
|
||||
Evas_List *l;
|
||||
E_Fm_Assoc_App *assoc;
|
||||
Ecore_Exe *exe;
|
||||
|
||||
for (l = sd->conf.main->apps; l; l = l->next)
|
||||
{
|
||||
char *ext;
|
||||
|
||||
assoc = l->data;
|
||||
ext = strrchr(file, '.');
|
||||
if(ext)
|
||||
if(!strcasecmp(ext, assoc->mime))
|
||||
break;
|
||||
assoc = NULL;
|
||||
}
|
||||
|
||||
if(!assoc) return 0;
|
||||
|
||||
snprintf(app, PATH_MAX * 2, "%s %s", assoc->app, file);
|
||||
exe = ecore_exe_run(app, NULL);
|
||||
|
||||
if (!exe)
|
||||
{
|
||||
e_error_dialog_show(_("Run Error"),
|
||||
_("Enlightenment was unable fork a child process:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"),
|
||||
app);
|
||||
D(("e_fm_assoc_exec: fail (%s)\n", app));
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* ecore_exe_tag_set(exe, "E/app");
|
||||
*/
|
||||
D(("e_fm_assoc_exec: ok (%s)\n", app));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
typedef struct _E_Event_Fm_Reconfigure E_Event_Fm_Reconfigure;
|
||||
typedef struct _E_Event_Fm_Directory_Change E_Event_Fm_Directory_Change;
|
||||
typedef struct _E_Fm_Assoc_App E_Fm_Assoc_App;
|
||||
|
||||
#else
|
||||
#ifndef E_FM_SMART_H
|
||||
|
@ -23,12 +22,6 @@ struct _E_Event_Fm_Directory_Change
|
|||
Evas_Coord w, h;
|
||||
};
|
||||
|
||||
struct _E_Fm_Assoc_App
|
||||
{
|
||||
char *mime;
|
||||
char *app;
|
||||
};
|
||||
|
||||
EAPI int e_fm_init(void);
|
||||
EAPI int e_fm_shutdown(void);
|
||||
EAPI Evas_Object *e_fm_add(Evas *evas);
|
||||
|
|
|
@ -22,13 +22,13 @@ e_thumb_init(void)
|
|||
|
||||
homedir = e_user_homedir_get();
|
||||
if (homedir)
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s/.e/e/fileman/thumbnails", homedir);
|
||||
if (!ecore_file_exists(path))
|
||||
ecore_file_mkpath(path);
|
||||
thumb_path = strdup(path);
|
||||
free(homedir);
|
||||
}
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s/.e/e/fileman/thumbnails", homedir);
|
||||
if (!ecore_file_exists(path))
|
||||
ecore_file_mkpath(path);
|
||||
thumb_path = strdup(path);
|
||||
free(homedir);
|
||||
}
|
||||
else return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -42,10 +42,10 @@ e_thumb_shutdown(void)
|
|||
}
|
||||
|
||||
/* return dir where thumbs are saved */
|
||||
char *
|
||||
const char *
|
||||
e_thumb_dir_get(void)
|
||||
{
|
||||
return strdup(thumb_path);
|
||||
return thumb_path;
|
||||
}
|
||||
|
||||
/* return hashed path of thumb */
|
||||
|
@ -56,7 +56,7 @@ e_thumb_file_get(char *file)
|
|||
char thumb[PATH_MAX];
|
||||
|
||||
id = _e_thumb_file_id(file);
|
||||
if(!id) { return NULL; }
|
||||
if (!id) return NULL;
|
||||
snprintf(thumb, sizeof(thumb), "%s/%s", thumb_path, id);
|
||||
free(id);
|
||||
return strdup(thumb);
|
||||
|
@ -70,17 +70,15 @@ e_thumb_exists(char *file)
|
|||
char *ext;
|
||||
|
||||
ext = strrchr(file, '.');
|
||||
if(ext)
|
||||
if(!strcasecmp(ext, ".eap"))
|
||||
return 1;
|
||||
if ((ext) && (!strcasecmp(ext, ".eap")))
|
||||
return 1;
|
||||
|
||||
thumb = e_thumb_file_get(file);
|
||||
if(ecore_file_exists(thumb))
|
||||
{
|
||||
free(thumb);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ecore_file_exists(thumb))
|
||||
{
|
||||
free(thumb);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -98,22 +96,22 @@ _e_thumb_image_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh,
|
|||
evas_object_image_size_get(*im, &iw, &ih);
|
||||
*alpha = evas_object_image_alpha_get(*im);
|
||||
if ((iw > 0) && (ih > 0))
|
||||
{
|
||||
*ww = w;
|
||||
*hh = (w * ih) / iw;
|
||||
if (*hh > h)
|
||||
{
|
||||
*hh = h;
|
||||
*ww = (h * iw) / ih;
|
||||
}
|
||||
ecore_evas_resize(*buf, *ww, *hh);
|
||||
evas_object_image_fill_set(*im, 0, 0, *ww, *hh);
|
||||
evas_object_resize(*im, *ww, *hh);
|
||||
evas_object_move(*im, 0, 0);
|
||||
evas_object_show(*im);
|
||||
{
|
||||
*ww = w;
|
||||
*hh = (w * ih) / iw;
|
||||
if (*hh > h)
|
||||
{
|
||||
*hh = h;
|
||||
*ww = (h * iw) / ih;
|
||||
}
|
||||
ecore_evas_resize(*buf, *ww, *hh);
|
||||
evas_object_image_fill_set(*im, 0, 0, *ww, *hh);
|
||||
evas_object_resize(*im, *ww, *hh);
|
||||
evas_object_move(*im, 0, 0);
|
||||
evas_object_show(*im);
|
||||
|
||||
return ecore_evas_buffer_pixels_get(*buf);
|
||||
}
|
||||
return ecore_evas_buffer_pixels_get(*buf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -137,7 +135,6 @@ _e_thumb_ebg_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, in
|
|||
|
||||
wallpaper = edje_object_add(evasbuf);
|
||||
|
||||
|
||||
edje_object_file_set(wallpaper, file, "desktop/background");
|
||||
|
||||
/* wallpaper */
|
||||
|
@ -242,29 +239,23 @@ e_thumb_create(char *file, Evas_Coord w, Evas_Coord h)
|
|||
int alpha;
|
||||
|
||||
ext = strrchr(file, '.');
|
||||
if(ext)
|
||||
{
|
||||
if(!strcasecmp(ext, ".eap"))
|
||||
return 1;
|
||||
}
|
||||
if ((ext) && (!strcasecmp(ext, ".eap")))
|
||||
return 1;
|
||||
|
||||
thumbpath = e_thumb_file_get(file);
|
||||
if (!thumbpath)
|
||||
{
|
||||
free(thumbpath);
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
|
||||
if(ext)
|
||||
{
|
||||
if(!strcasecmp(ext, ".edj"))
|
||||
{
|
||||
/* for now, this function does both the bg and theme previews */
|
||||
data = _e_thumb_etheme_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
|
||||
}
|
||||
else
|
||||
data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
|
||||
}
|
||||
if (ext)
|
||||
{
|
||||
if(!strcasecmp(ext, ".edj"))
|
||||
{
|
||||
/* for now, this function does both the bg and theme previews */
|
||||
data = _e_thumb_etheme_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
|
||||
}
|
||||
else
|
||||
data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
|
||||
}
|
||||
else
|
||||
data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
|
||||
|
||||
|
@ -314,31 +305,31 @@ e_thumb_evas_object_get(char *file, Evas *evas, Evas_Coord width, Evas_Coord hei
|
|||
|
||||
/* eap thumbnailer */
|
||||
ext = strrchr(file, '.');
|
||||
if(ext)
|
||||
{
|
||||
if(!strcasecmp(ext, ".eap"))
|
||||
{
|
||||
E_App *app;
|
||||
if (ext)
|
||||
{
|
||||
if (!strcasecmp(ext, ".eap"))
|
||||
{
|
||||
E_App *app;
|
||||
|
||||
D(("e_thumb_evas_object_get: eap found\n"));
|
||||
app = e_app_new(file, 0);
|
||||
D(("e_thumb_evas_object_get: eap loaded\n"));
|
||||
if(!app)
|
||||
{
|
||||
D(("e_thumb_evas_object_get: invalid eap\n"));
|
||||
DEF_THUMB_RETURN;
|
||||
}
|
||||
else
|
||||
{
|
||||
D(("e_thumb_evas_object_get: creating eap thumb\n"));
|
||||
im = edje_object_add(evas);
|
||||
edje_object_file_set(im, file, "icon");
|
||||
e_object_unref(E_OBJECT(app));
|
||||
D(("e_thumb_evas_object_get: returning eap thumb\n"));
|
||||
return im;
|
||||
}
|
||||
}
|
||||
}
|
||||
D(("e_thumb_evas_object_get: eap found\n"));
|
||||
app = e_app_new(file, 0);
|
||||
D(("e_thumb_evas_object_get: eap loaded\n"));
|
||||
if (!app)
|
||||
{
|
||||
D(("e_thumb_evas_object_get: invalid eap\n"));
|
||||
DEF_THUMB_RETURN;
|
||||
}
|
||||
else
|
||||
{
|
||||
D(("e_thumb_evas_object_get: creating eap thumb\n"));
|
||||
im = edje_object_add(evas);
|
||||
edje_object_file_set(im, file, "icon");
|
||||
e_object_unref(E_OBJECT(app));
|
||||
D(("e_thumb_evas_object_get: returning eap thumb\n"));
|
||||
return im;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* saved thumb */
|
||||
/* TODO: add ability to fetch thumbs from freedesktop dirs */
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
EAPI int e_thumb_init(void);
|
||||
EAPI int e_thumb_shutdown(void);
|
||||
EAPI char *e_thumb_dir_get(void);
|
||||
EAPI const char *e_thumb_dir_get(void);
|
||||
EAPI char *e_thumb_file_get(char *file);
|
||||
EAPI int e_thumb_exists(char *file);
|
||||
EAPI int e_thumb_create(char *file, Evas_Coord w, Evas_Coord h);
|
||||
|
|
Loading…
Reference in New Issue