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"
|
2006-01-09 20:23:43 -08:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* 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
|
|
|
*/
|
|
|
|
|
2006-07-28 03:59:27 -07:00
|
|
|
#define DEBUG 0
|
2006-09-15 14:46:25 -07:00
|
|
|
#define NO_APP_LIST 1
|
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;
|
|
|
|
};
|
|
|
|
|
2005-09-24 21:58:18 -07:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
static void _e_app_free (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);
|
2005-10-24 18:03:50 -07:00
|
|
|
static int _e_app_new_save (E_App *a);
|
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);
|
2005-09-13 23:39:59 -07:00
|
|
|
static int _e_app_cb_event_border_add(void *data, int type, void *event);
|
|
|
|
static int _e_app_cb_expire_timer (void *data);
|
2006-03-02 04:03:48 -08:00
|
|
|
static int _e_app_exe_valid_get (const char *exe);
|
2006-06-07 02:41:26 -07:00
|
|
|
static char *_e_app_localized_val_get (Eet_File *ef, const char *lang, const char *field, int *size);
|
2006-07-28 03:59:27 -07:00
|
|
|
#if DEBUG
|
2006-06-07 02:41:26 -07:00
|
|
|
static void _e_app_print(const char *path, Ecore_File_Event event);
|
2006-07-28 03:59:27 -07:00
|
|
|
#endif
|
2006-06-11 12:30:11 -07:00
|
|
|
static void _e_app_check_order(const char *file);
|
|
|
|
static int _e_app_order_contains(E_App *a, const char *file);
|
2006-08-29 22:00:58 -07:00
|
|
|
static void _e_app_resolve_file_name(char *buf, size_t size, const char *path, const char *file);
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* local subsystem globals */
|
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;
|
2005-09-13 23:39:59 -07:00
|
|
|
static Ecore_Event_Handler *_e_apps_border_add_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;
|
2006-03-02 04:03:48 -08:00
|
|
|
static const char *_e_apps_path_all = NULL;
|
|
|
|
static const char *_e_apps_path_trash = NULL;
|
2005-09-13 23:39:59 -07:00
|
|
|
static Evas_List *_e_apps_start_pending = NULL;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2006-01-14 13:05:44 -08:00
|
|
|
#define EAP_MIN_WIDTH 8
|
|
|
|
#define EAP_MIN_HEIGHT 8
|
|
|
|
|
2005-10-24 18:03:50 -07:00
|
|
|
#define EAP_EDC_TMPL \
|
|
|
|
"images {\n" \
|
|
|
|
" image: \"%s\" COMP;\n" \
|
|
|
|
"}\n" \
|
|
|
|
"collections {\n" \
|
2005-11-05 19:40:24 -08:00
|
|
|
" group {\n" \
|
2005-10-24 18:03:50 -07:00
|
|
|
" name: \"icon\";\n" \
|
2006-01-17 02:50:58 -08:00
|
|
|
" max: %d %d;\n" \
|
2005-10-24 18:03:50 -07:00
|
|
|
" 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"
|
|
|
|
|
2005-10-25 15:01:50 -07:00
|
|
|
#define EAP_EDC_TMPL_EMPTY \
|
|
|
|
"images {\n " \
|
|
|
|
"}\n" \
|
|
|
|
"collections {\n" \
|
|
|
|
"}\n"
|
2005-10-24 18:03:50 -07:00
|
|
|
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* externally accessible functions */
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_app_init(void)
|
|
|
|
{
|
2006-09-22 12:55:11 -07:00
|
|
|
const 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);
|
2005-12-02 01:08:58 -08:00
|
|
|
_e_apps_path_trash = evas_stringshare_add(buf);
|
2004-12-01 22:35:37 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.e/e/applications/all", home);
|
2005-12-02 01:08:58 -08:00
|
|
|
_e_apps_path_all = evas_stringshare_add(buf);
|
|
|
|
_e_apps_repositories = evas_list_append(_e_apps_repositories, evas_stringshare_add(buf));
|
2006-01-12 22:38:44 -08:00
|
|
|
_e_apps_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_apps_cb_exit, NULL);
|
2005-09-13 23:39:59 -07:00
|
|
|
_e_apps_border_add_handler = ecore_event_handler_add(E_EVENT_BORDER_ADD, _e_app_cb_event_border_add, NULL);
|
2006-09-22 03:12:32 -07:00
|
|
|
ecore_desktop_instrumentation_reset();
|
2004-12-02 02:07:51 -08:00
|
|
|
_e_apps_all = e_app_new(buf, 1);
|
2006-09-16 15:48:01 -07:00
|
|
|
#if NO_APP_LIST
|
2006-09-15 14:46:25 -07:00
|
|
|
/* The list already exists, and it doesn't care what order it is in. */
|
|
|
|
if (_e_apps_all)
|
|
|
|
_e_apps_list = _e_apps_all->subapps;
|
|
|
|
#endif
|
2006-09-22 03:12:32 -07:00
|
|
|
ecore_desktop_instrumentation_print();
|
2004-11-24 19:37:45 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_app_shutdown(void)
|
|
|
|
{
|
2005-09-13 23:39:59 -07:00
|
|
|
_e_apps_start_pending = evas_list_free(_e_apps_start_pending);
|
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)
|
|
|
|
{
|
2005-12-02 01:08:58 -08:00
|
|
|
evas_stringshare_del(_e_apps_repositories->data);
|
2004-12-01 22:35:37 -08:00
|
|
|
_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-09-13 23:39:59 -07:00
|
|
|
if (_e_apps_border_add_handler)
|
|
|
|
{
|
|
|
|
ecore_event_handler_del(_e_apps_border_add_handler);
|
|
|
|
_e_apps_border_add_handler = NULL;
|
|
|
|
}
|
2005-12-02 01:08:58 -08:00
|
|
|
evas_stringshare_del(_e_apps_path_trash);
|
|
|
|
evas_stringshare_del(_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;
|
|
|
|
}
|
|
|
|
|
2006-02-14 19:11:36 -08:00
|
|
|
EAPI void
|
|
|
|
e_app_unmonitor_all(void)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
if (a->monitor)
|
|
|
|
{
|
|
|
|
ecore_file_monitor_del(a->monitor);
|
|
|
|
a->monitor = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-16 05:09:29 -07:00
|
|
|
/* FIXME: Not actualy used anywhere, should we nuke it or should we use it everywhere that an E_App is allocated? */
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2005-09-24 10:25:48 -07:00
|
|
|
e_app_raw_new(void)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
E_App *a;
|
2005-09-24 10:25:48 -07:00
|
|
|
|
|
|
|
a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2005-09-24 10:25:48 -07:00
|
|
|
e_app_new(const char *path, int scan_subdirs)
|
|
|
|
{
|
|
|
|
E_App *a;
|
2006-09-15 10:44:23 -07:00
|
|
|
struct stat st;
|
|
|
|
int stated = 0;
|
2005-09-24 10:25:48 -07:00
|
|
|
char buf[PATH_MAX];
|
2006-09-05 06:42:19 -07:00
|
|
|
|
|
|
|
if (!path) return NULL;
|
|
|
|
|
2006-09-15 10:44:23 -07:00
|
|
|
a = e_app_path_find(path);
|
|
|
|
/* Check if the cache is still valid. */
|
|
|
|
if (a)
|
|
|
|
{
|
|
|
|
if (stat(a->path, &st) >= 0)
|
|
|
|
{
|
|
|
|
stated = 1;
|
2006-09-16 19:05:19 -07:00
|
|
|
if (st.st_mtime > a->mtime)
|
|
|
|
e_app_fields_empty(a);
|
2006-09-15 10:44:23 -07:00
|
|
|
}
|
2006-09-16 19:05:19 -07:00
|
|
|
e_object_ref(E_OBJECT(a));
|
2006-09-15 10:44:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!a)
|
2005-09-24 10:25:48 -07:00
|
|
|
{
|
|
|
|
if (ecore_file_exists(path))
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-09-24 10:25:48 -07:00
|
|
|
a = E_OBJECT_ALLOC(E_App, E_APP_TYPE, _e_app_free);
|
2005-10-24 14:52:31 -07:00
|
|
|
|
2006-09-16 19:05:19 -07:00
|
|
|
if (a)
|
|
|
|
{
|
|
|
|
/* no image for now */
|
|
|
|
a->image = NULL;
|
|
|
|
a->width = 0;
|
|
|
|
a->height = 0;
|
|
|
|
/* record the path */
|
|
|
|
a->path = evas_stringshare_add(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((a) && (a->path))
|
|
|
|
{
|
|
|
|
if (ecore_file_is_dir(a->path))
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.directory.eap", path);
|
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
e_app_fields_fill(a, buf);
|
|
|
|
else
|
|
|
|
a->name = evas_stringshare_add(ecore_file_get_file(a->path));
|
|
|
|
if (scan_subdirs)
|
|
|
|
{
|
|
|
|
if (stated)
|
|
|
|
_e_app_subdir_rescan(a);
|
|
|
|
else
|
|
|
|
e_app_subdir_scan(a, scan_subdirs);
|
|
|
|
}
|
2005-09-24 10:25:48 -07:00
|
|
|
|
2006-09-16 19:05:19 -07:00
|
|
|
/* Don't monitor the all directory, all changes to that must go through e_app. */
|
|
|
|
if ((!stated) && (strcmp(_e_apps_path_all, a->path) != 0))
|
|
|
|
a->monitor = ecore_file_monitor_add(a->path, _e_app_cb_monitor, a);
|
|
|
|
}
|
|
|
|
else if (_e_app_is_eapp(path))
|
|
|
|
{
|
|
|
|
e_app_fields_fill(a, path);
|
2005-09-24 10:25:48 -07:00
|
|
|
|
2006-09-16 19:05:19 -07:00
|
|
|
/* no exe field.. not valid. drop it */
|
2006-09-03 08:57:13 -07:00
|
|
|
// if (!_e_app_exe_valid_get(a->exe))
|
2006-09-16 19:05:19 -07:00
|
|
|
// goto error;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Timestamp the cache, and no need to stat the file twice if the cache was stale. */
|
|
|
|
if ((stated) || (stat(a->path, &st) >= 0))
|
|
|
|
{
|
|
|
|
a->mtime = st.st_mtime;
|
|
|
|
stated = 1;
|
|
|
|
}
|
2006-09-15 14:46:25 -07:00
|
|
|
#if ! NO_APP_LIST
|
2006-09-16 19:05:19 -07:00
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
2006-09-15 14:46:25 -07:00
|
|
|
#endif
|
2006-09-16 19:05:19 -07:00
|
|
|
}
|
2006-09-16 17:13:52 -07:00
|
|
|
else
|
2006-09-16 19:05:19 -07:00
|
|
|
goto error;
|
2006-09-16 17:13:52 -07:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
return a;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
|
|
|
error:
|
2006-09-16 19:05:19 -07:00
|
|
|
if (a)
|
|
|
|
{
|
|
|
|
if (a->monitor) ecore_file_monitor_del(a->monitor);
|
|
|
|
if (a->path) evas_stringshare_del(a->path);
|
|
|
|
e_app_fields_empty(a);
|
|
|
|
free(a);
|
|
|
|
}
|
2005-02-21 08:21:13 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2005-10-24 14:52:31 -07:00
|
|
|
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;
|
2005-12-02 01:08:58 -08:00
|
|
|
if (path) a->path = evas_stringshare_add(path);
|
2006-07-20 04:24:28 -07:00
|
|
|
else if ((_e_apps_all) && (_e_apps_all->path))
|
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
|
2006-09-03 05:43:08 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/_new_app_%1.1f.desktop",
|
2006-07-20 04:24:28 -07:00
|
|
|
_e_apps_all->path, ecore_time_get());
|
|
|
|
a->path = evas_stringshare_add(buf);
|
2006-05-13 09:05:15 -07:00
|
|
|
}
|
|
|
|
return a;
|
2005-10-24 14:52:31 -07:00
|
|
|
}
|
|
|
|
|
2006-01-14 13:05:44 -08:00
|
|
|
EAPI void
|
|
|
|
e_app_image_size_set(E_App *a, int w, int h)
|
|
|
|
{
|
|
|
|
a->width = w;
|
|
|
|
a->height = h;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-02-21 08:21:13 -08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-09-26 03:03:49 -07:00
|
|
|
e_app_equals(E_App *app1, E_App *app2)
|
|
|
|
{
|
2005-09-28 04:09:33 -07:00
|
|
|
if ((!app1) || (!app2)) return 0;
|
2005-09-26 03:03:49 -07:00
|
|
|
return ((app1 == app2) || (app1->orig == app2) ||
|
|
|
|
(app1 == app2->orig) || (app1->orig == app2->orig));
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2004-11-24 19:37:45 -08:00
|
|
|
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];
|
2005-09-24 10:25:48 -07:00
|
|
|
|
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);
|
2006-09-15 14:46:25 -07:00
|
|
|
/* FIXME: This is probably the wrong test. */
|
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-09-24 10:25:48 -07: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;
|
|
|
|
|
2006-08-29 22:00:58 -07:00
|
|
|
_e_app_resolve_file_name(buf, sizeof(buf), a->path, s);
|
2005-04-20 00:28:37 -07:00
|
|
|
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);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(a2));
|
2005-04-20 00:28:37 -07:00
|
|
|
}
|
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
|
|
|
{
|
2006-08-29 22:00:58 -07:00
|
|
|
_e_app_resolve_file_name(buf, sizeof(buf), (char *)pl->data, s);
|
2005-04-20 00:28:37 -07:00
|
|
|
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);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(a3));
|
2005-08-09 06:22:25 -07:00
|
|
|
a2->references = evas_list_append(a2->references, a3);
|
2006-09-15 14:46:25 -07:00
|
|
|
#if ! NO_APP_LIST
|
2005-09-26 02:13:44 -07:00
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a3);
|
2006-09-15 14:46:25 -07:00
|
|
|
#endif
|
2005-08-09 06:22:25 -07:00
|
|
|
}
|
|
|
|
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
|
|
|
ecore_list_destroy(files);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-09-24 10:25:48 -07:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-09-13 23:39:59 -07:00
|
|
|
e_app_exec(E_App *a, int launch_id)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
Ecore_Exe *exe;
|
2005-09-13 23:39:59 -07:00
|
|
|
E_App_Instance *inst;
|
2006-05-13 18:13:42 -07:00
|
|
|
Evas_List *l;
|
2006-09-07 01:53:09 -07:00
|
|
|
char *command;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
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;
|
2006-09-04 12:57:22 -07:00
|
|
|
|
|
|
|
/* no exe field, don't exe it. */
|
|
|
|
if (!_e_app_exe_valid_get(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 */
|
2005-09-26 12:26:58 -07:00
|
|
|
inst = E_NEW(E_App_Instance, 1);
|
|
|
|
if (!inst) return 0;
|
2006-09-07 01:53:09 -07:00
|
|
|
|
|
|
|
if (a->desktop)
|
|
|
|
command = ecore_desktop_get_command(a->desktop, NULL, 1);
|
|
|
|
else
|
|
|
|
command = strdup(a->exe);
|
|
|
|
if (!command)
|
|
|
|
{
|
|
|
|
free(inst);
|
|
|
|
e_util_dialog_show(_("Run Error"),
|
|
|
|
_("Enlightenment was unable to process a command line:<br>"
|
|
|
|
"<br>"
|
|
|
|
"%s %s<br>"),
|
|
|
|
a->exe, (a->exe_params != NULL) ? a->exe_params : "" );
|
|
|
|
return 0;
|
|
|
|
}
|
2006-01-21 07:39:03 -08:00
|
|
|
/* We want the stdout and stderr as lines for the error dialog if it exits abnormally. */
|
2006-09-07 01:53:09 -07:00
|
|
|
exe = ecore_exe_pipe_run(command, ECORE_EXE_PIPE_AUTO | ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR | ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR_LINE_BUFFERED, inst);
|
2005-06-29 00:29:10 -07:00
|
|
|
if (!exe)
|
|
|
|
{
|
2006-09-07 01:53:09 -07:00
|
|
|
free(command);
|
2005-09-26 02:13:44 -07:00
|
|
|
free(inst);
|
2006-02-12 22:32:26 -08:00
|
|
|
e_util_dialog_show(_("Run Error"),
|
|
|
|
_("Enlightenment was unable to fork a child process:<br>"
|
|
|
|
"<br>"
|
2006-09-07 01:53:09 -07:00
|
|
|
"%s %s<br>"),
|
|
|
|
a->exe, (a->exe_params != NULL) ? a->exe_params : "" );
|
2005-06-29 00:29:10 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2006-01-21 07:39:03 -08:00
|
|
|
/* 20 lines at start and end, 20x100 limit on bytes at each end. */
|
|
|
|
ecore_exe_auto_limits_set(exe, 2000, 2000, 20, 20);
|
2005-09-28 06:11:10 -07:00
|
|
|
ecore_exe_tag_set(exe, "E/app");
|
2005-09-13 23:39:59 -07:00
|
|
|
inst->app = a;
|
|
|
|
inst->exe = exe;
|
|
|
|
inst->launch_id = launch_id;
|
|
|
|
inst->launch_time = ecore_time_get();
|
|
|
|
inst->expire_timer = ecore_timer_add(10.0, _e_app_cb_expire_timer, inst);
|
|
|
|
a->instances = evas_list_append(a->instances, inst);
|
2005-09-26 02:13:44 -07:00
|
|
|
_e_apps_start_pending = evas_list_append(_e_apps_start_pending, a);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (a->startup_notify) a->starting = 1;
|
2006-05-13 18:13:42 -07:00
|
|
|
for (l = a->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
_e_app_change(a2, E_APP_EXEC);
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
_e_app_change(a, E_APP_EXEC);
|
2006-09-07 01:53:09 -07:00
|
|
|
free(command);
|
2004-11-24 19:37:45 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-03-24 21:28:57 -08:00
|
|
|
static void
|
|
|
|
_e_app_list_prepend_relative(E_App *add, E_App *before, E_App *parent)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if ((!add) || (!parent)) return;
|
|
|
|
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;
|
|
|
|
if (a == before) fprintf(f, "%s\n", ecore_file_get_file(add->path));
|
|
|
|
fprintf(f, "%s\n", ecore_file_get_file(a->path));
|
|
|
|
}
|
|
|
|
if (before == NULL) fprintf(f, "%s\n", ecore_file_get_file(add->path));
|
|
|
|
fclose(f);
|
2006-06-07 16:30:15 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", parent->path);
|
|
|
|
ecore_file_unlink(buf);
|
2006-03-24 21:28:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_files_list_prepend_relative(Evas_List *files, E_App *before, E_App *parent)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
Evas_List *l, *l2;
|
|
|
|
|
|
|
|
if ((!files) || (!parent)) return;
|
|
|
|
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;
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
if (before == NULL)
|
|
|
|
{
|
|
|
|
/* 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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
2006-06-07 16:30:15 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", parent->path);
|
|
|
|
ecore_file_unlink(buf);
|
2006-03-24 21:28:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_files_download(Evas_List *files)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = files; l; l = l->next)
|
|
|
|
{
|
|
|
|
char *file;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
file = l->data;
|
|
|
|
if (!_e_app_is_eapp(file)) continue;
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_all,
|
|
|
|
ecore_file_get_file(file));
|
2006-04-07 05:27:20 -07:00
|
|
|
if (!ecore_file_download(file, buf, NULL, NULL, NULL)) continue;
|
2006-06-07 16:30:15 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", _e_apps_path_all);
|
|
|
|
ecore_file_unlink(buf);
|
2006-03-24 21:28:57 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_app_list_prepend_relative(E_App *add, E_App *before)
|
|
|
|
{
|
|
|
|
if ((!add) || (!before)) return;
|
|
|
|
if (!before->parent) return;
|
|
|
|
_e_app_list_prepend_relative(add, before, before->parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_app_list_append(E_App *add, E_App *parent)
|
|
|
|
{
|
|
|
|
if ((!add) || (!parent)) return;
|
|
|
|
_e_app_list_prepend_relative(add, NULL, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_app_files_list_prepend_relative(Evas_List *files, E_App *before)
|
|
|
|
{
|
|
|
|
_e_app_files_download(files);
|
|
|
|
/* Force rescan of all subdir */
|
|
|
|
_e_app_subdir_rescan(_e_apps_all);
|
|
|
|
/* Change .order file */
|
|
|
|
_e_app_files_list_prepend_relative(files, before, before->parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_app_files_list_append(Evas_List *files, E_App *parent)
|
|
|
|
{
|
|
|
|
_e_app_files_download(files);
|
|
|
|
/* Force rescan of all subdir */
|
|
|
|
_e_app_subdir_rescan(_e_apps_all);
|
|
|
|
/* Change .order file */
|
|
|
|
_e_app_files_list_prepend_relative(files, NULL, parent);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-05-03 06:44:43 -07:00
|
|
|
e_app_prepend_relative(E_App *add, E_App *before)
|
|
|
|
{
|
2005-05-11 02:00:32 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2005-09-26 20:57:03 -07:00
|
|
|
if ((!add) || (!before)) return;
|
2005-05-03 06:44:43 -07:00
|
|
|
if (!before->parent) return;
|
|
|
|
|
|
|
|
before->parent->subapps = evas_list_prepend_relative(before->parent->subapps,
|
|
|
|
add, before);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(add));
|
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);
|
2005-12-02 01:08:58 -08:00
|
|
|
evas_stringshare_del(add->path);
|
|
|
|
add->path = evas_stringshare_add(buf);
|
2005-05-11 02:00:32 -07:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-05-03 06:44:43 -07:00
|
|
|
e_app_append(E_App *add, E_App *parent)
|
|
|
|
{
|
2005-05-11 02:00:32 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2005-09-26 20:57:03 -07:00
|
|
|
if ((!add) || (!parent)) return;
|
2005-05-03 06:44:43 -07:00
|
|
|
parent->subapps = evas_list_append(parent->subapps, add);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(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);
|
2005-12-02 01:08:58 -08:00
|
|
|
evas_stringshare_del(add->path);
|
|
|
|
add->path = evas_stringshare_add(buf);
|
2005-05-11 02:00:32 -07:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-06-10 14:26:50 -07:00
|
|
|
e_app_files_prepend_relative(Evas_List *files, E_App *before)
|
|
|
|
{
|
2005-06-15 18:55:19 -07:00
|
|
|
Evas_List *l;
|
|
|
|
|
2005-09-26 20:57:03 -07:00
|
|
|
if (!before) return;
|
2005-06-15 18:55:19 -07:00
|
|
|
if (!before->parent) return;
|
|
|
|
|
2006-03-24 21:28:57 -08:00
|
|
|
_e_app_files_download(files);
|
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);
|
2006-06-07 16:30:15 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", before->parent->path);
|
|
|
|
ecore_file_unlink(buf);
|
2005-06-15 18:55:19 -07:00
|
|
|
}
|
2005-06-10 14:26:50 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-06-10 14:26:50 -07:00
|
|
|
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
|
|
|
|
2005-09-26 20:57:03 -07:00
|
|
|
if (!parent) return;
|
2005-06-15 18:55:19 -07:00
|
|
|
subapps = parent->subapps;
|
|
|
|
|
2006-03-24 21:28:57 -08:00
|
|
|
_e_app_files_download(files);
|
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);
|
2006-06-07 16:30:15 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", parent->path);
|
|
|
|
ecore_file_unlink(buf);
|
2005-06-15 18:55:19 -07:00
|
|
|
}
|
2005-06-10 14:26:50 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-09-27 20:35:16 -07:00
|
|
|
e_app_remove(E_App *a)
|
2005-05-03 06:44:43 -07:00
|
|
|
{
|
2006-05-13 18:13:42 -07:00
|
|
|
Evas_List *l;
|
2005-05-11 02:00:32 -07:00
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2005-09-27 20:35:16 -07:00
|
|
|
if (!a) return;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK(a);
|
|
|
|
E_OBJECT_TYPE_CHECK(a, E_APP_TYPE);
|
2005-09-27 20:35:16 -07:00
|
|
|
if (!a->parent) return;
|
2005-05-03 06:44:43 -07:00
|
|
|
|
2005-09-27 20:35:16 -07:00
|
|
|
a->parent->subapps = evas_list_remove(a->parent->subapps, a);
|
2005-05-11 02:00:32 -07:00
|
|
|
/* Check if this app is in a repository or in the parents dir */
|
2005-09-27 20:35:16 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", a->parent->path, ecore_file_get_file(a->path));
|
2005-05-11 02:00:32 -07:00
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
/* Move to trash */
|
2005-09-27 20:35:16 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_path_trash, ecore_file_get_file(a->path));
|
|
|
|
ecore_file_mv(a->path, buf);
|
2005-12-02 01:08:58 -08:00
|
|
|
evas_stringshare_del(a->path);
|
|
|
|
a->path = evas_stringshare_add(buf);
|
2005-09-27 20:35:16 -07:00
|
|
|
}
|
|
|
|
_e_app_save_order(a->parent);
|
2006-05-13 18:13:42 -07:00
|
|
|
for (l = a->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
e_app_remove(a2);
|
|
|
|
}
|
2006-06-07 16:30:15 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", a->parent->path);
|
|
|
|
ecore_file_unlink(buf);
|
2005-09-27 20:35:16 -07:00
|
|
|
_e_app_change(a, E_APP_DEL);
|
|
|
|
a->parent = NULL;
|
2006-05-13 18:13:42 -07:00
|
|
|
e_object_unref(E_OBJECT(a));
|
2005-05-03 06:44:43 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2004-11-24 19:37:45 -08:00
|
|
|
e_app_change_callback_add(void (*func) (void *data, E_App *a, E_App_Change ch), void *data)
|
|
|
|
{
|
|
|
|
E_App_Callback *cb;
|
|
|
|
|
2006-05-31 09:31:52 -07:00
|
|
|
cb = E_NEW(E_App_Callback, 1);
|
2004-11-24 19:37:45 -08:00
|
|
|
cb->func = func;
|
|
|
|
cb->data = data;
|
|
|
|
_e_apps_change_callbacks = evas_list_append(_e_apps_change_callbacks, cb);
|
|
|
|
}
|
|
|
|
|
2006-02-21 07:00:10 -08:00
|
|
|
/*
|
|
|
|
* Delete the registered callback which has been registered with the data
|
|
|
|
* given data pointer. This function will return after the first match is
|
|
|
|
* made.
|
|
|
|
*
|
|
|
|
* This will only delete the internal callback function reference. It will
|
|
|
|
* not delete the data. If the data or callback pointers can not be matched
|
|
|
|
* this function does nothing.
|
|
|
|
*
|
|
|
|
* @func pointer to function to be deleted
|
|
|
|
* @data pointer that was initialy registered with the add function
|
|
|
|
*/
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2004-11-24 19:37:45 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2005-09-26 02:13:44 -07:00
|
|
|
e_app_launch_id_pid_find(int launch_id, pid_t pid)
|
|
|
|
{
|
|
|
|
Evas_List *l, *ll;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
2005-09-28 05:45:14 -07:00
|
|
|
|
2005-09-26 02:13:44 -07:00
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-09-26 02:13:44 -07:00
|
|
|
for (ll = a->instances; ll; ll = ll->next)
|
|
|
|
{
|
|
|
|
E_App_Instance *ai;
|
|
|
|
|
|
|
|
ai = ll->data;
|
|
|
|
if (((launch_id > 0) && (ai->launch_id > 0) && (ai->launch_id == launch_id)) ||
|
|
|
|
((pid > 1) && (ai->exe) && (ecore_exe_pid_get(ai->exe) == pid)))
|
|
|
|
{
|
|
|
|
_e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
2006-09-18 17:02:40 -07:00
|
|
|
printf("e_app_launch_id_pid_find() - FOUND - %s\n", a->path);
|
2005-09-26 02:13:44 -07:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2006-09-05 07:44:28 -07:00
|
|
|
e_app_border_find(E_Border *bd)
|
2004-12-02 02:07:51 -08:00
|
|
|
{
|
2006-06-07 16:30:15 -07:00
|
|
|
Evas_List *l, *l_match = NULL;
|
|
|
|
int ok, match = 0;
|
|
|
|
E_App *a, *a_match = NULL;
|
2006-09-05 07:44:28 -07:00
|
|
|
char *title;
|
2004-12-02 02:07:51 -08:00
|
|
|
|
2006-09-05 07:44:28 -07:00
|
|
|
if ((!bd->client.icccm.name) && (!bd->client.icccm.class) &&
|
|
|
|
(!bd->client.icccm.title) && (bd->client.netwm.name) &&
|
|
|
|
(!bd->client.icccm.window_role) && (!bd->client.icccm.command.argv))
|
2005-02-07 05:51:09 -08:00
|
|
|
return NULL;
|
|
|
|
|
2006-09-05 07:44:28 -07:00
|
|
|
title = bd->client.netwm.name;
|
|
|
|
if (!title) title = bd->client.icccm.title;
|
2004-12-02 02:07:51 -08:00
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-06-30 21:09:30 -07:00
|
|
|
ok = 0;
|
2006-09-18 17:02:40 -07:00
|
|
|
if ((a->win_name) || (a->win_class) || (a->win_title) || (a->win_role) || (a->exe))
|
2004-12-02 02:07:51 -08:00
|
|
|
{
|
2006-09-05 07:44:28 -07:00
|
|
|
if ((a->win_name) && (a->win_class) &&
|
|
|
|
(bd->client.icccm.name) && (bd->client.icccm.class))
|
2006-06-07 16:30:15 -07:00
|
|
|
{
|
2006-09-05 07:44:28 -07:00
|
|
|
if ((e_util_glob_match(bd->client.icccm.name, a->win_name)) &&
|
|
|
|
(e_util_glob_match(bd->client.icccm.class, a->win_class)))
|
2006-06-07 16:30:15 -07:00
|
|
|
ok += 2;
|
|
|
|
}
|
2006-09-05 07:44:28 -07:00
|
|
|
else if ((a->win_class) && (bd->client.icccm.class))
|
2006-06-07 16:30:15 -07:00
|
|
|
{
|
2006-09-05 07:44:28 -07:00
|
|
|
if (e_util_glob_match(bd->client.icccm.class, a->win_class))
|
2006-06-07 16:30:15 -07:00
|
|
|
ok += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (//(!a->win_title) ||
|
2005-06-30 21:09:30 -07:00
|
|
|
((a->win_title) && (title) && (e_util_glob_match(title, a->win_title))))
|
|
|
|
ok++;
|
2006-06-07 16:30:15 -07:00
|
|
|
if (//(!a->win_role) ||
|
2006-09-05 07:44:28 -07:00
|
|
|
((a->win_role) && (bd->client.icccm.window_role) && (e_util_glob_match(bd->client.icccm.window_role, a->win_role))))
|
2005-06-30 21:41:34 -07:00
|
|
|
ok++;
|
2006-09-05 07:44:28 -07:00
|
|
|
if (
|
2006-09-19 14:50:20 -07:00
|
|
|
(a->exe) && (bd->client.icccm.command.argc) && (bd->client.icccm.command.argv))
|
2006-09-05 07:44:28 -07:00
|
|
|
{
|
|
|
|
char *ts, *p;
|
|
|
|
|
|
|
|
ts = alloca(strlen(a->exe) + 1);
|
|
|
|
strcpy(ts, a->exe);
|
|
|
|
p = ts;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (isspace(*p))
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
2006-09-18 17:02:40 -07:00
|
|
|
if (!strcmp(ts, bd->client.icccm.command.argv[0]))
|
2006-09-05 07:44:28 -07:00
|
|
|
ok++;
|
|
|
|
}
|
2005-06-30 21:09:30 -07:00
|
|
|
}
|
2006-06-07 16:30:15 -07:00
|
|
|
if (ok > match)
|
2005-06-30 21:09:30 -07:00
|
|
|
{
|
2006-06-07 16:30:15 -07:00
|
|
|
match = ok;
|
|
|
|
a_match = a;
|
|
|
|
l_match = l;
|
2004-12-02 02:07:51 -08:00
|
|
|
}
|
|
|
|
}
|
2006-06-07 16:30:15 -07:00
|
|
|
if ((a_match) && (l_match))
|
|
|
|
{
|
2006-06-11 23:38:50 -07:00
|
|
|
_e_apps_list = evas_list_remove_list(_e_apps_list, l_match);
|
2006-06-07 16:30:15 -07:00
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a_match);
|
|
|
|
}
|
|
|
|
return a_match;
|
2004-12-02 02:07:51 -08:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_file_find(const char *file)
|
2005-06-02 01:25:14 -07:00
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!file) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-06-02 01:25:14 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-09-15 10:44:23 -07:00
|
|
|
EAPI E_App *
|
|
|
|
e_app_path_find(const char *path)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!path) return NULL;
|
|
|
|
|
2006-09-15 14:46:25 -07:00
|
|
|
if (_e_apps_list)
|
|
|
|
{
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
2006-09-15 10:44:23 -07:00
|
|
|
|
2006-09-15 14:46:25 -07:00
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2006-09-15 14:46:25 -07:00
|
|
|
if (a->path)
|
|
|
|
{
|
|
|
|
if (!strcmp(a->path, path))
|
|
|
|
{
|
|
|
|
// _e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
|
|
|
// _e_apps_list = evas_list_prepend(_e_apps_list, a);
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-15 10:44:23 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_name_find(const char *name)
|
2005-06-02 01:25:14 -07:00
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!name) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-06-02 01:25:14 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_generic_find(const char *generic)
|
2005-06-02 01:25:14 -07:00
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!generic) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-06-02 01:25:14 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_App *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_exe_find(const char *exe)
|
2005-06-02 01:25:14 -07:00
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!exe) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-06-02 01:25:14 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-12-14 07:54:51 -08:00
|
|
|
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_List *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_name_glob_list(const char *name)
|
2005-12-14 07:54:51 -08:00
|
|
|
{
|
|
|
|
Evas_List *l, *list = NULL;
|
|
|
|
|
|
|
|
if (!name) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-12-14 07:54:51 -08:00
|
|
|
if (a->name)
|
|
|
|
{
|
|
|
|
if (e_util_glob_case_match(a->name, name))
|
|
|
|
list = evas_list_append(list, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_List *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_generic_glob_list(const char *generic)
|
2005-12-14 07:54:51 -08:00
|
|
|
{
|
|
|
|
Evas_List *l, *list = NULL;
|
|
|
|
|
|
|
|
if (!generic) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-12-14 07:54:51 -08:00
|
|
|
if (a->generic)
|
|
|
|
{
|
|
|
|
if (e_util_glob_case_match(a->generic, generic))
|
|
|
|
list = evas_list_append(list, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_List *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_exe_glob_list(const char *exe)
|
2005-12-14 07:54:51 -08:00
|
|
|
{
|
|
|
|
Evas_List *l, *list = NULL;
|
|
|
|
|
|
|
|
if (!exe) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-12-14 07:54:51 -08:00
|
|
|
if (a->exe)
|
|
|
|
{
|
|
|
|
if (e_util_glob_match(a->exe, exe))
|
|
|
|
list = evas_list_append(list, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_List *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_app_comment_glob_list(const char *comment)
|
2005-12-14 07:54:51 -08:00
|
|
|
{
|
|
|
|
Evas_List *l, *list = NULL;
|
|
|
|
|
|
|
|
if (!comment) return NULL;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a, E_APP_TYPE, NULL);
|
2005-12-14 07:54:51 -08:00
|
|
|
if (a->comment)
|
|
|
|
{
|
|
|
|
if (e_util_glob_case_match(a->comment, comment))
|
|
|
|
list = evas_list_append(list, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-09-24 10:25:48 -07: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
|
|
|
char *str, *v;
|
2006-08-14 14:56:13 -07:00
|
|
|
const char *lang, *ext;
|
2004-12-01 20:24:54 -08:00
|
|
|
int size;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* get our current language */
|
2006-03-13 05:51:22 -08:00
|
|
|
lang = e_intl_language_alias_get();
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* if its "C" its the default - so drop it */
|
2006-03-13 05:51:22 -08:00
|
|
|
if (!strcmp(lang, "C"))
|
|
|
|
{
|
|
|
|
lang = NULL;
|
|
|
|
}
|
2005-01-21 21:21:48 -08:00
|
|
|
if (!path) path = a->path;
|
2004-12-10 08:34:36 -08:00
|
|
|
|
2006-08-29 22:00:58 -07:00
|
|
|
ext = strrchr(path, '.');
|
2006-08-14 14:56:13 -07:00
|
|
|
if ((ext) && (strcmp(ext, ".desktop") == 0))
|
|
|
|
{ /* It's a .desktop file. */
|
|
|
|
Ecore_Desktop *desktop;
|
|
|
|
|
|
|
|
desktop = ecore_desktop_get(path, lang);
|
|
|
|
if (desktop)
|
|
|
|
{
|
2006-09-07 01:53:09 -07:00
|
|
|
a->desktop = desktop;
|
2006-09-16 10:37:05 -07:00
|
|
|
|
2006-08-14 14:56:13 -07:00
|
|
|
if (desktop->name) a->name = evas_stringshare_add(desktop->name);
|
|
|
|
if (desktop->generic) a->generic = evas_stringshare_add(desktop->generic);
|
|
|
|
if (desktop->comment) a->comment = evas_stringshare_add(desktop->comment);
|
|
|
|
|
|
|
|
if (desktop->exec) a->exe = evas_stringshare_add(desktop->exec);
|
2006-09-11 14:37:18 -07:00
|
|
|
if (desktop->exec_params) a->exe_params = evas_stringshare_add(desktop->exec_params);
|
2006-09-22 07:56:41 -07:00
|
|
|
if (desktop->icon) a->icon = evas_stringshare_add(desktop->icon);
|
|
|
|
if (desktop->icon_theme) a->icon_theme = evas_stringshare_add(desktop->icon_theme);
|
2006-08-14 14:56:13 -07:00
|
|
|
if (desktop->icon_class) a->icon_class = evas_stringshare_add(desktop->icon_class);
|
2006-09-01 08:06:30 -07:00
|
|
|
if (desktop->icon_path) a->icon_path = evas_stringshare_add(desktop->icon_path);
|
2006-09-13 06:51:39 -07:00
|
|
|
if (desktop->window_name) a->win_name = evas_stringshare_add(desktop->window_name);
|
2006-08-14 14:56:13 -07:00
|
|
|
if (desktop->window_class) a->win_class = evas_stringshare_add(desktop->window_class);
|
2006-09-13 06:51:39 -07:00
|
|
|
if (desktop->window_title) a->win_title = evas_stringshare_add(desktop->window_title);
|
|
|
|
if (desktop->window_role) a->win_role = evas_stringshare_add(desktop->window_role);
|
2006-09-22 07:56:41 -07:00
|
|
|
a->icon_time = desktop->icon_time;
|
2006-09-04 08:21:15 -07:00
|
|
|
a->startup_notify = desktop->startup;
|
2006-09-13 06:51:39 -07:00
|
|
|
a->wait_exit = desktop->wait_exit;
|
2006-09-25 07:17:42 -07:00
|
|
|
a->dirty_icon = 0;
|
2006-08-14 14:56:13 -07:00
|
|
|
|
|
|
|
// if (desktop->type) a->type = evas_stringshare_add(desktop->type);
|
|
|
|
// 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) \
|
2005-12-02 01:08:58 -08:00
|
|
|
if (v) \
|
2006-08-14 14:56:13 -07:00
|
|
|
{ \
|
|
|
|
str = alloca(size + 1); \
|
|
|
|
memcpy(str, (v), size); \
|
|
|
|
str[size] = 0; \
|
|
|
|
a->member = evas_stringshare_add(str); \
|
|
|
|
free(v); \
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2006-03-09 06:50:12 -08:00
|
|
|
static char *
|
|
|
|
_e_app_localized_val_get(Eet_File *ef, const char *lang, const char *field, int *size)
|
|
|
|
{
|
|
|
|
char *s, *v;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
if (lang)
|
|
|
|
{
|
|
|
|
s = e_intl_locale_canonic_get(lang, E_INTL_LOC_LANG | E_INTL_LOC_REGION);
|
|
|
|
snprintf(buf, sizeof(buf), "%s[%s]", field, s);
|
|
|
|
free(s);
|
|
|
|
v = eet_read(ef, buf, size);
|
|
|
|
if (v)
|
|
|
|
return v;
|
|
|
|
|
|
|
|
s = e_intl_locale_canonic_get(lang, E_INTL_LOC_LANG);
|
|
|
|
snprintf(buf, sizeof(buf), "%s[%s]", field, s);
|
|
|
|
free(s);
|
|
|
|
v = eet_read(ef, buf, size);
|
|
|
|
if (v)
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
/* Fall back to default locale */
|
|
|
|
return eet_read(ef, field, size);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-24 14:52:31 -07:00
|
|
|
e_app_fields_save(E_App *a)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
2006-09-03 05:43:08 -07:00
|
|
|
const char *lang, *ext = NULL;
|
2006-09-16 05:09:29 -07:00
|
|
|
int new_eap = 0;
|
2006-09-03 05:43:08 -07:00
|
|
|
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK(a);
|
|
|
|
E_OBJECT_TYPE_CHECK(a, E_APP_TYPE);
|
2006-09-03 05:43:08 -07:00
|
|
|
/* Check if it's a new one that has not been saved yet. */
|
|
|
|
if (a->path)
|
|
|
|
ext = ecore_file_get_file(a->path);
|
|
|
|
if ( (!a->path) || ((strncmp(ext, "_new_app_", 9) == 0) && (!ecore_file_exists(a->path))) )
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s.desktop", _e_apps_all->path, a->name);
|
2006-09-18 13:52:59 -07:00
|
|
|
if (a->path) evas_stringshare_del(a->path);
|
2006-09-03 05:43:08 -07:00
|
|
|
a->path = evas_stringshare_add(buf);
|
|
|
|
}
|
2006-09-16 05:09:29 -07:00
|
|
|
if (!a->path) return;
|
|
|
|
/* This still lets old ones that are not in all to be saved, but new ones are forced to be in all. */
|
|
|
|
if (!ecore_file_exists(a->path))
|
|
|
|
{
|
|
|
|
/* Force it to be in all. */
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", _e_apps_all->path, ecore_file_get_file(a->path));
|
2006-09-18 13:52:59 -07:00
|
|
|
if (a->path) evas_stringshare_del(a->path);
|
2006-09-16 05:09:29 -07:00
|
|
|
a->path = evas_stringshare_add(buf);
|
|
|
|
}
|
|
|
|
if (!a->path) return;
|
|
|
|
if (!ecore_file_exists(a->path))
|
|
|
|
{
|
|
|
|
new_eap = 1;
|
|
|
|
}
|
2005-10-26 13:10:44 -07:00
|
|
|
|
2006-08-31 05:11:20 -07:00
|
|
|
ext = strrchr(a->path, '.');
|
|
|
|
if ((ext) && (strcmp(ext, ".desktop") == 0))
|
|
|
|
{ /* It's a .desktop file. */
|
|
|
|
Ecore_Desktop *desktop;
|
|
|
|
int created = 0;
|
|
|
|
|
|
|
|
desktop = ecore_desktop_get(a->path, NULL);
|
|
|
|
if (!desktop)
|
|
|
|
{
|
|
|
|
desktop = E_NEW(Ecore_Desktop, 1);
|
2006-09-03 05:43:08 -07:00
|
|
|
desktop->original_path = strdup(a->path);
|
2006-08-31 05:11:20 -07:00
|
|
|
created = 1;
|
|
|
|
}
|
|
|
|
if (desktop)
|
|
|
|
{
|
|
|
|
desktop->name = (char *) a->name;
|
|
|
|
desktop->generic = (char *) a->generic;
|
|
|
|
desktop->comment = (char *) a->comment;
|
|
|
|
|
|
|
|
desktop->exec = (char *) a->exe;
|
2006-09-07 01:53:09 -07:00
|
|
|
desktop->exec_params = (char *) a->exe_params;
|
2006-09-22 07:56:41 -07:00
|
|
|
desktop->icon = (char *) a->icon;
|
|
|
|
desktop->icon_theme = (char *) a->icon_theme;
|
2006-08-31 05:11:20 -07:00
|
|
|
desktop->icon_class = (char *) a->icon_class;
|
|
|
|
desktop->icon_path = (char *) a->icon_path;
|
2006-09-13 06:51:39 -07:00
|
|
|
desktop->window_name = (char *) a->win_name;
|
2006-08-31 05:11:20 -07:00
|
|
|
desktop->window_class = (char *) a->win_class;
|
2006-09-13 06:51:39 -07:00
|
|
|
desktop->window_title = (char *) a->win_title;
|
|
|
|
desktop->window_role = (char *) a->win_role;
|
2006-09-22 07:56:41 -07:00
|
|
|
desktop->icon_time = a->icon_time;
|
2006-09-04 08:21:15 -07:00
|
|
|
desktop->startup = a->startup_notify;
|
2006-09-13 06:51:39 -07:00
|
|
|
desktop->wait_exit = a->wait_exit;
|
2006-08-31 05:11:20 -07:00
|
|
|
|
|
|
|
desktop->type = "Application";
|
|
|
|
// desktop.categories = a->categories;
|
|
|
|
|
|
|
|
ecore_desktop_save(desktop);
|
2006-09-25 07:17:42 -07:00
|
|
|
a->dirty_icon = 0;
|
2006-08-31 05:11:20 -07:00
|
|
|
if (created)
|
|
|
|
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);
|
|
|
|
}
|
2005-10-24 14:52:31 -07:00
|
|
|
|
2006-08-31 05:11:20 -07:00
|
|
|
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);
|
2005-10-24 14:52:31 -07:00
|
|
|
|
2006-08-31 05:11:20 -07:00
|
|
|
if (a->startup_notify)
|
|
|
|
tmp[0] = 1;
|
|
|
|
else
|
|
|
|
tmp[0] = 0;
|
|
|
|
eet_write(ef, "app/info/startup_notify", tmp, 1, 0);
|
2005-10-24 14:52:31 -07:00
|
|
|
|
2006-08-31 05:11:20 -07:00
|
|
|
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);
|
|
|
|
}
|
2005-10-24 14:52:31 -07:00
|
|
|
|
2006-09-16 05:09:29 -07:00
|
|
|
if (new_eap)
|
|
|
|
{
|
|
|
|
/* Careful, if this is being created from the border icon, this E_App is already part of the border. */
|
|
|
|
a->parent = _e_apps_all;
|
|
|
|
_e_apps_all->subapps = evas_list_append(_e_apps_all->subapps, a);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(a));
|
2006-09-16 05:09:29 -07:00
|
|
|
/* FIXME: Don't know if we need to copy and reference this since it is in the repository. */
|
|
|
|
_e_app_change(a, E_APP_ADD);
|
|
|
|
}
|
2006-09-18 13:52:59 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = a->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
if (_e_app_copy(a2, a)) _e_app_change(a2, E_APP_CHANGE);
|
|
|
|
}
|
|
|
|
if (a->orig)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = a->orig;
|
|
|
|
if (_e_app_copy(a2, a)) _e_app_change(a2, E_APP_CHANGE);
|
|
|
|
}
|
|
|
|
_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.
|
|
|
|
* B) monitoring will catch other changes.
|
|
|
|
* C) it's a waste of time.
|
|
|
|
_e_app_subdir_rescan(a->parent);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
2005-10-24 14:52:31 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-09-24 10:25:48 -07:00
|
|
|
e_app_fields_empty(E_App *a)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-12-02 01:08:58 -08:00
|
|
|
if (a->name) evas_stringshare_del(a->name);
|
|
|
|
if (a->generic) evas_stringshare_del(a->generic);
|
|
|
|
if (a->comment) evas_stringshare_del(a->comment);
|
|
|
|
if (a->exe) evas_stringshare_del(a->exe);
|
2006-09-07 01:53:09 -07:00
|
|
|
if (a->exe_params) evas_stringshare_del(a->exe_params);
|
2006-09-22 07:56:41 -07:00
|
|
|
if (a->icon_theme) evas_stringshare_del(a->icon_theme);
|
|
|
|
if (a->icon) evas_stringshare_del(a->icon);
|
2005-12-02 01:08:58 -08:00
|
|
|
if (a->icon_class) evas_stringshare_del(a->icon_class);
|
2006-08-16 02:37:14 -07:00
|
|
|
if (a->icon_path) evas_stringshare_del(a->icon_path);
|
2005-12-02 01:08:58 -08:00
|
|
|
if (a->win_name) evas_stringshare_del(a->win_name);
|
|
|
|
if (a->win_class) evas_stringshare_del(a->win_class);
|
|
|
|
if (a->win_title) evas_stringshare_del(a->win_title);
|
|
|
|
if (a->win_role) evas_stringshare_del(a->win_role);
|
2006-09-11 14:37:18 -07:00
|
|
|
a->desktop = NULL;
|
2005-12-02 01:08:58 -08:00
|
|
|
a->name = NULL;
|
|
|
|
a->generic = NULL;
|
|
|
|
a->comment = NULL;
|
|
|
|
a->exe = NULL;
|
2006-09-07 01:53:09 -07:00
|
|
|
a->exe_params = NULL;
|
2006-09-22 07:56:41 -07:00
|
|
|
a->icon_theme = NULL;
|
|
|
|
a->icon = NULL;
|
2005-12-02 01:08:58 -08:00
|
|
|
a->icon_class = NULL;
|
2006-08-16 02:37:14 -07:00
|
|
|
a->icon_path = NULL;
|
2005-12-02 01:08:58 -08:00
|
|
|
a->win_name = NULL;
|
|
|
|
a->win_class = NULL;
|
|
|
|
a->win_title = NULL;
|
|
|
|
a->win_role = NULL;
|
2006-09-25 07:17:42 -07:00
|
|
|
a->dirty_icon = 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Ecore_List *
|
2005-09-24 10:25:48 -07: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();
|
2005-10-04 14:59:15 -07:00
|
|
|
ecore_list_set_free_cb(files2, free);
|
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)))
|
|
|
|
{
|
2006-08-14 14:56:13 -07:00
|
|
|
if (ecore_file_get_file(file)[0] != '.')
|
2005-10-06 12:38:46 -07:00
|
|
|
ecore_list_append(files2, strdup(file));
|
2005-04-14 03:52:58 -07:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-09-27 20:35:16 -07:00
|
|
|
e_app_valid_exe_get(E_App *a)
|
|
|
|
{
|
2005-09-27 22:57:14 -07:00
|
|
|
char *exe;
|
|
|
|
int ok = 1;
|
|
|
|
|
2005-09-27 20:35:16 -07:00
|
|
|
if (!a->exe) return 0;
|
2005-09-27 22:57:14 -07:00
|
|
|
exe = ecore_file_app_exe_get(a->exe);
|
|
|
|
if (!exe) return 0;
|
|
|
|
ok = ecore_file_app_installed(exe);
|
|
|
|
free(exe);
|
|
|
|
return ok;
|
2005-09-27 20:35:16 -07:00
|
|
|
}
|
|
|
|
|
2006-09-02 04:58:53 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_e_app_icon_path_add(Evas *evas, E_App *a)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
char *ext;
|
|
|
|
|
|
|
|
o = e_icon_add(evas);
|
|
|
|
ext = strrchr(a->icon_path, '.');
|
|
|
|
if (ext)
|
|
|
|
{
|
|
|
|
if (strcmp(ext, ".edj") == 0)
|
|
|
|
e_icon_file_edje_set(o, a->icon_path, "icon");
|
|
|
|
else
|
|
|
|
e_icon_file_set(o, a->icon_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_icon_file_set(o, a->icon_path);
|
|
|
|
e_icon_fill_inside_set(o, 1);
|
2006-09-02 06:29:59 -07:00
|
|
|
|
2006-09-02 04:58:53 -07:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 10:37:05 -07:00
|
|
|
static void
|
|
|
|
_e_app_icon_path_add_to_menu_item(E_Menu_Item *mi, E_App *a)
|
|
|
|
{
|
|
|
|
char *ext;
|
|
|
|
|
|
|
|
ext = strrchr(a->icon_path, '.');
|
|
|
|
if (ext)
|
|
|
|
{
|
|
|
|
if (strcmp(ext, ".edj") == 0)
|
|
|
|
e_menu_item_icon_edje_set(mi, a->icon_path, "icon");
|
|
|
|
else
|
|
|
|
e_menu_item_icon_file_set(mi, a->icon_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
e_menu_item_icon_file_set(mi, a->icon_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-14 23:12:00 -08:00
|
|
|
EAPI Evas_Object *
|
|
|
|
e_app_icon_add(Evas *evas, E_App *a)
|
|
|
|
{
|
2006-09-02 06:29:59 -07:00
|
|
|
Evas_Object *o = NULL;
|
2006-09-25 07:17:42 -07:00
|
|
|
int theme_match = 0;
|
2006-09-16 13:59:40 -07:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
printf("e_app_icon_add(%s) %s %s %s\n", a->path, a->icon_class, e_config->icon_theme, a->icon_path);
|
|
|
|
#endif
|
2006-09-25 07:17:42 -07:00
|
|
|
|
|
|
|
/* First check to see if the icon theme is different. */
|
|
|
|
if ((e_config->icon_theme) && (a->icon_theme))
|
|
|
|
{
|
|
|
|
if (strcmp(e_config->icon_theme, a->icon_theme) == 0)
|
|
|
|
theme_match = 1;
|
|
|
|
}
|
|
|
|
else if ((e_config->icon_theme == NULL) && (a->icon_theme == NULL))
|
|
|
|
theme_match = 1;
|
|
|
|
|
|
|
|
/* Then check if we already know the icon path. */
|
|
|
|
if ((theme_match) && (a->icon_path) && (a->icon_path[0] != 0))
|
2006-09-03 08:57:13 -07:00
|
|
|
o = _e_app_icon_path_add(evas, a);
|
2006-09-02 04:58:53 -07:00
|
|
|
else
|
2006-09-03 08:57:13 -07:00
|
|
|
{
|
|
|
|
o = edje_object_add(evas);
|
2006-09-25 07:17:42 -07:00
|
|
|
/* Check the theme for icons. */
|
2006-09-03 08:57:13 -07:00
|
|
|
if (!e_util_edje_icon_list_set(o, a->icon_class))
|
|
|
|
{
|
|
|
|
if (edje_object_file_set(o, a->path, "icon"))
|
|
|
|
{
|
|
|
|
; /* It's a bit more obvious this way. */
|
|
|
|
}
|
|
|
|
else if (a->icon_class) /* If that fails, then this might be an FDO icon. */
|
|
|
|
{
|
2006-09-10 03:34:17 -07:00
|
|
|
char *v = NULL;
|
2006-09-03 08:57:13 -07:00
|
|
|
|
|
|
|
/* FIXME: Use a real icon size. */
|
2006-09-10 03:34:17 -07:00
|
|
|
v = (char *)ecore_desktop_icon_find(a->icon_class, NULL, e_config->icon_theme);
|
2006-09-03 08:57:13 -07:00
|
|
|
if (v)
|
2006-09-10 03:34:17 -07:00
|
|
|
{
|
2006-09-25 07:17:42 -07:00
|
|
|
if (a->icon_path) evas_stringshare_del(a->icon_path);
|
2006-09-10 03:34:17 -07:00
|
|
|
a->icon_path = evas_stringshare_add(v);
|
2006-09-25 07:17:42 -07:00
|
|
|
if (e_config->icon_theme)
|
|
|
|
{
|
|
|
|
if (a->icon_theme) evas_stringshare_del(a->icon_theme);
|
|
|
|
a->icon_theme = evas_stringshare_add(e_config->icon_theme);
|
|
|
|
}
|
|
|
|
a->dirty_icon = 1;
|
2006-09-10 03:34:17 -07:00
|
|
|
free(v);
|
|
|
|
}
|
2006-09-03 08:57:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (a->icon_path)
|
|
|
|
{
|
|
|
|
/* Free the aborted object first. */
|
|
|
|
if (o) evas_object_del(o);
|
|
|
|
o = _e_app_icon_path_add(evas, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-14 23:12:00 -08:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2006-09-01 02:01:52 -07:00
|
|
|
/* Search order? -
|
2006-09-01 21:20:10 -07:00
|
|
|
*
|
2006-09-01 02:01:52 -07:00
|
|
|
* fixed path to icon
|
2006-09-01 21:20:10 -07:00
|
|
|
* an .edj icon in ~/.e/e/icons
|
2006-09-01 02:01:52 -07:00
|
|
|
* icon_class in theme
|
|
|
|
* icon from a->path in theme
|
|
|
|
* FDO search for icon_class
|
|
|
|
*/
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_app_icon_add_to_menu_item(E_Menu_Item *mi, E_App *a)
|
|
|
|
{
|
2006-09-25 07:17:42 -07:00
|
|
|
int theme_match = 0;
|
|
|
|
|
2006-09-03 04:32:13 -07:00
|
|
|
mi->app = a;
|
2006-09-01 21:20:10 -07:00
|
|
|
/* e_menu_item_icon_edje_set() just tucks away the params, the actual call to edje_object_file_set() happens later. */
|
|
|
|
/* e_menu_item_icon_file_set() just tucks away the params, the actual call to e_icon_add() happens later. */
|
2006-09-16 10:37:05 -07:00
|
|
|
|
2006-09-16 13:59:40 -07:00
|
|
|
#if DEBUG
|
|
|
|
printf("e_app_icon_add_to_menu_item(%s) %s %s %s\n", a->path, a->icon_class, e_config->icon_theme, a->icon_path);
|
|
|
|
#endif
|
2006-09-25 07:17:42 -07:00
|
|
|
/* First check to see if the icon theme is different. */
|
|
|
|
if ((e_config->icon_theme) && (a->icon_theme))
|
|
|
|
{
|
|
|
|
if (strcmp(e_config->icon_theme, a->icon_theme) == 0)
|
|
|
|
theme_match = 1;
|
|
|
|
}
|
|
|
|
else if ((e_config->icon_theme == NULL) && (a->icon_theme == NULL))
|
|
|
|
theme_match = 1;
|
|
|
|
|
|
|
|
/* Then check if we already know the icon path. */
|
|
|
|
if ((theme_match) && (a->icon_path) && (a->icon_path[0] != 0))
|
2006-09-16 10:37:05 -07:00
|
|
|
_e_app_icon_path_add_to_menu_item(mi, a);
|
|
|
|
else
|
|
|
|
{
|
2006-09-25 07:17:42 -07:00
|
|
|
/* Check the theme for icons. */
|
2006-09-16 10:37:05 -07:00
|
|
|
if (!e_util_menu_item_edje_icon_list_set(mi, a->icon_class))
|
|
|
|
{
|
|
|
|
if (edje_file_group_exists(a->path, "icon"))
|
|
|
|
{
|
|
|
|
e_menu_item_icon_edje_set(mi, a->path, "icon");
|
|
|
|
}
|
2006-09-25 07:17:42 -07:00
|
|
|
else if ((a->icon_class)) /* If that fails, then this might be an FDO icon. */
|
2006-09-16 10:37:05 -07:00
|
|
|
{
|
|
|
|
char *v;
|
|
|
|
|
|
|
|
/* FIXME: Use a real icon size. */
|
|
|
|
v = (char *) ecore_desktop_icon_find(a->icon_class, NULL, e_config->icon_theme);
|
|
|
|
if (v)
|
|
|
|
{
|
2006-09-25 07:17:42 -07:00
|
|
|
if (a->icon_path) evas_stringshare_del(a->icon_path);
|
|
|
|
a->icon_path = evas_stringshare_add(v);
|
|
|
|
if (e_config->icon_theme)
|
|
|
|
{
|
|
|
|
if (a->icon_theme) evas_stringshare_del(a->icon_theme);
|
|
|
|
a->icon_theme = evas_stringshare_add(e_config->icon_theme);
|
|
|
|
}
|
|
|
|
a->dirty_icon = 1;
|
2006-09-16 10:37:05 -07:00
|
|
|
free(v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a->icon_path)
|
|
|
|
_e_app_icon_path_add_to_menu_item(mi, a);
|
|
|
|
}
|
|
|
|
}
|
2006-09-01 02:01:52 -07:00
|
|
|
}
|
|
|
|
|
2005-09-27 20:35:16 -07:00
|
|
|
|
|
|
|
/* local subsystem functions */
|
2005-10-24 18:03:50 -07:00
|
|
|
|
|
|
|
/* write out a new eap, code borrowed from Engrave */
|
|
|
|
static int
|
|
|
|
_e_app_new_save(E_App *a)
|
|
|
|
{
|
2006-05-13 08:20:15 -07:00
|
|
|
static char tmpn[4096];
|
2005-10-24 18:03:50 -07:00
|
|
|
int fd = 0, ret = 0;
|
|
|
|
char cmd[2048];
|
|
|
|
char ipart[512];
|
|
|
|
FILE *out = NULL;
|
2005-11-23 17:37:01 -08:00
|
|
|
char *start, *end, *imgdir = NULL;
|
2005-10-24 18:03:50 -07:00
|
|
|
int i;
|
|
|
|
|
2006-05-13 09:05:15 -07:00
|
|
|
if (!a->path) return 0;
|
2005-10-24 18:03:50 -07:00
|
|
|
strcpy(tmpn, "/tmp/eapp_edit_cc.edc-tmp-XXXXXX");
|
|
|
|
fd = mkstemp(tmpn);
|
2005-10-26 13:10:44 -07:00
|
|
|
if (fd < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Unable to create tmp file: %s\n", strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
2005-10-24 18:03:50 -07:00
|
|
|
close(fd);
|
|
|
|
|
|
|
|
out = fopen(tmpn, "w");
|
|
|
|
if (!out)
|
|
|
|
{
|
|
|
|
printf("can't open %s for writing\n", tmpn);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
2005-10-26 13:10:44 -07:00
|
|
|
if (a->image)
|
2005-10-24 18:03:50 -07:00
|
|
|
{
|
2005-10-25 15:01:50 -07:00
|
|
|
start = strchr(a->image, '/');
|
2006-05-13 08:20:15 -07:00
|
|
|
end = strrchr(a->image, '/');
|
2005-10-26 13:10:44 -07:00
|
|
|
|
2006-05-13 08:20:15 -07:00
|
|
|
if (start == end) imgdir = strdup("/");
|
|
|
|
else if ((!start) || (!end)) imgdir = strdup("");
|
2005-10-25 15:01:50 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
imgdir = malloc((end - start + 1));
|
|
|
|
if (imgdir)
|
|
|
|
{
|
|
|
|
memcpy(imgdir, start, end - start);
|
|
|
|
imgdir[end - start] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-10-26 13:10:44 -07:00
|
|
|
|
2005-11-23 17:37:01 -08:00
|
|
|
if (imgdir)
|
|
|
|
{
|
2006-05-13 08:20:15 -07:00
|
|
|
snprintf(ipart, sizeof(ipart), "-id %s",
|
|
|
|
e_util_filename_escape(imgdir));
|
2005-11-23 17:37:01 -08:00
|
|
|
free(imgdir);
|
|
|
|
}
|
2006-05-13 08:20:15 -07:00
|
|
|
else ipart[0] = 0;
|
2005-10-24 18:03:50 -07:00
|
|
|
|
2005-10-26 13:10:44 -07:00
|
|
|
if (a->image)
|
2006-01-14 13:05:44 -08:00
|
|
|
{
|
2006-05-13 08:20:15 -07:00
|
|
|
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)));
|
2006-01-14 13:05:44 -08:00
|
|
|
}
|
2005-10-25 15:01:50 -07:00
|
|
|
else
|
|
|
|
fprintf(out, EAP_EDC_TMPL_EMPTY);
|
2005-10-24 18:03:50 -07:00
|
|
|
fclose(out);
|
|
|
|
|
2006-05-13 08:20:15 -07:00
|
|
|
snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", ipart, tmpn,
|
|
|
|
e_util_filename_escape(a->path));
|
2005-10-24 18:03:50 -07:00
|
|
|
ret = system(cmd);
|
|
|
|
|
2005-10-26 13:10:44 -07:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Unable to execute edje_cc on tmp file: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
2005-10-24 18:03:50 -07:00
|
|
|
|
2006-06-07 16:30:15 -07:00
|
|
|
if (a->parent)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", a->parent->path);
|
|
|
|
ecore_file_unlink(buf);
|
|
|
|
}
|
2006-05-13 08:20:15 -07:00
|
|
|
ecore_file_unlink(tmpn);
|
2005-10-24 18:03:50 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-09-27 20:35:16 -07:00
|
|
|
static void
|
|
|
|
_e_app_free(E_App *a)
|
|
|
|
{
|
|
|
|
while (evas_list_find(_e_apps_start_pending, a))
|
|
|
|
_e_apps_start_pending = evas_list_remove(_e_apps_start_pending, a);
|
|
|
|
if (a->orig)
|
|
|
|
{
|
|
|
|
while (a->instances)
|
|
|
|
{
|
|
|
|
E_App_Instance *inst;
|
|
|
|
|
|
|
|
inst = a->instances->data;
|
|
|
|
inst->app = a->orig;
|
|
|
|
a->orig->instances = evas_list_append(a->orig->instances, inst);
|
|
|
|
a->instances = evas_list_remove_list(a->instances, a->instances);
|
|
|
|
_e_apps_start_pending = evas_list_append(_e_apps_start_pending, a->orig);
|
|
|
|
}
|
|
|
|
/* If this is a copy, it shouldn't have any references! */
|
|
|
|
if (a->references)
|
|
|
|
printf("BUG: A eapp copy shouldn't have any references!\n");
|
|
|
|
if (a->parent)
|
2006-09-18 13:52:59 -07:00
|
|
|
{
|
|
|
|
a->parent->subapps = evas_list_remove(a->parent->subapps, a);
|
|
|
|
}
|
2005-09-27 20:35:16 -07:00
|
|
|
a->orig->references = evas_list_remove(a->orig->references, a);
|
2006-09-15 14:46:25 -07:00
|
|
|
#if ! NO_APP_LIST
|
2005-09-27 20:35:16 -07:00
|
|
|
_e_apps_list = evas_list_remove(_e_apps_list, a);
|
2006-09-15 14:46:25 -07:00
|
|
|
#endif
|
2005-09-27 20:35:16 -07:00
|
|
|
e_object_unref(E_OBJECT(a->orig));
|
|
|
|
free(a);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (a->instances)
|
|
|
|
{
|
|
|
|
E_App_Instance *inst;
|
|
|
|
|
|
|
|
inst = a->instances->data;
|
|
|
|
if (inst->expire_timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(inst->expire_timer);
|
|
|
|
inst->expire_timer = NULL;
|
|
|
|
}
|
|
|
|
if (inst->exe)
|
|
|
|
{
|
2006-09-06 05:09:53 -07:00
|
|
|
ecore_exe_tag_set(inst->exe, NULL);
|
2006-09-05 03:52:51 -07:00
|
|
|
// ecore_exe_free(inst->exe);
|
2005-09-27 20:35:16 -07:00
|
|
|
inst->exe = NULL;
|
|
|
|
}
|
|
|
|
free(inst);
|
|
|
|
a->instances = evas_list_remove_list(a->instances, a->instances);
|
|
|
|
}
|
|
|
|
while (a->subapps)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
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 */
|
2006-05-13 18:13:42 -07:00
|
|
|
while (a->references)
|
2005-09-27 20:35:16 -07:00
|
|
|
{
|
2006-05-13 18:13:42 -07:00
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = a->references->data;
|
|
|
|
a2->orig = NULL;
|
|
|
|
a->references = evas_list_remove_list(a->references, a->references);
|
2005-09-27 20:35:16 -07:00
|
|
|
printf("BUG: An original eapp shouldn't have any references when freed! %d\n", evas_list_count(a->references));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a->parent)
|
|
|
|
a->parent->subapps = evas_list_remove(a->parent->subapps, a);
|
|
|
|
if (a->monitor)
|
|
|
|
ecore_file_monitor_del(a->monitor);
|
2006-09-15 14:46:25 -07:00
|
|
|
#if ! NO_APP_LIST
|
2005-09-27 20:35:16 -07:00
|
|
|
_e_apps_list = evas_list_remove(_e_apps_list, a);
|
2006-09-15 14:46:25 -07:00
|
|
|
#endif
|
2005-09-27 20:35:16 -07:00
|
|
|
e_app_fields_empty(a);
|
2005-12-02 01:08:58 -08:00
|
|
|
if (a->path) evas_stringshare_del(a->path);
|
2005-09-27 20:35:16 -07:00
|
|
|
free(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
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;
|
2006-09-18 13:52:59 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(a2, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(a2, E_APP_TYPE, NULL);
|
2005-04-19 08:11:45 -07:00
|
|
|
if ((a2->deleted) || ((a2->orig) && (a2->orig->deleted))) continue;
|
2006-08-14 14:56:13 -07:00
|
|
|
if (!strcmp(ecore_file_get_file(a2->path), ecore_file_get_file(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
|
|
|
|
2006-05-13 18:13:42 -07:00
|
|
|
if (ch == E_APP_DEL)
|
|
|
|
printf("APP_DEL %s\n", a->path);
|
|
|
|
if (ch == E_APP_CHANGE)
|
|
|
|
printf("APP_CHANGE %s\n", a->path);
|
|
|
|
if (ch == E_APP_ADD)
|
|
|
|
printf("APP_ADD %s\n", a->path);
|
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;
|
2006-05-13 18:13:42 -07:00
|
|
|
if (!cb->delete_me) cb->func(cb->data, a, ch);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2006-05-13 18:13:42 -07:00
|
|
|
Evas_List *l;
|
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;
|
|
|
|
|
2006-07-28 03:59:27 -07:00
|
|
|
#if DEBUG
|
2006-06-07 02:41:26 -07:00
|
|
|
_e_app_print(path, event);
|
|
|
|
#endif
|
|
|
|
|
2006-08-21 08:54:40 -07:00
|
|
|
file = (char *)ecore_file_get_file(path);
|
2005-02-21 08:21:13 -08:00
|
|
|
if (!strcmp(file, ".order"))
|
|
|
|
{
|
2006-06-07 01:48:52 -07: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-11-07 19:28:02 -08:00
|
|
|
_e_app_subdir_rescan(app);
|
2005-02-21 08:21:13 -08:00
|
|
|
}
|
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
|
|
|
{
|
2006-06-07 01:48:52 -07:00
|
|
|
if ((event == ECORE_FILE_EVENT_CREATED_FILE) ||
|
|
|
|
(event == ECORE_FILE_EVENT_MODIFIED))
|
2005-03-29 22:36:58 -08:00
|
|
|
{
|
2005-09-24 10:25:48 -07:00
|
|
|
e_app_fields_empty(app);
|
|
|
|
e_app_fields_fill(app, path);
|
2005-03-29 22:36:58 -08:00
|
|
|
_e_app_change(app, E_APP_CHANGE);
|
2006-05-13 18:13:42 -07:00
|
|
|
for (l = app->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
if (_e_app_copy(a2, app)) _e_app_change(a2, E_APP_CHANGE);
|
|
|
|
}
|
2005-03-29 22:36:58 -08:00
|
|
|
}
|
|
|
|
else if (event == ECORE_FILE_EVENT_DELETED_FILE)
|
2005-02-21 08:21:13 -08:00
|
|
|
{
|
2005-09-24 10:25:48 -07:00
|
|
|
e_app_fields_empty(app);
|
2005-12-02 01:08:58 -08:00
|
|
|
app->name = evas_stringshare_add(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
|
|
|
}
|
2006-02-12 22:32:26 -08:00
|
|
|
else if (!strcmp(file, ".eap.cache.cfg"))
|
|
|
|
{
|
|
|
|
/* ignore this file */
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
else
|
|
|
|
{
|
2005-03-29 22:36:58 -08:00
|
|
|
if (event == ECORE_FILE_EVENT_MODIFIED)
|
|
|
|
{
|
2005-09-27 18:55:03 -07:00
|
|
|
E_App *a;
|
2005-02-21 08:21:13 -08:00
|
|
|
|
2005-09-27 18:55:03 -07:00
|
|
|
a = _e_app_subapp_file_find(app, file);
|
|
|
|
if (a)
|
2005-03-29 22:36:58 -08:00
|
|
|
{
|
2005-08-09 06:22:25 -07:00
|
|
|
Evas_List *l;
|
|
|
|
|
2005-09-27 18:55:03 -07:00
|
|
|
e_app_fields_empty(a);
|
|
|
|
e_app_fields_fill(a, path);
|
2005-09-27 20:35:16 -07:00
|
|
|
if (!_e_app_exe_valid_get(a->exe))
|
2005-09-27 18:55:03 -07:00
|
|
|
{
|
|
|
|
a->deleted = 1;
|
|
|
|
for (l = a->references; l;)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
2005-08-09 06:22:25 -07:00
|
|
|
|
2005-09-27 18:55:03 -07:00
|
|
|
a2 = l->data;
|
|
|
|
l = l->next;
|
|
|
|
if (a2->parent)
|
|
|
|
_e_app_subdir_rescan(a2->parent);
|
|
|
|
}
|
|
|
|
_e_app_subdir_rescan(app);
|
|
|
|
}
|
|
|
|
else
|
2005-08-09 06:22:25 -07:00
|
|
|
{
|
2005-09-27 18:55:03 -07:00
|
|
|
_e_app_change(a, E_APP_CHANGE);
|
|
|
|
for (l = a->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
if (_e_app_copy(a2, a))
|
|
|
|
_e_app_change(a2, E_APP_CHANGE);
|
|
|
|
}
|
2005-11-07 19:28:02 -08:00
|
|
|
_e_app_subdir_rescan(app);
|
2005-08-09 06:22:25 -07:00
|
|
|
}
|
2005-03-29 22:36:58 -08:00
|
|
|
}
|
|
|
|
}
|
2006-06-07 01:48:52 -07:00
|
|
|
else if ((event == ECORE_FILE_EVENT_CREATED_FILE) ||
|
|
|
|
(event == ECORE_FILE_EVENT_CREATED_DIRECTORY))
|
2005-03-29 22:36:58 -08:00
|
|
|
{
|
|
|
|
_e_app_subdir_rescan(app);
|
2006-06-11 12:30:11 -07:00
|
|
|
/* If this is the all app, check if someone wants to reference this app */
|
|
|
|
if (app == _e_apps_all)
|
|
|
|
_e_app_check_order(file);
|
|
|
|
|
2005-03-29 22:36:58 -08:00
|
|
|
}
|
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
|
|
|
|
2005-09-24 10:25:48 -07: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);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(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! */
|
2006-08-29 22:00:58 -07:00
|
|
|
_e_app_resolve_file_name(buf, sizeof(buf), app->path, s);
|
2005-04-20 00:28:37 -07:00
|
|
|
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;
|
2006-05-31 09:31:52 -07:00
|
|
|
ch = E_NEW(E_App_Change_Info, 1);
|
2005-04-20 00:28:37 -07:00
|
|
|
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);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(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
|
|
|
{
|
2006-08-29 22:00:58 -07:00
|
|
|
_e_app_resolve_file_name(buf, sizeof(buf), (char *)pl->data, s);
|
2005-04-20 00:28:37 -07:00
|
|
|
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;
|
2006-05-31 09:31:52 -07:00
|
|
|
ch = E_NEW(E_App_Change_Info, 1);
|
2005-08-09 06:22:25 -07:00
|
|
|
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);
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(a3));
|
2005-08-09 06:22:25 -07:00
|
|
|
a2->references = evas_list_append(a2->references, a3);
|
2006-09-15 14:46:25 -07:00
|
|
|
#if ! NO_APP_LIST
|
2005-09-26 02:13:44 -07:00
|
|
|
_e_apps_list = evas_list_prepend(_e_apps_list, a3);
|
2006-09-15 14:46:25 -07:00
|
|
|
#endif
|
2005-08-09 06:22:25 -07:00
|
|
|
}
|
|
|
|
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
|
|
|
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 */
|
2006-09-18 21:07:25 -07:00
|
|
|
e_object_unref(E_OBJECT(a2));
|
2005-02-21 08:21:13 -08:00
|
|
|
a2 = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (a2)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-04-19 02:05:53 -07:00
|
|
|
a2->deleted = 1;
|
2006-05-31 09:31:52 -07:00
|
|
|
ch = E_NEW(E_App_Change_Info, 1);
|
2005-04-19 02:05:53 -07:00
|
|
|
ch->app = a2;
|
|
|
|
ch->change = E_APP_DEL;
|
2006-09-18 13:52:59 -07:00
|
|
|
e_object_ref(E_OBJECT(ch->app));
|
2005-04-19 02:05:53 -07:00
|
|
|
changes = evas_list_append(changes, ch);
|
2006-09-18 21:07:25 -07:00
|
|
|
e_object_unref(E_OBJECT(a2));
|
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;
|
2006-05-31 09:31:52 -07:00
|
|
|
ch = E_NEW(E_App_Change_Info, 1);
|
2005-02-21 08:21:13 -08:00
|
|
|
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;
|
|
|
|
|
2006-08-30 17:50:57 -07:00
|
|
|
if (!path)
|
|
|
|
return 0;
|
2005-02-21 08:21:13 -08:00
|
|
|
p = strrchr(path, '.');
|
|
|
|
if (!p)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
p++;
|
2006-08-14 14:56:13 -07:00
|
|
|
if ((strcasecmp(p, "eap")) && (strcasecmp(p, "desktop")))
|
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;
|
2006-09-11 14:37:18 -07:00
|
|
|
dst->desktop = src->desktop;
|
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;
|
2006-09-07 01:53:09 -07:00
|
|
|
dst->exe_params = src->exe_params;
|
2005-08-09 06:22:25 -07:00
|
|
|
dst->path = src->path;
|
|
|
|
dst->win_name = src->win_name;
|
|
|
|
dst->win_class = src->win_class;
|
2005-09-14 23:25:28 -07:00
|
|
|
dst->win_title = src->win_title;
|
|
|
|
dst->win_role = src->win_role;
|
2006-09-22 07:56:41 -07:00
|
|
|
dst->icon_theme = src->icon_theme;
|
|
|
|
dst->icon = src->icon;
|
2005-09-14 23:25:28 -07:00
|
|
|
dst->icon_class = src->icon_class;
|
2006-08-16 02:37:14 -07:00
|
|
|
dst->icon_path = src->icon_path;
|
2005-08-09 06:22:25 -07:00
|
|
|
dst->startup_notify = src->startup_notify;
|
|
|
|
dst->wait_exit = src->wait_exit;
|
2006-09-22 07:56:41 -07:00
|
|
|
dst->icon_time = src->icon_time;
|
2005-08-09 06:22:25 -07:00
|
|
|
dst->starting = src->starting;
|
|
|
|
dst->scanned = src->scanned;
|
2006-09-25 08:19:09 -07:00
|
|
|
dst->dirty_icon = src->dirty_icon;
|
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);
|
2006-06-07 16:30:15 -07:00
|
|
|
if (app->parent)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", app ->parent->path);
|
|
|
|
ecore_file_unlink(buf);
|
|
|
|
}
|
2005-05-03 10:27:42 -07:00
|
|
|
}
|
2005-09-13 23:39:59 -07:00
|
|
|
|
2005-09-26 02:13:44 -07:00
|
|
|
static int
|
|
|
|
_e_apps_cb_exit(void *data, int type, void *event)
|
|
|
|
{
|
2006-01-15 03:27:19 -08:00
|
|
|
Ecore_Exe_Event_Del *ev;
|
2005-09-28 05:48:38 -07:00
|
|
|
E_App_Instance *ai;
|
2005-09-26 02:13:44 -07:00
|
|
|
E_App *a;
|
2006-05-13 18:13:42 -07:00
|
|
|
Evas_List *l;
|
2005-09-26 08:01:40 -07:00
|
|
|
|
2005-09-26 12:26:58 -07:00
|
|
|
ev = event;
|
|
|
|
if (!ev->exe) return 1;
|
2005-09-28 06:11:10 -07:00
|
|
|
if (!(ecore_exe_tag_get(ev->exe) &&
|
|
|
|
(!strcmp(ecore_exe_tag_get(ev->exe), "E/app")))) return 1;
|
2005-09-28 05:48:38 -07:00
|
|
|
ai = ecore_exe_data_get(ev->exe);
|
|
|
|
if (!ai) return 1;
|
|
|
|
a = ai->app;
|
2005-09-26 12:26:58 -07:00
|
|
|
if (!a) return 1;
|
|
|
|
|
2006-01-25 00:22:33 -08:00
|
|
|
/* /bin/sh uses this if cmd not found */
|
|
|
|
if ((ev->exited) &&
|
|
|
|
((ev->exit_code == 127) || (ev->exit_code == 255)))
|
2006-01-21 07:39:03 -08:00
|
|
|
{
|
2006-01-25 00:22:33 -08:00
|
|
|
E_Dialog *dia;
|
|
|
|
|
2006-08-14 08:22:46 -07:00
|
|
|
dia = e_dialog_new(e_container_current_get(e_manager_current_get()), "E", "_app_run_error_dialog");
|
2006-01-25 00:22:33 -08:00
|
|
|
if (dia)
|
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
e_dialog_title_set(dia, _("Application run error"));
|
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
_("Enlightenment was unable to run the application:<br>"
|
|
|
|
"<br>"
|
|
|
|
"%s<br>"
|
|
|
|
"<br>"
|
|
|
|
"The application failed to start."),
|
|
|
|
a->exe);
|
|
|
|
e_dialog_text_set(dia, buf);
|
|
|
|
// e_dialog_icon_set(dia, "enlightenment/error", 64);
|
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
|
|
|
|
e_dialog_button_focus_num(dia, 1);
|
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Let's hope that everyhing returns this properly. */
|
|
|
|
else if (!((ev->exited) && (ev->exit_code == EXIT_SUCCESS)))
|
|
|
|
{ /* Show the error dialog with details from the exe. */
|
|
|
|
E_App_Autopsy *aut;
|
|
|
|
|
|
|
|
aut = E_NEW(E_App_Autopsy, 1);
|
|
|
|
aut->app = a;
|
|
|
|
aut->del = *ev;
|
|
|
|
aut->error = ecore_exe_event_data_get(ai->exe, ECORE_EXE_PIPE_ERROR);
|
|
|
|
aut->read = ecore_exe_event_data_get(ai->exe, ECORE_EXE_PIPE_READ);
|
2006-01-25 23:38:06 -08:00
|
|
|
e_app_error_dialog(NULL, aut);
|
2006-01-25 00:22:33 -08:00
|
|
|
}
|
2006-08-25 18:24:27 -07:00
|
|
|
a->instances = evas_list_remove(a->instances, ai);
|
|
|
|
ai->exe = NULL;
|
2005-09-28 05:48:38 -07:00
|
|
|
if (ai->expire_timer) ecore_timer_del(ai->expire_timer);
|
|
|
|
free(ai);
|
|
|
|
_e_apps_start_pending = evas_list_remove(_e_apps_start_pending, a);
|
2006-05-13 18:13:42 -07:00
|
|
|
for (l = a->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
_e_app_change(a2, E_APP_EXIT);
|
|
|
|
}
|
2005-09-26 12:26:58 -07:00
|
|
|
_e_app_change(a, E_APP_EXIT);
|
2005-09-26 02:13:44 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-09-13 23:39:59 -07:00
|
|
|
static int
|
|
|
|
_e_app_cb_event_border_add(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
E_Event_Border_Add *ev;
|
|
|
|
Evas_List *l, *ll, *removes = NULL;
|
|
|
|
E_App *a;
|
|
|
|
E_App_Instance *inst;
|
|
|
|
|
|
|
|
ev = event;
|
2005-09-29 08:01:04 -07:00
|
|
|
if (ev->border->client.netwm.startup_id <= 0) return 1;
|
2005-09-13 23:39:59 -07:00
|
|
|
for (l = _e_apps_start_pending; l; l = l->next)
|
|
|
|
{
|
|
|
|
a = l->data;
|
|
|
|
for (ll = a->instances; ll; ll = ll->next)
|
|
|
|
{
|
|
|
|
inst = ll->data;
|
2005-09-29 08:01:04 -07:00
|
|
|
if (inst->launch_id == ev->border->client.netwm.startup_id)
|
2005-09-13 23:39:59 -07:00
|
|
|
{
|
|
|
|
if (inst->expire_timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(inst->expire_timer);
|
|
|
|
inst->expire_timer = NULL;
|
|
|
|
}
|
|
|
|
removes = evas_list_append(removes, a);
|
|
|
|
e_object_ref(E_OBJECT(a));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (removes)
|
|
|
|
{
|
|
|
|
a = removes->data;
|
2006-05-13 18:13:42 -07:00
|
|
|
for (l = a->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
_e_app_change(a2, E_APP_READY);
|
|
|
|
}
|
2005-09-13 23:39:59 -07:00
|
|
|
_e_app_change(a, E_APP_READY);
|
|
|
|
_e_apps_start_pending = evas_list_remove(_e_apps_start_pending, a);
|
|
|
|
e_object_unref(E_OBJECT(a));
|
2005-09-26 02:13:44 -07:00
|
|
|
removes = evas_list_remove_list(removes, removes);
|
2005-09-13 23:39:59 -07:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_app_cb_expire_timer(void *data)
|
|
|
|
{
|
|
|
|
E_App_Instance *inst;
|
|
|
|
E_App *a;
|
2006-05-13 18:13:42 -07:00
|
|
|
Evas_List *l;
|
2005-09-13 23:39:59 -07:00
|
|
|
|
|
|
|
inst = data;
|
|
|
|
a = inst->app;
|
|
|
|
_e_apps_start_pending = evas_list_remove(_e_apps_start_pending, a);
|
|
|
|
inst->expire_timer = NULL;
|
2006-05-13 18:13:42 -07:00
|
|
|
for (l = a->references; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a2;
|
|
|
|
|
|
|
|
a2 = l->data;
|
|
|
|
_e_app_change(a2, E_APP_READY_EXPIRE);
|
|
|
|
}
|
2005-09-13 23:39:59 -07:00
|
|
|
_e_app_change(a, E_APP_READY_EXPIRE);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-09-26 12:26:58 -07:00
|
|
|
|
2005-09-27 20:35:16 -07:00
|
|
|
|
|
|
|
static int
|
2006-03-02 04:03:48 -08:00
|
|
|
_e_app_exe_valid_get(const char *exe)
|
2005-09-27 20:35:16 -07:00
|
|
|
{
|
2005-11-03 23:49:12 -08:00
|
|
|
if ((!exe) || (!exe[0])) return 0;
|
2005-09-27 20:35:16 -07:00
|
|
|
return 1;
|
|
|
|
}
|
2006-06-07 02:41:26 -07:00
|
|
|
|
2006-07-28 03:59:27 -07:00
|
|
|
#if DEBUG
|
2006-06-07 02:41:26 -07:00
|
|
|
static void
|
|
|
|
_e_app_print(const char *path, Ecore_File_Event event)
|
|
|
|
{
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case ECORE_FILE_EVENT_NONE:
|
|
|
|
printf("E_App none: %s\n", path);
|
|
|
|
break;
|
|
|
|
case ECORE_FILE_EVENT_CREATED_FILE:
|
|
|
|
printf("E_App created file: %s\n", path);
|
|
|
|
break;
|
|
|
|
case ECORE_FILE_EVENT_CREATED_DIRECTORY:
|
|
|
|
printf("E_App created directory: %s\n", path);
|
|
|
|
break;
|
|
|
|
case ECORE_FILE_EVENT_DELETED_FILE:
|
|
|
|
printf("E_App deleted file: %s\n", path);
|
|
|
|
break;
|
|
|
|
case ECORE_FILE_EVENT_DELETED_DIRECTORY:
|
|
|
|
printf("E_App deleted directory: %s\n", path);
|
|
|
|
break;
|
|
|
|
case ECORE_FILE_EVENT_DELETED_SELF:
|
|
|
|
printf("E_App deleted self: %s\n", path);
|
|
|
|
break;
|
|
|
|
case ECORE_FILE_EVENT_MODIFIED:
|
|
|
|
printf("E_App modified: %s\n", path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-07-28 03:59:27 -07:00
|
|
|
#endif
|
2006-06-11 12:30:11 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_check_order(const char *file)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = _e_apps_list; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_App *a;
|
|
|
|
|
|
|
|
a = l->data;
|
|
|
|
if (a->monitor)
|
|
|
|
{
|
|
|
|
/* This is a directory */
|
|
|
|
if (_e_app_order_contains(a, file))
|
|
|
|
_e_app_subdir_rescan(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_app_order_contains(E_App *a, const char *file)
|
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
int ret = 0;
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/.order", a->path);
|
|
|
|
if (!ecore_file_exists(buf)) return 0;
|
|
|
|
f = fopen(buf, "rb");
|
|
|
|
if (!f) return 0;
|
|
|
|
|
|
|
|
while (fgets(buf, sizeof(buf), f))
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = strlen(buf);
|
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
if (buf[len - 1] == '\n')
|
|
|
|
{
|
|
|
|
buf[len - 1] = 0;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
if (!strcmp(buf, file))
|
|
|
|
{
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
return ret;
|
|
|
|
}
|
2006-08-29 22:00:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_app_resolve_file_name(char *buf, size_t size, const char *path, const char *file)
|
|
|
|
{
|
|
|
|
size_t length;
|
|
|
|
|
|
|
|
length = strlen(path);
|
|
|
|
if (file[0] == '/')
|
|
|
|
snprintf(buf, size, "%s", file);
|
|
|
|
else if ((length > 0) && (path[length - 1] == '/'))
|
|
|
|
snprintf(buf, size, "%s%s", path, file);
|
|
|
|
else
|
|
|
|
snprintf(buf, size, "%s/%s", path, file);
|
|
|
|
}
|