> On Tue, Oct 10, 2006 at 07:21:14PM +1000, Metrics wrote:
> > Hi all,
> >
> > I've attached some patches and additional files that add a protected
> > file registry to E. Basically, the point of this is to protect files
> > that are in use from being deleted by fm2 in its various guises.
> > The patch adds file protection for themes and desktops at the moment,
> > and works reliably. e_filereg.c and e_filereg.h go into e/src/bin (of
> > course :)).
On Mon, Oct 16, 2006 at 11:29:16AM +1000, Metrics wrote:
> Modified version of the file registry, changed a hash for a list and
> basically simplified it all so it now operates with ref counts. Had to
> make some changes to setting and unsetting default desktops, but it's for
> the best as it is now all in e_bg.c and consistent.
This third revision of the filereg patch fixes some conflicts with
current CVS changes (all for you raster :)). It also sorts out some
inconsistent behaviour with the file deletion in fm2. Basically, if you
had a single file selected but right-clicked on another, it would ask
you if you wanted to delete one file and then delete a different one.
Fixed in here too. Let that be an incentive for merge...brouhahhaha.
This patch simply replaces the previous patch (e_filereg_002.patch).
e_filereg.c and e_filereg.h haven't changed.
Complaints about me spamming the list with large patches should be sent
to raster. :)
metrics
Index: Makefile.am
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/Makefile.am,v
retrieving revision 1.160
diff -u -r1.160 Makefile.am
--- Makefile.am 14 Oct 2006 09:43:12 -0000 1.160
+++ Makefile.am 17 Oct 2006 03:01:25 -0000
@@ -173,6 +173,7 @@
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
@@ -324,6 +325,7 @@
e_fwin.c \
e_widget_aspect.c \
e_widget_desk_preview.c \
+e_filereg.c \
e_int_config_borders.c \
$(ENLIGHTENMENTHEADERS)
Index: e_bg.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_bg.c,v
retrieving revision 1.22
diff -u -r1.22 e_bg.c
--- e_bg.c 16 Oct 2006 23:45:16 -0000 1.22
+++ e_bg.c 17 Oct 2006 03:01:29 -0000
@@ -7,8 +7,47 @@
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)
{
@@ -166,6 +205,24 @@
}
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;
@@ -178,6 +235,7 @@
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
@@ -194,6 +252,7 @@
(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;
@@ -208,7 +267,7 @@
E_Manager *man;
E_Container *con;
E_Zone *zone;
-
+
for (l = e_manager_list(); l; l = l->next)
{
man = l->data;
@@ -249,3 +308,4 @@
evas_object_clip_set(zone->bg_object, zone->bg_clip_object);
evas_object_show(zone->bg_object);
}
+
Index: e_bg.h
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_bg.h,v
retrieving revision 1.7
diff -u -r1.7 e_bg.h
--- e_bg.h 16 Oct 2006 23:45:16 -0000 1.7
+++ e_bg.h 17 Oct 2006 03:01:32 -0000
@@ -14,10 +14,14 @@
#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
Index: e_fm.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_fm.c,v
retrieving revision 1.93
diff -u -r1.93 e_fm.c
--- e_fm.c 15 Oct 2006 23:52:36 -0000 1.93
+++ e_fm.c 17 Oct 2006 03:02:12 -0000
@@ -4223,7 +4223,8 @@
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;
@@ -4308,7 +4309,17 @@
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);
@@ -4556,6 +4567,8 @@
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();
@@ -4665,7 +4678,7 @@
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)
{
@@ -4674,6 +4687,7 @@
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)))
@@ -4713,6 +4727,7 @@
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)))
Index: e_includes.h
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_includes.h,v
retrieving revision 1.137
diff -u -r1.137 e_includes.h
--- e_includes.h 14 Oct 2006 09:43:12 -0000 1.137
+++ e_includes.h 17 Oct 2006 03:02:13 -0000
@@ -148,6 +148,7 @@
#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"
Index: e_int_config_wallpaper.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_int_config_wallpaper.c,v
retrieving revision 1.19
diff -u -r1.19 e_int_config_wallpaper.c
--- e_int_config_wallpaper.c 16 Oct 2006 04:52:31 -0000 1.19
+++ e_int_config_wallpaper.c 17 Oct 2006 03:02:20 -0000
@@ -515,12 +515,10 @@
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;
@@ -681,9 +679,7 @@
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
{
@@ -695,9 +691,7 @@
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)
{
Index: e_main.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_main.c,v
retrieving revision 1.190
diff -u -r1.190 e_main.c
--- e_main.c 30 Sep 2006 04:49:31 -0000 1.190
+++ e_main.c 17 Oct 2006 03:02:34 -0000
@@ -489,6 +489,13 @@
_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())
{
@@ -553,6 +560,13 @@
_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 */
Index: e_theme.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_theme.c,v
retrieving revision 1.24
diff -u -r1.24 e_theme.c
--- e_theme.c 23 Aug 2006 14:00:31 -0000 1.24
+++ e_theme.c 17 Oct 2006 03:02:39 -0000
@@ -271,6 +271,7 @@
e_theme_file_set(const char *category, const char *file)
{
E_Theme_Result *res;
+ char buf[4096];
if (group_cache)
{
@@ -282,12 +283,16 @@
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);
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel