Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_actions.c e_config.c e_config.h e_exebuf.c e_zone.c e_zone.h Log Message: working on mr. exebuf... =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_actions.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -3 -r1.44 -r1.45 --- e_actions.c 4 Dec 2005 03:25:33 -0000 1.44 +++ e_actions.c 7 Dec 2005 13:24:58 -0000 1.45 @@ -704,26 +704,27 @@ e_desk_xy_get(bd->desk, &dx, &dy); - to_x = dx + x; to_y = dy + y; - while( ( desk = e_desk_at_xy_get(bd->zone, to_x , to_y ) ) == NULL ) + to_x = dx + x; + to_y = dy + y; + while ((desk = e_desk_at_xy_get(bd->zone, to_x, to_y )) == NULL) { // here we are out of our desktop range - while( to_x >= bd->zone->desk_x_count ) + while (to_x >= bd->zone->desk_x_count) { to_x -= bd->zone->desk_x_count; - to_y ++; + to_y++; } - while( to_x < 0 ) + while (to_x < 0) { to_x += bd->zone->desk_x_count; - to_y --; + to_y--; } - while( to_y >= bd->zone->desk_y_count ) + while (to_y >= bd->zone->desk_y_count) { to_y -= bd->zone->desk_y_count; } - while( to_y < 0 ) + while (to_y < 0) { to_y += bd->zone->desk_y_count; } @@ -732,10 +733,10 @@ if (desk) { // switch desktop. Quite usefull from the interface point of view. - e_zone_desk_flip_by( bd->zone, to_x - dx , to_y - dy ); + e_zone_desk_flip_by(bd->zone, to_x - dx, to_y - dy); // send the border to the required desktop. e_border_desk_set(bd, desk); - e_border_focus_set( bd, 1, 1); + e_border_focus_set(bd, 1, 1); } } } @@ -1325,6 +1326,16 @@ e_pointer_type_pop(man->pointer, obj, params); } +/***************************************************************************/ +ACT_FN_GO(exebuf) +{ + E_Zone *zone; + + zone = _e_actions_zone_get(obj); + if (zone) + e_exebuf_show(zone); +} + /* local subsystem globals */ static Evas_Hash *actions = NULL; static Evas_List *action_names = NULL; @@ -1418,6 +1429,8 @@ ACT_GO(pointer_resize_push); ACT_GO(pointer_resize_pop); + ACT_GO(exebuf); + return 1; } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config.c,v retrieving revision 1.129 retrieving revision 1.130 diff -u -3 -r1.129 -r1.130 --- e_config.c 4 Dec 2005 12:03:58 -0000 1.129 +++ e_config.c 7 Dec 2005 13:24:58 -0000 1.130 @@ -1017,6 +1017,15 @@ eb->params = NULL; e_config->key_bindings = evas_list_append(e_config->key_bindings, eb); + eb = E_NEW(E_Config_Binding_Key, 1); + eb->context = E_BINDING_CONTEXT_ANY; + eb->key = evas_stringshare_add("grave"); + eb->modifiers = E_BINDING_MODIFIER_ALT; + eb->any_mod = 0; + eb->action = evas_stringshare_add("exebuf"); + eb->params = NULL; + e_config->key_bindings = evas_list_append(e_config->key_bindings, eb); + /* need to support fullscreen anyway for this - ie netwm and the border * system need to handle this as well as possibly using xrandr/xvidmode */ =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config.h,v retrieving revision 1.68 retrieving revision 1.69 diff -u -3 -r1.68 -r1.69 --- e_config.h 4 Dec 2005 12:03:58 -0000 1.68 +++ e_config.h 7 Dec 2005 13:24:58 -0000 1.69 @@ -44,7 +44,7 @@ * versioning feature. the value of this is really irrelevant - just as * long as it increases every time we change something */ -#define E_CONFIG_FILE_VERSION 132 +#define E_CONFIG_FILE_VERSION 133 #define E_EVAS_ENGINE_DEFAULT 0 #define E_EVAS_ENGINE_SOFTWARE_X11 1 =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_exebuf.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_exebuf.c 6 Dec 2005 14:25:57 -0000 1.1 +++ e_exebuf.c 7 Dec 2005 13:24:58 -0000 1.2 @@ -3,8 +3,18 @@ */ #include "e.h" +/* currently default bind is alt+` buf alt+space has been suggested */ + /* local subsystem functions */ +static void _e_exebuf_matches_clear(void); +static void _e_exebuf_update(void); +static void _e_exebuf_exec(void); +static void _e_exebuf_next(void); +static void _e_exebuf_prev(void); +static void _e_exebuf_complete(void); +static void _e_exebuf_backspace(void); +static void _e_exebuf_matches_update(void); static int _e_exebuf_cb_key_down(void *data, int type, void *event); static int _e_exebuf_cb_mouse_down(void *data, int type, void *event); static int _e_exebuf_cb_mouse_up(void *data, int type, void *event); @@ -15,6 +25,13 @@ static Evas_Object *bg_object = NULL; static Evas_List *handlers = NULL; static Ecore_X_Window input_window = 0; +static char *cmd_buf = NULL; +static Evas_List *eap_matches = NULL; +static Evas_List *exe_matches = NULL; +static E_App *eap_sel = NULL; +static Ecore_List *exe_list = NULL; + +#define EXEBUFLEN 2048 /* externally accessible functions */ int @@ -35,6 +52,7 @@ { Evas_Object *o; int x, y, w, h; + Evas_Coord mw, mh; E_OBJECT_CHECK_RETURN(zone, 0); E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0); @@ -52,16 +70,35 @@ exebuf = e_popup_new(zone, x, y, w, h); if (!exebuf) return 0; + + cmd_buf = malloc(EXEBUFLEN); + if (!cmd_buf) + { + e_object_del(E_OBJECT(exebuf)); + return 0; + } + cmd_buf[0] = 0; + e_popup_layer_set(exebuf, 255); evas_event_freeze(exebuf->evas); o = edje_object_add(exebuf->evas); bg_object = o; e_theme_edje_object_set(o, "base/theme/exebuf", "widgets/exebuf/main"); + edje_object_part_text_set(o, "label", cmd_buf); + edje_object_size_min_calc(o, &mw, &mh); + + x = zone->x + 20; + y = zone->y + 20 + ((zone->h - 20 - 20 - mh) / 2); + w = zone->w - 20 - 20; + h = mh; + + e_popup_move_resize(exebuf, x, y, w, h); evas_object_move(o, 0, 0); evas_object_resize(o, w, h); evas_object_show(o); e_popup_edje_bg_object_set(exebuf, o); + evas_event_thaw(exebuf->evas); @@ -78,6 +115,8 @@ (handlers, ecore_event_handler_add (ECORE_X_EVENT_MOUSE_WHEEL, _e_exebuf_cb_mouse_wheel, NULL)); + exe_list = ecore_file_app_list(); + e_popup_show(exebuf); return 1; } @@ -102,10 +141,183 @@ ecore_x_window_del(input_window); e_grabinput_release(input_window, input_window); input_window = 0; + free(cmd_buf); + cmd_buf = NULL; + if (exe_list) + { + ecore_list_destroy(exe_list); + exe_list = NULL; + } + _e_exebuf_matches_clear(); } /* local subsystem functions */ +static void +_e_exebuf_matches_clear(void) +{ + while (eap_matches) + { + e_object_unref(E_OBJECT(eap_matches->data)); + eap_matches = evas_list_remove_list(eap_matches, eap_matches); + } + while (exe_matches) + { + free(exe_matches->data); + exe_matches = evas_list_remove_list(exe_matches, exe_matches); + } + eap_sel = NULL; +} + +static void +_e_exebuf_update(void) +{ + edje_object_part_text_set(bg_object, "label", cmd_buf); + /* FIXME: if cmd_buf is an exact match for an eap or exe display an icon + * to show it is */ + /* FIXME: display match lists. if match is exat match for cmd_buf dont + * list it as it will be matched and indicated + */ +} + +static void +_e_exebuf_exec(void) +{ + if (eap_sel) + e_zone_app_exec(exebuf->zone, eap_sel); + else + e_zone_exec(exebuf->zone, cmd_buf); + + e_exebuf_hide(); +} + +static void +_e_exebuf_next(void) +{ + char *exe = NULL; + + if (exe_matches) exe = exe_matches->data; + if (exe) + { + if (strlen(exe < (EXEBUFLEN - 1))) + { + strcpy(cmd_buf, exe); + _e_exebuf_update(); + } + } +} + +static void +_e_exebuf_prev(void) +{ +} + +static void +_e_exebuf_complete(void) +{ + char common[EXEBUFLEN], *exe; + Evas_List *l; + int orig_len, common_len, exe_len, next_char, val, pos, matches; + + strcpy(common, cmd_buf); + orig_len = common_len = strlen(common); + matches = 1; + while (matches) + { + next_char = 0; + matches = 0; + for (l = exe_matches; l; l = l->next) + { + matches = 1; + exe = l->data; + exe_len = strlen(exe); + if (exe_len > common_len) + { + val = 0; + pos = evas_string_char_next_get(exe, common_len, &val); + if (!next_char) + next_char = val; + else if (next_char != val) + { + matches = 0; + break; + } + } + else + { + matches = 0; + break; + } + } + if (matches) common_len++; + } + if ((exe) && (orig_len < common_len) && (common_len < (EXEBUFLEN - 1))) + { + strncpy(cmd_buf, exe, common_len); + cmd_buf[common_len] = 0; + _e_exebuf_update(); + _e_exebuf_matches_update(); + } +} + +static void +_e_exebuf_backspace(void) +{ + int len, val, pos; + + len = strlen(cmd_buf); + if (len > 0) + { + pos = evas_string_char_prev_get(cmd_buf, len, &val); + if ((pos < len) && (pos >= 0)) + { + cmd_buf[pos] = 0; + _e_exebuf_update(); + } + } +} + +static void +_e_exebuf_matches_update(void) +{ + char *path, *file, buf[4096]; + Evas_Hash *added = NULL; + + /* how to match: + * + * eap_matches (above the exebuf) + * match cmd_buf* for all eap->exe fields + * match cmd_buf* for all eap->name fields + * match *cmd_buf* for all eap->generic fields + * match *cmd_buf* for all eap->comment fields + * + * exe_matches (below the exebuf) + * match cmd_buf* for all executables in $PATH (exclude duplicates in eap_matches) + */ + _e_exebuf_matches_clear(); + snprintf(buf, sizeof(buf), "%s*", cmd_buf); + if (exe_list) + { + ecore_list_goto_first(exe_list); + while ((path = ecore_list_next(exe_list)) != NULL) + { + file = ecore_file_get_file(path); + if (file) + { + if (e_util_glob_match(file, buf)) + { + if (!evas_hash_find(added, file)) + { + exe_matches = evas_list_append(exe_matches, strdup(file)); + added = evas_hash_direct_add(added, file, file); + } + } + } + } + } + if (added) evas_hash_free(added); +} + static int _e_exebuf_cb_key_down(void *data, int type, void *event) { @@ -114,17 +326,41 @@ ev = event; if (ev->win != input_window) return 1; if (!strcmp(ev->keysymbol, "Up")) - e_exebuf_hide(); + _e_exebuf_prev(); else if (!strcmp(ev->keysymbol, "Down")) - e_exebuf_hide(); + _e_exebuf_next(); + else if (!strcmp(ev->keysymbol, "Prior")) + _e_exebuf_prev(); + else if (!strcmp(ev->keysymbol, "Next")) + _e_exebuf_next(); else if (!strcmp(ev->keysymbol, "Left")) - e_exebuf_hide(); + _e_exebuf_prev(); else if (!strcmp(ev->keysymbol, "Right")) - e_exebuf_hide(); + _e_exebuf_complete(); + else if (!strcmp(ev->keysymbol, "Tab")) + _e_exebuf_complete(); else if (!strcmp(ev->keysymbol, "Return")) - e_exebuf_hide(); + _e_exebuf_exec(); + else if (!strcmp(ev->keysymbol, "KP_Enter")) + _e_exebuf_exec(); else if (!strcmp(ev->keysymbol, "Escape")) e_exebuf_hide(); + else if (!strcmp(ev->keysymbol, "BackSpace")) + _e_exebuf_backspace(); + else if (!strcmp(ev->keysymbol, "Delete")) + _e_exebuf_backspace(); + else + { + if (ev->key_compose) + { + if ((strlen(cmd_buf) < (EXEBUFLEN - strlen(ev->key_compose)))) + { + strcat(cmd_buf, ev->key_compose); + _e_exebuf_update(); + _e_exebuf_matches_update(); + } + } + } return 1; } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_zone.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -3 -r1.87 -r1.88 --- e_zone.c 4 Dec 2005 12:03:58 -0000 1.87 +++ e_zone.c 7 Dec 2005 13:24:58 -0000 1.88 @@ -556,19 +556,17 @@ } int -e_zone_app_exec(E_Zone *zone, E_App *a) +e_zone_exec(E_Zone *zone, char *exe) { - int ret; + int ret = 0; char *p1, *p2; char *penv_display; - /*char *penv_ld_preload; - char *penv_ld_preload_path;*/ char buf[4096], buf2[32]; + Ecore_Exe *ex; E_OBJECT_CHECK_RETURN(zone, 0); E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0); - if (!a) return 0; if (startup_id == 0) { p1 = getenv("E_STARTUP_ID"); @@ -578,10 +576,6 @@ /* save previous env vars we need to save */ penv_display = getenv("DISPLAY"); if (penv_display) penv_display = strdup(penv_display); - /*penv_ld_preload = getenv("LD_PRELOAD"); - if (penv_ld_preload) penv_ld_preload = strdup(penv_ld_preload); - penv_ld_preload_path = getenv("LD_PRELOAD_PATH"); - if (penv_ld_preload_path) penv_ld_preload_path = strdup(penv_ld_preload_path);*/ /* set env vars */ p1 = strrchr(penv_display, ':'); @@ -605,44 +599,89 @@ else strcpy(buf, penv_display); e_util_env_set("DISPLAY", buf); -/* - snprintf(buf, sizeof(buf), "%i %i", zone->desk_x_current, zone->desk_y_current); - e_util_env_set("E_DESK", buf); - snprintf(buf, sizeof(buf), "%i", zone->num); - e_util_env_set("E_ZONE", buf); - snprintf(buf, sizeof(buf), "%i", zone->container->num); - e_util_env_set("E_CONTAINER", buf); - snprintf(buf, sizeof(buf), "%i", zone->container->manager->num); - e_util_env_set("E_MANAGER", buf); - snprintf(buf, sizeof(buf), "%i", startup_id); - e_util_env_set("E_LAUNCH_ID", buf); - snprintf(buf, sizeof(buf), "%s/enlightenment/preload", e_prefix_lib_get()); - e_util_env_set("LD_PRELOAD_PATH", buf); - snprintf(buf, sizeof(buf), "%s/enlightenment/preload/e_hack.so", e_prefix_lib_get()); - */ snprintf(buf, sizeof(buf), "E_START|%i", startup_id); e_util_env_set("DESKTOP_STARTUP_ID", buf); /* execute */ - ret = e_app_exec(a, startup_id); - + ex = ecore_exe_run(exe, NULL); + if (!ex) + { + e_error_dialog_show(_("Run Error"), + _("Enlightenment was unable fork a child process:\n" + "\n" + "%s\n" + "\n"), + exe); + ret = 0; + } + else + { + ecore_exe_free(ex); + ret = 1; + } /* reset env vars */ if (penv_display) { e_util_env_set("DISPLAY", penv_display); free(penv_display); } -/* - if (penv_ld_preload) + return ret; +} + +int +e_zone_app_exec(E_Zone *zone, E_App *a) +{ + int ret; + char *p1, *p2; + char *penv_display; + char buf[4096], buf2[32]; + + E_OBJECT_CHECK_RETURN(zone, 0); + E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0); + + if (!a) return 0; + if (startup_id == 0) + { + p1 = getenv("E_STARTUP_ID"); + if (p1) startup_id = atoi(p1); + } + if (++startup_id < 1) startup_id = 1; + /* save previous env vars we need to save */ + penv_display = getenv("DISPLAY"); + if (penv_display) penv_display = strdup(penv_display); + + /* set env vars */ + p1 = strrchr(penv_display, ':'); + p2 = strrchr(penv_display, '.'); + if ((p1) && (p2) && (p2 > p1)) /* "blah:x.y" */ + { + /* yes it could overflow... but who will overflow DISPLAY eh? why? to + * "exploit" your own applications running as you? + */ + strcpy(buf, penv_display); + buf[p2 - penv_display + 1] = 0; + snprintf(buf2, sizeof(buf2), "%i", zone->container->manager->num); + strcat(buf, buf2); + } + else if (p1) /* "blah:x */ { - e_util_env_set("LD_PRELOAD", penv_ld_preload); - free(penv_ld_preload); + strcpy(buf, penv_display); + snprintf(buf2, sizeof(buf2), ".%i", zone->container->manager->num); + strcat(buf, buf2); } - if (penv_ld_preload_path) + else + strcpy(buf, penv_display); + e_util_env_set("DISPLAY", buf); + snprintf(buf, sizeof(buf), "E_START|%i", startup_id); + e_util_env_set("DESKTOP_STARTUP_ID", buf); + /* execute */ + ret = e_app_exec(a, startup_id); + + /* reset env vars */ + if (penv_display) { - e_util_env_set("LD_PRELOAD_PATH", penv_ld_preload_path); - free(penv_ld_preload_path); + e_util_env_set("DISPLAY", penv_display); + free(penv_display); } - */ return ret; } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_zone.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- e_zone.h 2 Sep 2005 09:56:01 -0000 1.33 +++ e_zone.h 7 Dec 2005 13:24:58 -0000 1.34 @@ -90,6 +90,7 @@ EAPI void e_zone_flip_win_disable(void); EAPI void e_zone_flip_win_restore(void); +EAPI int e_zone_exec(E_Zone *zone, char *exe); EAPI int e_zone_app_exec(E_Zone *zone, E_App *a); extern EAPI int E_EVENT_ZONE_DESK_COUNT_SET; ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs