forked from enlightenment/enlightenment
aaah..
click to focus actually works now.. wheeee :) as does alt+drag and other bindings u can add to a window.... :) SVN revision: 5596
This commit is contained in:
parent
0986c3331b
commit
6266018527
|
@ -221,10 +221,11 @@ e_action_free(E_Action *a)
|
|||
FREE(a);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Event_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry)
|
||||
{
|
||||
Evas_List l;
|
||||
int started_long_action = 0;
|
||||
|
||||
e_action_find(action, act, button, key, mods, o);
|
||||
again:
|
||||
|
@ -236,7 +237,10 @@ e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Eve
|
|||
if (!a->started)
|
||||
{
|
||||
if (a->action_impl->func_stop)
|
||||
a->started = 1;
|
||||
{
|
||||
a->started = 1;
|
||||
started_long_action = 1;
|
||||
}
|
||||
if (a->action_impl->func_start)
|
||||
{
|
||||
E_Object *obj;
|
||||
|
@ -257,6 +261,7 @@ e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Eve
|
|||
goto again;
|
||||
}
|
||||
}
|
||||
return started_long_action;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -56,7 +56,7 @@ struct _E_Action_Impl
|
|||
};
|
||||
|
||||
|
||||
void e_action_start(char *action, E_Action_Type act, int button, char *key,
|
||||
int e_action_start(char *action, E_Action_Type act, int button, char *key,
|
||||
Ecore_Event_Key_Modifiers mods, void *o, void *data,
|
||||
int x, int y, int rx, int ry);
|
||||
void e_action_stop(char *action, E_Action_Type act, int button, char *key,
|
||||
|
|
132
src/border.c
132
src/border.c
|
@ -67,6 +67,24 @@ static void e_cb_border_visibility(E_Border *b);
|
|||
|
||||
static void e_border_poll(int val, void *data);
|
||||
|
||||
static int e_border_replay_query(Ecore_Event_Mouse_Down *ev)
|
||||
{
|
||||
E_Border *b;
|
||||
|
||||
b = e_border_find_by_window(ev->win);
|
||||
if (b)
|
||||
{
|
||||
int focus_mode;
|
||||
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
|
||||
|
||||
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
|
||||
if ((focus_mode == 2) && (ev->mods == ECORE_EVENT_KEY_MODIFIER_NONE))
|
||||
/* FIXME: also if pass click always set */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* what to dowhen we're idle */
|
||||
|
||||
void
|
||||
|
@ -345,11 +363,11 @@ e_reparent(Ecore_Event * ev)
|
|||
|
||||
current_ev = ev;
|
||||
e = ev->event;
|
||||
#if 0
|
||||
{
|
||||
E_Border *b;
|
||||
|
||||
b = e_border_find_by_window(e->win);
|
||||
#if 0
|
||||
if ((b) && (e->parent_from == b->win.container))
|
||||
{
|
||||
if (b)
|
||||
|
@ -366,8 +384,8 @@ e_reparent(Ecore_Event * ev)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
current_ev = NULL;
|
||||
}
|
||||
|
||||
|
@ -413,6 +431,29 @@ ecore_focus_in(Ecore_Event * ev)
|
|||
b->current.selected = 1;
|
||||
b->changed = 1;
|
||||
OBS_NOTIFY(b, ECORE_EVENT_WINDOW_FOCUS_IN);
|
||||
{
|
||||
Evas_List l;
|
||||
|
||||
again:
|
||||
for (l = b->grabs; l; l = l->next)
|
||||
{
|
||||
E_Grab *g;
|
||||
|
||||
g = l->data;
|
||||
/* find a grab that triggered this */
|
||||
if (b->click_grab == g)
|
||||
{
|
||||
printf("ungrab %s\n", b->client.title);
|
||||
/* ecore_pointer_ungrab(e->time);*/
|
||||
ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
|
||||
/* ecore_window_button_grab_auto_replay_set(b->win.main, 0);*/
|
||||
free(g);
|
||||
b->grabs = evas_list_remove(b->grabs, g);
|
||||
b->click_grab = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
current_ev = NULL;
|
||||
|
@ -441,7 +482,7 @@ ecore_focus_out(Ecore_Event * ev)
|
|||
b->current.selected = 0;
|
||||
if (e->key_grab) b->current.select_lost_from_grab = 1;
|
||||
/* settings - click to focus would affect grabs */
|
||||
if (focus_mode == 2) /* click to focus */
|
||||
if ((!b->client.internal) && (focus_mode == 2)) /* click to focus */
|
||||
{
|
||||
E_Grab *g;
|
||||
|
||||
|
@ -449,13 +490,13 @@ ecore_focus_out(Ecore_Event * ev)
|
|||
ZERO(g, E_Grab, 1);
|
||||
g->button = 0;
|
||||
g->mods = ECORE_EVENT_KEY_MODIFIER_NONE;
|
||||
g->any_mod = 1;
|
||||
g->any_mod = 0;
|
||||
g->remove_after = 1;
|
||||
b->grabs = evas_list_append(b->grabs, g);
|
||||
printf("grab me baaaybe %s\n", b->client.title);
|
||||
ecore_button_grab(b->win.main, 0,
|
||||
XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 1);
|
||||
ecore_window_button_grab_auto_replay_set(b->win.main, 1);
|
||||
printf("grab me baaaybe %8x | %s\n", b->win.client, b->client.title);
|
||||
ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS | XEV_BUTTON_RELEASE, ECORE_EVENT_KEY_MODIFIER_NONE, 0);
|
||||
ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query);
|
||||
b->click_grab = g;
|
||||
}
|
||||
b->changed = 1;
|
||||
}
|
||||
|
@ -488,7 +529,8 @@ static void
|
|||
e_mouse_down(Ecore_Event * ev)
|
||||
{
|
||||
Ecore_Event_Mouse_Down *e;
|
||||
|
||||
|
||||
printf("doooown\n");
|
||||
current_ev = ev;
|
||||
e = ev->event;
|
||||
{
|
||||
|
@ -500,8 +542,15 @@ e_mouse_down(Ecore_Event * ev)
|
|||
mouse_y = e->ry;
|
||||
mouse_buttons |= (1 << e->button);
|
||||
b = e_border_find_by_window(e->win);
|
||||
printf("%p (%x)\n", b, e->win);
|
||||
if (b)
|
||||
{
|
||||
int focus_mode;
|
||||
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
|
||||
|
||||
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
|
||||
if (focus_mode == 2)
|
||||
ecore_focus_to_window(b->win.client);
|
||||
if (e->win == b->win.main) e_cb_border_mouse_down(b, ev);
|
||||
else
|
||||
{
|
||||
|
@ -911,7 +960,7 @@ e_cb_border_mouse_in(E_Border *b, Ecore_Event *e)
|
|||
int focus_mode;
|
||||
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
|
||||
|
||||
if (border_mouse_buttons) return;
|
||||
/* if (border_mouse_buttons) return;*/
|
||||
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
|
||||
/* pointer focus stuff */
|
||||
if (focus_mode == 0)
|
||||
|
@ -921,7 +970,7 @@ e_cb_border_mouse_in(E_Border *b, Ecore_Event *e)
|
|||
|
||||
border_mouse_x = mouse_x;
|
||||
border_mouse_y = mouse_y;
|
||||
border_mouse_buttons = mouse_buttons;
|
||||
/* border_mouse_buttons = mouse_buttons;*/
|
||||
if (!current_ev) return;
|
||||
|
||||
x = ((Ecore_Event_Window_Enter *)(e->event))->x;
|
||||
|
@ -939,7 +988,7 @@ e_cb_border_mouse_out(E_Border *b, Ecore_Event *e)
|
|||
int x, y;
|
||||
char *class = "Window_Grab";
|
||||
|
||||
if (border_mouse_buttons) return;
|
||||
/* if (border_mouse_buttons) return; */
|
||||
/* pointer focus stuff */
|
||||
/* ecore_focus_to_window(0);*/
|
||||
|
||||
|
@ -947,7 +996,7 @@ e_cb_border_mouse_out(E_Border *b, Ecore_Event *e)
|
|||
y = mouse_y;
|
||||
border_mouse_x = mouse_x;
|
||||
border_mouse_y = mouse_y;
|
||||
border_mouse_buttons = mouse_buttons;
|
||||
/* border_mouse_buttons = mouse_buttons; */
|
||||
if (!current_ev) return;
|
||||
|
||||
e_action_stop(class, ACT_MOUSE_OUT, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE,
|
||||
|
@ -970,8 +1019,10 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e)
|
|||
ecore_pointer_grab(b->win.main, CurrentTime);
|
||||
border_mouse_x = mouse_x;
|
||||
border_mouse_y = mouse_y;
|
||||
if (border_mouse_buttons) return;
|
||||
border_mouse_buttons = mouse_buttons;
|
||||
printf("%i\n", border_mouse_buttons);
|
||||
/* if (border_mouse_buttons) return; */
|
||||
/* border_mouse_buttons = mouse_buttons; */
|
||||
printf("%p\n", current_ev);
|
||||
if (!current_ev) return;
|
||||
x = ((Ecore_Event_Mouse_Down *)(e->event))->x;
|
||||
y = ((Ecore_Event_Mouse_Down *)(e->event))->y;
|
||||
|
@ -991,13 +1042,12 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e)
|
|||
((g->any_mod) ||
|
||||
(((Ecore_Event_Mouse_Down *)(e->event))->mods == g->mods)))
|
||||
{
|
||||
if (b->click_grab == g) b->click_grab = NULL;
|
||||
if (g->remove_after)
|
||||
{
|
||||
if (focus_mode == 2)
|
||||
ecore_focus_to_window(b->win.client);
|
||||
printf("ungrab %s\n", b->client.title);
|
||||
printf("pfft ungrab %s\n", b->client.title);
|
||||
ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
|
||||
ecore_window_button_grab_auto_replay_set(b->win.main, 0);
|
||||
ecore_window_button_grab_auto_replay_set(b->win.main, NULL);
|
||||
ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *)(e->event))->time);
|
||||
free(g);
|
||||
b->grabs = evas_list_remove(b->grabs, g);
|
||||
|
@ -1006,6 +1056,7 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e)
|
|||
}
|
||||
}
|
||||
}
|
||||
printf("(...e_cb_border_mouse_down...)\n");
|
||||
{
|
||||
E_Action_Type act;
|
||||
Ecore_Event_Key_Modifiers mods;
|
||||
|
@ -1020,13 +1071,17 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e)
|
|||
|
||||
e_action_stop(class, act, bt, NULL, mods, b, NULL,
|
||||
x, y, border_mouse_x, border_mouse_y);
|
||||
e_action_start(class, act, bt, NULL, mods, b, NULL,
|
||||
x, y, border_mouse_x, border_mouse_y);
|
||||
if (!e_action_start(class, act, bt, NULL, mods, b, NULL,
|
||||
x, y, border_mouse_x, border_mouse_y))
|
||||
{
|
||||
ecore_pointer_ungrab(((Ecore_Event_Mouse_Down *)(e->event))->time);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecore_pointer_grab(((Ecore_Event_Mouse_Down *)(e->event))->win,
|
||||
((Ecore_Event_Mouse_Down *)(e->event))->time);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *)(e->event))->time);
|
||||
* ecore_pointer_replay(((Ecore_Event_Mouse_Up *)(e->event))->time);
|
||||
*/
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1038,7 +1093,7 @@ e_cb_border_mouse_up(E_Border *b, Ecore_Event *e)
|
|||
ecore_pointer_ungrab(CurrentTime);
|
||||
border_mouse_x = mouse_x;
|
||||
border_mouse_y = mouse_y;
|
||||
border_mouse_buttons = mouse_buttons;
|
||||
/* border_mouse_buttons = mouse_buttons; */
|
||||
if (!current_ev) return;
|
||||
x = ((Ecore_Event_Mouse_Up *)(e->event))->x;
|
||||
y = ((Ecore_Event_Mouse_Up *)(e->event))->y;
|
||||
|
@ -1610,6 +1665,22 @@ e_border_remove_mouse_grabs(E_Border *b)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
e_border_remove_click_grab(E_Border *b)
|
||||
{
|
||||
if (b->click_grab)
|
||||
{
|
||||
E_Grab *g;
|
||||
|
||||
g = b->click_grab;
|
||||
b->grabs = evas_list_remove(b->grabs, b->click_grab);
|
||||
ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
|
||||
ecore_window_button_grab_auto_replay_set(b->win.main, NULL);
|
||||
b->click_grab = NULL;
|
||||
FREE(g);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
e_border_attach_mouse_grabs(E_Border *b)
|
||||
{
|
||||
|
@ -1633,12 +1704,13 @@ e_border_attach_mouse_grabs(E_Border *b)
|
|||
ZERO(g, E_Grab, 1);
|
||||
g->button = 0;
|
||||
g->mods = ECORE_EVENT_KEY_MODIFIER_NONE;
|
||||
g->any_mod = 1;
|
||||
g->any_mod = 0;
|
||||
g->remove_after = 1;
|
||||
b->grabs = evas_list_append(b->grabs, g);
|
||||
printf("grab me baaaybe %s\n", b->client.title);
|
||||
ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 1);
|
||||
ecore_window_button_grab_auto_replay_set(b->win.main, 1);
|
||||
printf("attach... grab me baaaybe %8x | %s\n", b->win.client, b->client.title);
|
||||
ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS | XEV_BUTTON_RELEASE, ECORE_EVENT_KEY_MODIFIER_NONE, 0);
|
||||
ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query);
|
||||
b->click_grab = g;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ struct _E_Border
|
|||
struct {
|
||||
int x, y;
|
||||
} area;
|
||||
int internal;
|
||||
} client;
|
||||
|
||||
struct {
|
||||
|
@ -119,6 +120,7 @@ struct _E_Border
|
|||
int placed;
|
||||
|
||||
Evas_List grabs;
|
||||
E_Grab *click_grab;
|
||||
E_Desktop *desk;
|
||||
|
||||
char *border_style;
|
||||
|
@ -139,6 +141,7 @@ E_Border *e_border_adopt(Window win, int use_client_pos);
|
|||
E_Border *e_border_new(void);
|
||||
void e_border_free(E_Border *b);
|
||||
void e_border_remove_mouse_grabs(E_Border *b);
|
||||
void e_border_remove_click_grab(E_Border *b);
|
||||
void e_border_attach_mouse_grabs(E_Border *b);
|
||||
void e_border_remove_all_mouse_grabs(void);
|
||||
void e_border_attach_all_mouse_grabs(void);
|
||||
|
|
|
@ -204,6 +204,8 @@ e_desktops_init_file_display(E_Desktop *desk)
|
|||
ecore_window_set_min_size(v->win.base, desk->real.w, desk->real.h);
|
||||
ecore_window_set_max_size(v->win.base, desk->real.w, desk->real.h);
|
||||
b = e_border_adopt(v->win.base, 1);
|
||||
b->client.internal = 1;
|
||||
e_border_remove_click_grab(b);
|
||||
b->client.sticky = 1;
|
||||
b->client.fixed = 1;
|
||||
b->client.is_desktop = 1;
|
||||
|
|
2
src/e.h
2
src/e.h
|
@ -27,7 +27,7 @@
|
|||
#include <Edb.h>
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4095
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -62,7 +62,7 @@ int
|
|||
e_file_cp(char *src, char *dst)
|
||||
{
|
||||
FILE *f1, *f2;
|
||||
char buf[PATH_MAX];
|
||||
char buf[16384];
|
||||
size_t num;
|
||||
|
||||
f1 = fopen(src, "rb");
|
||||
|
@ -73,7 +73,7 @@ e_file_cp(char *src, char *dst)
|
|||
fclose(f1);
|
||||
return 0;
|
||||
}
|
||||
while ((num = fread(buf, 1, PATH_MAX, f1)) > 0) fwrite(buf, 1, num, f2);
|
||||
while ((num = fread(buf, 1, 16384, f1)) > 0) fwrite(buf, 1, num, f2);
|
||||
fclose(f1);
|
||||
fclose(f2);
|
||||
return 1;
|
||||
|
@ -91,7 +91,7 @@ e_file_real(char *file)
|
|||
}
|
||||
|
||||
char *
|
||||
e_filecore_get_file(char *file)
|
||||
e_file_get_file(char *file)
|
||||
{
|
||||
char *p;
|
||||
char *f;
|
||||
|
@ -107,7 +107,7 @@ e_filecore_get_file(char *file)
|
|||
}
|
||||
|
||||
char *
|
||||
e_filecore_get_dir(char *file)
|
||||
e_file_get_dir(char *file)
|
||||
{
|
||||
char *p;
|
||||
char *f;
|
||||
|
|
|
@ -1478,6 +1478,12 @@ e_mouse_down(Ecore_Event * ev)
|
|||
v = l->data;
|
||||
if (e->win == v->win.main)
|
||||
{
|
||||
int focus_mode;
|
||||
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
|
||||
|
||||
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
|
||||
if (focus_mode == 2)
|
||||
ecore_focus_to_window(v->win.base);
|
||||
evas_event_button_down(v->evas, e->x, e->y, e->button);
|
||||
current_ev = NULL;
|
||||
return;
|
||||
|
@ -2738,6 +2744,8 @@ e_view_handle_fs(EfsdEvent *ev)
|
|||
e_background_set_size(v->bg, v->size.w, v->size.h);
|
||||
if (v->options.back_pixmap) e_view_update(v);
|
||||
b = e_border_adopt(v->win.base, 1);
|
||||
b->client.internal = 1;
|
||||
e_border_remove_click_grab(b);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
229
tools/e_setup.c
229
tools/e_setup.c
|
@ -7,8 +7,17 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include <errno.h>
|
||||
#include "../config.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
/* stuff we want from e */
|
||||
#define OBJ_PROPERTIES \
|
||||
int references; \
|
||||
|
@ -364,6 +373,226 @@ e_background_set_color_class(E_Background *bg, char *cc, int r, int g, int b, in
|
|||
/* */
|
||||
/* */
|
||||
|
||||
int
|
||||
e_file_exists(char *file)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(file, &st) < 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
e_file_is_dir(char *file)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(file, &st) < 0) return 0;
|
||||
if (S_ISDIR(st.st_mode)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
e_file_home(void)
|
||||
{
|
||||
static char *home = NULL;
|
||||
|
||||
if (home) return home;
|
||||
home = getenv("HOME");
|
||||
if (!home) home = getenv("TMPDIR");
|
||||
if (!home) home = "/tmp";
|
||||
return home;
|
||||
}
|
||||
|
||||
static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
|
||||
int
|
||||
e_file_mkdir(char *dir)
|
||||
{
|
||||
if (mkdir(dir, default_mode) < 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
e_file_mkdirs(char *s)
|
||||
{
|
||||
char ss[PATH_MAX];
|
||||
int i, ii;
|
||||
|
||||
i = 0;
|
||||
ii = 0;
|
||||
while (s[i])
|
||||
{
|
||||
ss[ii++] = s[i];
|
||||
ss[ii] = 0;
|
||||
if (s[i] == '/')
|
||||
{
|
||||
if (!e_file_exists(ss))
|
||||
e_file_mkdir(ss);
|
||||
else if (!e_file_is_dir(ss))
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
e_file_cp(char *src, char *dst)
|
||||
{
|
||||
FILE *f1, *f2;
|
||||
char buf[16384];
|
||||
size_t num;
|
||||
|
||||
f1 = fopen(src, "rb");
|
||||
if (!f1) return 0;
|
||||
f2 = fopen(dst, "wb");
|
||||
if (!f2)
|
||||
{
|
||||
fclose(f1);
|
||||
return 0;
|
||||
}
|
||||
while ((num = fread(buf, 1, 16384, f1)) > 0) fwrite(buf, 1, num, f2);
|
||||
fclose(f1);
|
||||
fclose(f2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
e_file_delete(char *s)
|
||||
{
|
||||
unlink(s);
|
||||
}
|
||||
|
||||
void
|
||||
e_file_rename(char *s, char *ss)
|
||||
{
|
||||
rename(s, ss);
|
||||
}
|
||||
|
||||
int
|
||||
e_glob_matches(char *str, char *glob)
|
||||
{
|
||||
if (!fnmatch(glob, str, 0)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
e_file_get_file(char *file)
|
||||
{
|
||||
char *p;
|
||||
char *f;
|
||||
|
||||
p = strrchr(file, '/');
|
||||
if (!p)
|
||||
{
|
||||
e_strdup(f, file);
|
||||
return f;
|
||||
}
|
||||
e_strdup(f, &(p[1]));
|
||||
return f;
|
||||
}
|
||||
|
||||
char *
|
||||
e_file_get_dir(char *file)
|
||||
{
|
||||
char *p;
|
||||
char *f;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
strcpy(buf, file);
|
||||
p = strrchr(buf, '/');
|
||||
if (!p)
|
||||
{
|
||||
e_strdup(f, file);
|
||||
return f;
|
||||
}
|
||||
*p = 0;
|
||||
e_strdup(f, buf);
|
||||
return f;
|
||||
}
|
||||
|
||||
int
|
||||
e_file_can_exec(struct stat *st)
|
||||
{
|
||||
static int have_uid = 0;
|
||||
static uid_t uid = -1;
|
||||
static gid_t gid = -1;
|
||||
int ok;
|
||||
|
||||
if (!st) return 0;
|
||||
ok = 0;
|
||||
if (!have_uid) uid = getuid();
|
||||
if (!have_uid) gid = getgid();
|
||||
have_uid = 1;
|
||||
if (st->st_uid == uid)
|
||||
{
|
||||
if (st->st_mode & S_IXUSR) ok = 1;
|
||||
}
|
||||
else if (st->st_gid == gid)
|
||||
{
|
||||
if (st->st_mode & S_IXGRP) ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (st->st_mode & S_IXOTH) ok = 1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
char *
|
||||
e_file_link(char *link)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
char *f;
|
||||
int count;
|
||||
|
||||
if ((count = readlink(link, buf, sizeof(buf))) < 0) return NULL;
|
||||
buf[count] = 0;
|
||||
e_strdup(f, buf);
|
||||
return f;
|
||||
}
|
||||
|
||||
Evas_List
|
||||
e_file_list_dir(char *dir)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
Evas_List list;
|
||||
|
||||
dirp = opendir(dir);
|
||||
if (!dirp) return NULL;
|
||||
list = NULL;
|
||||
while ((dp = readdir(dirp)))
|
||||
{
|
||||
if ((strcmp(dp->d_name, ".")) &&
|
||||
(strcmp(dp->d_name, "..")))
|
||||
{
|
||||
Evas_List l;
|
||||
char *f;
|
||||
|
||||
/* insertion sort */
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
if (strcmp(l->data, dp->d_name) > 0)
|
||||
{
|
||||
e_strdup(f, dp->d_name);
|
||||
list = evas_list_prepend_relative(list, f, l->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* nowhwre to go? just append it */
|
||||
e_strdup(f, dp->d_name);
|
||||
if (!l) list = evas_list_append(list, f);
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
|
||||
typedef struct _text_zone Text_Zone;
|
||||
|
||||
|
|
Loading…
Reference in New Issue