fm2 has some slightly better keyboard nav ability - needs to become better

with old efm typebuffer-like matching etc. etc.

added a seg fix for .desktop parse fails.

also fixed linuxtitan's error checking for stat()


SVN revision: 25843
This commit is contained in:
Carsten Haitzler 2006-09-14 16:07:57 +00:00
parent ab40044e0e
commit 00634a43ad
6 changed files with 327 additions and 33 deletions

Binary file not shown.

View File

@ -134,6 +134,7 @@ static void _e_fm2_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, voi
static void _e_fm2_cb_icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_fm2_cb_icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_fm2_cb_icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_fm2_cb_icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_fm2_cb_icon_thumb_gen(void *data, Evas_Object *obj, void *event_info); static void _e_fm2_cb_icon_thumb_gen(void *data, Evas_Object *obj, void *event_info);
static void _e_fm2_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_fm2_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_fm2_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_fm2_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_fm2_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_fm2_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_fm2_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
@ -581,9 +582,6 @@ e_fm2_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
if (h) *h = sd->max.h; if (h) *h = sd->max.h;
} }
/* local subsystem functions */ /* local subsystem functions */
static const char * static const char *
_e_fm2_dev_path_map(const char *dev, const char *path) _e_fm2_dev_path_map(const char *dev, const char *path)
@ -1736,7 +1734,6 @@ static int
_e_fm2_icon_desktop_load(E_Fm2_Icon *ic) _e_fm2_icon_desktop_load(E_Fm2_Icon *ic)
{ {
char buf[4096], key[256], val[4096]; char buf[4096], key[256], val[4096];
FILE *f;
Ecore_Desktop *desktop; Ecore_Desktop *desktop;
if (ic->info.pseudo_link) if (ic->info.pseudo_link)
@ -1796,7 +1793,6 @@ _e_fm2_icon_desktop_load(E_Fm2_Icon *ic)
ic->info.icon = NULL; ic->info.icon = NULL;
ic->info.link = NULL; ic->info.link = NULL;
ic->info.pseudo_dir = NULL; ic->info.pseudo_dir = NULL;
fclose(f);
return 0; return 0;
} }
@ -1993,7 +1989,7 @@ _e_fm2_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_inf
_e_fm2_icon_deselect(ic); _e_fm2_icon_deselect(ic);
else else
_e_fm2_icon_select(ic); _e_fm2_icon_select(ic);
evas_object_smart_callback_call(ic->sd->obj, "selection_change", NULL); evas_object_smart_callback_call(ic->sd->obj, "selection_change", NULL);
if ((!(S_ISDIR(ic->info.statinfo.st_mode)) || if ((!(S_ISDIR(ic->info.statinfo.st_mode)) ||
(ic->sd->config->view.no_subdir_jump)) && (ic->sd->config->view.no_subdir_jump)) &&
(ic->sd->config->view.single_click) (ic->sd->config->view.single_click)
@ -2055,7 +2051,276 @@ _e_fm2_cb_icon_thumb_gen(void *data, Evas_Object *obj, void *event_info)
edje_object_signal_emit(ic->obj, "e,action,thumb,gen", "e"); edje_object_signal_emit(ic->obj, "e,action,thumb,gen", "e");
} }
} }
/* FIXME: prototype */
static void
_e_fm2_icon_make_visible(E_Fm2_Icon *ic)
{
if (ic->sd->config->view.mode == E_FM2_VIEW_MODE_LIST)
{
if (
((ic->y - ic->sd->pos.y) >= 0) &&
((ic->y + ic->h - ic->sd->pos.y) <= (ic->sd->h))
)
return;
if ((ic->y - ic->sd->pos.y) < 0)
e_fm2_pan_set(ic->sd->obj, ic->sd->pos.x, ic->y);
else
e_fm2_pan_set(ic->sd->obj, ic->sd->pos.x, ic->y - ic->sd->h + ic->h);
}
else
{
Evas_Coord x, y;
if (
((ic->y - ic->sd->pos.y) >= 0) &&
((ic->y + ic->h - ic->sd->pos.y) <= (ic->sd->h)) &&
((ic->x - ic->sd->pos.x) >= 0) &&
((ic->x + ic->w - ic->sd->pos.x) <= (ic->sd->w))
)
return;
x = ic->sd->pos.x;
if ((ic->x - ic->sd->pos.x) < 0)
x = ic->x;
else if ((ic->x + ic->w - ic->sd->pos.x) > (ic->sd->w))
x = ic->x + ic->w - ic->sd->w;
y = ic->sd->pos.y;
if ((ic->y - ic->sd->pos.y) < 0)
y = ic->y;
else if ((ic->y + ic->h - ic->sd->pos.y) > (ic->sd->h))
y = ic->y + ic->h - ic->sd->h;
e_fm2_pan_set(ic->sd->obj, x, y);
}
evas_object_smart_callback_call(ic->sd->obj, "pan_changed", NULL);
}
/* FIXME: prototype */
static void
_e_fm2_icon_desel_any(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
Evas_List *l;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
for (l = sd->icons; l; l = l->next)
{
ic = l->data;
if (ic->selected) _e_fm2_icon_deselect(ic);
}
}
/* FIXME: prototype */
static E_Fm2_Icon *
_e_fm2_icon_first_selected_find(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
Evas_List *l;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL;
for (l = sd->icons; l; l = l->next)
{
ic = l->data;
if (ic->selected) return ic;
}
return NULL;
}
/* FIXME: prototype */
static void
_e_fm2_icon_sel_first(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (!sd->icons) return;
_e_fm2_icon_desel_any(obj);
ic = sd->icons->data;
_e_fm2_icon_select(ic);
evas_object_smart_callback_call(sd->obj, "selection_change", NULL);
_e_fm2_icon_make_visible(ic);
}
/* FIXME: prototype */
static void
_e_fm2_icon_sel_last(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (!sd->icons) return;
_e_fm2_icon_desel_any(obj);
ic = evas_list_last(sd->icons)->data;
_e_fm2_icon_select(ic);
evas_object_smart_callback_call(sd->obj, "selection_change", NULL);
_e_fm2_icon_make_visible(ic);
}
/* FIXME: prototype */
static void
_e_fm2_icon_sel_prev(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
Evas_List *l;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (!sd->icons) return;
for (l = sd->icons; l; l = l->next)
{
ic = l->data;
if (ic->selected)
{
if (!l->prev) return;
ic = l->prev->data;
break;
}
}
if (!ic)
{
_e_fm2_icon_sel_last(obj);
return;
}
_e_fm2_icon_desel_any(obj);
_e_fm2_icon_select(ic);
evas_object_smart_callback_call(sd->obj, "selection_change", NULL);
_e_fm2_icon_make_visible(ic);
}
/* FIXME: prototype */
static void
_e_fm2_icon_sel_next(Evas_Object *obj)
{
E_Fm2_Smart_Data *sd;
Evas_List *l;
E_Fm2_Icon *ic;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (!sd->icons) return;
for (l = sd->icons; l; l = l->next)
{
ic = l->data;
if (ic->selected)
{
if (!l->next) return;
ic = l->next->data;
break;
}
}
if (!ic)
{
_e_fm2_icon_sel_first(obj);
return;
}
_e_fm2_icon_desel_any(obj);
_e_fm2_icon_select(ic);
evas_object_smart_callback_call(sd->obj, "selection_change", NULL);
_e_fm2_icon_make_visible(ic);
}
static void
_e_fm2_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Key_Down *ev;
E_Fm2_Smart_Data *sd;
E_Fm2_Icon *ic;
// Evas_Coord x = 0, y = 0, w = 0, h = 0;
sd = data;
ev = event_info;
/* FIXME: handle key navigation, searching etc. etc. */
if (!strcmp(ev->keyname, "Left"))
{
/* list mode: scroll left n pix
* icon mode: prev icon
*/
_e_fm2_icon_sel_prev(obj);
}
else if (!strcmp(ev->keyname, "Right"))
{
/* list mode: scroll right n pix
* icon mode: next icon
*/
_e_fm2_icon_sel_next(obj);
}
else if (!strcmp(ev->keyname, "Up"))
{
/* list mode: prev icon
* icon mode: up an icon
*/
_e_fm2_icon_sel_prev(obj);
}
else if (!strcmp(ev->keyname, "Home"))
{
/* go to first icon */
_e_fm2_icon_sel_first(obj);
}
else if (!strcmp(ev->keyname, "End"))
{
/* go to last icon */
_e_fm2_icon_sel_last(obj);
}
else if (!strcmp(ev->keyname, "Down"))
{
/* list mode: next icon
* icon mode: down an icon
*/
_e_fm2_icon_sel_next(obj);
}
else if (!strcmp(ev->keyname, "Prior"))
{
/* up h * n pixels */
e_fm2_pan_set(obj, sd->pos.x, sd->pos.y - sd->h);
evas_object_smart_callback_call(sd->obj, "pan_changed", NULL);
}
else if (!strcmp(ev->keyname, "Next"))
{
/* down h * n pixels */
e_fm2_pan_set(obj, sd->pos.x, sd->pos.y + sd->h);
evas_object_smart_callback_call(sd->obj, "pan_changed", NULL);
}
else if (!strcmp(ev->keyname, "Escape"))
{
_e_fm2_icon_desel_any(obj);
}
else if (!strcmp(ev->keyname, "Return"))
{
/* selected */
ic = _e_fm2_icon_first_selected_find(obj);
if (ic)
evas_object_smart_callback_call(ic->sd->obj, "selected", NULL);
}
else if (!strcmp(ev->keyname, "Insert"))
{
/* dunno what to do with this yet */
}
else if (!strcmp(ev->keyname, "Tab"))
{
/* tab complete possible completes of typebuffer */
}
else if (!strcmp(ev->keyname, "Backspace"))
{
/* erase from typebuffer */
}
else if (!strcmp(ev->keyname, "Delete"))
{
/* delete file dialog */
}
else
{
/* just start typing a filename - a tmp match buffer jumps to first match (type a glob) ot typedfile* */
}
}
static void static void
_e_fm2_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) _e_fm2_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
@ -2360,6 +2625,7 @@ _e_fm2_smart_add(Evas_Object *obj)
evas_object_color_set(sd->underlay, 0, 0, 0, 0); evas_object_color_set(sd->underlay, 0, 0, 0, 0);
evas_object_show(sd->underlay); evas_object_show(sd->underlay);
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, _e_fm2_cb_key_down, sd);
evas_object_event_callback_add(sd->underlay, EVAS_CALLBACK_MOUSE_DOWN, _e_fm2_cb_mouse_down, sd); evas_object_event_callback_add(sd->underlay, EVAS_CALLBACK_MOUSE_DOWN, _e_fm2_cb_mouse_down, sd);
evas_object_event_callback_add(sd->underlay, EVAS_CALLBACK_MOUSE_UP, _e_fm2_cb_mouse_up, sd); evas_object_event_callback_add(sd->underlay, EVAS_CALLBACK_MOUSE_UP, _e_fm2_cb_mouse_up, sd);
evas_object_event_callback_add(sd->underlay, EVAS_CALLBACK_MOUSE_MOVE, _e_fm2_cb_mouse_move, sd); evas_object_event_callback_add(sd->underlay, EVAS_CALLBACK_MOUSE_MOVE, _e_fm2_cb_mouse_move, sd);
@ -2383,7 +2649,7 @@ _e_fm2_smart_del(Evas_Object *obj)
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
if (!sd) return; if (!sd) return;
_e_fm2_scan_stop(obj); _e_fm2_scan_stop(obj);
_e_fm2_queue_free(obj); _e_fm2_queue_free(obj);
_e_fm2_regions_free(obj); _e_fm2_regions_free(obj);

View File

@ -122,6 +122,5 @@ EAPI void e_fm2_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_C
EAPI void e_fm2_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y); EAPI void e_fm2_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
EAPI void e_fm2_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h); EAPI void e_fm2_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
#endif #endif
#endif #endif

View File

@ -78,15 +78,15 @@ _e_wid_fsel_favorites_add(void *data1, void *data2)
wd = data1; wd = data1;
current_path = e_fm2_real_path_get(wd->o_files_fm); current_path = e_fm2_real_path_get(wd->o_files_fm);
snprintf(dest_path, PATH_MAX, "%s/.e/e/fileman/favorites/%s", snprintf(dest_path, PATH_MAX, "%s/.e/e/fileman/favorites/%s",
getenv("HOME"), basename(current_path)); getenv("HOME"), basename(current_path));
if (stat(dest_path, &st) < 0) symlink(current_path, dest_path); if (stat(dest_path, &st) < 0) symlink(current_path, dest_path);
else else
{ {
while(stat(dest_path, &st) == 0) while (stat(dest_path, &st) == 0)
{ {
snprintf(dest_path, PATH_MAX, "%s/.e/e/fileman/favorites/%s-%d", snprintf(dest_path, PATH_MAX, "%s/.e/e/fileman/favorites/%s-%d",
getenv("HOME"), getenv("HOME"),
basename(current_path), i); basename(current_path), i);
i++; i++;
} }
symlink(current_path, dest_path); symlink(current_path, dest_path);
@ -211,13 +211,14 @@ _e_wid_fsel_files_selection_change(void *data, Evas_Object *obj, void *event_inf
realpath, ici->file); realpath, ici->file);
} }
wd->path = strdup(buf); wd->path = strdup(buf);
if (wd->preview) if (stat(wd->path, &st) == 0)
_e_wid_fsel_preview_file(wd); {
stat(wd->path, &st); if (wd->preview) _e_wid_fsel_preview_file(wd);
if (!S_ISDIR(st.st_mode)) if (!S_ISDIR(st.st_mode))
e_widget_entry_text_set(wd->o_entry, ici->file); e_widget_entry_text_set(wd->o_entry, ici->file);
else else
e_widget_entry_text_set(wd->o_entry, wd->path); e_widget_entry_text_set(wd->o_entry, wd->path);
}
evas_list_free(selected); evas_list_free(selected);
if (wd->chg_func) wd->chg_func(wd->chg_data, wd->obj); if (wd->chg_func) wd->chg_func(wd->chg_data, wd->obj);
} }
@ -399,6 +400,9 @@ e_widget_fsel_add(Evas *evas, const char *dev, const char *path, char *selected,
e_fm2_pan_get, e_fm2_pan_get,
e_fm2_pan_max_get, e_fm2_pan_max_get,
e_fm2_pan_child_size_get); e_fm2_pan_child_size_get);
evas_object_propagate_events_set(wd->o_favorites_fm, 0);
e_widget_scrollframe_focus_object_set(o, wd->o_favorites_fm);
wd->o_favorites_frame = o; wd->o_favorites_frame = o;
e_widget_sub_object_add(obj, o); e_widget_sub_object_add(obj, o);
e_widget_min_size_set(o, 128, 128); e_widget_min_size_set(o, 128, 128);
@ -439,6 +443,9 @@ e_widget_fsel_add(Evas *evas, const char *dev, const char *path, char *selected,
e_fm2_pan_get, e_fm2_pan_get,
e_fm2_pan_max_get, e_fm2_pan_max_get,
e_fm2_pan_child_size_get); e_fm2_pan_child_size_get);
evas_object_propagate_events_set(wd->o_files_fm, 0);
e_widget_scrollframe_focus_object_set(o, wd->o_files_fm);
wd->o_files_frame = o; wd->o_files_frame = o;
e_widget_sub_object_add(obj, o); e_widget_sub_object_add(obj, o);
e_widget_min_size_set(o, 128, 128); e_widget_min_size_set(o, 128, 128);
@ -535,7 +542,7 @@ _e_wid_fsel_preview_file(E_Widget_Data *wd)
char *size, *owner, *perms, *mtime; char *size, *owner, *perms, *mtime;
struct stat st; struct stat st;
stat(wd->path, &st); if (stat(wd->path, &st) < 0) return;
size = _e_wid_file_size_get(st.st_size); size = _e_wid_file_size_get(st.st_size);
owner = _e_wid_file_user_get(st.st_uid); owner = _e_wid_file_user_get(st.st_uid);

View File

@ -6,7 +6,7 @@
typedef struct _E_Widget_Data E_Widget_Data; typedef struct _E_Widget_Data E_Widget_Data;
struct _E_Widget_Data struct _E_Widget_Data
{ {
Evas_Object *o_scrollframe, *o_child; Evas_Object *o_scrollframe, *o_child, *o_fobj;
}; };
static void _e_wid_del_hook(Evas_Object *obj); static void _e_wid_del_hook(Evas_Object *obj);
@ -101,6 +101,24 @@ e_widget_scrollframe_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coor
e_scrollframe_child_region_show(wd->o_scrollframe, x, y, w, h); e_scrollframe_child_region_show(wd->o_scrollframe, x, y, w, h);
} }
EAPI void
e_widget_scrollframe_focus_object_set(Evas_Object *obj, Evas_Object *fobj)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
wd->o_fobj = fobj;
}
EAPI Evas_Object *
e_widget_scrollframe_object_get(Evas_Object *obj)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
return wd->o_scrollframe;
}
/* Private functions */ /* Private functions */
static void static void
_e_wid_del_hook(Evas_Object *obj) _e_wid_del_hook(Evas_Object *obj)
@ -120,11 +138,13 @@ _e_wid_focus_hook(Evas_Object *obj)
if (e_widget_focus_get(obj)) if (e_widget_focus_get(obj))
{ {
edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_scrollframe), "e,state,focused", "e"); edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_scrollframe), "e,state,focused", "e");
evas_object_focus_set(wd->o_scrollframe, 1); if (wd->o_fobj) evas_object_focus_set(wd->o_fobj, 1);
else evas_object_focus_set(wd->o_scrollframe, 1);
} }
else else
{ {
edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_scrollframe), "e,state,unfocused", "e"); edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_scrollframe), "e,state,unfocused", "e");
if (wd->o_fobj) evas_object_focus_set(wd->o_fobj, 0);
evas_object_focus_set(wd->o_scrollframe, 0); evas_object_focus_set(wd->o_scrollframe, 0);
} }
} }
@ -138,14 +158,14 @@ _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info)
static void static void
_e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) _e_wid_cb_scrollframe_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
Evas_Coord mw, mh, vw, vh, w, h; Evas_Coord mw, mh, vw, vh, w, h;
e_scrollframe_child_viewport_size_get(obj, &vw, &vh); e_scrollframe_child_viewport_size_get(obj, &vw, &vh);
e_widget_min_size_get(data, &mw, &mh); e_widget_min_size_get(data, &mw, &mh);
evas_object_geometry_get(data, NULL, NULL, &w, &h); evas_object_geometry_get(data, NULL, NULL, &w, &h);
if (vw >= mw) if (vw >= mw)
{ {
if (w != vw) evas_object_resize(data, vw, h); if (w != vw) evas_object_resize(data, vw, h);
} }
} }

View File

@ -11,6 +11,8 @@ EAPI Evas_Object *e_widget_scrollframe_simple_add(Evas *evas, Evas_Object *child
EAPI void e_widget_scrollframe_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y); EAPI void e_widget_scrollframe_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
EAPI void e_widget_scrollframe_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y); EAPI void e_widget_scrollframe_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
EAPI void e_widget_scrollframe_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); EAPI void e_widget_scrollframe_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
EAPI void e_widget_scrollframe_focus_object_set(Evas_Object *obj, Evas_Object *fobj);
EAPI Evas_Object *e_widget_scrollframe_object_get(Evas_Object *obj);
#endif #endif
#endif #endif