From 747900bff1dcb5e5793d9b97539883cda0c7eabc Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 2 Jun 2005 08:25:14 +0000 Subject: [PATCH] an app action - that launches an app - looked up by varios means (exe, name, generic, filename) the parameters to the "app" action can be name: Gnome Terminal OR name: XMMS OR exe: xmms OR exe: gimp OR generic: Web Browser OR generic: Terminal OR file: xterm.eapp OR file: gimp.eapp as a sample... SVN revision: 15053 --- TODO | 1 - src/bin/e_actions.c | 38 ++++++++++++++-- src/bin/e_apps.c | 108 ++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_apps.h | 6 ++- 4 files changed, 148 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 6f0e70fb1..a8020658c 100644 --- a/TODO +++ b/TODO @@ -55,7 +55,6 @@ Also look at all the .c files - they have their own localized TODO lists These are in no particular order: -* add app execute action (execute eapp - not just exe line) * add locale and encoding fields to eapp files (to launch eapp in that locale+encoding) * add input method selector stuff to eapp - same as locale * libechack needs to come back - and execute all things with libehack preloads active diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c index 36f0895c9..a55d3712c 100644 --- a/src/bin/e_actions.c +++ b/src/bin/e_actions.c @@ -471,6 +471,18 @@ ACT_FN_GO_KEY(menu_show) /***************************************************************************/ ACT_FN_GO(exec) +{ + if (params) + { + Ecore_Exe *exe; + + exe = ecore_exe_run(params, NULL); + if (exe) ecore_exe_free(exe); + } +} + +/***************************************************************************/ +ACT_FN_GO(app) { E_Zone *zone; @@ -481,10 +493,28 @@ ACT_FN_GO(exec) { if (params) { - Ecore_Exe *exe; + E_App *a = NULL; + char *p, *p2; - exe = ecore_exe_run(params, NULL); - if (exe) ecore_exe_free(exe); + p2 = strdup(params); + if (p2) + { + p = strchr(p2, ' '); + if (p) + { + *p = 0; + if (!strcmp(p2, "file:")) + a = e_app_file_find(p + 1); + else if (!strcmp(p2, "name:")) + a = e_app_name_find(p + 1); + else if (!strcmp(p2, "generic:")) + a = e_app_generic_find(p + 1); + else if (!strcmp(p2, "exe:")) + a = e_app_exe_find(p + 1); + if (a) e_app_exec(a); + } + free(p2); + } } } } @@ -543,6 +573,8 @@ e_actions_init(void) ACT_GO_KEY(menu_show); ACT_GO(exec); + + ACT_GO(app); return 1; } diff --git a/src/bin/e_apps.c b/src/bin/e_apps.c index b1eecc99e..d86656973 100644 --- a/src/bin/e_apps.c +++ b/src/bin/e_apps.c @@ -429,6 +429,114 @@ e_app_window_name_class_find(char *name, char *class) return NULL; } +E_App * +e_app_file_find(char *file) +{ + Evas_List *l; + + if (!file) return NULL; + + for (l = _e_apps_list; l; l = l->next) + { + E_App *a; + + a = l->data; + if (a->path) + { + char *p; + + p = strchr(a->path, '/'); + if (p) + { + p++; + if (!strcmp(p, file)) + { + _e_apps_list = evas_list_remove_list(_e_apps_list, l); + _e_apps_list = evas_list_prepend(_e_apps_list, a); + return a; + } + } + } + } + return NULL; +} + +E_App * +e_app_name_find(char *name) +{ + Evas_List *l; + + if (!name) return NULL; + + for (l = _e_apps_list; l; l = l->next) + { + E_App *a; + + a = l->data; + if (a->name) + { + if (!strcasecmp(a->name, name)) + { + _e_apps_list = evas_list_remove_list(_e_apps_list, l); + _e_apps_list = evas_list_prepend(_e_apps_list, a); + return a; + } + } + } + return NULL; +} + +E_App * +e_app_generic_find(char *generic) +{ + Evas_List *l; + + if (!generic) return NULL; + + for (l = _e_apps_list; l; l = l->next) + { + E_App *a; + + a = l->data; + if (a->generic) + { + if (!strcasecmp(a->generic, generic)) + { + _e_apps_list = evas_list_remove_list(_e_apps_list, l); + _e_apps_list = evas_list_prepend(_e_apps_list, a); + return a; + } + } + } + return NULL; +} + +E_App * +e_app_exe_find(char *exe) +{ + Evas_List *l; + + if (!exe) return NULL; + + for (l = _e_apps_list; l; l = l->next) + { + E_App *a; + + a = l->data; + if (a->exe) + { + if (!strcmp(a->exe, exe)) + { + _e_apps_list = evas_list_remove_list(_e_apps_list, l); + _e_apps_list = evas_list_prepend(_e_apps_list, a); + return a; + } + } + } + return NULL; +} + + /* local subsystem functions */ static void _e_app_free(E_App *a) diff --git a/src/bin/e_apps.h b/src/bin/e_apps.h index e928adb42..3fec9a53e 100644 --- a/src/bin/e_apps.h +++ b/src/bin/e_apps.h @@ -73,6 +73,10 @@ EAPI void e_app_change_callback_add(void (*func) (void *data, E_App *a, E_App_ EAPI void e_app_change_callback_del(void (*func) (void *data, E_App *a, E_App_Change ch), void *data); EAPI E_App *e_app_window_name_class_find(char *name, char *class); - +EAPI E_App *e_app_file_find(char *file); +EAPI E_App *e_app_name_find(char *name); +EAPI E_App *e_app_generic_find(char *generic); +EAPI E_App *e_app_exe_find(char *exe); + #endif #endif