working on mr. exebuf...

SVN revision: 18893
This commit is contained in:
Carsten Haitzler 2005-12-07 13:24:58 +00:00
parent 83b396cef4
commit c30558a79b
10 changed files with 590 additions and 54 deletions

View File

@ -48,7 +48,8 @@ default_label.edc \
default_button.edc \
default_scrollframe.edc \
default_ilist.edc \
default_slider.edc
default_slider.edc \
default_exebuf.edc
default.edj: Makefile $(EXTRA_DIST)
$(EDJE_CC) $(EDJE_FLAGS) \

View File

@ -57,5 +57,6 @@ collections {
#include "default_scrollframe.edc"
#include "default_ilist.edc"
#include "default_slider.edc"
#include "default_exebuf.edc"
}

View File

@ -1,6 +1,6 @@
images {
image: "e17_brushed.png" COMP;
image: "e17_"SM"reflection_shadow_overlay.png" LOSSY 70;
image: "e17_"SM"reflection_shadow_overlay.png" LOSSY 90;
}
group {
name: "desktop/background";

View File

@ -0,0 +1,236 @@
images {
image: "e17_menu_bg.png" COMP;
image: "e17_winlist_top.png" COMP;
image: "e17_winlist_bottom.png" COMP;
image: "e17_ibar_bg_h.png" COMP;
image: "e17_ibar_over_v.png" COMP;
image: "e17_gadman_overlay.png" COMP;
image: "e17_pager_window.png" COMP;
image: "e17_pager_window_shaded.png" COMP;
image: "e17_pager_desk.png" COMP;
}
group {
name: "widgets/exebuf/main";
parts {
part {
name: "base";
mouse_events: 0;
type: RECT;
description {
state: "default" 0.0;
rel1 {
relative: 0.0 1.0;
offset: 1 0;
to_y: "base2";
}
rel2 {
relative: 1.0 1.0;
offset: -2 -2;
}
color: 221 221 221 255;
}
}
part {
name: "base2";
mouse_events: 0;
description {
state: "default" 0.0;
max: 99999 48;
align: 0.5 0.0;
rel1 {
relative: 0.0 0.0;
offset: 1 1;
}
rel2 {
relative: 1.0 1.0;
offset: -2 -2;
}
image {
normal: "e17_menu_bg.png";
}
fill {
smooth: 0;
}
}
}
part {
name: "base3";
mouse_events: 0;
description {
state: "default" 0.0;
rel1 {
relative: 0.0 0.0;
offset: 0 0;
}
rel2 {
relative: 1.0 1.0;
offset: -1 -1;
}
image {
normal: "e17_menu_bg_border.png";
border: 1 1 1 1;
middle: 0;
}
fill {
smooth: 0;
}
}
}
part {
name: "top";
mouse_events: 0;
description {
state: "default" 0.0;
rel1 {
relative: 0.0 0.0;
offset: 1 1;
}
rel2 {
relative: 1.0 0.0;
offset: -2 16;
to_y: "label";
}
image {
normal: "e17_winlist_top.png";
border: 0 0 0 19;
}
fill {
smooth: 0;
}
}
}
part {
name: "icon_swallow";
type: SWALLOW;
description {
state: "default" 0.0;
color: 0 0 0 0;
aspect: 1.0 1.0;
align: 0.0 0.5;
min: 24 24;
fixed: 1 1;
aspect_preference: VERTICAL;
rel1 {
relative: 0.0 0.0;
offset: 16 16;
}
rel2 {
relative: 0.0 1.0;
offset: 16 -17;
}
}
}
part {
name: "icon_overlay";
mouse_events: 1;
description {
state: "default" 0.0;
rel1 {
to: "icon_swallow";
relative: 0.0 0.0;
offset: -8 -8;
}
rel2 {
to: "icon_swallow";
relative: 1.0 1.0;
offset: 7 7;
}
image {
normal: "e17_gadman_overlay.png";
border: 15 15 15 15;
}
}
}
part {
name: "label";
type: TEXT;
effect: SHADOW;
description {
state: "default" 0.0;
color: 0 0 0 255;
rel1 {
relative: 1.0 0.0;
offset: 16 24;
to_x: "icon_swallow";
}
rel2 {
relative: 1.0 1.0;
offset: -17 -25;
}
color: 0 0 0 255;
color3: 255 255 255 128;
text {
text: "COMMAND";
font: "Edje-Vera-Bold";
size: 16;
align: 0.0 0.5;
min: 0 1;
text_class: "exebuf_text";
}
}
}
part {
name: "bottom";
mouse_events: 0;
description {
state: "default" 0.0;
rel1 {
relative: 0.0 1.0;
offset: 1 -3;
to_y: "label";
}
rel2 {
relative: 1.0 1.0;
offset: -2 -2;
}
image {
normal: "e17_winlist_bottom.png";
border: 0 0 4 0;
}
fill {
smooth: 0;
}
}
}
}
/*
part {
name: "list_swallow";
type: SWALLOW;
clip_to: "list_clip";
description {
state: "default" 0.0;
color: 0 0 0 0;
rel1 {
relative: 0.0 1.0;
offset: 16 16;
to_y: "title";
}
rel2 {
relative: 1.0 0.0;
offset: -17 -17;
to_y: "icon_swallow";
}
}
}
part {
name: "list_clip";
type: RECT;
description {
state: "default" 0.0;
color: 255 255 255 255;
rel1 {
relative: 0.0 0.0;
offset: 0 0;
to_y: "list_swallow";
}
rel2 {
relative: 1.0 1.0;
offset: -1 -1;
to_y: "list_swallow";
}
}
}
*/
}

View File

@ -704,26 +704,27 @@ ACT_FN_GO(window_desk_move_by)
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 @@ ACT_FN_GO(window_desk_move_by)
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 @@ ACT_FN_GO(pointer_resize_pop)
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 @@ e_actions_init(void)
ACT_GO(pointer_resize_push);
ACT_GO(pointer_resize_pop);
ACT_GO(exebuf);
return 1;
}

View File

@ -1017,6 +1017,15 @@ e_config_init(void)
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
*/

View File

@ -44,7 +44,7 @@ typedef Eet_Data_Descriptor E_Config_DD;
* 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

View File

@ -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 E_Popup *exebuf = NULL;
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 @@ e_exebuf_show(E_Zone *zone)
{
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 @@ e_exebuf_show(E_Zone *zone)
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 @@ e_exebuf_show(E_Zone *zone)
(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 @@ e_exebuf_hide(void)
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 @@ _e_exebuf_cb_key_down(void *data, int type, void *event)
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;
}

View File

@ -556,19 +556,17 @@ e_zone_flip_win_restore(void)
}
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 @@ e_zone_app_exec(E_Zone *zone, E_App *a)
/* 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,21 +599,78 @@ e_zone_app_exec(E_Zone *zone, E_App *a)
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 */
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);
}
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 */
{
strcpy(buf, penv_display);
snprintf(buf2, sizeof(buf2), ".%i", zone->container->manager->num);
strcat(buf, buf2);
}
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 */
@ -631,18 +682,6 @@ e_zone_app_exec(E_Zone *zone, E_App *a)
e_util_env_set("DISPLAY", penv_display);
free(penv_display);
}
/*
if (penv_ld_preload)
{
e_util_env_set("LD_PRELOAD", penv_ld_preload);
free(penv_ld_preload);
}
if (penv_ld_preload_path)
{
e_util_env_set("LD_PRELOAD_PATH", penv_ld_preload_path);
free(penv_ld_preload_path);
}
*/
return ret;
}

View File

@ -90,6 +90,7 @@ EAPI void e_zone_desk_linear_flip_to(E_Zone *zone, int x);
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;