* There was still one cache left over, and it's needed for searching, so
search it and timestamp it. * App dialog now does all its own .order file mangling. This is temporary until e_app is back up to scratch following the cachectomy. SVN revision: 25857
This commit is contained in:
parent
3cc1775e81
commit
db2b722431
|
@ -199,10 +199,28 @@ EAPI E_App *
|
|||
e_app_new(const char *path, int scan_subdirs)
|
||||
{
|
||||
E_App *a;
|
||||
struct stat st;
|
||||
int stated = 0;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (!path) return NULL;
|
||||
|
||||
a = e_app_path_find(path);
|
||||
/* Check if the cache is still valid. */
|
||||
if (a)
|
||||
{
|
||||
if (stat(a->path, &st) >= 0)
|
||||
{
|
||||
if(st.st_mtime > a->mtime)
|
||||
{
|
||||
e_object_del(E_OBJECT(a));
|
||||
a = NULL;
|
||||
stated = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!a)
|
||||
{
|
||||
if (ecore_file_exists(path))
|
||||
{
|
||||
|
@ -241,6 +259,12 @@ e_app_new(const char *path, int scan_subdirs)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
/* Timestamp the cache, and no need to stat the file twice if the cache was stale. */
|
||||
if ((stated) || (stat(a->path, &st) >= 0))
|
||||
{
|
||||
a->mtime = st.st_mtime;
|
||||
stated = 1;
|
||||
}
|
||||
_e_apps_list = evas_list_prepend(_e_apps_list, a);
|
||||
}
|
||||
return a;
|
||||
|
@ -955,6 +979,31 @@ e_app_file_find(const char *file)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
EAPI E_App *
|
||||
e_app_path_find(const char *path)
|
||||
{
|
||||
Evas_List *l;
|
||||
|
||||
if (!path) return NULL;
|
||||
|
||||
for (l = _e_apps_list; l; l = l->next)
|
||||
{
|
||||
E_App *a;
|
||||
|
||||
a = l->data;
|
||||
if (a->path)
|
||||
{
|
||||
if (!strcmp(a->path, path))
|
||||
{
|
||||
// _e_apps_list = evas_list_remove_list(_e_apps_list, l);
|
||||
// _e_apps_list = evas_list_prepend(_e_apps_list, a);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI E_App *
|
||||
e_app_name_find(const char *name)
|
||||
{
|
||||
|
|
|
@ -65,6 +65,9 @@ struct _E_App
|
|||
unsigned char scanned : 1; /* have we scanned a subdir app yet */
|
||||
|
||||
unsigned char deleted : 1; /* this app's file is deleted from disk */
|
||||
|
||||
/* Actually calling this st_mtime causes compile issues, must be some strange macros at work. */
|
||||
time_t mtime; /* For checking if the cache is valid. */
|
||||
|
||||
/* used for eap edit */
|
||||
const char *image; /* used when we're saving a image into the eap */
|
||||
|
@ -121,6 +124,7 @@ EAPI void e_app_change_callback_del (void (*func) (void *da
|
|||
EAPI E_App *e_app_launch_id_pid_find (int launch_id, pid_t pid);
|
||||
EAPI E_App *e_app_border_find (E_Border *bd);
|
||||
EAPI E_App *e_app_file_find (const char *file);
|
||||
EAPI E_App *e_app_path_find (const char *path);
|
||||
EAPI E_App *e_app_name_find (const char *name);
|
||||
EAPI E_App *e_app_generic_find (const char *generic);
|
||||
EAPI E_App *e_app_exe_find (const char *exe);
|
||||
|
|
|
@ -22,6 +22,7 @@ static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _move_file_up_in_order(const char *order, const char *file);
|
||||
static void _move_file_down_in_order(const char *order, const char *file);
|
||||
static void _append_to_order(const char *order, const char *file);
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
|
@ -407,10 +408,15 @@ _cb_button_add(void *data1, void *data2)
|
|||
if (!selected) return;
|
||||
ici = selected->data;
|
||||
realpath = e_fm2_real_path_get(cfdata->gui.o_fm_all);
|
||||
if (!strcmp(realpath, "/"))
|
||||
snprintf(buf, sizeof(buf), "/%s", ici->file);
|
||||
if (cfdata->sorted)
|
||||
{
|
||||
if (!strcmp(realpath, "/"))
|
||||
snprintf(buf, sizeof(buf), "/%s", ici->file);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file);
|
||||
}
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file);
|
||||
snprintf(buf, sizeof(buf), "%s/%s", cfdata->path_everything, ici->file);
|
||||
evas_list_free(selected);
|
||||
if (ecore_file_is_dir(buf)) return;
|
||||
|
||||
|
@ -425,11 +431,12 @@ _cb_button_add(void *data1, void *data2)
|
|||
{
|
||||
if (!cfdata->gui.o_fm) return;
|
||||
|
||||
a = e_app_new(buf, 0);
|
||||
// a = e_app_new(buf, 0);
|
||||
realpath = e_fm2_real_path_get(cfdata->gui.o_fm);
|
||||
parent = e_app_new(realpath, 0);
|
||||
if ((a) && (parent))
|
||||
e_app_append(a, parent);
|
||||
// parent = e_app_new(realpath, 0);
|
||||
// if (parent) e_app_subdir_scan(parent, 0);
|
||||
// e_app_append(a, parent);
|
||||
_append_to_order(realpath, ecore_file_get_file(buf));
|
||||
}
|
||||
|
||||
e_fm2_refresh(cfdata->gui.o_fm);
|
||||
|
@ -790,3 +797,58 @@ _move_file_down_in_order(const char *order, const char *file)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_append_to_order(const char *order, const char *file)
|
||||
{
|
||||
char buf[4096];
|
||||
Evas_List *list = NULL, *l;
|
||||
int ret = 0;
|
||||
FILE *f;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.order", order);
|
||||
if (!ecore_file_exists(buf)) return;
|
||||
f = fopen(buf, "rb");
|
||||
if (!f) return;
|
||||
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
int len;
|
||||
|
||||
len = strlen(buf);
|
||||
if (len > 0)
|
||||
{
|
||||
if (buf[len - 1] == '\n')
|
||||
{
|
||||
buf[len - 1] = 0;
|
||||
len--;
|
||||
}
|
||||
list = evas_list_append(list, strdup(buf));
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
list = evas_list_append(list, strdup(file));
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.order", order);
|
||||
ecore_file_unlink(buf);
|
||||
f = fopen(buf, "wb");
|
||||
if (!f) return;
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
char *text;
|
||||
|
||||
text = l->data;
|
||||
fprintf(f, "%s\n", text);
|
||||
free(text);
|
||||
}
|
||||
fclose(f);
|
||||
evas_list_free(list);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", order);
|
||||
ecore_file_unlink(buf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue