forked from enlightenment/enlightenment
Make app deleting work. Sometimes the crude method is the best.
SVN revision: 25232
This commit is contained in:
parent
5d928cc664
commit
59379bbb49
|
@ -812,6 +812,87 @@ e_app_remove(E_App *a)
|
|||
e_object_unref(E_OBJECT(a));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_app_remove_from_order(E_App *a)
|
||||
{
|
||||
Evas_List *l;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (!a) return;
|
||||
if (!a->parent) return;
|
||||
|
||||
a->parent->subapps = evas_list_remove(a->parent->subapps, a);
|
||||
_e_app_save_order(a->parent);
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", a->parent->path);
|
||||
ecore_file_unlink(buf);
|
||||
_e_app_change(a, E_APP_DEL);
|
||||
a->parent = NULL;
|
||||
e_object_unref(E_OBJECT(a));
|
||||
}
|
||||
|
||||
|
||||
EAPI void
|
||||
e_app_remove_file_from_order(const char *order, const char *file)
|
||||
{
|
||||
char buf[4096];
|
||||
Evas_List *list = NULL, *l;
|
||||
int ret = 0;
|
||||
FILE *f;
|
||||
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s)\n", order, file);
|
||||
snprintf(buf, sizeof(buf), "%s/.order", order);
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - %s\n", order, file, buf);
|
||||
if (!ecore_file_exists(buf)) return;
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - EXISTS\n", order, file);
|
||||
f = fopen(buf, "rb");
|
||||
if (!f) return;
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - OPENED FOR READING\n", order, file);
|
||||
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
int len;
|
||||
|
||||
len = strlen(buf);
|
||||
if (len > 0)
|
||||
{
|
||||
if (buf[len - 1] == '\n')
|
||||
{
|
||||
buf[len - 1] = 0;
|
||||
len--;
|
||||
}
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - %s == %s\n", order, file, buf, file);
|
||||
if (strcmp(buf, file) != 0)
|
||||
list = evas_list_append(list, strdup(buf));
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - READ\n", order, file);
|
||||
snprintf(buf, sizeof(buf), "%s/.order", order);
|
||||
ecore_file_unlink(buf);
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - DELETED\n", order, file);
|
||||
f = fopen(buf, "wb");
|
||||
if (!f) return;
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - OPENED FOR WRITING\n", order, file);
|
||||
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);
|
||||
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - WRITTEN\n", order, file);
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", order);
|
||||
ecore_file_unlink(buf);
|
||||
printf("E_APP_REMOVE_FILE_FROM_ORDER(%s, %s) - CACHE NUKED\n", order, file);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_app_change_callback_add(void (*func) (void *data, E_App *a, E_App_Change ch), void *data)
|
||||
{
|
||||
|
|
|
@ -112,6 +112,8 @@ EAPI void e_app_append (E_App *add, E_App *par
|
|||
EAPI void e_app_files_prepend_relative (Evas_List *files, E_App *before);
|
||||
EAPI void e_app_files_append (Evas_List *files, E_App *parent);
|
||||
EAPI void e_app_remove (E_App *a);
|
||||
EAPI void e_app_remove_from_order (E_App *a);
|
||||
EAPI void e_app_remove_file_from_order (const char *order, const char *file);
|
||||
|
||||
EAPI void e_app_change_callback_add (void (*func) (void *data, E_App *a, E_App_Change ch), void *data);
|
||||
EAPI void e_app_change_callback_del (void (*func) (void *data, E_App *a, E_App_Change ch), void *data);
|
||||
|
|
|
@ -249,6 +249,8 @@ _cb_button_delete_left(void *data1, void *data2)
|
|||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_List *l;
|
||||
E_Fm2_Icon_Info *ici;
|
||||
const char *realpath;
|
||||
char buf[4096];
|
||||
|
||||
cfdata = data1;
|
||||
if (!cfdata->gui.o_fm_all) return;
|
||||
|
@ -258,6 +260,9 @@ _cb_button_delete_left(void *data1, void *data2)
|
|||
if (!l) return;
|
||||
ici = l->data;
|
||||
evas_list_free(l);
|
||||
|
||||
#if 0
|
||||
/* This just isn't working, lets try the crude method instead. */
|
||||
for (l = cfdata->parent_all->subapps; l; l = l->next)
|
||||
{
|
||||
E_App *a2;
|
||||
|
@ -271,6 +276,17 @@ _cb_button_delete_left(void *data1, void *data2)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
realpath = e_fm2_real_path_get(cfdata->gui.o_fm_all);
|
||||
if (!strcmp(realpath, "/"))
|
||||
snprintf(buf, sizeof(buf), "/%s", ici->file);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file);
|
||||
ecore_file_unlink(buf);
|
||||
snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", realpath);
|
||||
ecore_file_unlink(buf);
|
||||
e_fm2_refresh(cfdata->gui.o_fm_all);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -279,15 +295,19 @@ _cb_button_delete_right(void *data1, void *data2)
|
|||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_List *l;
|
||||
E_Fm2_Icon_Info *ici;
|
||||
const char *realpath;
|
||||
|
||||
cfdata = data1;
|
||||
if (!cfdata->gui.o_fm) return;
|
||||
if (!cfdata->parent) return;
|
||||
|
||||
l = e_fm2_selected_list_get(cfdata->gui.o_fm);
|
||||
if (!l) return;
|
||||
ici = l->data;
|
||||
evas_list_free(l);
|
||||
|
||||
#if 0
|
||||
/* This just isn't working, lets try the crude method instead. */
|
||||
if (!cfdata->parent) return;
|
||||
for (l = cfdata->parent->subapps; l; l = l->next)
|
||||
{
|
||||
E_App *a2;
|
||||
|
@ -296,11 +316,16 @@ _cb_button_delete_right(void *data1, void *data2)
|
|||
if ((a2->deleted) || ((a2->orig) && (a2->orig->deleted))) continue;
|
||||
if (!strcmp(ecore_file_get_file(a2->path), ecore_file_get_file(ici->file)))
|
||||
{
|
||||
e_app_remove(a2);
|
||||
e_app_remove_from_order(a2);
|
||||
e_fm2_refresh(cfdata->gui.o_fm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
realpath = e_fm2_real_path_get(cfdata->gui.o_fm);
|
||||
e_app_remove_file_from_order(realpath, ecore_file_get_file(ici->file));
|
||||
e_fm2_refresh(cfdata->gui.o_fm);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue