* replaced printf()s with D()s.

* cleaned up functions in utils in file utils and others, there's a
new file.[ch] for the file-related helpers.
* Added stat info to E_Icon, watch how directories become grayed when
you cannot access them :)


SVN revision: 5610
This commit is contained in:
cpk 2001-11-03 09:07:40 +00:00 committed by cpk
parent 80c5db9c3c
commit 454d2b917a
22 changed files with 513 additions and 366 deletions

View File

@ -5,7 +5,7 @@ DISTCLEANFILES = e_ferite_gen_*
## Enable -DDEBUG for debugging messages, -DDEBUG_NEST ## Enable -DDEBUG for debugging messages, -DDEBUG_NEST
## for call tracing. Caution -- this will produce a *lot* ## for call tracing. Caution -- this will produce a *lot*
## of output! ## of output!
DEBUGFLAGS = -g -DDEBUG #-DDEBUG_NEST DEBUGFLAGS = -W -Wall -g -DDEBUG #-DDEBUG_NEST
INCLUDES = \ INCLUDES = \
-I$(top_srcdir)/intl \ -I$(top_srcdir)/intl \
@ -35,6 +35,7 @@ enlightenment_SOURCES = \
embed.c embed.h \ embed.c embed.h \
entry.h entry.c \ entry.h entry.c \
exec.h exec.c \ exec.h exec.c \
file.h file.c \
fs.h fs.c \ fs.h fs.c \
$(ferite_c) \ $(ferite_c) \
guides.h guides.c \ guides.h guides.c \

View File

@ -1473,7 +1473,6 @@ e_act_exec_start (E_Object *object, E_Action *a, void *data, int x, int y, int r
exe = (char *) a->params; exe = (char *) a->params;
if(!exe) D_RETURN; if(!exe) D_RETURN;
/* printf("exe: %s\n",exe); */
e_exec_run(exe); e_exec_run(exe);
D_RETURN; D_RETURN;

View File

@ -139,7 +139,7 @@ e_background_realize(E_Background *bg, Evas evas)
#if 0 /* dont need this... do we? */ #if 0 /* dont need this... do we? */
if (evas_get_image_alpha(bg->evas, bl->obj)) if (evas_get_image_alpha(bg->evas, bl->obj))
{ {
printf("Adding rectangle to bg!\n"); D("Adding rectangle to bg!\n");
bg->base_obj = evas_add_rectangle(bg->evas); bg->base_obj = evas_add_rectangle(bg->evas);
evas_lower(bg->evas, bg->base_obj); evas_lower(bg->evas, bg->base_obj);
evas_move(bg->evas, bg->base_obj, 0, 0); evas_move(bg->evas, bg->base_obj, 0, 0);

View File

@ -7,6 +7,7 @@
#include "desktops.h" #include "desktops.h"
#include "resist.h" #include "resist.h"
#include "icccm.h" #include "icccm.h"
#include "file.h"
#include "util.h" #include "util.h"
#include "place.h" #include "place.h"
#include "match.h" #include "match.h"
@ -471,14 +472,14 @@ e_focus_in(Ecore_Event * ev)
current_ev = ev; current_ev = ev;
e = ev->event; e = ev->event;
printf("focus in event\n"); D("focus in event\n");
{ {
E_Border *b; E_Border *b;
b = e_border_find_by_window(e->win); b = e_border_find_by_window(e->win);
if ((b) && (b->win.client == e->win)) if ((b) && (b->win.client == e->win))
{ {
printf("focus in %s\n", b->client.title); D("focus in %s\n", b->client.title);
e_border_focus_grab_ended(); e_border_focus_grab_ended();
b->current.selected = 1; b->current.selected = 1;
b->changed = 1; b->changed = 1;
@ -496,7 +497,7 @@ e_focus_in(Ecore_Event * ev)
/* find a grab that triggered this */ /* find a grab that triggered this */
if (b->click_grab == g) if (b->click_grab == g)
{ {
printf("ungrab %s\n", b->client.title); D("ungrab %s\n", b->client.title);
/* ecore_pointer_ungrab(e->time);*/ /* ecore_pointer_ungrab(e->time);*/
ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); 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, 0);*/
@ -524,7 +525,7 @@ e_focus_out(Ecore_Event * ev)
current_ev = ev; current_ev = ev;
e = ev->event; e = ev->event;
printf("focus out event\n"); D("focus out event\n");
{ {
E_Border *b; E_Border *b;
@ -535,7 +536,7 @@ e_focus_out(Ecore_Event * ev)
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
printf("focus out %s\n", b->client.title); D("focus out %s\n", b->client.title);
b->current.selected = 0; b->current.selected = 0;
if (e->key_grab) b->current.select_lost_from_grab = 1; if (e->key_grab) b->current.select_lost_from_grab = 1;
/* settings - click to focus would affect grabs */ /* settings - click to focus would affect grabs */
@ -550,7 +551,7 @@ e_focus_out(Ecore_Event * ev)
g->any_mod = 0; g->any_mod = 0;
g->remove_after = 1; g->remove_after = 1;
b->grabs = evas_list_append(b->grabs, g); b->grabs = evas_list_append(b->grabs, g);
printf("grab me baaaybe %8x | %s\n", b->win.client, b->client.title); D("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_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); ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query);
b->click_grab = g; b->click_grab = g;
@ -595,7 +596,7 @@ e_mouse_down(Ecore_Event * ev)
D_ENTER; D_ENTER;
printf("doooown\n"); D("doooown\n");
current_ev = ev; current_ev = ev;
e = ev->event; e = ev->event;
{ {
@ -607,7 +608,7 @@ e_mouse_down(Ecore_Event * ev)
mouse_y = e->ry; mouse_y = e->ry;
mouse_buttons |= (1 << e->button); mouse_buttons |= (1 << e->button);
b = e_border_find_by_window(e->win); b = e_border_find_by_window(e->win);
printf("%p (%x)\n", b, e->win); D("%p (%x)\n", b, e->win);
if (b) if (b)
{ {
int focus_mode; int focus_mode;
@ -1125,10 +1126,10 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e)
ecore_pointer_grab(b->win.main, CurrentTime); ecore_pointer_grab(b->win.main, CurrentTime);
border_mouse_x = mouse_x; border_mouse_x = mouse_x;
border_mouse_y = mouse_y; border_mouse_y = mouse_y;
printf("%i\n", border_mouse_buttons); D("%i\n", border_mouse_buttons);
/* if (border_mouse_buttons) D_RETURN; */ /* if (border_mouse_buttons) D_RETURN; */
/* border_mouse_buttons = mouse_buttons; */ /* border_mouse_buttons = mouse_buttons; */
printf("%p\n", current_ev); D("%p\n", current_ev);
if (!current_ev) D_RETURN; if (!current_ev) D_RETURN;
x = ((Ecore_Event_Mouse_Down *)(e->event))->x; x = ((Ecore_Event_Mouse_Down *)(e->event))->x;
y = ((Ecore_Event_Mouse_Down *)(e->event))->y; y = ((Ecore_Event_Mouse_Down *)(e->event))->y;
@ -1151,7 +1152,7 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e)
if (b->click_grab == g) b->click_grab = NULL; if (b->click_grab == g) b->click_grab = NULL;
if (g->remove_after) if (g->remove_after)
{ {
printf("pfft ungrab %s\n", b->client.title); D("pfft ungrab %s\n", b->client.title);
ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
ecore_window_button_grab_auto_replay_set(b->win.main, NULL); ecore_window_button_grab_auto_replay_set(b->win.main, NULL);
ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *)(e->event))->time); ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *)(e->event))->time);
@ -1162,7 +1163,7 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e)
} }
} }
} }
printf("(...e_cb_border_mouse_down...)\n"); D("(...e_cb_border_mouse_down...)\n");
{ {
E_Action_Type act; E_Action_Type act;
Ecore_Event_Key_Modifiers mods; Ecore_Event_Key_Modifiers mods;
@ -1801,7 +1802,7 @@ e_border_remove_mouse_grabs(E_Border *b)
E_Grab *g; E_Grab *g;
g = l->data; g = l->data;
printf("nooo grabs\n"); D("nooo grabs\n");
ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
FREE(g); FREE(g);
} }
@ -1860,7 +1861,7 @@ e_border_attach_mouse_grabs(E_Border *b)
g->any_mod = 0; g->any_mod = 0;
g->remove_after = 1; g->remove_after = 1;
b->grabs = evas_list_append(b->grabs, g); b->grabs = evas_list_append(b->grabs, g);
printf("attach... grab me baaaybe %8x | %s\n", b->win.client, b->client.title); D("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_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); ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query);
b->click_grab = g; b->click_grab = g;
@ -1955,12 +1956,12 @@ e_border_redo_grabs(void)
grabs_db = e_config_get("grabs"); grabs_db = e_config_get("grabs");
settings_db = e_config_get("settings"); settings_db = e_config_get("settings");
mod = e_file_modified_time(grabs_db); mod = e_file_mod_time(grabs_db);
if (mod != mod_date_grabs) changed = 1; if (mod != mod_date_grabs) changed = 1;
mod_date_grabs = mod; mod_date_grabs = mod;
if (!changed) if (!changed)
{ {
mod = e_file_modified_time(settings_db); mod = e_file_mod_time(settings_db);
if (mod != mod_date_settings) changed = 1; if (mod != mod_date_settings) changed = 1;
mod_date_settings = mod; mod_date_settings = mod;
} }
@ -2713,7 +2714,7 @@ e_border_current_focused(void)
E_Border *b; E_Border *b;
b = l->data; b = l->data;
printf("%s: %i | %i\n", b->client.title, D("%s: %i | %i\n", b->client.title,
b->current.selected, b->current.select_lost_from_grab); b->current.selected, b->current.select_lost_from_grab);
} }
for (l = borders; l; l = l->next) for (l = borders; l; l = l->next)
@ -2823,9 +2824,9 @@ e_border_raise_next(void)
current = (E_Border *)next->data; current = (E_Border *)next->data;
} }
printf("current desk coords %d, %d, real dim %d, %d\n", current->desk->x, D("current desk coords %d, %d, real dim %d, %d\n", current->desk->x,
current->desk->y, current->desk->real.w, current->desk->real.h); current->desk->y, current->desk->real.w, current->desk->real.h);
printf("current coords %d, %d\n", current->current.x, D("current coords %d, %d\n", current->current.x,
current->current.y); current->current.y);
e_border_raise(current); e_border_raise(current);

View File

@ -1,5 +1,6 @@
#include "debug.h" #include "debug.h"
#include "config.h" #include "config.h"
#include "file.h"
#include "util.h" #include "util.h"
static char cfg_root[] = ""; static char cfg_root[] = "";
@ -154,7 +155,7 @@ e_config_user_dir(void)
if (cfg_user_dir[0]) D_RETURN_(cfg_user_dir); if (cfg_user_dir[0]) D_RETURN_(cfg_user_dir);
if (cfg_root[0]) D_RETURN_(cfg_root); if (cfg_root[0]) D_RETURN_(cfg_root);
#if 1 /* disabled for now - use system ones only */ #if 1 /* disabled for now - use system ones only */
sprintf(cfg_user_dir, "%s/.e/", e_file_home()); sprintf(cfg_user_dir, "%s/.e/", e_util_get_user_home());
#else #else
sprintf(cfg_user_dir, PACKAGE_DATA_DIR"/data/config/"); sprintf(cfg_user_dir, PACKAGE_DATA_DIR"/data/config/");
#endif #endif
@ -288,8 +289,6 @@ e_config_load(char *file, char *prefix, E_Config_Base_Type *type)
break; break;
case E_CFG_TYPE_KEY: case E_CFG_TYPE_KEY:
{ {
char *val;
sprintf(buf, "%s/%s", prefix, node->prefix); sprintf(buf, "%s/%s", prefix, node->prefix);
(*((char **)(&(data[node->offset])))) = strdup(buf); (*((char **)(&(data[node->offset])))) = strdup(buf);
} }
@ -346,7 +345,7 @@ void ts(void)
/* no data file? */ /* no data file? */
if (!cfg_data) if (!cfg_data)
{ {
printf("no load!\n"); D("no load!\n");
} }
/* got data */ /* got data */
else else
@ -357,11 +356,11 @@ void ts(void)
{ {
List_Element *cfg_element; List_Element *cfg_element;
printf("element\n"); D("element\n");
cfg_element = l->data; cfg_element = l->data;
printf("... name %s\n", cfg_element->name); D("... name %s\n", cfg_element->name);
printf("... size %i\n", cfg_element->size); D("... size %i\n", cfg_element->size);
printf("... perc %3.3f\n", cfg_element->perc); D("... perc %3.3f\n", cfg_element->perc);
} }
} }
exit(0); exit(0);

View File

@ -2,6 +2,7 @@
#include "cursors.h" #include "cursors.h"
#include "config.h" #include "config.h"
#include "util.h" #include "util.h"
#include "file.h"
typedef struct _e_cursor E_Cursor; typedef struct _e_cursor E_Cursor;
@ -73,7 +74,7 @@ e_cursors_find(char *type)
char buf[PATH_MAX]; char buf[PATH_MAX];
sprintf(buf, "%s/%s.db", e_config_get("cursors"), type); sprintf(buf, "%s/%s.db", e_config_get("cursors"), type);
if (e_file_modified_time(buf) > c->mod) if (e_file_mod_time(buf) > c->mod)
{ {
cursors = evas_list_remove(cursors, c); cursors = evas_list_remove(cursors, c);
IF_FREE(c->type); IF_FREE(c->type);
@ -113,7 +114,7 @@ e_cursors_display_in_window(Window win, char *type)
e_strdup(c->type, type); e_strdup(c->type, type);
sprintf(buf, "%s/%s.db", e_config_get("cursors"), type); sprintf(buf, "%s/%s.db", e_config_get("cursors"), type);
c->mod = e_file_modified_time(buf); c->mod = e_file_mod_time(buf);
E_DB_INT_GET(buf, "/cursor/x", hx, ok); E_DB_INT_GET(buf, "/cursor/x", hx, ok);
E_DB_INT_GET(buf, "/cursor/y", hy, ok); E_DB_INT_GET(buf, "/cursor/y", hy, ok);
sprintf(buf, "%s/%s.db:/cursor/image", e_config_get("cursors"), type); sprintf(buf, "%s/%s.db:/cursor/image", e_config_get("cursors"), type);
@ -247,7 +248,6 @@ e_cursors_display(char *type)
IF_FREE(cur_cursor); IF_FREE(cur_cursor);
e_strdup(cur_cursor, type); e_strdup(cur_cursor, type);
printf("%s\n", type);
cursor_change = 1; cursor_change = 1;
D_RETURN; D_RETURN;

View File

@ -47,15 +47,38 @@ void e_desktops_init(void);
void e_desktops_scroll(E_Desktop *desk, int dx, int dy); void e_desktops_scroll(E_Desktop *desk, int dx, int dy);
void e_desktops_free(E_Desktop *desk); void e_desktops_free(E_Desktop *desk);
/**
* e_desktops_init_file_display - Loads desktop graphics information
* @desk: The desktop for which the graphics are loaded
*
* This function loads the desktop's graphics from the user's desktop
* file definition, which lives in ~/.e/desktop/default/.e_background.bg.db.
*/
void e_desktops_init_file_display(E_Desktop *desk); void e_desktops_init_file_display(E_Desktop *desk);
E_Desktop *e_desktops_new(void); E_Desktop *e_desktops_new(void);
void e_desktops_add_border(E_Desktop *d, E_Border *b); void e_desktops_add_border(E_Desktop *d, E_Border *b);
void e_desktops_del_border(E_Desktop *d, E_Border *b); void e_desktops_del_border(E_Desktop *d, E_Border *b);
void e_desktops_delete(E_Desktop *d); void e_desktops_delete(E_Desktop *d);
void e_desktops_show(E_Desktop *d); void e_desktops_show(E_Desktop *d);
void e_desktops_hide(E_Desktop *d); void e_desktops_hide(E_Desktop *d);
/**
* e_desktops_get_num - Returns number of desktops.
*/
int e_desktops_get_num(void); int e_desktops_get_num(void);
/**
* e_desktops_get - Returns nth desktop
* @d: The number of the desktop to get
*
* The desktops are stored in a linked list. This function
* returns the nth of those desktops, NULL if no desktop
* was found at that index.
*/
E_Desktop *e_desktops_get(int d); E_Desktop *e_desktops_get(int d);
int e_desktops_get_current(void); int e_desktops_get_current(void);
void e_desktops_goto_desk(int d); void e_desktops_goto_desk(int d);
void e_desktops_goto(int d, int ax, int ay); void e_desktops_goto(int d, int ax, int ay);

View File

@ -6,7 +6,7 @@ void e_ferite_init(void)
{ {
D_ENTER; D_ENTER;
printf( "Initialising ferite....\n" ); D( "Initialising ferite....\n" );
ferite_init( 0, NULL ); ferite_init( 0, NULL );
D_RETURN; D_RETURN;
@ -16,7 +16,7 @@ void e_ferite_deinit(void)
{ {
D_ENTER; D_ENTER;
printf( "Deinitialising ferite....\n" ); D( "Deinitialising ferite....\n" );
ferite_deinit(); ferite_deinit();
D_RETURN; D_RETURN;
@ -46,14 +46,14 @@ void e_ferite_run( char *txt )
D_ENTER; D_ENTER;
printf( "Compiling script `%s'\n", txt ); D("Ferite: Compiling script `%s'\n", txt);
script = __ferite_compile_string( txt ); script = __ferite_compile_string( txt );
e_ferite_register( script, script->mainns ); e_ferite_register( script, script->mainns );
script->error_cb = e_ferite_script_error; script->error_cb = e_ferite_script_error;
script->warning_cb = e_ferite_script_warning; script->warning_cb = e_ferite_script_warning;
printf( "Executing script.\n" ); D("Ferite: executing script.\n");
ferite_script_execute( script ); ferite_script_execute( script );
printf( "Cleaning up.\n" ); D("Ferite: Cleaning up.\n");
ferite_script_delete( script ); ferite_script_delete( script );
D_RETURN; D_RETURN;

View File

@ -431,7 +431,7 @@ e_entry_new(void)
} }
void void
e_entry_handlecore_keypress(E_Entry *entry, Ecore_Event_Key_Down *e) e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e)
{ {
D_ENTER; D_ENTER;
@ -506,7 +506,7 @@ e_entry_handlecore_keypress(E_Entry *entry, Ecore_Event_Key_Down *e)
type = ecore_keypress_translate_into_typeable(e); type = ecore_keypress_translate_into_typeable(e);
if (type) if (type)
{ {
printf("%0x\n", type[0]); D("Keypress: %0x\n", type[0]);
if ((strlen(type) == 1) && (type[0] == 0x01)) /* ctrl+a */ if ((strlen(type) == 1) && (type[0] == 0x01)) /* ctrl+a */
{ {
entry->cursor_pos = 0; entry->cursor_pos = 0;
@ -970,7 +970,7 @@ e_entry_get_selection(E_Entry *entry)
len = entry->select.length; len = entry->select.length;
if (entry->select.start + entry->select.length >= (int)strlen(entry->buffer)) if (entry->select.start + entry->select.length >= (int)strlen(entry->buffer))
len = strlen(entry->buffer) - entry->select.start; len = strlen(entry->buffer) - entry->select.start;
str2 = e_memdup(&(entry->buffer[entry->select.start]), len + 1); str2 = e_util_memdup(&(entry->buffer[entry->select.start]), len + 1);
str2[len] = 0; str2[len] = 0;
D_RETURN_(str2); D_RETURN_(str2);
} }

View File

@ -49,7 +49,7 @@ void e_entry_init(void);
void e_entry_free(E_Entry *entry); void e_entry_free(E_Entry *entry);
E_Entry *e_entry_new(void); E_Entry *e_entry_new(void);
void e_entry_handlecore_keypress(E_Entry *entry, Ecore_Event_Key_Down *e); void e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e);
void e_entry_set_evas(E_Entry *entry, Evas evas); void e_entry_set_evas(E_Entry *entry, Evas evas);
void e_entry_show(E_Entry *entry); void e_entry_show(E_Entry *entry);
void e_entry_hide(E_Entry *entry); void e_entry_hide(E_Entry *entry);

View File

@ -25,7 +25,7 @@ e_exec_restart(void)
D_ENTER; D_ENTER;
printf("e_exec_restart()\n"); D("e_exec_restart()\n");
/* unset events on root */ /* unset events on root */
ecore_window_set_events(0, XEV_NONE); ecore_window_set_events(0, XEV_NONE);
/* destroy all desktops */ /* destroy all desktops */
@ -107,14 +107,14 @@ e_exec_in_dir_with_env(char *exe, char *dir, int *launch_id_ret, char **env, cha
{ {
while (*env) while (*env)
{ {
e_set_env(env[0], env[1]); e_util_set_env(env[0], env[1]);
env += 2; env += 2;
} }
} }
/* launch Id hack - if it's an X program the windows popped up should */ /* launch Id hack - if it's an X program the windows popped up should */
/* have this launch Id number set on them - as well as process ID */ /* have this launch Id number set on them - as well as process ID */
/* machine name, and user name */ /* machine name, and user name */
if (launch_path) e_set_env("E_HACK_LAUNCH_PATH", launch_path); if (launch_path) e_util_set_env("E_HACK_LAUNCH_PATH", launch_path);
sprintf(preload_paths, "E_HACK_LAUNCH_ID=%i LD_PRELOAD_PATH='%s'", sprintf(preload_paths, "E_HACK_LAUNCH_ID=%i LD_PRELOAD_PATH='%s'",
launch_id, PACKAGE_LIB_DIR); launch_id, PACKAGE_LIB_DIR);
sprintf(preload, "LD_PRELOAD='libehack.so libX11.so libdl.so'"); sprintf(preload, "LD_PRELOAD='libehack.so libX11.so libdl.so'");

218
src/file.c Normal file
View File

@ -0,0 +1,218 @@
#include "debug.h"
#include "file.h"
#include "util.h"
time_t
e_file_mod_time(char *file)
{
struct stat st;
D_ENTER;
if (stat(file, &st) < 0) D_RETURN_(0);
D_RETURN_(st.st_mtime);
}
int
e_file_exists(char *file)
{
struct stat st;
D_ENTER;
if (stat(file, &st) < 0) D_RETURN_(0);
D_RETURN_(1);
}
int
e_file_is_dir(char *file)
{
struct stat st;
D_ENTER;
if (stat(file, &st) < 0) D_RETURN_(0);
if (S_ISDIR(st.st_mode)) D_RETURN_(1);
D_RETURN_(0);
}
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)
{
D_ENTER;
if (mkdir(dir, default_mode) < 0) D_RETURN_(0);
D_RETURN_(1);
}
int
e_file_cp(char *src, char *dst)
{
FILE *f1, *f2;
char buf[16384];
size_t num;
D_ENTER;
f1 = fopen(src, "rb");
if (!f1) D_RETURN_(0);
f2 = fopen(dst, "wb");
if (!f2)
{
fclose(f1);
D_RETURN_(0);
}
while ((num = fread(buf, 1, 16384, f1)) > 0) fwrite(buf, 1, num, f2);
fclose(f1);
fclose(f2);
D_RETURN_(1);
}
char *
e_file_realpath(char *file)
{
char buf[PATH_MAX];
char *f;
D_ENTER;
if (!realpath(file, buf)) D_RETURN_(strdup(""));
e_strdup(f, buf);
D_RETURN_(f);
}
char *
e_file_get_file(char *path)
{
char *result = NULL;
D_ENTER;
if (!path)
D_RETURN_(NULL);
if ((result = strrchr(path, '/')))
result++;
else
result = path;
D_RETURN_(result);
}
char *
e_file_get_dir(char *file)
{
char *p;
char *f;
char buf[PATH_MAX];
D_ENTER;
strcpy(buf, file);
p = strrchr(buf, '/');
if (!p)
{
e_strdup(f, file);
D_RETURN_(f);
}
*p = 0;
e_strdup(f, buf);
D_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;
D_ENTER;
if (!st) D_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;
}
D_RETURN_(ok);
}
char *
e_file_readlink(char *link)
{
char buf[PATH_MAX];
char *f;
int count;
D_ENTER;
if ((count = readlink(link, buf, sizeof(buf))) < 0) D_RETURN_(NULL);
buf[count] = 0;
e_strdup(f, buf);
D_RETURN_(f);
}
Evas_List
e_file_ls(char *dir)
{
DIR *dirp;
struct dirent *dp;
Evas_List list;
D_ENTER;
dirp = opendir(dir);
if (!dirp) D_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);
D_RETURN_(list);
}

39
src/file.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef E_FILE_H
#define E_FILE_H
#include "e.h"
time_t e_file_mod_time(char *file);
int e_file_exists(char *file);
int e_file_is_dir(char *file);
int e_file_mkdir(char *dir);
int e_file_cp(char *src, char *dst);
char *e_file_realpath(char *file);
/**
* e_file_get_file - returns file in a path
* @path: The chanonical path to a file
*
* This functions returns the file name (everything
* after the last "/") of a full path. It returns
* a pointer into the original string, so you don't
* need to free the result.
*/
char *e_file_get_file(char *path);
/**
* e_file_get_dir - returns directory in a path
* @path: The chanonical path to a file
*
* This functions returns the directory name (everything
* before the last "/") of a full path. It returns
* a freshly allocated string, so you need to free
*the result.
*/
char *e_file_get_dir(char *path);
int e_file_can_exec(struct stat *st);
char *e_file_readlink(char *link);
Evas_List e_file_ls(char *dir);
#endif

View File

@ -8,8 +8,8 @@ static Evas_List fs_restart_handlers = NULL;
static pid_t efsd_pid = 0; static pid_t efsd_pid = 0;
static void e_fs_child_handle(Ecore_Event *ev); static void e_fs_child_handle(Ecore_Event *ev);
static void _e_fs_fd_handle(int fd); static void e_fs_fd_handle(int fd);
static void _e_fs_restarter(int val, void *data); static void e_fs_restarter(int val, void *data);
static void e_fs_idle(void *data); static void e_fs_idle(void *data);
static void e_fs_flush_timeout(int val, void *data); static void e_fs_flush_timeout(int val, void *data);
@ -50,21 +50,21 @@ e_fs_child_handle(Ecore_Event *ev)
D_ENTER; D_ENTER;
e = ev->event; e = ev->event;
printf("pid went splat! (%i)\n", e->pid); D("pid went splat! (%i)\n", e->pid);
if (e->pid == efsd_pid) if (e->pid == efsd_pid)
{ {
printf("it was efsd!\n"); D("it was efsd!\n");
if (ec) efsd_close(ec); if (ec) efsd_close(ec);
ec = NULL; ec = NULL;
efsd_pid = 0; efsd_pid = 0;
_e_fs_restarter(1, NULL); e_fs_restarter(1, NULL);
} }
D_RETURN; D_RETURN;
} }
static void static void
_e_fs_fd_handle(int fd) e_fs_fd_handle(int fd)
{ {
double start, current; double start, current;
@ -93,17 +93,17 @@ _e_fs_fd_handle(int fd)
efsd_close(ec); efsd_close(ec);
ecore_del_event_fd(fd); ecore_del_event_fd(fd);
ec = NULL; ec = NULL;
_e_fs_restarter(0, NULL); e_fs_restarter(0, NULL);
/* FIXME: need to queue a popup dialog here saying */ /* FIXME: need to queue a popup dialog here saying */
/* efsd went wonky */ /* efsd went wonky */
printf("EEEEEEEEEEK efsd went wonky. Bye bye efsd.\n"); D("EEEEEEEEEEK efsd went wonky. Bye bye efsd.\n");
} }
/* spent more thna 1/20th of a second here.. get out */ /* spent more thna 1/20th of a second here.. get out */
current = ecore_get_time(); current = ecore_get_time();
if ((current - start) > 0.05) if ((current - start) > 0.05)
{ {
printf("fs... too much time spent..\n"); D("fs... too much time spent..\n");
break; break;
} }
} }
@ -112,7 +112,7 @@ _e_fs_fd_handle(int fd)
} }
static void static void
_e_fs_restarter(int val, void *data) e_fs_restarter(int val, void *data)
{ {
D_ENTER; D_ENTER;
@ -125,7 +125,7 @@ _e_fs_restarter(int val, void *data)
if (efsd_pid <= 0) if (efsd_pid <= 0)
{ {
efsd_pid = e_exec_run("efsd -f"); efsd_pid = e_exec_run("efsd -f");
printf("launch efsd... %i\n", efsd_pid); D("launch efsd... %i\n", efsd_pid);
} }
if (efsd_pid > 0) ec = efsd_open(); if (efsd_pid > 0) ec = efsd_open();
} }
@ -133,7 +133,7 @@ _e_fs_restarter(int val, void *data)
{ {
Evas_List l; Evas_List l;
ecore_add_event_fd(efsd_get_connection_fd(ec), _e_fs_fd_handle); ecore_add_event_fd(efsd_get_connection_fd(ec), e_fs_fd_handle);
for (l = fs_restart_handlers; l; l = l->next) for (l = fs_restart_handlers; l; l = l->next)
{ {
E_FS_Restarter *rs; E_FS_Restarter *rs;
@ -148,7 +148,7 @@ _e_fs_restarter(int val, void *data)
gap = (double)val / 10; gap = (double)val / 10;
if (gap > 10.0) gap = 10.0; if (gap > 10.0) gap = 10.0;
ecore_add_event_timer("e_fs_restarter", gap, _e_fs_restarter, val + 1, NULL); ecore_add_event_timer("e_fs_restarter", gap, e_fs_restarter, val + 1, NULL);
} }
D_RETURN; D_RETURN;
@ -214,7 +214,7 @@ e_fs_init(void)
writeable, and then calling efsd_flush(). writeable, and then calling efsd_flush().
*/ */
ecore_event_filter_idle_handler_add(e_fs_idle, NULL); ecore_event_filter_idle_handler_add(e_fs_idle, NULL);
_e_fs_restarter(0, NULL); e_fs_restarter(0, NULL);
D_RETURN; D_RETURN;
} }

View File

@ -180,7 +180,7 @@ e_icccm_get_pos_info(Window win, E_Border *b)
{ {
int x, y, w, h; int x, y, w, h;
printf("%li %li\n", hint.flags & USPosition, hint.flags & PPosition); D("%li %li\n", hint.flags & USPosition, hint.flags & PPosition);
b->client.pos.requested = 1; b->client.pos.requested = 1;
b->client.pos.gravity = NorthWestGravity; b->client.pos.gravity = NorthWestGravity;
if (hint.flags & PWinGravity) if (hint.flags & PWinGravity)

View File

@ -1207,7 +1207,7 @@ e_menu_hide(E_Menu *m)
{ {
D_ENTER; D_ENTER;
printf("Menu hide!\n"); D("Menu hide!\n");
if (m->selected) if (m->selected)
{ {

View File

@ -3,6 +3,7 @@
#include "menubuild.h" #include "menubuild.h"
#include "exec.h" #include "exec.h"
#include "util.h" #include "util.h"
#include "file.h"
#ifdef USE_FERITE #ifdef USE_FERITE
# include "e_ferite.h" # include "e_ferite.h"
@ -47,7 +48,7 @@ e_build_menu_cb_script(E_Menu *m, E_Menu_Item *mi, void *data)
script = data; script = data;
e_ferite_run(script); e_ferite_run(script);
#else #else
printf( "No cookies for you. You will have to install ferite.\n" ); D("No cookies for you. You will have to install ferite.\n");
#endif #endif
D_RETURN; D_RETURN;
@ -106,7 +107,7 @@ e_build_menu_db_poll(int val, void *data)
D_ENTER; D_ENTER;
bm = data; bm = data;
mod = e_file_modified_time(bm->file); mod = e_file_mod_time(bm->file);
if (mod <= bm->mod_time) if (mod <= bm->mod_time)
{ {
ecore_add_event_timer(bm->file, 1.0, e_build_menu_db_poll, 0, data); ecore_add_event_timer(bm->file, 1.0, e_build_menu_db_poll, 0, data);
@ -133,7 +134,7 @@ e_build_menu_gnome_apps_poll(int val, void *data)
D_ENTER; D_ENTER;
bm = data; bm = data;
mod = e_file_modified_time(bm->file); mod = e_file_mod_time(bm->file);
if (mod <= bm->mod_time) if (mod <= bm->mod_time)
{ {
ecore_add_event_timer(bm->file, 1.0, e_build_menu_gnome_apps_poll, 0, data); ecore_add_event_timer(bm->file, 1.0, e_build_menu_gnome_apps_poll, 0, data);
@ -278,7 +279,7 @@ e_build_menu_gnome_apps_build_dir(E_Build_Menu *bm, char *dir)
fclose(f); fclose(f);
} }
/* read dir listing in alphabetical order and use that to suppliment */ /* read dir listing in alphabetical order and use that to suppliment */
dirlist = e_file_list_dir(dir); dirlist = e_file_ls(dir);
for (l = dirlist; l; l = l->next) for (l = dirlist; l; l = l->next)
{ {
char *s; char *s;
@ -353,8 +354,8 @@ e_build_menu_gnome_apps_build_dir(E_Build_Menu *bm, char *dir)
buf[buf_len - 1] = 0; buf[buf_len - 1] = 0;
/* look for Name= */ /* look for Name= */
if ((!name) && if ((!name) &&
(((e_glob_matches(buf, "Name[en]=*")) || (((e_util_glob_matches(buf, "Name[en]=*")) ||
(e_glob_matches(buf, "Name=*"))))) (e_util_glob_matches(buf, "Name=*")))))
{ {
char *eq; char *eq;
@ -364,7 +365,7 @@ e_build_menu_gnome_apps_build_dir(E_Build_Menu *bm, char *dir)
} }
/* look for Icon= */ /* look for Icon= */
else if ((!icon) && else if ((!icon) &&
((e_glob_matches(buf, "Icon=*")))) ((e_util_glob_matches(buf, "Icon=*"))))
{ {
char *eq; char *eq;
@ -379,7 +380,7 @@ e_build_menu_gnome_apps_build_dir(E_Build_Menu *bm, char *dir)
} }
/* look for Icon= */ /* look for Icon= */
else if ((!exe) && else if ((!exe) &&
((e_glob_matches(buf, "Exec=*")))) ((e_util_glob_matches(buf, "Exec=*"))))
{ {
char *eq; char *eq;

View File

@ -39,7 +39,7 @@ e_object_ref(E_Object *obj)
D_RETURN; D_RETURN;
obj->references++; obj->references++;
printf("++ refcount on %p, now %i\n", obj, obj->references); D("++ refcount on %p, now %i\n", obj, obj->references);
D_RETURN; D_RETURN;
} }
@ -54,11 +54,11 @@ e_object_unref(E_Object *obj)
obj->references--; obj->references--;
printf("-- refcount on %p, now %i\n", obj, obj->references); D("-- refcount on %p, now %i\n", obj, obj->references);
if (obj->references == 0 && obj->cleanup_func) if (obj->references == 0 && obj->cleanup_func)
{ {
printf("Refcount is zero, freeing.\n"); D("Refcount is zero, freeing.\n");
obj->cleanup_func(obj); obj->cleanup_func(obj);
D_RETURN_(0); D_RETURN_(0);
} }

View File

@ -1,20 +1,8 @@
#include "debug.h" #include "debug.h"
#include "util.h" #include "util.h"
time_t
e_file_modified_time(char *file)
{
struct stat st;
D_ENTER;
if (stat(file, &st) < 0) D_RETURN_(0);
D_RETURN_(st.st_mtime);
}
void void
e_set_env(char *variable, char *content) e_util_set_env(char *variable, char *content)
{ {
char env[PATH_MAX]; char env[PATH_MAX];
@ -26,33 +14,8 @@ e_set_env(char *variable, char *content)
D_RETURN; D_RETURN;
} }
int
e_file_exists(char *file)
{
struct stat st;
D_ENTER;
if (stat(file, &st) < 0) D_RETURN_(0);
D_RETURN_(1);
}
int
e_file_is_dir(char *file)
{
struct stat st;
D_ENTER;
if (stat(file, &st) < 0) D_RETURN_(0);
if (S_ISDIR(st.st_mode)) D_RETURN_(1);
D_RETURN_(0);
}
char * char *
e_file_home(void) e_util_get_user_home(void)
{ {
static char *home = NULL; static char *home = NULL;
@ -66,99 +29,8 @@ e_file_home(void)
D_RETURN_(home); D_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)
{
D_ENTER;
if (mkdir(dir, default_mode) < 0) D_RETURN_(0);
D_RETURN_(1);
}
int
e_file_cp(char *src, char *dst)
{
FILE *f1, *f2;
char buf[16384];
size_t num;
D_ENTER;
f1 = fopen(src, "rb");
if (!f1) D_RETURN_(0);
f2 = fopen(dst, "wb");
if (!f2)
{
fclose(f1);
D_RETURN_(0);
}
while ((num = fread(buf, 1, 16384, f1)) > 0) fwrite(buf, 1, num, f2);
fclose(f1);
fclose(f2);
D_RETURN_(1);
}
char *
e_file_real(char *file)
{
char buf[PATH_MAX];
char *f;
D_ENTER;
if (!realpath(file, buf)) D_RETURN_(strdup(""));
e_strdup(f, buf);
D_RETURN_(f);
}
char *
e_file_get_file(char *file)
{
char *p;
char *f;
D_ENTER;
p = strrchr(file, '/');
if (!p)
{
e_strdup(f, file);
D_RETURN_(f);
}
e_strdup(f, &(p[1]));
D_RETURN_(f);
}
char *
e_file_get_dir(char *file)
{
char *p;
char *f;
char buf[PATH_MAX];
D_ENTER;
strcpy(buf, file);
p = strrchr(buf, '/');
if (!p)
{
e_strdup(f, file);
D_RETURN_(f);
}
*p = 0;
e_strdup(f, buf);
D_RETURN_(f);
}
void * void *
e_memdup(void *data, int size) e_util_memdup(void *data, int size)
{ {
void *data_dup; void *data_dup;
@ -172,7 +44,7 @@ e_memdup(void *data, int size)
} }
int int
e_glob_matches(char *str, char *glob) e_util_glob_matches(char *str, char *glob)
{ {
D_ENTER; D_ENTER;
@ -181,89 +53,3 @@ e_glob_matches(char *str, char *glob)
D_RETURN_(0); D_RETURN_(0);
} }
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;
D_ENTER;
if (!st) D_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;
}
D_RETURN_(ok);
}
char *
e_file_link(char *link)
{
char buf[PATH_MAX];
char *f;
int count;
D_ENTER;
if ((count = readlink(link, buf, sizeof(buf))) < 0) D_RETURN_(NULL);
buf[count] = 0;
e_strdup(f, buf);
D_RETURN_(f);
}
Evas_List
e_file_list_dir(char *dir)
{
DIR *dirp;
struct dirent *dp;
Evas_List list;
D_ENTER;
dirp = opendir(dir);
if (!dirp) D_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);
D_RETURN_(list);
}

View File

@ -3,21 +3,10 @@
#include "e.h" #include "e.h"
time_t e_file_modified_time(char *file); void e_util_set_env(char *variable, char *content);
void e_set_env(char *variable, char *content); char *e_util_get_user_home(void);
int e_file_exists(char *file); void *e_util_memdup(void *data, int size);
int e_file_is_dir(char *file); int e_util_glob_matches(char *str, char *glob);
char *e_file_home(void);
int e_file_mkdir(char *dir);
int e_file_cp(char *src, char *dst);
char *e_file_real(char *file);
char *e_file_get_file(char *file);
char *e_file_get_dir(char *file);
void *e_memdup(void *data, int size);
int e_glob_matches(char *str, char *glob);
int e_file_can_exec(struct stat *st);
char *e_file_link(char *link);
Evas_List e_file_list_dir(char *dir);
#define e_strdup(__dest, __var) \ #define e_strdup(__dest, __var) \
{ \ { \

View File

@ -10,6 +10,7 @@
#include "menu.h" #include "menu.h"
#include "menubuild.h" #include "menubuild.h"
#include "fs.h" #include "fs.h"
#include "file.h"
#include "util.h" #include "util.h"
static Evas_List views = NULL; static Evas_List views = NULL;
@ -72,7 +73,7 @@ e_view_write_icon_xy_timeout(int val, void *data)
ic->q.write_xy = 0; ic->q.write_xy = 0;
sprintf(buf, "%s/%s", ic->view->dir, ic->file); sprintf(buf, "%s/%s", ic->view->dir, ic->file);
printf("write meta xy for icon for file %s\n", ic->file); D("write meta xy for icon for file %s\n", ic->file);
efsd_set_metadata_int(e_fs_get_connection(), efsd_set_metadata_int(e_fs_get_connection(),
"/pos/x", buf, "/pos/x", buf,
ic->geom.x); ic->geom.x);
@ -83,6 +84,7 @@ e_view_write_icon_xy_timeout(int val, void *data)
} }
D_RETURN; D_RETURN;
UN(val);
} }
void void
@ -489,7 +491,7 @@ e_view_icon_update_state(E_Icon *ic)
if (!ic->info.icon) if (!ic->info.icon)
{ {
printf("EEEEEEEEEEK %s has no icon\n", ic->file); D("EEEEEEEEEEK %s has no icon\n", ic->file);
D_RETURN; D_RETURN;
} }
if (ic->state.clicked) if (ic->state.clicked)
@ -662,7 +664,8 @@ e_view_icon_exec(E_Icon *ic)
{ {
D_ENTER; D_ENTER;
if (!strcmp(ic->info.mime.base, "dir")) if (!strcmp(ic->info.mime.base, "dir") &&
e_file_can_exec(&ic->stat))
{ {
E_View *v; E_View *v;
char buf[PATH_MAX]; char buf[PATH_MAX];
@ -680,7 +683,7 @@ e_view_icon_exec(E_Icon *ic)
v->bg = e_background_load(buf); v->bg = e_background_load(buf);
} }
sprintf(buf, "%s/%s", ic->view->dir, ic->file); sprintf(buf, "%s/%s", ic->view->dir, ic->file);
printf("new dir >%s<\n", buf); D("new dir >%s<\n", buf);
v->dir = strdup(buf); v->dir = strdup(buf);
e_view_realize(v); e_view_realize(v);
ecore_window_set_title(v->win.base, ic->file); ecore_window_set_title(v->win.base, ic->file);
@ -1068,7 +1071,7 @@ e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
Evas_List ll; Evas_List ll;
v = l->data; v = l->data;
printf("sel count %i\n", v->sel_count); D("sel count %i\n", v->sel_count);
if (v->sel_count > 0) if (v->sel_count > 0)
{ {
for (ll = v->icons; ll; ll = ll->next) for (ll = v->icons; ll; ll = ll->next)
@ -1163,7 +1166,7 @@ e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
icy = iy + v->location.y - wy; icy = iy + v->location.y - wy;
if (!ic->info.icon) if (!ic->info.icon)
{ {
printf("EEEEEEEEEEK %s has no icon\n", ic->file); D("EEEEEEEEEEK %s has no icon\n", ic->file);
D_RETURN; D_RETURN;
} }
if (ic->state.clicked) if (ic->state.clicked)
@ -1196,7 +1199,7 @@ e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
} }
else else
{ {
printf("eek cant load\n"); D("eek cant load\n");
} }
} }
} }
@ -1346,10 +1349,10 @@ e_configure(Ecore_Event * ev)
if (e->win == v->win.base) if (e->win == v->win.base)
{ {
/* win, root, x, y, w, h, wm_generated */ /* win, root, x, y, w, h, wm_generated */
printf("configure for view %s\n", v->dir); D("configure for view %s\n", v->dir);
if (e->wm_generated) if (e->wm_generated)
{ {
printf("wm generated %i %i, %ix%i\n", e->x, e->y, e->w, e->h); D("wm generated %i %i, %ix%i\n", e->x, e->y, e->w, e->h);
if ((e->x != v->location.x) || (e->y != v->location.y)) if ((e->x != v->location.x) || (e->y != v->location.y))
{ {
v->location.x = e->x; v->location.x = e->x;
@ -1357,11 +1360,11 @@ e_configure(Ecore_Event * ev)
e_view_queue_geometry_record(v); e_view_queue_geometry_record(v);
} }
} }
printf("size %ix%i\n", e->w, e->h); D("size %ix%i\n", e->w, e->h);
if ((e->w != v->size.w) || (e->h != v->size.h) || (v->size.force)) if ((e->w != v->size.w) || (e->h != v->size.h) || (v->size.force))
{ {
v->size.force = 0; v->size.force = 0;
printf("... a new size!\n"); D("... a new size!\n");
v->size.w = e->w; v->size.w = e->w;
v->size.h = e->h; v->size.h = e->h;
if (v->pmap) ecore_pixmap_free(v->pmap); if (v->pmap) ecore_pixmap_free(v->pmap);
@ -1380,7 +1383,7 @@ e_configure(Ecore_Event * ev)
{ {
e_background_set_size(v->bg, v->size.w, v->size.h); e_background_set_size(v->bg, v->size.w, v->size.h);
} }
printf("evas_set_output_viewpor(%p)\n", v->evas); D("evas_set_output_viewpor(%p)\n", v->evas);
evas_set_output_viewport(v->evas, 0, 0, v->size.w, v->size.h); evas_set_output_viewport(v->evas, 0, 0, v->size.w, v->size.h);
evas_set_output_size(v->evas, v->size.w, v->size.h); evas_set_output_size(v->evas, v->size.w, v->size.h);
e_view_scroll_to(v, v->scroll.x, v->scroll.y); e_view_scroll_to(v, v->scroll.x, v->scroll.y);
@ -1806,7 +1809,7 @@ e_view_handle_fs_restart(void *data)
v = data; v = data;
printf("e_view_handle_fs_restart\n"); D("e_view_handle_fs_restart\n");
for (l = v->icons; l; l = l->next) for (l = v->icons; l; l = l->next)
{ {
icons = evas_list_prepend(icons, l->data); icons = evas_list_prepend(icons, l->data);
@ -1849,7 +1852,7 @@ e_view_handle_fs_restart(void *data)
} }
v->is_listing = 1; v->is_listing = 1;
} }
printf("restarted monitor id (connection = %p), %i for %s\n", e_fs_get_connection(), v->monitor_id, v->dir); D("restarted monitor id (connection = %p), %i for %s\n", e_fs_get_connection(), v->monitor_id, v->dir);
v->is_listing = 1; v->is_listing = 1;
D_RETURN; D_RETURN;
@ -1923,7 +1926,10 @@ e_view_icon_show(E_Icon *ic)
{ {
D_ENTER; D_ENTER;
D("SHOWING ICON\n");
if (ic->state.visible) D_RETURN; if (ic->state.visible) D_RETURN;
D("SHOWING ICON REALLY\n");
ic->state.visible = 1; ic->state.visible = 1;
if (!ic->obj.event1) if (!ic->obj.event1)
{ {
@ -2067,6 +2073,27 @@ e_view_icon_apply_xy(E_Icon *ic)
D_RETURN; D_RETURN;
} }
void
e_view_icon_check_permissions(E_Icon *ic)
{
D_ENTER;
if (!ic || !ic->info.mime.base || ic->stat.st_ino == 0)
D_RETURN;
if (!strcmp(ic->info.mime.base, "dir"))
{
if (e_file_can_exec(&ic->stat))
evas_set_color(ic->view->evas, ic->obj.icon, 255, 255, 255, 255);
else
evas_set_color(ic->view->evas, ic->obj.icon, 128, 128, 128, 128);
}
D_RETURN;
}
static int static int
e_view_restart_alphabetical_qsort_cb(const void *data1, const void *data2) e_view_restart_alphabetical_qsort_cb(const void *data1, const void *data2)
{ {
@ -2093,7 +2120,7 @@ e_view_resort_alphabetical(E_View *v)
for (count = 0, l = v->icons; l; l = l->next) count++; for (count = 0, l = v->icons; l; l = l->next) count++;
array = malloc(sizeof(E_Icon *) * count); array = malloc(sizeof(E_Icon *) * count);
for (i = 0, l = v->icons; l; l = l->next) array[i++] = l->data; for (i = 0, l = v->icons; l; l = l->next) array[i++] = l->data;
printf("qsort %i elements...\n", count); D("qsort %i elements...\n", count);
qsort(array, count, sizeof(E_Icon *), qsort(array, count, sizeof(E_Icon *),
e_view_restart_alphabetical_qsort_cb); e_view_restart_alphabetical_qsort_cb);
for (i = 0; i < count; i++) icons = evas_list_append(icons, array[i]); for (i = 0; i < count; i++) icons = evas_list_append(icons, array[i]);
@ -2102,7 +2129,7 @@ e_view_resort_alphabetical(E_View *v)
evas_list_free(v->icons); evas_list_free(v->icons);
v->icons = icons; v->icons = icons;
printf("done...\n"); D("done...\n");
D_RETURN; D_RETURN;
} }
@ -2207,10 +2234,12 @@ e_view_icon_initial_show(E_Icon *ic)
{ {
D_ENTER; D_ENTER;
D("INITIAL SHOWING ICON\n");
/* check if we have enuf info and we havent been shown yet */ /* check if we have enuf info and we havent been shown yet */
if (!ic->info.icon) D_RETURN; if (!ic->info.icon) D_RETURN;
if (ic->state.visible) D_RETURN; if (ic->state.visible) D_RETURN;
D("INITIAL SHOWING ICON REALLY\n");
/* first. lets figure out the size of the icon */ /* first. lets figure out the size of the icon */
evas_get_image_size(ic->view->evas, ic->obj.icon, evas_get_image_size(ic->view->evas, ic->obj.icon,
&(ic->geom.icon.w), &(ic->geom.icon.h)); &(ic->geom.icon.w), &(ic->geom.icon.h));
@ -2255,7 +2284,7 @@ e_view_icon_set_mime(E_Icon *ic, char *base, char *mime)
ic->info.mime.base = strdup(base); ic->info.mime.base = strdup(base);
ic->info.mime.type = strdup(mime); ic->info.mime.type = strdup(mime);
printf("%40s: %s/%s\n", ic->file, base, mime); D("%40s: %s/%s\n", ic->file, base, mime);
/* effect changes here */ /* effect changes here */
if (ic->info.custom_icon) if (ic->info.custom_icon)
@ -2340,9 +2369,9 @@ e_view_file_added(int id, char *file)
D_ENTER; D_ENTER;
/* if we get a path - ignore it - its not a file in the a dir */ /* if we get a path - ignore it - its not a file in the dir */
if (!file) D_RETURN; if (!file) D_RETURN;
/* printf("FILE ADD: %s\n", file);*/ /* D("FILE ADD: %s\n", file);*/
if (file[0] == '/') D_RETURN; if (file[0] == '/') D_RETURN;
v = e_view_find_by_monitor_id(id); v = e_view_find_by_monitor_id(id);
if (!v) D_RETURN; if (!v) D_RETURN;
@ -2430,7 +2459,7 @@ e_view_file_moved(int id, char *file)
/* never gets called ? */ /* never gets called ? */
if (!file) D_RETURN; if (!file) D_RETURN;
printf(".!WOW!. e_view_file_moved(%i, %s);\n", id, file); D(".!WOW!. e_view_file_moved(%i, %s);\n", id, file);
if (file[0] == '/') D_RETURN; if (file[0] == '/') D_RETURN;
v = e_view_find_by_monitor_id(id); v = e_view_find_by_monitor_id(id);
if (!v) D_RETURN; if (!v) D_RETURN;
@ -2575,7 +2604,7 @@ e_view_set_dir(E_View *v, char *dir)
v->monitor_id = 0; v->monitor_id = 0;
} }
IF_FREE(v->dir); IF_FREE(v->dir);
v->dir = e_file_real(dir); v->dir = e_file_realpath(dir);
/* start monitoring new dir */ /* start monitoring new dir */
v->restarter = e_fs_add_restart_handler(e_view_handle_fs_restart, v); v->restarter = e_fs_add_restart_handler(e_view_handle_fs_restart, v);
if (e_fs_get_connection()) if (e_fs_get_connection())
@ -2600,7 +2629,7 @@ e_view_set_dir(E_View *v, char *dir)
v->monitor_id = efsd_start_monitor(e_fs_get_connection(), v->dir, v->monitor_id = efsd_start_monitor(e_fs_get_connection(), v->dir,
ops, TRUE); ops, TRUE);
} }
printf("monitor id for %s = %i\n", v->dir, v->monitor_id); D("monitor id for %s = %i\n", v->dir, v->monitor_id);
v->is_listing = 1; v->is_listing = 1;
v->changed = 1; v->changed = 1;
} }
@ -2768,35 +2797,35 @@ e_view_handle_fs(EfsdEvent *ev)
switch (ev->efsd_filechange_event.changetype) switch (ev->efsd_filechange_event.changetype)
{ {
case EFSD_FILE_CREATED: case EFSD_FILE_CREATED:
/* printf("EFSD_FILE_CREATED: %i %s\n", /* D("EFSD_FILE_CREATED: %i %s\n",
ev->efsd_filechange_event.id, ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
*/ e_view_file_added(ev->efsd_filechange_event.id, */ e_view_file_added(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
break; break;
case EFSD_FILE_EXISTS: case EFSD_FILE_EXISTS:
/* printf("EFSD_FILE_EXISTS: %i %s\n", /* D("EFSD_FILE_EXISTS: %i %s\n",
ev->efsd_filechange_event.id, ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file); */
*/ e_view_file_added(ev->efsd_filechange_event.id, e_view_file_added(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
break; break;
case EFSD_FILE_DELETED: case EFSD_FILE_DELETED:
/* printf("EFSD_FILE_DELETED: %i %s\n", /* D("EFSD_FILE_DELETED: %i %s\n",
ev->efsd_filechange_event.id, ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
*/ e_view_file_deleted(ev->efsd_filechange_event.id, */ e_view_file_deleted(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
break; break;
case EFSD_FILE_CHANGED: case EFSD_FILE_CHANGED:
/* printf("EFSD_CHANGE_CHANGED: %i %s\n", /* D("EFSD_CHANGE_CHANGED: %i %s\n",
ev->efsd_filechange_event.id, ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
*/ e_view_file_changed(ev->efsd_filechange_event.id, */ e_view_file_changed(ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
break; break;
case EFSD_FILE_MOVED: case EFSD_FILE_MOVED:
/* printf("EFSD_CHANGE_MOVED: %i %s\n", /* D("EFSD_CHANGE_MOVED: %i %s\n",
ev->efsd_filechange_event.id, ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
*/ e_view_file_moved(ev->efsd_filechange_event.id, */ e_view_file_moved(ev->efsd_filechange_event.id,
@ -2806,9 +2835,9 @@ e_view_handle_fs(EfsdEvent *ev)
{ {
E_View *v; E_View *v;
v = e_view_find_by_monitor_id(ev->efsd_filechange_event.id); v = e_view_find_by_monitor_id(efsd_reply_id(ev));
if (v) v->is_listing = 0; if (v) v->is_listing = 0;
/* printf("EFSD_CHANGE_END_EXISTS: %i %s\n", /* D("EFSD_CHANGE_END_EXISTS: %i %s\n",
ev->efsd_filechange_event.id, ev->efsd_filechange_event.id,
ev->efsd_filechange_event.file); ev->efsd_filechange_event.file);
*/ } */ }
@ -2833,23 +2862,21 @@ e_view_handle_fs(EfsdEvent *ev)
case EFSD_CMD_CHMOD: case EFSD_CMD_CHMOD:
break; break;
case EFSD_CMD_GETFILETYPE: case EFSD_CMD_GETFILETYPE:
/* printf("Getmime event %i\n", D("Getmime event %i\n",
ev->efsd_reply_event.command.efsd_file_cmd.id); ev->efsd_reply_event.command.efsd_file_cmd.id);
*/ if (ev->efsd_reply_event.errorcode == 0) if (ev->efsd_reply_event.errorcode == 0)
{ {
E_Icon *ic; E_Icon *ic;
E_View *v; E_View *v;
char *file, *file2; char *file;
file = NULL; file = NULL;
if (ev->efsd_reply_event.command.efsd_file_cmd.files) if ( (file = efsd_reply_filename(ev)) )
file = ev->efsd_reply_event.command.efsd_file_cmd.files[0];
if (file)
{ {
file2 = strrchr(file, '/'); file = e_file_get_file(file);
if (file2) file = file2 + 1;
} }
v = e_view_find_by_monitor_id(ev->efsd_reply_event.command.efsd_file_cmd.id); v = e_view_find_by_monitor_id(efsd_reply_id(ev));
if ((v) && (file)) if ((v) && (file))
{ {
ic = e_view_find_icon_by_file(v, file); ic = e_view_find_icon_by_file(v, file);
@ -2873,17 +2900,46 @@ e_view_handle_fs(EfsdEvent *ev)
strcpy(base, m); strcpy(base, m);
strcpy(mime, "unknown"); strcpy(mime, "unknown");
} }
/* printf("MIME: %s\n", m); /* D("MIME: %s\n", m);
*/ e_view_icon_set_mime(ic, base, mime); */ e_view_icon_set_mime(ic, base, mime);
/* Try to update the GUI according to the file permissions.
It's just a try because we need to have the file's stat
info as well.
*/
e_view_icon_check_permissions(ic);
D("GOT THERE!");
e_view_icon_initial_show(ic); e_view_icon_initial_show(ic);
} }
} }
} }
break; break;
case EFSD_CMD_STAT: case EFSD_CMD_STAT:
/* printf("Stat event %i\n", D("Stat event %i on %s\n",
ev->efsd_reply_event.command.efsd_file_cmd.id); efsd_reply_id(ev), efsd_reply_filename(ev));
*/ {
/* When everything went okay and we can find a view and an icon,
set the file stat data for the icon. Then try to check the
permissions and possibly update the gui. It's just a try
because we need to have received the filetype info too.
*/
if (ev->efsd_reply_event.errorcode == 0)
{
E_Icon *ic;
E_View *v;
v = e_view_find_by_monitor_id(efsd_reply_id(ev));
if (v)
{
ic = e_view_find_icon_by_file(v, e_file_get_file(efsd_reply_filename(ev)));
if (ic)
{
ic->stat = *((struct stat*)efsd_reply_data(ev));
e_view_icon_check_permissions(ic);
}
}
} }
break; break;
case EFSD_CMD_READLINK: case EFSD_CMD_READLINK:
@ -2892,23 +2948,20 @@ e_view_handle_fs(EfsdEvent *ev)
E_Icon *ic; E_Icon *ic;
E_View *v; E_View *v;
char *file, *file2; char *file;
file = NULL; file = NULL;
if (ev->efsd_reply_event.command.efsd_file_cmd.files) if ( (file = efsd_reply_filename(ev)) )
file = ev->efsd_reply_event.command.efsd_file_cmd.files[0];
if (file)
{ {
file2 = strrchr(file, '/'); file = e_file_get_file(file);
if (file2) file = file2 + 1;
} }
v = e_view_find_by_monitor_id(ev->efsd_reply_event.command.efsd_file_cmd.id); v = e_view_find_by_monitor_id(efsd_reply_id(ev));
if ((v) && (file)) if ((v) && (file))
{ {
ic = e_view_find_icon_by_file(v, file); ic = e_view_find_icon_by_file(v, file);
if ((ic) && if ((ic) &&
(ev->efsd_reply_event.data)) (ev->efsd_reply_event.data))
e_view_icon_set_link(ic, (char*)ev->efsd_reply_event.data); e_view_icon_set_link(ic, (char*)efsd_reply_data(ev));
e_view_icon_initial_show(ic); e_view_icon_initial_show(ic);
} }
} }
@ -2918,13 +2971,13 @@ e_view_handle_fs(EfsdEvent *ev)
case EFSD_CMD_SETMETA: case EFSD_CMD_SETMETA:
break; break;
case EFSD_CMD_GETMETA: case EFSD_CMD_GETMETA:
printf("Getmeta event %i\n", /* D("Getmeta event %i\n",
ev->efsd_reply_event.command.efsd_get_metadata_cmd.id); efsd_reply_id(ev));*/
{ {
Evas_List l; Evas_List l;
EfsdCmdId cmd; EfsdCmdId cmd;
cmd = ev->efsd_reply_event.command.efsd_get_metadata_cmd.id; cmd = efsd_reply_id(ev);
for (l = views; l; l = l->next) for (l = views; l; l = l->next)
{ {
E_View *v; E_View *v;
@ -3023,7 +3076,7 @@ e_view_handle_fs(EfsdEvent *ev)
struct stat st; struct stat st;
if (stat(efsd_metadata_get_str(ev), &st) != -1 ) if (stat(efsd_metadata_get_str(ev), &st) != -1 )
{ {
printf("Attempted to set background for: %s\n", v->dir); D("Attempted to set background for: %s\n", v->dir);
v->bg = e_background_load(efsd_metadata_get_str(ev)); v->bg = e_background_load(efsd_metadata_get_str(ev));
e_background_realize(v->bg, v->evas); e_background_realize(v->bg, v->evas);
e_background_set_size(v->bg, v->size.w, v->size.h); e_background_set_size(v->bg, v->size.w, v->size.h);
@ -3052,15 +3105,13 @@ e_view_handle_fs(EfsdEvent *ev)
} }
} }
} }
/*
*/
break; break;
case EFSD_CMD_STARTMON_DIR: case EFSD_CMD_STARTMON_DIR:
/* printf("Startmon event %i\n", /* D("Startmon event %i\n",
ev->efsd_reply_event.command.efsd_file_cmd.id); ev->efsd_reply_event.command.efsd_file_cmd.id);
*/ break; */ break;
case EFSD_CMD_STARTMON_FILE: case EFSD_CMD_STARTMON_FILE:
/* printf("Startmon file event %i\n", /* D("Startmon file event %i\n",
ev->efsd_reply_event.command.efsd_file_cmd.id); ev->efsd_reply_event.command.efsd_file_cmd.id);
*/ break; */ break;
case EFSD_CMD_STOPMON_DIR: case EFSD_CMD_STOPMON_DIR:

View File

@ -150,6 +150,7 @@ struct _E_Icon
E_Object o; E_Object o;
char *file; char *file;
struct stat stat;
E_View *view; E_View *view;
@ -230,7 +231,16 @@ void e_view_icon_update_state(E_Icon *ic);
void e_view_icon_invert_selection(E_Icon *ic); void e_view_icon_invert_selection(E_Icon *ic);
void e_view_icon_select(E_Icon *ic); void e_view_icon_select(E_Icon *ic);
void e_view_icon_deselect(E_Icon *ic); void e_view_icon_deselect(E_Icon *ic);
/**
* e_view_icon_exec - handles execution paths when user activates an icon
* @ic: The activated icon
*
* This function takes care of opening views when the user activates a
* directory, launching commands when an executable is activated etc.
*/
void e_view_icon_exec(E_Icon *ic); void e_view_icon_exec(E_Icon *ic);
void e_view_icon_initial_show(E_Icon *ic); void e_view_icon_initial_show(E_Icon *ic);
void e_view_icon_set_mime(E_Icon *ic, char *base, char *mime); void e_view_icon_set_mime(E_Icon *ic, char *base, char *mime);
void e_view_icon_set_link(E_Icon *ic, char *link); void e_view_icon_set_link(E_Icon *ic, char *link);
@ -239,6 +249,7 @@ E_Icon *e_view_find_icon_by_file(E_View *view, char *file);
void e_view_icon_show(E_Icon *ic); void e_view_icon_show(E_Icon *ic);
void e_view_icon_hide(E_Icon *ic); void e_view_icon_hide(E_Icon *ic);
void e_view_icon_apply_xy(E_Icon *ic); void e_view_icon_apply_xy(E_Icon *ic);
void e_view_icon_check_permissions(E_Icon *ic);
void e_view_resort_alphabetical(E_View *v); void e_view_resort_alphabetical(E_View *v);
void e_view_arrange(E_View *v); void e_view_arrange(E_View *v);
void e_view_resort(E_View *v); void e_view_resort(E_View *v);
@ -250,10 +261,39 @@ void e_view_file_deleted(int id, char *file);
void e_view_file_changed(int id, char *file); void e_view_file_changed(int id, char *file);
void e_view_file_moved(int id, char *file); void e_view_file_moved(int id, char *file);
E_View *e_view_find_by_monitor_id(int id); E_View *e_view_find_by_monitor_id(int id);
/**
* e_view_new - Creates a new view object
*
* This function creates a new view and sets default
* properties on it, such as colors and icon spacings.
*/
E_View *e_view_new(void); E_View *e_view_new(void);
void e_view_set_background(E_View *v); void e_view_set_background(E_View *v);
/**
* e_view_set_dir - Sets view to a given directory
* @v The view for which to set the directory
* @dir The directory to set the view to
*
* This function sets a view to a directory, loading the
* view's metadata (view window coordinates etc) from that
* directory, it also requests monitoring of the files in
* the directory @dir from efsd.
*/
void e_view_set_dir(E_View *v, char *dir); void e_view_set_dir(E_View *v, char *dir);
/**
* e_view_realize - Initializes a view's graphics and content
* @v: The view to initialize
*
* This function initializes a created view by loading
* all the graphics, and sets the view to a given directory
* by calling e_view_set_dir().
*/
void e_view_realize(E_View *v); void e_view_realize(E_View *v);
void e_view_update(E_View *v); void e_view_update(E_View *v);
#endif #endif