- add ability to save eap info to disk

- add ability to create and populate empty eaps


SVN revision: 17896
This commit is contained in:
codewarrior 2005-10-24 21:52:31 +00:00 committed by codewarrior
parent cf0be0ae46
commit 5103d613fc
3 changed files with 129 additions and 1 deletions

View File

@ -189,6 +189,9 @@ e_app_new(const char *path, int scan_subdirs)
if (ecore_file_exists(path))
{
a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
/* no image for now */
a->image = NULL;
/* record the path */
a->path = strdup(path);
@ -233,6 +236,17 @@ error:
return NULL;
}
E_App *
e_app_empty_new(const char *path)
{
E_App *a;
a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
a->image = NULL;
a->path = strdup(path);
return a;
}
int
e_app_is_parent(E_App *parent, E_App *app)
{
@ -932,6 +946,116 @@ e_app_fields_fill(E_App *a, const char *path)
eet_close(ef);
}
/* If we are saving a new non-existant .eap, we need to add more info
* so edje can decompile it. Image saving doesnt work yet with newly
* created eaps.
*
* We also need to fix startup-notify and wait-exit as they currently
* dont save too.
*/
void
e_app_fields_save(E_App *a)
{
Eet_File *ef;
char buf[PATH_MAX];
char *str, *v;
char *lang;
int size;
unsigned char tmp[1];
/* get our current language */
lang = getenv("LANG");
/* if its "C" its the default - so drop it */
if ((lang) && (!strcmp(lang, "C")))
lang = NULL;
if(ecore_file_exists(a->path))
ef = eet_open(a->path, EET_FILE_MODE_READ_WRITE);
else
ef = eet_open(a->path, EET_FILE_MODE_WRITE);
if (!ef) return;
printf("opened %s\n", a->path);
if(a->name)
{
/*if (lang) snprintf(buf, sizeof(buf), "app/info/name[%s]", lang);
else */snprintf(buf, sizeof(buf), "app/info/name");
eet_write(ef, buf, a->name, strlen(a->name), 0);
}
if(a->generic)
{
/*if (lang) snprintf(buf, sizeof(buf), "app/info/generic[%s]", lang);
else */snprintf(buf, sizeof(buf), "app/info/generic");
eet_write(ef, buf, a->generic, strlen(a->generic), 0);
}
if(a->comment)
{
/*if (lang) snprintf(buf, sizeof(buf), "app/info/comment[%s]", lang);
else*/ snprintf(buf, sizeof(buf), "app/info/comment");
eet_write(ef, buf, a->comment, strlen(a->comment), 0);
}
if(a->exe)
eet_write(ef, "app/info/exe", a->exe, strlen(a->exe), 0);
if(a->win_name)
eet_write(ef, "app/window/name", a->win_name, strlen(a->win_name), 0);
if(a->win_class)
eet_write(ef, "app/window/class", a->win_class, strlen(a->win_class), 0);
if(a->win_title)
eet_write(ef, "app/window/title", a->win_title, strlen(a->win_title), 0);
if(a->win_role)
eet_write(ef, "app/window/role", a->win_role, strlen(a->win_role), 0);
if(a->icon_class)
eet_write(ef, "app/icon/class", a->icon_class, strlen(a->icon_class), 0);
if(a->startup_notify)
tmp[0] = 1;
else
tmp[0] = 0;
eet_write(ef, "app/info/startup_notify", tmp, 1, 0);
if(a->wait_exit)
tmp[0] = 1;
else
tmp[0] = 0;
eet_write(ef, "app/info/wait_exit", tmp, 1, 0);
if(a->image)
{
int alpha;
Ecore_Evas *buf;
Evas *evasbuf;
Evas_Coord iw, ih;
Evas_Object *im;
int *data;
buf = ecore_evas_buffer_new(1, 1);
evasbuf = ecore_evas_get(buf);
im = evas_object_image_add(evasbuf);
evas_object_image_file_set(im, a->image, NULL);
iw = 0; ih = 0;
evas_object_image_size_get(im, &iw, &ih);
alpha = evas_object_image_alpha_get(im);
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);
evas_object_move(im, 0, 0);
evas_object_show(im);
data = ecore_evas_buffer_pixels_get(buf);
eet_data_image_write(ef, "images/0", data, 48, 48, alpha, 1, 0, 0);
}
}
eet_close(ef);
}
void
e_app_fields_empty(E_App *a)
{

View File

@ -61,6 +61,8 @@ struct _E_App
unsigned char scanned : 1; /* have we scanned a subdir app yet */
unsigned char deleted : 1; /* this app's file is deleted from disk */
char *image; /* used when we're saving a image into the eap */
};
struct _E_App_Instance
@ -76,6 +78,7 @@ EAPI int e_app_init (void);
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 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);
@ -99,6 +102,7 @@ EAPI E_App *e_app_generic_find (char *generic);
EAPI E_App *e_app_exe_find (char *exe);
EAPI void e_app_fields_fill (E_App *a, const char *path);
EAPI void e_app_fields_save (E_App *a);
EAPI E_App *e_app_raw_new (void);
EAPI Ecore_List *e_app_dir_file_list_get (E_App *a);
EAPI void e_app_fields_empty (E_App *a);

View File

@ -34,6 +34,6 @@ EAPI void e_entry_cursor_move_at_end(Evas_Object *object);
EAPI void e_entry_cursor_move_left(Evas_Object *object);
EAPI void e_entry_cursor_move_right(Evas_Object *object);
EAPI void e_entry_cursor_show(Evas_Object *object);
EAPI void e_entry_cursor_hide(Evas_Object *object);
EAPI void e_entry_cursor_hide(Evas_Object *object);
#endif