e_int_config_transitions.h \
e_fwin.h \
e_widget_aspect.h \
+e_filereg.h \
e_widget_desk_preview.h \
e_int_config_borders.h
e_fwin.c \
e_widget_aspect.c \
e_widget_desk_preview.c \
+e_filereg.c \
e_int_config_borders.c \
$(ENLIGHTENMENTHEADERS)
static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source);
/* local subsystem globals */
+static int _e_bg_reg_files = 0;
/* externally accessible functions */
+EAPI int
+e_bg_init(void)
+{
+ Evas_List *l;
+
+ /* Register files in use */
+ if (e_config->desktop_default_background)
+ e_filereg_register(e_config->desktop_default_background);
+
+ for (l = e_config->desktop_backgrounds; l; l = l->next)
+ {
+ E_Config_Desktop_Background *cfbg;
+ cfbg = l->data;
+ e_filereg_register(cfbg->file);
+ }
+
+ return 1;
+}
+
+EAPI int
+e_bg_shutdown(void)
+{
+ Evas_List *l;
+
+ /* Register files in use */
+ if (e_config->desktop_default_background)
+ e_filereg_deregister(e_config->desktop_default_background);
+
+ for (l = e_config->desktop_backgrounds; l; l = l->next)
+ {
+ E_Config_Desktop_Background *cfbg;
+ cfbg = l->data;
+ e_filereg_deregister(cfbg->file);
+ }
+
+ return 1;
+}
+
EAPI const char *
e_bg_file_get(int container_num, int zone_num, int desk_x, int desk_y)
{
}
EAPI void
+e_bg_default_set(char * file)
+{
+ if (e_config->desktop_default_background)
+ {
+ e_filereg_deregister(e_config->desktop_default_background);
+ evas_stringshare_del(e_config->desktop_default_background);
+ }
+
+ if (file)
+ {
+ e_filereg_register(file);
+ e_config->desktop_default_background = evas_stringshare_add(file);
+ }
+ else
+ e_config->desktop_default_background = NULL;
+}
+
+EAPI void
e_bg_add(int container, int zone, int desk_x, int desk_y, char *file)
{
E_Config_Desktop_Background *cfbg;
cfbg->desk_y = desk_y;
cfbg->file = evas_stringshare_add(file);
e_config->desktop_backgrounds = evas_list_append(e_config->desktop_backgrounds, cfbg);
+ e_filereg_register(cfbg->file);
}
EAPI void
(cfbg->desk_x == desk_x) && (cfbg->desk_y == desk_y))
{
e_config->desktop_backgrounds = evas_list_remove_list(e_config->desktop_backgrounds, l);
+ e_filereg_deregister(cfbg->file);
if (cfbg->file) evas_stringshare_del(cfbg->file);
free(cfbg);
break;
E_Manager *man;
E_Container *con;
E_Zone *zone;
-
+
for (l = e_manager_list(); l; l = l->next)
{
man = l->data;
evas_object_clip_set(zone->bg_object, zone->bg_clip_object);
evas_object_show(zone->bg_object);
}
+
#ifndef E_BG_H
#define E_BG_H
+EAPI int e_bg_init(void);
+EAPI int e_bg_shutdown(void);
+
EAPI const char *e_bg_file_get(int container_num, int zone_num, int desk_x, int desk_y);
EAPI void e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition);
EAPI void e_bg_add(int container, int zone, int desk_x, int desk_y, char *file);
EAPI void e_bg_del(int container, int zone, int desk_x, int desk_y);
+EAPI void e_bg_default_set(char *file);
EAPI void e_bg_update(void);
#endif
--- /dev/null
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#include "e.h"
+
+/*
+ * Implementation of a protected file registry. Any files that are
+ * currently being used by E in core components should be registered
+ * here and will be protected as best as E can. :)
+ */
+
+/* Local subsystem globals */
+static Evas_List *_e_filereg = NULL;
+
+typedef struct _Filereg_Item Filereg_Item;
+
+struct _Filereg_Item
+{
+ char * path;
+ int ref_count;
+};
+
+/* Externally accessible functions */
+EAPI int
+e_filereg_init(void)
+{
+ return 1;
+}
+
+EAPI int
+e_filereg_shutdown(void)
+{
+ Evas_List * ll;
+ Filereg_Item * item;
+
+ /* Delete all strings in the hash */
+ for (ll = _e_filereg; ll; ll = ll->next)
+ {
+ item = ll->data;
+ E_FREE(item->path);
+ E_FREE(item);
+ }
+
+ _e_filereg = evas_list_free(_e_filereg);
+}
+
+EAPI int
+e_filereg_register(const char * path)
+{
+ Evas_List * ll;
+ Filereg_Item * item;
+
+ for (ll = _e_filereg; ll; ll = ll->next)
+ {
+ item = ll->data;
+ if (!strcmp(item->path, path))
+ {
+ /* File already registered, increment ref. count */
+ item->ref_count++;
+ return 1;
+ }
+ }
+
+ /* Doesn't exist so add to list. */
+ item = E_NEW(Filereg_Item, 1);
+ if (!item) return 0;
+
+ item->path = strdup(path);
+ item->ref_count = 1;
+ _e_filereg = evas_list_append(_e_filereg, item);
+
+ return 1;
+}
+
+EAPI void
+e_filereg_deregister(const char * path)
+{
+ Evas_List * ll;
+ Filereg_Item * item;
+
+ for (ll = _e_filereg; ll; ll = ll->next)
+ {
+ item = ll->data;
+ if (!strcmp(item->path, path))
+ {
+ item->ref_count--;
+ if (item->ref_count == 0)
+ {
+ _e_filereg = evas_list_remove_list(_e_filereg, ll);
+ E_FREE(item->path);
+ E_FREE(item);
+ }
+
+ return;
+ }
+ }
+}
+
+EAPI Evas_Bool
+e_filereg_file_protected(const char * path)
+{
+ Evas_List * ll;
+ Filereg_Item * item;
+
+ for (ll = _e_filereg; ll; ll = ll->next)
+ {
+ item = ll->data;
+ if (!strcmp(item->path, path))
+ return 1;
+ }
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#ifdef E_TYPEDEFS
+
+#else
+#ifndef E_FILEREG_H
+#define E_FILEREG_H
+
+EAPI int e_filereg_init(void);
+EAPI int e_filereg_shutdown(void);
+
+EAPI int e_filereg_register(const char * path);
+EAPI void e_filereg_deregister(const char * path);
+EAPI Evas_Bool e_filereg_file_protected(const char * path);
+
+#endif
+#endif
+
+
E_Manager *man;
E_Container *con;
E_Zone *zone;
- int x, y, can_w, can_w2;
+ Evas_List *sel;
+ int x, y, can_w, can_w2, protected;
char buf[4096];
sd = ic->sd;
snprintf(buf, sizeof(buf), "%s/.order", sd->realpath);
if (ecore_file_can_write(buf)) can_w = 1;
}
- if ((can_w) && (can_w2))
+
+ sel = e_fm2_selected_list_get(ic->sd->obj);
+ if ((!sel) || evas_list_count(sel) == 1)
+ {
+ snprintf(buf, sizeof(buf), "%s/%s", sd->realpath, ic->info.file);
+ protected = e_filereg_file_protected(buf);
+ }
+ else
+ protected = 0;
+
+ if ((can_w) && (can_w2) && !(protected))
{
mi = e_menu_item_new(mn);
e_menu_item_separator_set(mi, 1);
snprintf(oldpath, sizeof(oldpath), "%s/%s", ic->sd->realpath, ic->info.file);
snprintf(newpath, sizeof(newpath), "%s/%s", ic->sd->realpath, text);
}
+ if (e_filereg_file_protected(oldpath)) return;
+
if (!ecore_file_mv(oldpath, newpath))
{
man = e_manager_current_get();
e_object_del(E_OBJECT(dialog));
sel = e_fm2_selected_list_get(ic->sd->obj);
- if (sel)
+ if (sel && (evas_list_count(sel) != 1))
{
for (l = sel; l; l = l->next)
{
if (!ici->pseudo_link)
{
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ici->file);
+ if (e_filereg_file_protected(buf)) continue;
/* FIXME: recursive rm might block - need to get smart */
if (!(ecore_file_recursive_rm(buf)))
if (!ic->info.pseudo_link)
{
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file);
+ if (e_filereg_file_protected(buf)) return;
/* FIXME: recursive rm might block - need to get smart */
if (!(ecore_file_recursive_rm(buf)))
#include "e_int_config_transitions.h"
#include "e_obj_dialog.h"
#include "e_fwin.h"
+#include "e_filereg.h"
#include "e_widget_aspect.h"
#include "e_widget_desk_preview.h"
#include "e_int_config_borders.h"
cfbg = e_config->desktop_backgrounds->data;
e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
}
- if (e_config->desktop_default_background)
- evas_stringshare_del(e_config->desktop_default_background);
if ((cfdata->use_theme_bg) || (!cfdata->bg))
- e_config->desktop_default_background = NULL;
+ e_bg_default_set(NULL);
else
- e_config->desktop_default_background = evas_stringshare_add(cfdata->bg);
+ e_bg_default_set(cfdata->bg);
cfdata->all_this_desk_screen = 0;
cfbg = e_config->desktop_backgrounds->data;
e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
}
- if (e_config->desktop_default_background)
- evas_stringshare_del(e_config->desktop_default_background);
- e_config->desktop_default_background = NULL;
+ e_bg_default_set(NULL);
}
else
{
cfbg = e_config->desktop_backgrounds->data;
e_bg_del(cfbg->container, cfbg->zone, cfbg->desk_x, cfbg->desk_y);
}
- if (e_config->desktop_default_background)
- evas_stringshare_del(e_config->desktop_default_background);
- e_config->desktop_default_background = evas_stringshare_add(cfdata->bg);
+ e_bg_default_set(cfdata->bg);
}
else if (cfdata->all_this_desk_screen == 1)
{
_e_main_shutdown(-1);
}
_e_main_shutdown_push(_e_main_dirs_shutdown);
+ /* setup file registry */
+ if (!e_filereg_init())
+ {
+ e_error_message_show(_("Enlightenment cannot set up its file registry system."));
+ _e_main_shutdown(-1);
+ }
+ _e_main_shutdown_push(e_filereg_shutdown);
/* init config system */
if (!e_config_init())
{
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_theme_shutdown);
+ /* init desktop background system */
+ if (!e_bg_init())
+ {
+ e_error_message_show(_("Enlightenment cannot set up its desktop background system."));
+ _e_main_shutdown(-1);
+ }
+ _e_main_shutdown_push(e_bg_init);
if (!((!e_config->show_splash) || (after_restart)))
{
/* setup init status window/screen */
e_theme_file_set(const char *category, const char *file)
{
E_Theme_Result *res;
+ char buf[4096];
if (group_cache)
{
if (res)
{
mappings = evas_hash_del(mappings, category, res);
- if (res->file) evas_stringshare_del(res->file);
+ if (res->file) {
+ e_filereg_deregister(res->file);
+ evas_stringshare_del(res->file);
+ }
if (res->cache) evas_stringshare_del(res->cache);
free(res);
}
res = calloc(1, sizeof(E_Theme_Result));
res->file = evas_stringshare_add(file);
+ e_filereg_register(res->file);
mappings = evas_hash_add(mappings, category, res);
}