summaryrefslogtreecommitdiff
path: root/src/bin/e_fileman_smart.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/e_fileman_smart.c')
-rw-r--r--src/bin/e_fileman_smart.c105
1 files changed, 55 insertions, 50 deletions
diff --git a/src/bin/e_fileman_smart.c b/src/bin/e_fileman_smart.c
index 3365d00..3eb551e 100644
--- a/src/bin/e_fileman_smart.c
+++ b/src/bin/e_fileman_smart.c
@@ -9,6 +9,7 @@
9#include <pwd.h> 9#include <pwd.h>
10#include <grp.h> 10#include <grp.h>
11#include <regex.h> 11#include <regex.h>
12#include <glob.h>
12 13
13/* TODO: 14/* TODO:
14 * 15 *
@@ -235,7 +236,9 @@ static void _e_fm_icon_mouse_out_cb (void *data, Evas *e, Evas_O
235static void _e_fm_icon_mouse_move_cb (void *data, Evas *e, Evas_Object *obj, void *event_info); 236static void _e_fm_icon_mouse_move_cb (void *data, Evas *e, Evas_Object *obj, void *event_info);
236static int _e_fm_win_mouse_up_cb (void *data, int type, void *event); 237static int _e_fm_win_mouse_up_cb (void *data, int type, void *event);
237 238
238static void _e_fm_icon_select_regex(E_Fm_Smart_Data *sd, char *glob); 239static void _e_fm_string_replace(const char *src, const char *key, const char *replacement, char *result, size_t resultsize);
240
241static void _e_fm_icon_select_glob(E_Fm_Smart_Data *sd, char *glb);
239static void _e_fm_icon_select_up(E_Fm_Smart_Data *sd); 242static void _e_fm_icon_select_up(E_Fm_Smart_Data *sd);
240static void _e_fm_icon_select_down(E_Fm_Smart_Data *sd); 243static void _e_fm_icon_select_down(E_Fm_Smart_Data *sd);
241static void _e_fm_icon_select_left(E_Fm_Smart_Data *sd); 244static void _e_fm_icon_select_left(E_Fm_Smart_Data *sd);
@@ -2301,64 +2304,65 @@ _e_fm_string_replace(const char *src, const char *key, const char *replacement,
2301 result[resultlen] = '\0'; 2304 result[resultlen] = '\0';
2302} 2305}
2303 2306
2304
2305static void 2307static void
2306_e_fm_icon_select_regex(E_Fm_Smart_Data *sd, char *glob) 2308_e_fm_icon_select_glob(E_Fm_Smart_Data *sd, char *glb)
2307{ 2309{
2308 E_Fm_Icon *icon; 2310 E_Fm_Icon *icon, *anchor;
2309 Evas_List *l; 2311 Evas_List *l;
2310 char *regex, *tregex; 2312 char *glbpath;
2311 regex_t reg, *creg; 2313 Evas_Coord x, y, w, h;
2312 int stars, i; 2314 E_Event_Fm_Reconfigure *ev;
2315 int i;
2316 glob_t globbuf;
2313 2317
2314 stars = 0; 2318 anchor = NULL;
2315 for(i = 0; i < strlen(glob); i++) 2319 ev = NULL;
2316 if(glob[i] == '*') 2320 glbpath = E_NEW(char, strlen(sd->dir) + strlen(glb) + 2);
2317 stars++; 2321 snprintf(glbpath, strlen(sd->dir) + strlen(glb) + 2, "%s/%s", sd->dir, glb);
2318 2322 if(glob(glbpath, 0, NULL, &globbuf))
2319 tregex = calloc(strlen(glob) + stars + 1, sizeof(char));
2320 _e_fm_string_replace(glob, "*", ".*", tregex, (strlen(glob) + stars + 1)*sizeof(char));
2321 regex = calloc(strlen(tregex) + 3, sizeof(char));
2322 snprintf(regex, (strlen(tregex) + 3)*sizeof(char), "^%s$", tregex);
2323 if(regcomp(&reg, regex, REG_NOSUB | REG_EXTENDED))
2324 return; 2323 return;
2325 _e_fm_selections_clear(sd); 2324
2325 _e_fm_selections_clear(sd);
2326 for (l = sd->files; l; l = l->next) 2326 for (l = sd->files; l; l = l->next)
2327 { 2327 {
2328 icon = l->data; 2328 icon = l->data;
2329 creg = &reg; 2329 for(i = 0; i < globbuf.gl_pathc; i++)
2330 if(!regexec(creg, icon->file->name, 0, NULL, 0))
2331 {
2332 _e_fm_selections_add(l->data, l);
2333 }
2334 }
2335
2336 return;
2337#if 0
2338position:
2339 {
2340 Evas_Coord x, y, w, h;
2341 icon = l->data;
2342 evas_object_geometry_get(icon->icon_object, &x, &y, &w, &h);
2343 if(!E_CONTAINS(sd->x, sd->y, sd->w, sd->h, x, y, w, h))
2344 { 2330 {
2345 E_Event_Fm_Reconfigure *ev; 2331 char *file;
2346 2332
2347 ev = E_NEW(E_Event_Fm_Reconfigure, 1); 2333 file = ecore_file_get_file(globbuf.gl_pathv[i]);
2348 if (ev) 2334 if(!strcmp(icon->file->name, file))
2349 { 2335 {
2350 ev->object = sd->object; 2336 _e_fm_selections_add(l->data, l);
2351 ev->x = sd->x; 2337 if(!anchor)
2352 ev->y = sd->child.y - (sd->y - (y - sd->icon_info.y_space)); 2338 {
2353 ev->w = sd->w; 2339 evas_object_geometry_get(icon->icon_object, &x, &y, &w, &h);
2354 ev->h = sd->h; 2340
2355 ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL); 2341 if(!E_CONTAINS(sd->x, sd->y, sd->w, sd->h, x, y, w, h))
2356 } 2342 {
2343 ev = E_NEW(E_Event_Fm_Reconfigure, 1);
2344 if (ev)
2345 {
2346 anchor = icon;
2347 ev->object = sd->object;
2348 ev->x = sd->x;
2349 ev->y = sd->child.y - (sd->y - (y - sd->icon_info.y_space));
2350 ev->w = sd->w;
2351 ev->h = sd->h;
2352 }
2353 }
2354 }
2355 }
2357 } 2356 }
2358 } 2357 }
2359#endif 2358
2359 if(anchor && ev)
2360 ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
2360} 2361}
2361 2362
2363/* do we keep this? might come in handy if we need to jump to a file starting
2364 * with a certain char
2365 */
2362static void 2366static void
2363__e_fm_icon_goto_key(E_Fm_Smart_Data *sd, char *c) 2367__e_fm_icon_goto_key(E_Fm_Smart_Data *sd, char *c)
2364{ 2368{
@@ -2727,7 +2731,7 @@ _e_fm_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2727 2731
2728 ev = event_info; 2732 ev = event_info;
2729 sd = data; 2733 sd = data;
2730 2734
2731 if (!strcmp(ev->keyname, "Up")) 2735 if (!strcmp(ev->keyname, "Up"))
2732 { 2736 {
2733 if(!strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown")) 2737 if(!strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown"))
@@ -2780,7 +2784,7 @@ _e_fm_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2780 buf = strdup(edje_object_part_text_get(sd->edje_obj, "text")); 2784 buf = strdup(edje_object_part_text_get(sd->edje_obj, "text"));
2781 edje_object_part_text_set(sd->edje_obj, "text", ""); 2785 edje_object_part_text_set(sd->edje_obj, "text", "");
2782 if(strcmp(buf, "")) 2786 if(strcmp(buf, ""))
2783 _e_fm_icon_select_regex(sd, buf); 2787 _e_fm_icon_select_glob(sd, buf);
2784 } 2788 }
2785 else 2789 else
2786 _e_fm_icon_run(sd); 2790 _e_fm_icon_run(sd);
@@ -2816,7 +2820,7 @@ _e_fm_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2816 } 2820 }
2817 } 2821 }
2818 } 2822 }
2819 else if(strlen(ev->keyname) == 1) 2823 else if (ev->string)
2820 { 2824 {
2821 char *str; 2825 char *str;
2822 str = NULL; 2826 str = NULL;
@@ -2834,6 +2838,7 @@ _e_fm_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2834 { 2838 {
2835 edje_object_part_text_set(sd->edje_obj, "text", ev->string); 2839 edje_object_part_text_set(sd->edje_obj, "text", ev->string);
2836 } 2840 }
2841
2837 if(strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown")) 2842 if(strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown"))
2838 edje_object_signal_emit(sd->edje_obj, "typebuf_show", ""); 2843 edje_object_signal_emit(sd->edje_obj, "typebuf_show", "");
2839 } 2844 }