2005-02-07 05:51:09 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2004-11-24 19:37:45 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
/* TODO List:
|
|
|
|
*
|
2005-06-27 07:24:20 -07:00
|
|
|
* - We assume only .eap files in 'all', no subdirs
|
2005-02-21 08:21:13 -08:00
|
|
|
* - 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
|
|
|
|
* - calls to execute an app or query its runing/starting state etc.
|
2005-06-15 18:55:19 -07:00
|
|
|
* - clean up the add app functions. To much similar code.
|
2004-11-24 19:37:45 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
typedef struct _E_App_Change_Info E_App_Change_Info;
|
|
|
|
typedef struct _E_App_Callback E_App_Callback;
|
|
|
|
|
|
|
|
struct _E_App_Change_Info
|
|
|
|
{
|
|
|
|
E_App *app;
|
|
|
|
E_App_Change change;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _E_App_Callback
|
|
|
|
{
|
|
|
|
void (*func) (void *data, E_App *a, E_App_Change ch);
|
|
|
|
void *data;
|
|
|
|
unsigned char delete_me : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void _e_app_free (E_App *a);
|
2005-02-21 08:21:13 -08:00
|
|
|
static void _e_app_fields_fill (E_App *a, const char *path);
|
2004-11-24 19:37:45 -08:00
|
|
|
static void _e_app_fields_empty (E_App *a);
|
2005-04-14 03:52:58 -07:00
|
|
|
static Ecore_List *_e_app_dir_file_list_get (E_App *a);
|
2005-03-29 22:36:58 -08:00
|
|
|
static E_App *_e_app_subapp_file_find (E_App *a, const char *file);
|
2004-11-24 19:37:45 -08:00
|
|
|
static void _e_app_change (E_App *a, E_App_Change ch);
|
|
|
|
static int _e_apps_cb_exit (void *data, int type, void *event);
|
2005-03-29 22:36:58 -08:00
|
|
|
static void _e_app_cb_monitor (void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path);
|
2005-02-21 08:21:13 -08:00
|
|
|
static void _e_app_subdir_rescan (E_App *app);
|
|
|
|
static int _e_app_is_eapp (const char *path);
|
2005-08-09 06:22:25 -07:00
|
|
|
static int _e_app_copy (E_App *dst, E_App *src);
|
2005-05-03 10:27:42 -07:00
|
|
|
static void _e_app_save_order (E_App *app);
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* local subsystem globals */
|
|
|
|
static Evas_Hash *_e_apps = NULL;
|
2004-12-02 02:07:51 -08:00
|
|
|
static Evas_List *_e_apps_list = NULL;
|
2004-11-24 19:37:45 -08:00
|
|
|
static int _e_apps_callbacks_walking = 0;
|
|
|
|
static int _e_apps_callbacks_delete_me = 0;
|
|
|
|
static Evas_List *_e_apps_change_callbacks = NULL;
|
|
|
|
static Ecore_Event_Handler *_e_apps_exit_handler = NULL;
|
2004-12-01 22:35:37 -08:00
|
|
|
static Evas_List *_e_apps_repositories = NULL;
|
2004-12-02 02:07:51 -08:00
|
|
|
static E_App *_e_apps_all = NULL;
|
2005-05-11 02:00:32 -07:00
|
|
|
static char *_e_apps_path_all = NULL;
|
|
|
|
static char *_e_apps_path_trash = NULL;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* externally accessible functions */
|
|
|
|
int
|
|
|
|
e_app_init(void)
|
|
|
|
{
|
2004-12-01 22:35:37 -08:00
|
|
|
char *home;
|
2005-02-21 08:21:13 -08:00
|
|
|
char buf[PATH_MAX];
|
2004-12-01 22:35:37 -08:00
|
|
|
|
|
|
|
home = e_user_homedir_get();
|
2005-05-11 02:00:32 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.e/e/applications/trash", home);
|
|
|
|
_e_apps_path_trash = strdup(buf);
|
2004-12-01 22:35:37 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.e/e/applications/all", home);
|
2005-05-11 02:00:32 -07:00
|
|
|
_e_apps_path_all = strdup(buf);
|
2004-12-02 02:07:51 -08:00
|
|
|
free(home);
|
2004-12-01 22:35:37 -08:00
|
|
|
_e_apps_repositories = evas_list_append(_e_apps_repositories, strdup(buf));
|
2004-11-24 19:37:45 -08:00
|
|
|
_e_apps_exit_handler = ecore_event_handler_add(ECORE_EVENT_EXE_EXIT, _e_apps_cb_exit, NULL);
|
2004-12-02 02:07:51 -08:00
|
|
|
_e_apps_all = e_app_new(buf, 1);
|
2004-11-24 19:37:45 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_app_shutdown(void)
|
|
|
|
{
|
2004-12-02 02:07:51 -08:00
|
|
|
if (_e_apps_all)
|
|
|
|
{
|
|
|
|
e_object_unref(E_OBJECT(_e_apps_all));
|
|
|
|
_e_apps_all = NULL;
|
|
|
|
}
|
2004-12-01 22:35:37 -08:00
|
|
|
while (_e_apps_repositories)
|
|
|
|
{
|
|
|
|
free(_e_apps_repositories->data);
|
|
|
|
_e_apps_repositories = evas_list_remove_list(_e_apps_repositories, _e_apps_repositories);
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
if (_e_apps_exit_handler)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(_e_apps_exit_handler);
|
|
|
|
_e_apps_exit_handler = NULL;
|
|
|
|
}
|
2005-05-11 02:00:32 -07:00
|
|
|
free(_e_apps_path_trash);
|
|
|
|
free(_e_apps_path_all);
|
2005-02-24 01:54:58 -08:00
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
a = l->data;
|
2005-04-20 22:21:13 -07:00
|
|
|
printf("BUG: References %d %s\n", E_OBJECT(a)->references, a->path);
|
2005-02-24 01:54:58 -08:00
|
|
|
}
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_App *
|
2005-02-21 08:21:13 -08:00
|
|
|
e_app_new(const char *path, int scan_subdirs)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
E_App *a;
|
2005-02-21 08:21:13 -08:00
|
|
|
char buf[PATH_MAX];
|
2004-12-01 23:00:30 -08:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
a = evas_hash_find(_e_apps, path);
|
2005-02-23 03:29:41 -08:00
|
|
|
if (a)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-23 03:29:41 -08:00
|
|
|
if (a->deleted)
|
2005-04-20 00:28:37 -07:00
|
|
|
return NULL;
|
2004-11-24 19:37:45 -08:00
|
|
|
e_object_ref(E_OBJECT(a));
|
|
|
|
return a;
|
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
|
|
|
|
if (ecore_file_exists(path))
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-21 08:21:13 -08:00
|
|
|
a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
|
|
|
/* record the path */
|
2004-11-24 19:37:45 -08:00
|
|
|
a->path = strdup(path);
|
2005-02-21 08:21:13 -08:00
|
|
|
|
|
|
|
if (ecore_file_is_dir(a->path))
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-06-23 19:29:27 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.directory.eap", path);
|
2005-02-21 08:21:13 -08:00
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
_e_app_fields_fill(a, buf);
|
|
|
|
else
|
2005-02-22 04:49:18 -08:00
|
|
|
a->name = strdup(ecore_file_get_file(a->path));
|
2005-02-21 08:21:13 -08:00
|
|
|
if (scan_subdirs) e_app_subdir_scan(a, scan_subdirs);
|
|
|
|
|
|
|
|
a->monitor = ecore_file_monitor_add(a->path, _e_app_cb_monitor, a);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
else if (_e_app_is_eapp(path))
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-21 08:21:13 -08:00
|
|
|
_e_app_fields_fill(a, path);
|
|
|
|
|
|
|
|
/* no exe field.. not valid. drop it */
|
|
|
|
if (!a->exe)
|
|
|
|
goto error;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
else
|
|
|
|
goto error;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
else
|
2005-02-21 08:21:13 -08:00
|
|
|
return NULL;
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
_e_apps = evas_hash_add(_e_apps, a->path, a);
|
2004-12-02 02:07:51 -08:00
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
2004-11-24 19:37:45 -08:00
|
|
|
return a;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (a->monitor) ecore_file_monitor_del(a->monitor);
|
2005-03-22 01:20:12 -08:00
|
|
|
if (a->path) free(a->path);
|
2005-02-21 08:21:13 -08:00
|
|
|
_e_app_fields_empty(a);
|
|
|
|
free(a);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_app_is_parent(E_App *parent, E_App *app)
|
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
E_App *current;
|
|
|
|
|
|
|
|
current = app->parent;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
2005-04-20 00:28:37 -07:00
|
|
|
while (current)
|
|
|
|
{
|
|
|
|
if (current == parent)
|
|
|
|
return 1;
|
|
|
|
current = current->parent;
|
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
|
|
|
|
return 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_app_subdir_scan(E_App *a, int scan_subdirs)
|
|
|
|
{
|
2005-04-14 03:52:58 -07:00
|
|
|
Ecore_List *files;
|
|
|
|
char *s;
|
2005-02-21 08:21:13 -08:00
|
|
|
char buf[PATH_MAX];
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
E_OBJECT_CHECK(a);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK(a, E_APP_TYPE);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (a->exe) return;
|
|
|
|
if (a->scanned)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!scan_subdirs) return;
|
|
|
|
for (l = a->subapps; l; l = l->next)
|
|
|
|
e_app_subdir_scan(l->data, scan_subdirs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
a->scanned = 1;
|
2005-02-21 08:21:13 -08:00
|
|
|
files = _e_app_dir_file_list_get(a);
|
2005-04-20 00:28:37 -07:00
|
|
|
if (files)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
while ((s = ecore_list_next(files)))
|
2005-02-21 08:21:13 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
E_App *a2;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
2005-04-20 00:28:37 -07:00
|
|
|
a2 = NULL;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", a->path, s);
|
|
|
|
if (ecore_file_exists(buf))
|
2004-12-01 22:35:37 -08:00
|
|
|
{
|
|
|
|
a2 = e_app_new(buf, scan_subdirs);
|
2005-04-20 00:28:37 -07:00
|
|
|
if (a2)
|
|
|
|
{
|
|
|
|
a2->parent = a;
|
|
|
|
a->subapps = evas_list_append(a->subapps, a2);
|
|
|
|
}
|
2004-12-01 22:35:37 -08:00
|
|
|
}
|
2005-04-20 00:28:37 -07:00
|
|
|
else
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
E_App *a3;
|
|
|
|
Evas_List *pl;
|
|
|
|
|
|
|
|
pl = _e_apps_repositories;
|
|
|
|
while ((!a2) && (pl))
|
2005-04-19 08:11:45 -07:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", (char *)pl->data, s);
|
|
|
|
a2 = e_app_new(buf, scan_subdirs);
|
|
|
|
pl = pl->next;
|
|
|
|
}
|
|
|
|
if (a2)
|
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
a3 = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
2005-04-20 00:28:37 -07:00
|
|
|
if (a3)
|
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
if (_e_app_copy(a3, a2))
|
|
|
|
{
|
|
|
|
a3->parent = a;
|
|
|
|
a->subapps = evas_list_append(a->subapps, a3);
|
|
|
|
a2->references = evas_list_append(a2->references, a3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_object_del(E_OBJECT(a3));
|
2005-04-20 00:28:37 -07:00
|
|
|
}
|
2005-04-19 08:11:45 -07:00
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-04-20 00:28:37 -07:00
|
|
|
free(s);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-04-20 00:28:37 -07:00
|
|
|
ecore_list_destroy(files);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_app_exec(E_App *a)
|
|
|
|
{
|
|
|
|
Ecore_Exe *exe;
|
|
|
|
|
|
|
|
E_OBJECT_CHECK_RETURN(a, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, 0);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (!a->exe) return 0;
|
2005-06-02 02:49:07 -07:00
|
|
|
/* FIXME: set up locale, encoding and input method env vars if they are in
|
|
|
|
* the eapp file */
|
2004-11-24 19:37:45 -08:00
|
|
|
exe = ecore_exe_run(a->exe, a);
|
2005-06-29 00:29:10 -07:00
|
|
|
if (!exe)
|
|
|
|
{
|
|
|
|
e_error_dialog_show(_("Run Error"),
|
2005-07-11 20:53:56 -07:00
|
|
|
_("Enlightenment was unable fork a child process:\n"
|
2005-06-29 00:29:10 -07:00
|
|
|
"\n"
|
|
|
|
"%s\n"
|
|
|
|
"\n"),
|
|
|
|
a->exe);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
a->instances = evas_list_append(a->instances, exe);
|
2005-06-29 00:29:10 -07:00
|
|
|
e_object_ref(E_OBJECT(a));
|
2004-11-24 19:37:45 -08:00
|
|
|
if (a->startup_notify) a->starting = 1;
|
|
|
|
_e_app_change(a, E_APP_EXEC);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_app_starting_get(E_App *a)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(a, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, 0);
|
2004-11-24 19:37:45 -08:00
|
|
|
return a->starting;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_app_running_get(E_App *a)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(a, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, 0);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (a->instances) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-05-03 06:44:43 -07:00
|
|
|
void
|
|
|
|
e_app_prepend_relative(E_App *add, E_App *before)
|
|
|
|
{
|
2005-05-11 02:00:32 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2005-05-03 06:44:43 -07:00
|
|
|
if (!before->parent) return;
|
|
|
|
|
|
|
|
before->parent->subapps = evas_list_prepend_relative(before->parent->subapps,
|
|
|
|
add, before);
|
2005-05-03 23:54:34 -07:00
|
|
|
add->parent = before->parent;
|
2005-05-03 06:44:43 -07:00
|
|
|
|
2005-05-11 02:00:32 -07:00
|
|
|
/* Check if this app is in the trash */
|
|
|
|
if (!strncmp(add->path, _e_apps_path_trash, strlen(_e_apps_path_trash)))
|
|
|
|
{
|
|
|
|
/* Move to all */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_all, ecore_file_get_file(add->path));
|
2005-05-11 02:07:37 -07:00
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", before->parent->path, ecore_file_get_file(add->path));
|
2005-05-11 02:00:32 -07:00
|
|
|
ecore_file_mv(add->path, buf);
|
|
|
|
free(add->path);
|
|
|
|
add->path = strdup(buf);
|
|
|
|
}
|
|
|
|
|
2005-05-03 10:27:42 -07:00
|
|
|
_e_app_save_order(before->parent);
|
2005-05-03 06:44:43 -07:00
|
|
|
_e_app_change(add, E_APP_ADD);
|
|
|
|
_e_app_change(before->parent, E_APP_ORDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_app_append(E_App *add, E_App *parent)
|
|
|
|
{
|
2005-05-11 02:00:32 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2005-05-03 06:44:43 -07:00
|
|
|
parent->subapps = evas_list_append(parent->subapps, add);
|
2005-05-03 23:54:34 -07:00
|
|
|
add->parent = parent;
|
2005-05-03 06:44:43 -07:00
|
|
|
|
2005-05-11 02:00:32 -07:00
|
|
|
/* Check if this app is in the trash */
|
|
|
|
if (!strncmp(add->path, _e_apps_path_trash, strlen(_e_apps_path_trash)))
|
|
|
|
{
|
|
|
|
/* Move to all */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_all, ecore_file_get_file(add->path));
|
2005-05-11 02:07:37 -07:00
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", parent->path, ecore_file_get_file(add->path));
|
2005-05-11 02:00:32 -07:00
|
|
|
ecore_file_mv(add->path, buf);
|
|
|
|
free(add->path);
|
|
|
|
add->path = strdup(buf);
|
|
|
|
}
|
|
|
|
|
2005-05-03 10:27:42 -07:00
|
|
|
_e_app_save_order(parent);
|
2005-05-03 06:44:43 -07:00
|
|
|
_e_app_change(add, E_APP_ADD);
|
|
|
|
}
|
|
|
|
|
2005-06-10 14:26:50 -07:00
|
|
|
void
|
|
|
|
e_app_files_prepend_relative(Evas_List *files, E_App *before)
|
|
|
|
{
|
2005-06-15 18:55:19 -07:00
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!before->parent) return;
|
|
|
|
|
|
|
|
for (l = files; l; l = l->next)
|
|
|
|
{
|
|
|
|
char *file;
|
2005-06-17 17:13:04 -07:00
|
|
|
char buf[PATH_MAX];
|
2005-06-15 18:55:19 -07:00
|
|
|
|
|
|
|
file = l->data;
|
|
|
|
if (!_e_app_is_eapp(file)) continue;
|
2005-06-17 17:13:04 -07:00
|
|
|
/* FIXME: If we are downloading something from net, we must
|
|
|
|
* attach a callback and wait for the download to finish */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_all,
|
|
|
|
ecore_file_get_file(file));
|
2005-06-17 18:51:37 -07:00
|
|
|
if (!ecore_file_download(file, buf, NULL, NULL)) continue;
|
2005-06-15 18:55:19 -07:00
|
|
|
}
|
|
|
|
/* Force rescan of all subdir */
|
|
|
|
_e_app_subdir_rescan(_e_apps_all);
|
|
|
|
/* Change .order file */
|
|
|
|
if (before->parent != _e_apps_all)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.order", before->parent->path);
|
|
|
|
f = fopen(buf, "wb");
|
|
|
|
if (!f) return;
|
|
|
|
|
|
|
|
for (l = before->parent->subapps; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
Evas_List *l2;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
if (a == before)
|
|
|
|
{
|
|
|
|
/* Add the new files */
|
|
|
|
for (l2 = files; l2; l2 = l2->next)
|
|
|
|
{
|
|
|
|
char *file;
|
|
|
|
|
|
|
|
file = l2->data;
|
|
|
|
fprintf(f, "%s\n", ecore_file_get_file(file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(f, "%s\n", ecore_file_get_file(a->path));
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
2005-06-10 14:26:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_app_files_append(Evas_List *files, E_App *parent)
|
|
|
|
{
|
2005-06-17 17:13:04 -07:00
|
|
|
Evas_List *l, *subapps;
|
2005-06-15 18:55:19 -07:00
|
|
|
|
|
|
|
subapps = parent->subapps;
|
|
|
|
|
|
|
|
for (l = files; l; l = l->next)
|
|
|
|
{
|
|
|
|
char *file;
|
2005-06-17 17:13:04 -07:00
|
|
|
char buf[PATH_MAX];
|
2005-06-15 18:55:19 -07:00
|
|
|
|
|
|
|
file = l->data;
|
|
|
|
if (!_e_app_is_eapp(file)) continue;
|
2005-06-17 17:13:04 -07:00
|
|
|
/* FIXME: If we are downloading something from net, we must
|
|
|
|
* attach a callback and wait for the download to finish */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_all,
|
|
|
|
ecore_file_get_file(file));
|
|
|
|
if (!ecore_file_download(file, buf, NULL, NULL)) continue;
|
2005-06-15 18:55:19 -07:00
|
|
|
}
|
|
|
|
/* Force rescan of all subdir */
|
|
|
|
_e_app_subdir_rescan(_e_apps_all);
|
|
|
|
/* Change .order file */
|
|
|
|
if (parent != _e_apps_all)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.order", parent->path);
|
|
|
|
f = fopen(buf, "wb");
|
|
|
|
if (!f) return;
|
|
|
|
|
|
|
|
for (l = parent->subapps; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
fprintf(f, "%s\n", ecore_file_get_file(a->path));
|
|
|
|
}
|
|
|
|
/* Add the new files */
|
|
|
|
for (l = files; l; l = l->next)
|
|
|
|
{
|
|
|
|
char *file;
|
|
|
|
|
|
|
|
file = l->data;
|
|
|
|
fprintf(f, "%s\n", ecore_file_get_file(file));
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
2005-06-10 14:26:50 -07:00
|
|
|
}
|
|
|
|
|
2005-05-03 06:44:43 -07:00
|
|
|
void
|
2005-05-03 10:27:42 -07:00
|
|
|
e_app_remove(E_App *remove)
|
2005-05-03 06:44:43 -07:00
|
|
|
{
|
2005-05-11 02:00:32 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2005-05-03 10:27:42 -07:00
|
|
|
if (!remove->parent) return;
|
2005-05-03 06:44:43 -07:00
|
|
|
|
2005-05-03 10:27:42 -07:00
|
|
|
remove->parent->subapps = evas_list_remove(remove->parent->subapps, remove);
|
|
|
|
|
2005-05-11 02:00:32 -07:00
|
|
|
/* Check if this app is in a repository or in the parents dir */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", remove->parent->path, ecore_file_get_file(remove->path));
|
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
/* Move to trash */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_trash, ecore_file_get_file(remove->path));
|
|
|
|
ecore_file_mv(remove->path, buf);
|
|
|
|
free(remove->path);
|
|
|
|
remove->path = strdup(buf);
|
|
|
|
}
|
2005-05-03 10:27:42 -07:00
|
|
|
_e_app_save_order(remove->parent);
|
2005-05-03 06:44:43 -07:00
|
|
|
_e_app_change(remove, E_APP_DEL);
|
2005-05-04 04:04:08 -07:00
|
|
|
remove->parent = NULL;
|
2005-05-03 06:44:43 -07:00
|
|
|
}
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
void
|
|
|
|
e_app_change_callback_add(void (*func) (void *data, E_App *a, E_App_Change ch), void *data)
|
|
|
|
{
|
|
|
|
E_App_Callback *cb;
|
|
|
|
|
|
|
|
cb = calloc(1, sizeof(E_App_Callback));
|
|
|
|
cb->func = func;
|
|
|
|
cb->data = data;
|
|
|
|
_e_apps_change_callbacks = evas_list_append(_e_apps_change_callbacks, cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_app_change_callback_del(void (*func) (void *data, E_App *a, E_App_Change ch), void *data)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = _e_apps_change_callbacks; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App_Callback *cb;
|
|
|
|
|
|
|
|
cb = l->data;
|
|
|
|
if ((cb->func == func) && (cb->data == data))
|
|
|
|
{
|
|
|
|
if (_e_apps_callbacks_walking)
|
|
|
|
{
|
|
|
|
cb->delete_me = 1;
|
|
|
|
_e_apps_callbacks_delete_me = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_e_apps_change_callbacks = evas_list_remove_list(_e_apps_change_callbacks, l);
|
|
|
|
free(cb);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-02 02:07:51 -08:00
|
|
|
E_App *
|
2005-06-30 21:41:34 -07:00
|
|
|
e_app_window_name_class_title_role_find(char *name, char *class, char *title, char *role)
|
2004-12-02 02:07:51 -08:00
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
2005-02-07 05:51:09 -08:00
|
|
|
if (!name && !class)
|
|
|
|
return NULL;
|
|
|
|
|
2004-12-02 02:07:51 -08:00
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
2005-06-30 21:09:30 -07:00
|
|
|
int ok;
|
2004-12-02 02:07:51 -08:00
|
|
|
|
|
|
|
a = l->data;
|
2005-06-30 21:09:30 -07:00
|
|
|
ok = 0;
|
2005-06-30 21:41:34 -07:00
|
|
|
if ((a->win_name) || (a->win_class) || (a->win_title) || (a->win_role))
|
2004-12-02 02:07:51 -08:00
|
|
|
{
|
|
|
|
if ((!a->win_name) ||
|
2005-06-30 21:41:34 -07:00
|
|
|
((a->win_name) && (name) && (e_util_glob_match(name, a->win_name))))
|
2004-12-02 02:07:51 -08:00
|
|
|
ok++;
|
|
|
|
if ((!a->win_class) ||
|
2005-06-30 21:41:34 -07:00
|
|
|
((a->win_class) && (class) && (e_util_glob_match(class, a->win_class))))
|
2004-12-02 02:07:51 -08:00
|
|
|
ok++;
|
2005-06-30 21:09:30 -07:00
|
|
|
if ((!a->win_title) ||
|
|
|
|
((a->win_title) && (title) && (e_util_glob_match(title, a->win_title))))
|
|
|
|
ok++;
|
2005-06-30 21:41:34 -07:00
|
|
|
if ((!a->win_role) ||
|
|
|
|
((a->win_role) && (role) && (e_util_glob_match(role, a->win_role))))
|
|
|
|
ok++;
|
2005-06-30 21:09:30 -07:00
|
|
|
}
|
2005-06-30 21:41:34 -07:00
|
|
|
if (ok >= 4)
|
2005-06-30 21:09:30 -07:00
|
|
|
{
|
|
|
|
_e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
|
|
|
return a;
|
2004-12-02 02:07:51 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-06-02 01:25:14 -07:00
|
|
|
E_App *
|
|
|
|
e_app_file_find(char *file)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!file) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
if (a->path)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = strchr(a->path, '/');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
if (!strcmp(p, file))
|
|
|
|
{
|
|
|
|
_e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_App *
|
|
|
|
e_app_name_find(char *name)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!name) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
if (a->name)
|
|
|
|
{
|
|
|
|
if (!strcasecmp(a->name, name))
|
|
|
|
{
|
|
|
|
_e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_App *
|
|
|
|
e_app_generic_find(char *generic)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!generic) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
if (a->generic)
|
|
|
|
{
|
|
|
|
if (!strcasecmp(a->generic, generic))
|
|
|
|
{
|
|
|
|
_e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_App *
|
|
|
|
e_app_exe_find(char *exe)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!exe) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
if (a->exe)
|
|
|
|
{
|
|
|
|
if (!strcmp(a->exe, exe))
|
|
|
|
{
|
|
|
|
_e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* local subsystem functions */
|
|
|
|
static void
|
|
|
|
_e_app_free(E_App *a)
|
|
|
|
{
|
2005-04-19 08:11:45 -07:00
|
|
|
if (a->orig)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-19 08:11:45 -07:00
|
|
|
while (a->instances)
|
|
|
|
{
|
|
|
|
Ecore_Exe *exe;
|
|
|
|
|
|
|
|
exe = a->instances->data;
|
|
|
|
ecore_exe_free(exe);
|
|
|
|
a->instances = evas_list_remove_list(a->instances, a->instances);
|
|
|
|
}
|
2005-04-20 00:28:37 -07:00
|
|
|
/* If this is a copy, it shouldn't have any references! */
|
2005-04-19 08:11:45 -07:00
|
|
|
if (a->references)
|
|
|
|
printf("BUG: A eapp copy shouldn't have any references!\n");
|
|
|
|
if (a->parent)
|
|
|
|
a->parent->subapps = evas_list_remove(a->parent->subapps, a);
|
|
|
|
a->orig->references = evas_list_remove(a->orig->references, a);
|
|
|
|
e_object_unref(E_OBJECT(a->orig));
|
|
|
|
free(a);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-04-19 08:11:45 -07:00
|
|
|
else
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-19 08:11:45 -07:00
|
|
|
while (a->instances)
|
2005-02-24 01:54:58 -08:00
|
|
|
{
|
2005-04-19 08:11:45 -07:00
|
|
|
Ecore_Exe *exe;
|
|
|
|
|
|
|
|
exe = a->instances->data;
|
|
|
|
ecore_exe_free(exe);
|
|
|
|
a->instances = evas_list_remove_list(a->instances, a->instances);
|
2005-02-24 01:54:58 -08:00
|
|
|
}
|
2005-04-19 08:11:45 -07:00
|
|
|
while (a->subapps)
|
2005-02-24 01:54:58 -08:00
|
|
|
{
|
2005-04-19 08:11:45 -07:00
|
|
|
E_App *a2;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
2005-04-19 08:11:45 -07:00
|
|
|
a2 = a->subapps->data;
|
|
|
|
a->subapps = evas_list_remove_list(a->subapps, a->subapps);
|
|
|
|
/* remove us as the parent */
|
|
|
|
a2->parent = NULL;
|
|
|
|
/* unref the child so it will be deleted too */
|
|
|
|
e_object_unref(E_OBJECT(a2));
|
|
|
|
}
|
|
|
|
/* If this is an original, it wont be deleted until all references
|
|
|
|
* are gone */
|
|
|
|
if (a->references)
|
2005-04-20 00:28:37 -07:00
|
|
|
{
|
|
|
|
printf("BUG: An original eapp shouldn't have any references when freed! %d\n", evas_list_count(a->references));
|
|
|
|
}
|
2005-04-19 08:11:45 -07:00
|
|
|
|
|
|
|
if (a->parent)
|
|
|
|
a->parent->subapps = evas_list_remove(a->parent->subapps, a);
|
|
|
|
if (a->monitor)
|
|
|
|
ecore_file_monitor_del(a->monitor);
|
|
|
|
_e_apps = evas_hash_del(_e_apps, a->path, a);
|
|
|
|
_e_apps_list = evas_list_remove(_e_apps_list, a);
|
|
|
|
_e_app_fields_empty(a);
|
2005-07-30 00:46:05 -07:00
|
|
|
IF_FREE(a->path);
|
2005-04-19 08:11:45 -07:00
|
|
|
free(a);
|
2005-02-21 08:21:13 -08:00
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-02-21 08:21:13 -08:00
|
|
|
_e_app_fields_fill(E_App *a, const char *path)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2004-12-01 20:24:54 -08:00
|
|
|
Eet_File *ef;
|
2005-02-21 08:21:13 -08:00
|
|
|
char buf[PATH_MAX];
|
2004-12-01 20:24:54 -08:00
|
|
|
char *str, *v;
|
2004-11-24 19:37:45 -08:00
|
|
|
char *lang;
|
2004-12-01 20:24:54 -08:00
|
|
|
int size;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* get our current language */
|
|
|
|
lang = getenv("LANG");
|
|
|
|
/* if its "C" its the default - so drop it */
|
|
|
|
if ((lang) && (!strcmp(lang, "C")))
|
|
|
|
lang = NULL;
|
2005-01-21 21:21:48 -08:00
|
|
|
if (!path) path = a->path;
|
|
|
|
ef = eet_open(path, EET_FILE_MODE_READ);
|
2004-12-01 20:24:54 -08:00
|
|
|
if (!ef) return;
|
2004-12-10 08:34:36 -08:00
|
|
|
|
2004-12-10 08:24:00 -08:00
|
|
|
if (lang)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "app/info/name[%s]", lang);
|
|
|
|
v = eet_read(ef, buf, &size);
|
2004-12-10 20:02:26 -08:00
|
|
|
if (!v) v = eet_read(ef, "app/info/name", &size);
|
2004-12-10 08:24:00 -08:00
|
|
|
}
|
|
|
|
else
|
2004-12-10 08:34:36 -08:00
|
|
|
v = eet_read(ef, "app/info/name", &size);
|
2004-12-01 20:24:54 -08:00
|
|
|
if (v)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2004-12-01 20:24:54 -08:00
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->name = str;
|
|
|
|
free(v);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2004-12-10 08:34:36 -08:00
|
|
|
|
2004-12-10 08:24:00 -08:00
|
|
|
if (lang)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "app/info/generic[%s]", lang);
|
|
|
|
v = eet_read(ef, buf, &size);
|
2004-12-10 20:02:26 -08:00
|
|
|
if (!v) v = eet_read(ef, "app/info/generic", &size);
|
2004-12-10 08:24:00 -08:00
|
|
|
}
|
|
|
|
else
|
2004-12-10 08:34:36 -08:00
|
|
|
v = eet_read(ef, "app/info/generic", &size);
|
|
|
|
|
2004-12-01 20:24:54 -08:00
|
|
|
if (v)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2004-12-01 20:24:54 -08:00
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->generic = str;
|
|
|
|
free(v);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2004-12-10 08:34:36 -08:00
|
|
|
|
2004-12-10 08:24:00 -08:00
|
|
|
if (lang)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "app/info/comment[%s]", lang);
|
|
|
|
v = eet_read(ef, buf, &size);
|
2004-12-10 20:02:26 -08:00
|
|
|
if (!v) v = eet_read(ef, "app/info/comment", &size);
|
2004-12-10 08:24:00 -08:00
|
|
|
}
|
|
|
|
else
|
2004-12-10 08:34:36 -08:00
|
|
|
v = eet_read(ef, "app/info/comment", &size);
|
|
|
|
|
2004-12-01 20:24:54 -08:00
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->comment = str;
|
|
|
|
free(v);
|
|
|
|
}
|
2004-12-10 08:34:36 -08:00
|
|
|
|
2004-12-01 20:24:54 -08:00
|
|
|
v = eet_read(ef, "app/info/exe", &size);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->exe = str;
|
|
|
|
free(v);
|
|
|
|
}
|
2005-07-30 00:46:05 -07:00
|
|
|
v = eet_read(ef, "app/icon/class", &size);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->icon_class = str;
|
|
|
|
free(v);
|
|
|
|
}
|
2004-12-01 20:24:54 -08:00
|
|
|
v = eet_read(ef, "app/window/name", &size);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->win_name = str;
|
|
|
|
free(v);
|
|
|
|
}
|
|
|
|
v = eet_read(ef, "app/window/class", &size);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->win_class = str;
|
|
|
|
free(v);
|
|
|
|
}
|
2005-06-30 21:09:30 -07:00
|
|
|
v = eet_read(ef, "app/window/title", &size);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->win_title = str;
|
|
|
|
free(v);
|
|
|
|
}
|
2005-06-30 21:41:34 -07:00
|
|
|
v = eet_read(ef, "app/window/role", &size);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
str = malloc(size + 1);
|
|
|
|
memcpy(str, v, size);
|
|
|
|
str[size] = 0;
|
|
|
|
a->win_role = str;
|
|
|
|
free(v);
|
|
|
|
}
|
2004-12-01 20:24:54 -08:00
|
|
|
v = eet_read(ef, "app/info/startup_notify", &size);
|
|
|
|
if (v)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2004-12-01 20:24:54 -08:00
|
|
|
a->startup_notify = *v;
|
|
|
|
free(v);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2004-12-09 05:56:06 -08:00
|
|
|
v = eet_read(ef, "app/info/wait_exit", &size);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
a->wait_exit = *v;
|
|
|
|
free(v);
|
|
|
|
}
|
2004-12-01 20:24:54 -08:00
|
|
|
eet_close(ef);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_fields_empty(E_App *a)
|
|
|
|
{
|
2005-07-30 00:46:05 -07:00
|
|
|
IF_FREE(a->name);
|
|
|
|
IF_FREE(a->generic);
|
|
|
|
IF_FREE(a->comment);
|
|
|
|
IF_FREE(a->exe);
|
|
|
|
IF_FREE(a->icon_class);
|
|
|
|
IF_FREE(a->win_name);
|
|
|
|
IF_FREE(a->win_class);
|
|
|
|
IF_FREE(a->win_title);
|
|
|
|
IF_FREE(a->win_role);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2005-04-14 03:52:58 -07:00
|
|
|
static Ecore_List *
|
2005-02-21 08:21:13 -08:00
|
|
|
_e_app_dir_file_list_get(E_App *a)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-14 03:52:58 -07:00
|
|
|
Ecore_List *files, *files2;
|
|
|
|
char *file;
|
2004-11-24 19:37:45 -08:00
|
|
|
FILE *f;
|
2005-02-21 08:21:13 -08:00
|
|
|
char buf[PATH_MAX];
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2005-02-21 08:21:13 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.order", a->path);
|
|
|
|
files = ecore_file_ls(a->path);
|
2004-11-24 19:37:45 -08:00
|
|
|
f = fopen(buf, "rb");
|
|
|
|
if (f)
|
|
|
|
{
|
2005-04-14 03:52:58 -07:00
|
|
|
files2 = ecore_list_new();
|
2004-11-24 19:37:45 -08:00
|
|
|
while (fgets(buf, sizeof(buf), f))
|
|
|
|
{
|
|
|
|
int len;
|
2005-04-14 06:31:16 -07:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
len = strlen(buf);
|
|
|
|
if (len > 0)
|
|
|
|
{
|
2004-12-01 23:00:30 -08:00
|
|
|
if (buf[len - 1] == '\n')
|
|
|
|
{
|
|
|
|
buf[len - 1] = 0;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
if (len > 0)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
if (files)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
ecore_list_goto_first(files);
|
|
|
|
while ((file = ecore_list_current(files)))
|
2004-12-01 23:00:30 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
if (!strcmp(buf, file))
|
|
|
|
{
|
|
|
|
ecore_list_remove(files);
|
|
|
|
free(file);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ecore_list_next(files);
|
2004-12-01 23:00:30 -08:00
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-04-14 03:52:58 -07:00
|
|
|
ecore_list_append(files2, strdup(buf));
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
files2 = files;
|
|
|
|
files = NULL;
|
|
|
|
}
|
2005-04-14 03:52:58 -07:00
|
|
|
if (files)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-14 03:52:58 -07:00
|
|
|
ecore_list_goto_first(files);
|
|
|
|
while ((file = ecore_list_next(files)))
|
|
|
|
{
|
|
|
|
if (file[0] != '.')
|
|
|
|
ecore_list_append(files2, file);
|
|
|
|
else
|
|
|
|
free(file);
|
|
|
|
}
|
|
|
|
ecore_list_destroy(files);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
files = files2;
|
2005-04-20 00:28:37 -07:00
|
|
|
if (files)
|
|
|
|
ecore_list_goto_first(files);
|
2004-11-24 19:37:45 -08:00
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_App *
|
2005-03-29 22:36:58 -08:00
|
|
|
_e_app_subapp_file_find(E_App *a, const char *file)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = a->subapps; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
2005-04-19 08:11:45 -07:00
|
|
|
if ((a2->deleted) || ((a2->orig) && (a2->orig->deleted))) continue;
|
|
|
|
if (!strcmp(ecore_file_get_file(a2->path), file)) return a2;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_change(E_App *a, E_App_Change ch)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
2005-08-09 06:22:25 -07:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
_e_apps_callbacks_walking = 1;
|
|
|
|
for (l = _e_apps_change_callbacks; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App_Callback *cb;
|
|
|
|
|
|
|
|
cb = l->data;
|
|
|
|
if (!cb->delete_me)
|
|
|
|
{
|
|
|
|
cb->func(cb->data, a, ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_e_apps_callbacks_walking = 0;
|
|
|
|
if (_e_apps_callbacks_delete_me)
|
|
|
|
{
|
|
|
|
for (l = _e_apps_change_callbacks; l;)
|
|
|
|
{
|
|
|
|
E_App_Callback *cb;
|
|
|
|
Evas_List *pl;
|
|
|
|
|
|
|
|
cb = l->data;
|
|
|
|
pl = l;
|
|
|
|
l = l->next;
|
|
|
|
if (cb->delete_me)
|
|
|
|
{
|
|
|
|
_e_apps_change_callbacks = evas_list_remove_list(_e_apps_change_callbacks, pl);
|
|
|
|
free(cb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_e_apps_callbacks_delete_me = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-02-21 08:21:13 -08:00
|
|
|
_e_apps_cb_exit(void *data, int type, void *event)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-21 08:21:13 -08:00
|
|
|
Ecore_Event_Exe_Exit *ev;
|
|
|
|
E_App *a;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2005-02-21 08:21:13 -08:00
|
|
|
ev = event;
|
|
|
|
if (ev->exe)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-21 08:21:13 -08:00
|
|
|
a = ecore_exe_data_get(ev->exe);
|
|
|
|
if (a)
|
|
|
|
{
|
2005-06-29 00:29:10 -07:00
|
|
|
if (ev->exit_code == 127) /* /bin/sh uses this if cmd not found */
|
|
|
|
e_error_dialog_show(_("Run Error"),
|
|
|
|
_("Enlightenment was unable run the program:\n"
|
|
|
|
"\n"
|
|
|
|
"%s\n"
|
|
|
|
"\n"
|
|
|
|
"The command was not found\n"),
|
|
|
|
a->exe);
|
2005-02-21 08:21:13 -08:00
|
|
|
a->instances = evas_list_remove(a->instances, ev->exe);
|
|
|
|
_e_app_change(a, E_APP_EXIT);
|
2005-06-29 00:29:10 -07:00
|
|
|
e_object_unref(E_OBJECT(a));
|
2005-02-21 08:21:13 -08:00
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
return 1;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2005-02-21 08:21:13 -08:00
|
|
|
static void
|
|
|
|
_e_app_cb_monitor(void *data, Ecore_File_Monitor *em,
|
2005-03-29 22:36:58 -08:00
|
|
|
Ecore_File_Event event, const char *path)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-21 08:21:13 -08:00
|
|
|
E_App *app;
|
|
|
|
char *file;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2005-02-21 08:21:13 -08:00
|
|
|
app = data;
|
2005-04-20 00:28:37 -07:00
|
|
|
if ((!app) || (app->deleted))
|
|
|
|
{
|
|
|
|
printf("Event on a deleted eapp\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-21 08:21:13 -08:00
|
|
|
/* If this dir isn't scanned yet, no need to report changes! */
|
|
|
|
if (!app->scanned)
|
|
|
|
return;
|
|
|
|
|
|
|
|
file = ecore_file_get_file((char *)path);
|
|
|
|
if (!strcmp(file, ".order"))
|
|
|
|
{
|
2005-03-29 22:36:58 -08:00
|
|
|
if ((event == ECORE_FILE_EVENT_CREATED_FILE)
|
|
|
|
|| (event == ECORE_FILE_EVENT_DELETED_FILE)
|
|
|
|
|| (event == ECORE_FILE_EVENT_MODIFIED))
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-21 08:21:13 -08:00
|
|
|
_e_app_subdir_rescan(app);
|
|
|
|
}
|
2005-04-19 02:04:10 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("BUG: Weird event for .order: %d\n", event);
|
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
}
|
2005-06-23 19:29:27 -07:00
|
|
|
else if (!strcmp(file, ".directory.eap"))
|
2005-02-21 08:21:13 -08:00
|
|
|
{
|
2005-03-29 22:36:58 -08:00
|
|
|
if ((event == ECORE_FILE_EVENT_CREATED_FILE)
|
|
|
|
|| (event == ECORE_FILE_EVENT_MODIFIED))
|
|
|
|
{
|
|
|
|
_e_app_fields_empty(app);
|
|
|
|
_e_app_fields_fill(app, path);
|
|
|
|
_e_app_change(app, E_APP_CHANGE);
|
|
|
|
}
|
|
|
|
else if (event == ECORE_FILE_EVENT_DELETED_FILE)
|
2005-02-21 08:21:13 -08:00
|
|
|
{
|
2005-03-29 22:36:58 -08:00
|
|
|
_e_app_fields_empty(app);
|
|
|
|
app->name = strdup(ecore_file_get_file(app->path));
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-04-19 02:04:10 -07:00
|
|
|
else
|
|
|
|
{
|
2005-06-23 19:29:27 -07:00
|
|
|
printf("BUG: Weird event for .directory.eap: %d\n", event);
|
2005-04-19 02:04:10 -07:00
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-29 22:36:58 -08:00
|
|
|
if (event == ECORE_FILE_EVENT_MODIFIED)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
2005-03-29 22:36:58 -08:00
|
|
|
a2 = _e_app_subapp_file_find(app, file);
|
|
|
|
if (a2)
|
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
Evas_List *l;
|
|
|
|
|
2005-03-29 22:36:58 -08:00
|
|
|
_e_app_fields_empty(a2);
|
|
|
|
_e_app_fields_fill(a2, path);
|
|
|
|
_e_app_change(a2, E_APP_CHANGE);
|
2005-08-09 06:22:25 -07:00
|
|
|
|
2005-08-10 21:10:59 -07:00
|
|
|
for (l = a2->references; l; l = l = l->next)
|
2005-08-09 06:22:25 -07:00
|
|
|
{
|
|
|
|
E_App *a3;
|
|
|
|
|
|
|
|
a3 = l->data;
|
|
|
|
if (_e_app_copy(a3, a2))
|
|
|
|
_e_app_change(a3, E_APP_CHANGE);
|
|
|
|
}
|
2005-03-29 22:36:58 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((event == ECORE_FILE_EVENT_CREATED_FILE)
|
|
|
|
|| (event == ECORE_FILE_EVENT_CREATED_DIRECTORY))
|
|
|
|
{
|
|
|
|
/* FIXME: Check if someone wants a reference to this
|
|
|
|
* app */
|
|
|
|
_e_app_subdir_rescan(app);
|
|
|
|
}
|
2005-04-19 02:04:10 -07:00
|
|
|
else if (event == ECORE_FILE_EVENT_DELETED_FILE)
|
2005-03-29 22:36:58 -08:00
|
|
|
{
|
|
|
|
E_App *a;
|
2005-04-19 02:08:36 -07:00
|
|
|
Evas_List *l;
|
2005-03-29 22:36:58 -08:00
|
|
|
|
|
|
|
a = _e_app_subapp_file_find(app, file);
|
|
|
|
if (a)
|
|
|
|
{
|
|
|
|
a->deleted = 1;
|
2005-05-08 15:37:25 -07:00
|
|
|
for (l = a->references; l;)
|
2005-04-19 02:04:10 -07:00
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
2005-05-08 15:37:25 -07:00
|
|
|
l = l->next;
|
2005-04-20 00:28:37 -07:00
|
|
|
if (a2->parent)
|
|
|
|
_e_app_subdir_rescan(a2->parent);
|
2005-04-19 02:04:10 -07:00
|
|
|
}
|
2005-03-29 22:36:58 -08:00
|
|
|
_e_app_subdir_rescan(app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (event == ECORE_FILE_EVENT_DELETED_SELF)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-03-29 22:36:58 -08:00
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
app->deleted = 1;
|
2005-05-08 15:37:25 -07:00
|
|
|
for (l = app->references; l;)
|
2005-03-29 22:36:58 -08:00
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
2005-05-08 15:37:25 -07:00
|
|
|
l = l->next;
|
2005-04-20 00:28:37 -07:00
|
|
|
if (a2->parent)
|
|
|
|
_e_app_subdir_rescan(a2->parent);
|
2005-03-29 22:36:58 -08:00
|
|
|
}
|
2005-04-19 02:05:09 -07:00
|
|
|
if (app->parent)
|
|
|
|
_e_app_subdir_rescan(app->parent);
|
2005-04-20 00:28:37 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* A main e_app has been deleted!
|
|
|
|
* We don't unref this, the code which holds this
|
|
|
|
* eapp must do it. */
|
|
|
|
_e_app_change(app, E_APP_DEL);
|
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_subdir_rescan(E_App *app)
|
|
|
|
{
|
2005-04-14 03:52:58 -07:00
|
|
|
Ecore_List *files;
|
|
|
|
Evas_List *subapps = NULL, *changes = NULL, *l, *l2;
|
2005-02-21 08:21:13 -08:00
|
|
|
E_App_Change_Info *ch;
|
|
|
|
char buf[PATH_MAX];
|
2005-04-14 03:52:58 -07:00
|
|
|
char *s;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
|
|
|
files = _e_app_dir_file_list_get(app);
|
2005-04-20 00:28:37 -07:00
|
|
|
if (files)
|
2005-02-21 08:21:13 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
while ((s = ecore_list_next(files)))
|
2005-02-23 03:29:41 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = _e_app_subapp_file_find(app, s);
|
2005-02-21 08:21:13 -08:00
|
|
|
if (a2)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-19 08:11:45 -07:00
|
|
|
subapps = evas_list_append(subapps, a2);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
/* If we still haven't found it, it is new! */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", app->path, s);
|
|
|
|
a2 = e_app_new(buf, 1);
|
|
|
|
if (a2)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
a2->parent = app;
|
|
|
|
ch = calloc(1, sizeof(E_App_Change_Info));
|
|
|
|
ch->app = a2;
|
|
|
|
ch->change = E_APP_ADD;
|
|
|
|
e_object_ref(E_OBJECT(ch->app));
|
|
|
|
changes = evas_list_append(changes, ch);
|
|
|
|
|
|
|
|
subapps = evas_list_append(subapps, a2);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-04-20 00:28:37 -07:00
|
|
|
else
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
/* We ask for a reference! */
|
|
|
|
Evas_List *pl;
|
|
|
|
E_App *a3;
|
|
|
|
|
|
|
|
pl = _e_apps_repositories;
|
|
|
|
while ((!a2) && (pl))
|
2005-04-19 08:11:45 -07:00
|
|
|
{
|
2005-04-20 00:28:37 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", (char *)pl->data, s);
|
|
|
|
a2 = e_app_new(buf, 1);
|
|
|
|
pl = pl->next;
|
|
|
|
}
|
|
|
|
if (a2)
|
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
a3 = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
2005-04-20 00:28:37 -07:00
|
|
|
if (a3)
|
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
if (_e_app_copy(a3, a2))
|
|
|
|
{
|
|
|
|
a3->parent = app;
|
|
|
|
ch = calloc(1, sizeof(E_App_Change_Info));
|
|
|
|
ch->app = a3;
|
|
|
|
ch->change = E_APP_ADD;
|
|
|
|
e_object_ref(E_OBJECT(ch->app));
|
|
|
|
changes = evas_list_append(changes, ch);
|
|
|
|
|
|
|
|
subapps = evas_list_append(subapps, a3);
|
|
|
|
a2->references = evas_list_append(a2->references, a3);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_object_del(E_OBJECT(a3));
|
2005-04-20 00:28:37 -07:00
|
|
|
}
|
2005-04-19 08:11:45 -07:00
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
}
|
2005-04-20 00:28:37 -07:00
|
|
|
free(s);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-04-20 00:28:37 -07:00
|
|
|
ecore_list_destroy(files);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
for (l = app->subapps; l; l = l->next)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-21 08:21:13 -08:00
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
for (l2 = subapps; l2; l2 = l2->next)
|
|
|
|
if (l->data == l2->data)
|
|
|
|
{
|
|
|
|
/* We still have this app */
|
|
|
|
a2 = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (a2)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-19 02:05:53 -07:00
|
|
|
a2->deleted = 1;
|
|
|
|
ch = calloc(1, sizeof(E_App_Change_Info));
|
|
|
|
ch->app = a2;
|
|
|
|
ch->change = E_APP_DEL;
|
|
|
|
/* We don't need to ref this,
|
|
|
|
* it has an extra ref
|
|
|
|
e_object_ref(E_OBJECT(ch->app));
|
|
|
|
*/
|
|
|
|
changes = evas_list_append(changes, ch);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
}
|
2005-02-24 01:54:58 -08:00
|
|
|
/* FIXME: We only need to tell about order changes if there are! */
|
2005-02-21 08:21:13 -08:00
|
|
|
evas_list_free(app->subapps);
|
|
|
|
app->subapps = subapps;
|
|
|
|
ch = calloc(1, sizeof(E_App_Change_Info));
|
|
|
|
ch->app = app;
|
|
|
|
ch->change = E_APP_ORDER;
|
|
|
|
e_object_ref(E_OBJECT(ch->app));
|
|
|
|
changes = evas_list_append(changes, ch);
|
|
|
|
|
|
|
|
for (l = changes; l; l = l->next)
|
|
|
|
{
|
|
|
|
ch = l->data;
|
|
|
|
_e_app_change(ch->app, ch->change);
|
|
|
|
e_object_unref(E_OBJECT(ch->app));
|
|
|
|
free(ch);
|
|
|
|
}
|
|
|
|
evas_list_free(changes);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_app_is_eapp(const char *path)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = strrchr(path, '.');
|
|
|
|
if (!p)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
p++;
|
2005-06-23 19:29:27 -07:00
|
|
|
if ((strcasecmp(p, "eap")))
|
2005-02-21 08:21:13 -08:00
|
|
|
return 0;
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
return 1;
|
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
|
2005-08-09 06:22:25 -07:00
|
|
|
static int
|
|
|
|
_e_app_copy(E_App *dst, E_App *src)
|
2005-04-19 08:11:45 -07:00
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
if (src->deleted)
|
2005-04-19 08:11:45 -07:00
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
printf("BUG: This app is deleted, can't make a copy: %s\n", src->path);
|
|
|
|
return 0;
|
2005-04-19 08:11:45 -07:00
|
|
|
}
|
2005-08-09 06:22:25 -07:00
|
|
|
if (!_e_app_is_eapp(src->path))
|
2005-04-19 08:11:45 -07:00
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
printf("BUG: The app isn't an eapp: %s\n", src->path);
|
|
|
|
return 0;
|
2005-04-19 08:11:45 -07:00
|
|
|
}
|
|
|
|
|
2005-08-09 06:22:25 -07:00
|
|
|
dst->orig = src;
|
2005-04-19 08:11:45 -07:00
|
|
|
|
2005-08-09 06:22:25 -07:00
|
|
|
dst->name = src->name;
|
|
|
|
dst->generic = src->generic;
|
|
|
|
dst->comment = src->comment;
|
|
|
|
dst->exe = src->exe;
|
|
|
|
dst->path = src->path;
|
|
|
|
dst->win_name = src->win_name;
|
|
|
|
dst->win_class = src->win_class;
|
|
|
|
dst->startup_notify = src->startup_notify;
|
|
|
|
dst->wait_exit = src->wait_exit;
|
|
|
|
dst->starting = src->starting;
|
|
|
|
dst->scanned = src->scanned;
|
2005-04-19 08:11:45 -07:00
|
|
|
|
2005-08-09 06:22:25 -07:00
|
|
|
return 1;
|
2005-04-19 08:11:45 -07:00
|
|
|
}
|
2005-05-03 10:27:42 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_save_order(E_App *app)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!app) return;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.order", app->path);
|
|
|
|
f = fopen(buf, "wb");
|
|
|
|
if (!f) return;
|
|
|
|
|
|
|
|
for (l = app->subapps; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
fprintf(f, "%s\n", ecore_file_get_file(a->path));
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|