- patch from mista (Efm)

- allow eap image w/h to be changable.


SVN revision: 19808
This commit is contained in:
codewarrior 2006-01-14 21:05:44 +00:00 committed by codewarrior
parent bbea62a127
commit 6437ea875a
7 changed files with 197 additions and 194 deletions

View File

@ -72,6 +72,9 @@ static char *_e_apps_path_all = NULL;
static char *_e_apps_path_trash = NULL; static char *_e_apps_path_trash = NULL;
static Evas_List *_e_apps_start_pending = NULL; static Evas_List *_e_apps_start_pending = NULL;
#define EAP_MIN_WIDTH 8
#define EAP_MIN_HEIGHT 8
#define EAP_EDC_TMPL \ #define EAP_EDC_TMPL \
"images {\n" \ "images {\n" \
" image: \"%s\" COMP;\n" \ " image: \"%s\" COMP;\n" \
@ -234,6 +237,8 @@ e_app_new(const char *path, int scan_subdirs)
/* no image for now */ /* no image for now */
a->image = NULL; a->image = NULL;
a->width = 0;
a->height = 0;
/* record the path */ /* record the path */
a->path = evas_stringshare_add(path); a->path = evas_stringshare_add(path);
@ -289,6 +294,13 @@ e_app_empty_new(const char *path)
return a; return a;
} }
EAPI void
e_app_image_size_set(E_App *a, int w, int h)
{
a->width = w;
a->height = h;
}
EAPI int EAPI int
e_app_is_parent(E_App *parent, E_App *app) 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); eet_close(ef);
} }
/*
* We also need to fix startup-notify and wait-exit as they currently
* dont save too.
*/
EAPI void EAPI void
e_app_fields_save(E_App *a) e_app_fields_save(E_App *a)
{ {
@ -1119,16 +1127,20 @@ e_app_fields_save(E_App *a)
iw = 0; ih = 0; iw = 0; ih = 0;
evas_object_image_size_get(im, &iw, &ih); evas_object_image_size_get(im, &iw, &ih);
alpha = evas_object_image_alpha_get(im); 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)) if ((iw > 0) && (ih > 0))
{ {
/* we need to change the sizes */ /* we need to change the sizes */
ecore_evas_resize(buf, 48, 48); ecore_evas_resize(buf, a->width, a->height);
evas_object_image_fill_set(im, 0, 0, 48, 48); evas_object_image_fill_set(im, 0, 0, a->width, a->height);
evas_object_resize(im, 48, 48); evas_object_resize(im, a->height, a->width);
evas_object_move(im, 0, 0); evas_object_move(im, 0, 0);
evas_object_show(im); evas_object_show(im);
data = ecore_evas_buffer_pixels_get(buf); 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'; else ipart[0] = '\0';
if (a->image) 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 else
fprintf(out, EAP_EDC_TMPL_EMPTY); fprintf(out, EAP_EDC_TMPL_EMPTY);
fclose(out); fclose(out);

View File

@ -63,6 +63,8 @@ struct _E_App
unsigned char deleted : 1; /* this app's file is deleted from disk */ unsigned char deleted : 1; /* this app's file is deleted from disk */
char *image; /* used when we're saving a image into the eap */ 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 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_new (const char *path, int scan_subdirs);
EAPI E_App *e_app_empty_new (const char *path); 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_is_parent (E_App *parent, E_App *app);
EAPI int e_app_equals (E_App *app1, E_App *app2); EAPI int e_app_equals (E_App *app1, E_App *app2);
EAPI void e_app_subdir_scan (E_App *a, int scan_subdirs); EAPI void e_app_subdir_scan (E_App *a, int scan_subdirs);

View File

@ -161,6 +161,10 @@ _e_eap_edit_basic_apply_data(E_Config_Dialog *cfd, void *data)
eap->startup_notify = cfdata->startup_notify; eap->startup_notify = cfdata->startup_notify;
eap->wait_exit = cfdata->wait_exit; 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); e_app_fields_save(eap);
return 1; 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->iclass) eap->icon_class = evas_stringshare_add(cfdata->iclass);
if (cfdata->path) eap->path = evas_stringshare_add(cfdata->path); 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); e_app_fields_save(eap);
return 1; return 1;
} }

View File

@ -77,6 +77,10 @@ e_fm_file_new(const char *filename)
ext = strrchr(file->name, '.'); ext = strrchr(file->name, '.');
if (ext) if (ext)
{ {
char *ext2;
ext = strdup(ext);
ext2 = ext;
for (; *ext2; ext2++) *ext2 = tolower(*ext2);
file->mime = ext; file->mime = ext;
} }
else 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 EAPI int
e_fm_file_can_preview(E_Fm_File *file) 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 * If it isn't supported by evas, we can't show it in the
* canvas. * 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, '.'); return e_fm_file_is_regular(file)
if (!ext) return 0; &&(e_fm_file_has_mime(file,".jpg")
|| e_fm_file_has_mime(file,".jpeg")
D(("e_fm_file_is_image: (%p)\n", file)); || e_fm_file_has_mime(file,".png"));
return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png")) ||
(!strcasecmp(ext, ".jpeg"));
} }
EAPI int EAPI int
e_fm_file_is_etheme(E_Fm_File *file) e_fm_file_is_etheme(E_Fm_File *file)
{ {
int val; int val;
char *ext;
Evas_List *groups, *l; Evas_List *groups, *l;
if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
ext = strrchr(file->name, '.');
if (!ext) return 0;
if (strcasecmp(ext, ".edj"))
return 0; return 0;
val = 0; val = 0;
@ -231,15 +242,9 @@ EAPI int
e_fm_file_is_ebg(E_Fm_File *file) e_fm_file_is_ebg(E_Fm_File *file)
{ {
int val; int val;
char *ext;
Evas_List *groups, *l; Evas_List *groups, *l;
if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj"))
ext = strrchr(file->name, '.');
if (!ext) return 0;
if (strcasecmp(ext, ".edj"))
return 0; return 0;
val = 0; val = 0;
@ -262,15 +267,10 @@ e_fm_file_is_ebg(E_Fm_File *file)
EAPI int EAPI int
e_fm_file_is_eap(E_Fm_File *file) e_fm_file_is_eap(E_Fm_File *file)
{ {
char *ext;
E_App *app; E_App *app;
if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".eap"))
ext = strrchr(file->name, '.');
if (!ext) return 0;
if (strcasecmp(ext, ".eap"))
return 0; return 0;
app = e_app_new(file->path, 0); app = e_app_new(file->path, 0);
@ -286,17 +286,11 @@ e_fm_file_is_eap(E_Fm_File *file)
EAPI int EAPI int
e_fm_file_can_exec(E_Fm_File *file) e_fm_file_can_exec(E_Fm_File *file)
{ {
char *ext; if (e_fm_file_has_mime(file,".eap"))
ext = strrchr(file->name, '.');
if (ext)
{
if (!strcasecmp(ext, ".eap"))
{ {
D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name)); D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name));
return 1; return 1;
} }
}
if (ecore_file_can_exec(file->path)) if (ecore_file_can_exec(file->path))
{ {
@ -312,12 +306,8 @@ EAPI int
e_fm_file_exec(E_Fm_File *file) e_fm_file_exec(E_Fm_File *file)
{ {
Ecore_Exe *exe; Ecore_Exe *exe;
char *ext;
ext = strrchr(file->name, '.'); if(e_fm_file_has_mime(file,".eap"))
if (ext)
{
if (!strcasecmp(ext, ".eap"))
{ {
E_App *e_app; E_App *e_app;
Ecore_Exe *exe; 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)); D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name));
return 1; return 1;
} }
}
exe = ecore_exe_run(file->path, NULL); exe = ecore_exe_run(file->path, NULL);
if (!exe) if (!exe)
@ -372,11 +361,8 @@ e_fm_file_assoc_exec(E_Fm_File *file)
for (l = assoc_apps; l; l = l->next) for (l = assoc_apps; l; l = l->next)
{ {
char *ext;
assoc = l->data; assoc = l->data;
ext = strrchr(file->path, '.'); if (e_fm_file_has_mime(file,assoc->mime))
if ((ext) && (!strcasecmp(ext, assoc->mime)))
break; break;
assoc = NULL; assoc = NULL;
} }

View File

@ -37,7 +37,7 @@ struct _E_Fm_File
char *path; /* full name with path */ char *path; /* full name with path */
char *name; /* file name without parent directories */ 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 */ dev_t device; /* ID of device containing file */
ino_t inode; /* inode number */ 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_set (E_Fm_File *file, const char *assoc);
EAPI int e_fm_file_assoc_exec (E_Fm_File *file); 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_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
#endif #endif

View File

@ -496,30 +496,20 @@ _e_fm_icon_smart_clip_unset(Evas_Object *obj)
static void static void
_e_fm_icon_icon_mime_get(E_Smart_Data *sd) _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 part[PATH_MAX];
char *ext2;
ext = strdup(ext); sd->image_object = edje_object_add(sd->evas);
ext2 = ext;
for (; *ext2; ext2++) *ext2 = tolower(*ext2);
snprintf(part, PATH_MAX, "icons/fileman/%s", (ext + 1)); // since a mime is set with every creation of an E_Fm_File its existence isn´t checked here
if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part)) 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"); e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file");
free(ext);
}
else 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"); e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file");
} }
evas_object_show(sd->image_object); evas_object_show(sd->image_object);
@ -529,19 +519,16 @@ _e_fm_icon_icon_mime_get(E_Smart_Data *sd)
sd->image_object); sd->image_object);
} }
void void
_e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data) _e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data)
{ {
E_Smart_Data *sd; E_Smart_Data *sd;
char *ext;
sd = data; sd = data;
ext = strrchr(sd->file->name, '.'); if (e_fm_file_has_mime(sd->file,".eap") || (ecore_file_exists(sd->thumb_path)))
if ((ext) && (strcasecmp(ext, ".eap")))
ext = NULL;
if ((ext) || (ecore_file_exists(sd->thumb_path)))
{ {
Evas_Coord icon_w, icon_h; Evas_Coord icon_w, icon_h;

View File

@ -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), e_widget_frametable_object_append(o, e_widget_label_add(evas, text),
0, 2, 1, 1, 0, 2, 1, 1,
1, 1, 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), e_widget_frametable_object_append(o, e_widget_label_add(evas, text),
1, 2, 1, 1, 1, 2, 1, 1,
1, 1, 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) if(icon->sd->win)
icon->sd->drag.start = 0; 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, "..")) 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) for (l = icon->sd->conf.main->apps; l; l = l->next)
{ {
assoc = l->data; 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); mi = e_menu_item_new(mo);