parent
7cdf9af46b
commit
85269715de
350
src/bin/e_apps.c
350
src/bin/e_apps.c
|
@ -5,7 +5,6 @@
|
|||
|
||||
/* TODO List:
|
||||
*
|
||||
* - We assume only .eap files in 'all', no subdirs
|
||||
* - If a .order file references a non-existing file, and the file
|
||||
* is added in 'all', it doesn't show!
|
||||
* - track app execution state, visibility state etc. and call callbacks
|
||||
|
@ -52,7 +51,6 @@ static int _e_apps_hash_idler_cb (void *data);
|
|||
static Evas_Bool _e_apps_hash_idler_cb_init(Evas_Hash *hash, const char *key, void *data, void *fdata);
|
||||
static void _e_app_free (E_App *a);
|
||||
static E_App *_e_app_subapp_file_find (E_App *a, const char *file);
|
||||
static int _e_app_new_save (E_App *a);
|
||||
static void _e_app_change (E_App *a, E_App_Change ch);
|
||||
static int _e_apps_cb_exit (void *data, int type, void *event);
|
||||
static void _e_app_cb_monitor (void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path);
|
||||
|
@ -114,50 +112,6 @@ static int border_setup_count = 0, glob_count = 0;
|
|||
static double border_time = 0.0, border_clever_time = 0.0;
|
||||
static int border_count = 0;
|
||||
|
||||
#define EAP_MIN_WIDTH 8
|
||||
#define EAP_MIN_HEIGHT 8
|
||||
|
||||
#define EAP_EDC_TMPL \
|
||||
"images {\n" \
|
||||
" image: \"%s\" COMP;\n" \
|
||||
"}\n" \
|
||||
"collections {\n" \
|
||||
" group {\n" \
|
||||
" name: \"icon\";\n" \
|
||||
" max: %d %d;\n" \
|
||||
" parts {\n" \
|
||||
" part {\n" \
|
||||
" name: \"image\";\n" \
|
||||
" type: IMAGE;\n" \
|
||||
" mouse_events: 0;\n" \
|
||||
" description {\n" \
|
||||
" state: \"default\" 0.00;\n" \
|
||||
" visible: 1;\n" \
|
||||
" aspect: 1.00 1.00;\n" \
|
||||
" rel1 {\n" \
|
||||
" relative: 0.00 0.00;\n" \
|
||||
" offset: 0 0;\n" \
|
||||
" }\n" \
|
||||
" rel2 {\n" \
|
||||
" relative: 1.00 1.00;\n" \
|
||||
" offset: -1 -1;\n" \
|
||||
" }\n" \
|
||||
" image {\n" \
|
||||
" normal: \"%s\";\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"}\n"
|
||||
|
||||
#define EAP_EDC_TMPL_EMPTY \
|
||||
"images {\n " \
|
||||
"}\n" \
|
||||
"collections {\n" \
|
||||
"}\n"
|
||||
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI int
|
||||
e_app_init(void)
|
||||
|
@ -473,7 +427,7 @@ printf("+");
|
|||
{
|
||||
if ((!a->idle_fill) && (!a->filled))
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/.directory.eap", path);
|
||||
snprintf(buf, sizeof(buf), "%s/.directory.desktop", path);
|
||||
if (ecore_file_exists(buf))
|
||||
e_app_fields_fill(a, buf);
|
||||
else
|
||||
|
@ -784,8 +738,6 @@ _e_app_list_prepend_relative(E_App *add, E_App *before, E_App *parent)
|
|||
}
|
||||
if (before == NULL) fprintf(f, "%s\n", ecore_file_get_file(add->path));
|
||||
fclose(f);
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -830,8 +782,6 @@ _e_app_files_list_prepend_relative(Evas_List *files, E_App *before, E_App *paren
|
|||
}
|
||||
}
|
||||
fclose(f);
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -849,8 +799,6 @@ _e_app_files_download(Evas_List *files)
|
|||
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_all,
|
||||
ecore_file_get_file(file));
|
||||
if (!ecore_file_download(file, buf, NULL, NULL, NULL)) continue;
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", _e_apps_path_all);
|
||||
ecore_file_unlink(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,8 +936,6 @@ e_app_files_prepend_relative(Evas_List *files, E_App *before)
|
|||
fprintf(f, "%s\n", ecore_file_get_file(a->path));
|
||||
}
|
||||
fclose(f);
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", before->parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,8 +976,6 @@ e_app_files_append(Evas_List *files, E_App *parent)
|
|||
fprintf(f, "%s\n", ecore_file_get_file(file));
|
||||
}
|
||||
fclose(f);
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1067,8 +1011,6 @@ e_app_remove(E_App *a)
|
|||
a2 = l->data;
|
||||
e_app_remove(a2);
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", a->parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
_e_app_change(a, E_APP_DEL);
|
||||
a->parent = NULL;
|
||||
e_object_unref(E_OBJECT(a));
|
||||
|
@ -1825,80 +1767,6 @@ printf(".");
|
|||
// if (desktop->categories) a->categories = evas_stringshare_add(desktop->categories);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* Must be an .eap file. */
|
||||
Eet_File *ef;
|
||||
|
||||
/* FIXME: This entire process seems inefficient, each of the strings gets duped then freed three times.
|
||||
* On the other hand, raster wants .eaps to go away, so no big deal. B-)
|
||||
*/
|
||||
|
||||
#define STORE_N_FREE(member) \
|
||||
if (v) \
|
||||
{ \
|
||||
str = alloca(size + 1); \
|
||||
memcpy(str, (v), size); \
|
||||
str[size] = 0; \
|
||||
a->member = evas_stringshare_add(str); \
|
||||
free(v); \
|
||||
}
|
||||
|
||||
printf("E");
|
||||
ef = eet_open(path, EET_FILE_MODE_READ);
|
||||
if (!ef) return;
|
||||
|
||||
v = _e_app_localized_val_get(ef, lang, "app/info/name", &size);
|
||||
STORE_N_FREE(name);
|
||||
v = _e_app_localized_val_get(ef, lang, "app/info/generic", &size);
|
||||
STORE_N_FREE(generic);
|
||||
v = _e_app_localized_val_get(ef, lang, "app/info/comment", &size);
|
||||
STORE_N_FREE(comment);
|
||||
|
||||
v = eet_read(ef, "app/info/exe", &size);
|
||||
STORE_N_FREE(exe);
|
||||
v = eet_read(ef, "app/icon/class", &size);
|
||||
STORE_N_FREE(icon_class);
|
||||
v = eet_read(ef, "app/window/name", &size);
|
||||
STORE_N_FREE(win_name);
|
||||
v = eet_read(ef, "app/window/class", &size);
|
||||
STORE_N_FREE(win_class);
|
||||
v = eet_read(ef, "app/window/title", &size);
|
||||
STORE_N_FREE(win_title);
|
||||
v = eet_read(ef, "app/window/role", &size);
|
||||
STORE_N_FREE(win_role);
|
||||
v = eet_read(ef, "app/info/startup_notify", &size);
|
||||
if (v)
|
||||
{
|
||||
a->startup_notify = *v;
|
||||
free(v);
|
||||
}
|
||||
v = eet_read(ef, "app/info/wait_exit", &size);
|
||||
if (v)
|
||||
{
|
||||
a->wait_exit = *v;
|
||||
free(v);
|
||||
}
|
||||
eet_close(ef);
|
||||
a->filled = 1;
|
||||
}
|
||||
#if CLEVER_BORDERS
|
||||
if (a->filled)
|
||||
{
|
||||
double begin, time;
|
||||
|
||||
begin = ecore_time_get();
|
||||
|
||||
if ((a->path) && (a->win_class)) _e_apps_border_setup(&_e_apps_border_ng_win_class, &_e_apps_border_g_win_class, a->win_class, a->path, 'c');
|
||||
if ((a->path) && (a->win_name)) _e_apps_border_setup(&_e_apps_border_ng_win_name, &_e_apps_border_g_win_name, a->win_name, a->path, 'n');
|
||||
if ((a->path) && (a->win_title)) _e_apps_border_setup(&_e_apps_border_ng_win_title, &_e_apps_border_g_win_title, a->win_title, a->path, 't');
|
||||
if ((a->path) && (a->win_role)) _e_apps_border_setup(&_e_apps_border_ng_win_role, &_e_apps_border_g_win_role, a->win_role, a->path, 'r');
|
||||
if ((a->path) && (a->exe)) _e_apps_border_setup(&_e_apps_border_ng_exe, NULL, a->exe, a->path, 'e');
|
||||
|
||||
time = ecore_time_get() - begin;
|
||||
border_setup_count++;
|
||||
border_setup_time += time;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -2004,112 +1872,6 @@ e_app_fields_save(E_App *a)
|
|||
E_FREE(desktop);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* Must be an .eap file. */
|
||||
Eet_File *ef;
|
||||
unsigned char tmp[1];
|
||||
// int img;
|
||||
// if ((!a->path) || (!ecore_file_exists(a->path)))
|
||||
// {
|
||||
_e_app_new_save(a);
|
||||
// img = 0;
|
||||
// }
|
||||
// else
|
||||
// img = 1;
|
||||
|
||||
/* get our current language */
|
||||
lang = e_intl_language_alias_get();
|
||||
|
||||
/* if its "C" its the default - so drop it */
|
||||
if (!strcmp(lang, "C")) lang = NULL;
|
||||
|
||||
ef = eet_open(a->path, EET_FILE_MODE_READ_WRITE);
|
||||
if (!ef) return;
|
||||
|
||||
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) && (img))
|
||||
{
|
||||
int alpha;
|
||||
Ecore_Evas *buf;
|
||||
Evas *evasbuf;
|
||||
Evas_Coord iw, ih;
|
||||
Evas_Object *im;
|
||||
const 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 (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))
|
||||
{
|
||||
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, a->width, a->height, alpha, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
*/
|
||||
eet_close(ef);
|
||||
}
|
||||
|
||||
_e_apps_every_app = evas_hash_direct_add(_e_apps_every_app, a->path, a);
|
||||
if (new_eap)
|
||||
|
@ -2148,8 +1910,6 @@ _e_app_fields_save_others(E_App *a)
|
|||
_e_app_change(a, E_APP_CHANGE);
|
||||
if (a->parent)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", a->parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
_e_app_change(a->parent, E_APP_CHANGE);
|
||||
/* I don't think we need to rescan.
|
||||
* A) we should be changing all the relevant stuff here.
|
||||
|
@ -2475,97 +2235,6 @@ printf("e_app_icon_add_to_menu_item(%s) %s %s %s\n", a->path, a->icon_clas
|
|||
|
||||
/* local subsystem functions */
|
||||
|
||||
/* write out a new eap, code borrowed from Engrave */
|
||||
static int
|
||||
_e_app_new_save(E_App *a)
|
||||
{
|
||||
static char tmpn[4096];
|
||||
int fd = 0, ret = 0;
|
||||
char cmd[2048];
|
||||
char ipart[512];
|
||||
FILE *out = NULL;
|
||||
char *start, *end, *imgdir = NULL;
|
||||
int i;
|
||||
|
||||
if (!a->path) return 0;
|
||||
strcpy(tmpn, "/tmp/eapp_edit_cc.edc-tmp-XXXXXX");
|
||||
fd = mkstemp(tmpn);
|
||||
if (fd < 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to create tmp file: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
out = fopen(tmpn, "w");
|
||||
if (!out)
|
||||
{
|
||||
printf("can't open %s for writing\n", tmpn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
if (a->image)
|
||||
{
|
||||
start = strchr(a->image, '/');
|
||||
end = strrchr(a->image, '/');
|
||||
|
||||
if (start == end) imgdir = strdup("/");
|
||||
else if ((!start) || (!end)) imgdir = strdup("");
|
||||
else
|
||||
{
|
||||
imgdir = malloc((end - start + 1));
|
||||
if (imgdir)
|
||||
{
|
||||
memcpy(imgdir, start, end - start);
|
||||
imgdir[end - start] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imgdir)
|
||||
{
|
||||
snprintf(ipart, sizeof(ipart), "-id %s",
|
||||
e_util_filename_escape(imgdir));
|
||||
free(imgdir);
|
||||
}
|
||||
else ipart[0] = 0;
|
||||
|
||||
if (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,
|
||||
e_util_filename_escape(ecore_file_get_file(a->image)),
|
||||
a->width, a->height,
|
||||
e_util_filename_escape(ecore_file_get_file(a->image)));
|
||||
}
|
||||
else
|
||||
fprintf(out, EAP_EDC_TMPL_EMPTY);
|
||||
fclose(out);
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", ipart, tmpn,
|
||||
e_util_filename_escape(a->path));
|
||||
ret = system(cmd);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to execute edje_cc on tmp file: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a->parent)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", a->parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
}
|
||||
ecore_file_unlink(tmpn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_app_free(E_App *a)
|
||||
{
|
||||
|
@ -2758,7 +2427,7 @@ _e_app_cb_monitor(void *data, Ecore_File_Monitor *em,
|
|||
printf("BUG: Weird event for .order: %d\n", event);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(file, ".directory.eap"))
|
||||
else if (!strcmp(file, ".directory.desktop"))
|
||||
{
|
||||
if ((event == ECORE_FILE_EVENT_CREATED_FILE) ||
|
||||
(event == ECORE_FILE_EVENT_MODIFIED))
|
||||
|
@ -2784,13 +2453,9 @@ _e_app_cb_monitor(void *data, Ecore_File_Monitor *em,
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("BUG: Weird event for .directory.eap: %d\n", event);
|
||||
printf("BUG: Weird event for .directory.desktop: %d\n", event);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(file, ".eap.cache.cfg"))
|
||||
{
|
||||
/* ignore this file */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (event == ECORE_FILE_EVENT_MODIFIED)
|
||||
|
@ -2991,7 +2656,7 @@ _e_app_is_eapp(const char *path)
|
|||
return 0;
|
||||
|
||||
p++;
|
||||
if ((strcasecmp(p, "eap")) && (strcasecmp(p, "desktop")))
|
||||
if (strcasecmp(p, "desktop"))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -3064,13 +2729,6 @@ _e_app_save_order(E_App *app)
|
|||
fprintf(f, "%s\n", ecore_file_get_file(a->path));
|
||||
}
|
||||
fclose(f);
|
||||
if (app->parent)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", app->parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in New Issue