- patch from mista (Efm)
- allow eap image w/h to be changable. SVN revision: 19808
This commit is contained in:
parent
bbea62a127
commit
6437ea875a
|
@ -72,6 +72,9 @@ static char *_e_apps_path_all = NULL;
|
|||
static char *_e_apps_path_trash = NULL;
|
||||
static Evas_List *_e_apps_start_pending = NULL;
|
||||
|
||||
#define EAP_MIN_WIDTH 8
|
||||
#define EAP_MIN_HEIGHT 8
|
||||
|
||||
#define EAP_EDC_TMPL \
|
||||
"images {\n" \
|
||||
" image: \"%s\" COMP;\n" \
|
||||
|
@ -234,6 +237,8 @@ e_app_new(const char *path, int scan_subdirs)
|
|||
|
||||
/* no image for now */
|
||||
a->image = NULL;
|
||||
a->width = 0;
|
||||
a->height = 0;
|
||||
/* record the path */
|
||||
a->path = evas_stringshare_add(path);
|
||||
|
||||
|
@ -289,6 +294,13 @@ e_app_empty_new(const char *path)
|
|||
return a;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_app_image_size_set(E_App *a, int w, int h)
|
||||
{
|
||||
a->width = w;
|
||||
a->height = h;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_app_is_parent(E_App *parent, E_App *app)
|
||||
{
|
||||
|
@ -1022,10 +1034,6 @@ e_app_fields_fill(E_App *a, const char *path)
|
|||
eet_close(ef);
|
||||
}
|
||||
|
||||
/*
|
||||
* We also need to fix startup-notify and wait-exit as they currently
|
||||
* dont save too.
|
||||
*/
|
||||
EAPI void
|
||||
e_app_fields_save(E_App *a)
|
||||
{
|
||||
|
@ -1119,16 +1127,20 @@ e_app_fields_save(E_App *a)
|
|||
iw = 0; ih = 0;
|
||||
evas_object_image_size_get(im, &iw, &ih);
|
||||
alpha = evas_object_image_alpha_get(im);
|
||||
if(a->width <= EAP_MIN_WIDTH)
|
||||
a->width = EAP_MIN_WIDTH;
|
||||
if(a->height <= EAP_MIN_HEIGHT)
|
||||
a->height = EAP_MIN_HEIGHT;
|
||||
if ((iw > 0) && (ih > 0))
|
||||
{
|
||||
/* we need to change the sizes */
|
||||
ecore_evas_resize(buf, 48, 48);
|
||||
evas_object_image_fill_set(im, 0, 0, 48, 48);
|
||||
evas_object_resize(im, 48, 48);
|
||||
ecore_evas_resize(buf, a->width, a->height);
|
||||
evas_object_image_fill_set(im, 0, 0, a->width, a->height);
|
||||
evas_object_resize(im, a->height, a->width);
|
||||
evas_object_move(im, 0, 0);
|
||||
evas_object_show(im);
|
||||
data = ecore_evas_buffer_pixels_get(buf);
|
||||
eet_data_image_write(ef, "images/0", (void *)data, 48, 48, alpha, 1, 0, 0);
|
||||
eet_data_image_write(ef, "images/0", (void *)data, a->width, a->height, alpha, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1320,7 +1332,13 @@ _e_app_new_save(E_App *a)
|
|||
else ipart[0] = '\0';
|
||||
|
||||
if (a->image)
|
||||
fprintf(out, EAP_EDC_TMPL, a->image, "48", "48", a->image);
|
||||
{
|
||||
if(a->width <= 0)
|
||||
a->width = EAP_MIN_WIDTH;
|
||||
if(a->height <= 0)
|
||||
a->height = EAP_MIN_HEIGHT;
|
||||
fprintf(out, EAP_EDC_TMPL, a->image, a->width, a->height, a->image);
|
||||
}
|
||||
else
|
||||
fprintf(out, EAP_EDC_TMPL_EMPTY);
|
||||
fclose(out);
|
||||
|
|
|
@ -63,6 +63,8 @@ struct _E_App
|
|||
unsigned char deleted : 1; /* this app's file is deleted from disk */
|
||||
|
||||
char *image; /* used when we're saving a image into the eap */
|
||||
int width; /* used for saving eap's image width in edje */
|
||||
int height; /* used for saving eap's image height in edje */
|
||||
};
|
||||
|
||||
struct _E_App_Instance
|
||||
|
@ -79,6 +81,7 @@ EAPI int e_app_shutdown (void);
|
|||
|
||||
EAPI E_App *e_app_new (const char *path, int scan_subdirs);
|
||||
EAPI E_App *e_app_empty_new (const char *path);
|
||||
EAPI void e_app_image_size_set (E_App *a, int w, int h);
|
||||
EAPI int e_app_is_parent (E_App *parent, E_App *app);
|
||||
EAPI int e_app_equals (E_App *app1, E_App *app2);
|
||||
EAPI void e_app_subdir_scan (E_App *a, int scan_subdirs);
|
||||
|
|
|
@ -161,6 +161,10 @@ _e_eap_edit_basic_apply_data(E_Config_Dialog *cfd, void *data)
|
|||
eap->startup_notify = cfdata->startup_notify;
|
||||
eap->wait_exit = cfdata->wait_exit;
|
||||
|
||||
/* FIXME: hardcoded until the eap editor provides fields to change it */
|
||||
eap->width = 128;
|
||||
eap->height = 128;
|
||||
|
||||
e_app_fields_save(eap);
|
||||
|
||||
return 1;
|
||||
|
@ -214,6 +218,10 @@ _e_eap_edit_advanced_apply_data(E_Config_Dialog *cfd, void *data)
|
|||
if (cfdata->iclass) eap->icon_class = evas_stringshare_add(cfdata->iclass);
|
||||
if (cfdata->path) eap->path = evas_stringshare_add(cfdata->path);
|
||||
|
||||
/* FIXME: hardcoded until the eap editor provides fields to change it */
|
||||
eap->width = 128;
|
||||
eap->height = 128;
|
||||
|
||||
e_app_fields_save(eap);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,10 @@ e_fm_file_new(const char *filename)
|
|||
ext = strrchr(file->name, '.');
|
||||
if (ext)
|
||||
{
|
||||
char *ext2;
|
||||
ext = strdup(ext);
|
||||
ext2 = ext;
|
||||
for (; *ext2; ext2++) *ext2 = tolower(*ext2);
|
||||
file->mime = ext;
|
||||
}
|
||||
else
|
||||
|
@ -159,6 +163,22 @@ e_fm_file_copy(E_Fm_File *file, const char *name)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
e_fm_file_is_regular(E_Fm_File *file) /* TODO: find better name */
|
||||
{
|
||||
return ((file->type == E_FM_FILE_TYPE_FILE)
|
||||
|| (file->type == E_FM_FILE_TYPE_SYMLINK));
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_has_mime(E_Fm_File *file, char* mime)
|
||||
{
|
||||
if (!file->mime) return 0;
|
||||
|
||||
D(("e_fm_file_has_mime: (%p) : %s\n", file,file->mime));
|
||||
return (!strcasecmp(file->mime, mime));
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_can_preview(E_Fm_File *file)
|
||||
{
|
||||
|
@ -183,31 +203,22 @@ e_fm_file_is_image(E_Fm_File *file)
|
|||
* If it isn't supported by evas, we can't show it in the
|
||||
* canvas.
|
||||
*/
|
||||
char *ext;
|
||||
|
||||
if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
|
||||
//D(("e_fm_file_is_image: (%p)\n", file));
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
D(("e_fm_file_is_image: (%p)\n", file));
|
||||
return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png")) ||
|
||||
(!strcasecmp(ext, ".jpeg"));
|
||||
return e_fm_file_is_regular(file)
|
||||
&&(e_fm_file_has_mime(file,".jpg")
|
||||
|| e_fm_file_has_mime(file,".jpeg")
|
||||
|| e_fm_file_has_mime(file,".png"));
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_fm_file_is_etheme(E_Fm_File *file)
|
||||
{
|
||||
int val;
|
||||
char *ext;
|
||||
Evas_List *groups, *l;
|
||||
|
||||
if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
if (strcasecmp(ext, ".edj"))
|
||||
if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
|
||||
return 0;
|
||||
|
||||
val = 0;
|
||||
|
@ -231,15 +242,9 @@ EAPI int
|
|||
e_fm_file_is_ebg(E_Fm_File *file)
|
||||
{
|
||||
int val;
|
||||
char *ext;
|
||||
Evas_List *groups, *l;
|
||||
|
||||
if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
if (strcasecmp(ext, ".edj"))
|
||||
if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
|
||||
return 0;
|
||||
|
||||
val = 0;
|
||||
|
@ -262,15 +267,10 @@ e_fm_file_is_ebg(E_Fm_File *file)
|
|||
EAPI int
|
||||
e_fm_file_is_eap(E_Fm_File *file)
|
||||
{
|
||||
char *ext;
|
||||
|
||||
E_App *app;
|
||||
|
||||
if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if (!ext) return 0;
|
||||
|
||||
if (strcasecmp(ext, ".eap"))
|
||||
if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".eap"))
|
||||
return 0;
|
||||
|
||||
app = e_app_new(file->path, 0);
|
||||
|
@ -286,17 +286,11 @@ e_fm_file_is_eap(E_Fm_File *file)
|
|||
EAPI int
|
||||
e_fm_file_can_exec(E_Fm_File *file)
|
||||
{
|
||||
char *ext;
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if (ext)
|
||||
{
|
||||
if (!strcasecmp(ext, ".eap"))
|
||||
if (e_fm_file_has_mime(file,".eap"))
|
||||
{
|
||||
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ecore_file_can_exec(file->path))
|
||||
{
|
||||
|
@ -312,12 +306,8 @@ EAPI int
|
|||
e_fm_file_exec(E_Fm_File *file)
|
||||
{
|
||||
Ecore_Exe *exe;
|
||||
char *ext;
|
||||
|
||||
ext = strrchr(file->name, '.');
|
||||
if (ext)
|
||||
{
|
||||
if (!strcasecmp(ext, ".eap"))
|
||||
if(e_fm_file_has_mime(file,".eap"))
|
||||
{
|
||||
E_App *e_app;
|
||||
Ecore_Exe *exe;
|
||||
|
@ -332,7 +322,6 @@ e_fm_file_exec(E_Fm_File *file)
|
|||
D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
exe = ecore_exe_run(file->path, NULL);
|
||||
if (!exe)
|
||||
|
@ -372,11 +361,8 @@ e_fm_file_assoc_exec(E_Fm_File *file)
|
|||
|
||||
for (l = assoc_apps; l; l = l->next)
|
||||
{
|
||||
char *ext;
|
||||
|
||||
assoc = l->data;
|
||||
ext = strrchr(file->path, '.');
|
||||
if ((ext) && (!strcasecmp(ext, assoc->mime)))
|
||||
if (e_fm_file_has_mime(file,assoc->mime))
|
||||
break;
|
||||
assoc = NULL;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ struct _E_Fm_File
|
|||
|
||||
char *path; /* full name with path */
|
||||
char *name; /* file name without parent directories */
|
||||
char *mime; /* mimetype (just the extension) */
|
||||
char *mime; /* mimetype (just the extension, beginning with dot) */
|
||||
|
||||
dev_t device; /* ID of device containing file */
|
||||
ino_t inode; /* inode number */
|
||||
|
@ -68,7 +68,8 @@ 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);
|
||||
EAPI int e_fm_file_exec_with (E_Fm_File *file, char* exec_with);
|
||||
|
||||
EAPI int e_fm_file_has_mime (E_Fm_File *file, char* mime);
|
||||
EAPI int e_fm_file_is_regular (E_Fm_File *file);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -495,31 +495,21 @@ _e_fm_icon_smart_clip_unset(Evas_Object *obj)
|
|||
|
||||
static void
|
||||
_e_fm_icon_icon_mime_get(E_Smart_Data *sd)
|
||||
{
|
||||
sd->image_object = edje_object_add(sd->evas);
|
||||
if (sd->file->type == E_FM_FILE_TYPE_DIRECTORY)
|
||||
e_theme_edje_object_set(sd->image_object, "base/theme/fileman",
|
||||
"icons/fileman/folder");
|
||||
else
|
||||
{
|
||||
char *ext;
|
||||
|
||||
ext = strrchr(sd->file->name, '.');
|
||||
if (ext)
|
||||
{
|
||||
char part[PATH_MAX];
|
||||
char *ext2;
|
||||
|
||||
ext = strdup(ext);
|
||||
ext2 = ext;
|
||||
for (; *ext2; ext2++) *ext2 = tolower(*ext2);
|
||||
sd->image_object = edje_object_add(sd->evas);
|
||||
|
||||
snprintf(part, PATH_MAX, "icons/fileman/%s", (ext + 1));
|
||||
if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part))
|
||||
// since a mime is set with every creation of an E_Fm_File its existence isn´t checked here
|
||||
if(sd->file->type == E_FM_FILE_TYPE_DIRECTORY)
|
||||
e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/folder");
|
||||
|
||||
else if(e_fm_file_has_mime(sd->file,"unknown"))
|
||||
e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file");
|
||||
free(ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(part, PATH_MAX, "icons/fileman/%s", (sd->file->mime + 1));
|
||||
if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part))
|
||||
e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file");
|
||||
}
|
||||
evas_object_show(sd->image_object);
|
||||
|
@ -529,19 +519,16 @@ _e_fm_icon_icon_mime_get(E_Smart_Data *sd)
|
|||
sd->image_object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
_e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data)
|
||||
{
|
||||
E_Smart_Data *sd;
|
||||
char *ext;
|
||||
|
||||
sd = data;
|
||||
|
||||
ext = strrchr(sd->file->name, '.');
|
||||
if ((ext) && (strcasecmp(ext, ".eap")))
|
||||
ext = NULL;
|
||||
|
||||
if ((ext) || (ecore_file_exists(sd->thumb_path)))
|
||||
if (e_fm_file_has_mime(sd->file,".eap") || (ecore_file_exists(sd->thumb_path)))
|
||||
{
|
||||
Evas_Coord icon_w, icon_h;
|
||||
|
||||
|
|
|
@ -1211,7 +1211,7 @@ _e_fm_icon_prop_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, void *dat
|
|||
e_widget_frametable_object_append(o, e_widget_label_add(evas, text),
|
||||
0, 2, 1, 1,
|
||||
1, 1, 1, 1);
|
||||
snprintf(text, 512, "%s", "An Image");
|
||||
snprintf(text, 512, "%s", icon->file->mime);
|
||||
e_widget_frametable_object_append(o, e_widget_label_add(evas, text),
|
||||
1, 2, 1, 1,
|
||||
1, 1, 1, 1);
|
||||
|
@ -2120,7 +2120,7 @@ _e_fm_icon_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info
|
|||
if(icon->sd->win)
|
||||
icon->sd->drag.start = 0;
|
||||
|
||||
if (!strcmp(icon->file->name, ".")) return;
|
||||
if (!strcmp(icon->file->name, ".")) return; /* this case cant happen!? */
|
||||
|
||||
if (!strcmp(icon->file->name, ".."))
|
||||
{
|
||||
|
@ -2215,7 +2215,7 @@ _e_fm_icon_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info
|
|||
for (l = icon->sd->conf.main->apps; l; l = l->next)
|
||||
{
|
||||
assoc = l->data;
|
||||
if (strcmp(icon->file->mime, assoc->mime) == 0)
|
||||
if (e_fm_file_has_mime(icon->file, assoc->mime))
|
||||
{
|
||||
|
||||
mi = e_menu_item_new(mo);
|
||||
|
|
Loading…
Reference in New Issue