Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h comms.c config.c file.c globals.c ipc.c main.c misc.c 
        session.c theme.c 


Log Message:
Theme code and namespace shuffle.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -3 -r1.203 -r1.204
--- E.h 10 Feb 2004 20:25:17 -0000      1.203
+++ E.h 11 Feb 2004 15:27:41 -0000      1.204
@@ -2016,25 +2016,25 @@
 
 /* file.c */
 void                Etmp(char *s);
-void                md(char *s);
-int                 exists(char *s);
-void                mkdirs(char *s);
-int                 isfile(char *s);
-int                 isdir(char *s);
-char              **ls(char *dir, int *num);
+void                md(const char *s);
+int                 exists(const char *s);
+void                mkdirs(const char *s);
+int                 isfile(const char *s);
+int                 isdir(const char *s);
+char              **ls(const char *dir, int *num);
 void                freestrlist(char **l, int num);
-void                rm(char *s);
-void                mv(char *s, char *ss);
-void                cp(char *s, char *ss);
-time_t              moddate(char *s);
-int                 filesize(char *s);
-int                 fileinode(char *s);
-int                 filedev(char *s);
-void                cd(char *s);
+void                rm(const char *s);
+void                mv(const char *s, const char *ss);
+void                cp(const char *s, const char *ss);
+time_t              moddate(const char *s);
+int                 filesize(const char *s);
+int                 fileinode(const char *s);
+int                 filedev(const char *s);
+void                cd(const char *s);
 char               *cwd(void);
-int                 permissions(char *s);
-int                 owner(char *s);
-int                 group(char *s);
+int                 permissions(const char *s);
+int                 owner(const char *s);
+int                 group(const char *s);
 char               *username(int uid);
 char               *homedir(int uid);
 char               *usershell(int uid);
@@ -2042,18 +2042,19 @@
 char               *atchar(char *s, char c);
 char               *getword(char *s, int num);
 void                word(char *s, int num, char *wd);
-int                 canread(char *s);
-int                 canwrite(char *s);
-int                 canexec(char *s);
-char               *fileof(char *s);
-char               *fullfileof(char *s);
-char               *pathtoexec(char *file);
-char               *pathtofile(char *file);
+int                 canread(const char *s);
+int                 canwrite(const char *s);
+int                 canexec(const char *s);
+char               *fileof(const char *s);
+char               *fullfileof(const char *s);
+char               *pathtoexec(const char *file);
+char               *pathtofile(const char *file);
 char               *FileExtension(char *file);
 char               *field(char *s, int field);
 int                 fillfield(char *s, int field, char *buf);
 void                fword(char *s, int num, char *wd);
 int                 findLocalizedFile(char *fname);
+void                rmrf(const char *s);
 
 /* finders.c */
 EWin               *FindEwinByBase(Window win);
@@ -2335,7 +2336,6 @@
 void                EdgeHandleEnter(XEvent * ev);
 void                EdgeHandleLeave(XEvent * ev);
 void                EdgeHandleMotion(XEvent * ev);
-char                SanitiseThemeDir(char *dir);
 void                Quicksort(void **a, int l, int r,
                              int (*CompareFunc) (void *d1, void *d2));
 
@@ -2541,13 +2541,12 @@
                             int w, int h, int fsize, int justification);
 
 /* theme.c */
-char               *append_merge_dir(char *dir, char ***list, int *count);
+char               *ThemeGetDefault(void);
+void                ThemeSetDefault(const char *theme);
+void                ThemeCleanup(void);
+void                ThemeBadDialog(void);
 char              **ListThemes(int *number);
-char               *GetDefaultTheme(void);
-void                SetDefaultTheme(char *theme);
-void                BadThemeDialog(void);
-char               *FindTheme(char *theme);
-char               *ExtractTheme(char *theme);
+char               *FindTheme(const char *theme);
 
 /* timers.c */
 double              GetTime(void);
@@ -2730,7 +2729,6 @@
 extern char         themepath[FILEPATH_LEN_MAX];
 extern char         themename[FILEPATH_LEN_MAX];
 extern char        *command;
-extern char         mustdel;
 
 #define DRAW_QUEUE_ENABLE 1
 extern char         queue_up;
@@ -2743,8 +2741,6 @@
 extern int          mask_mod_combos[8];
 extern Group       *current_group;
 extern char        *dstr;
-extern char        *badtheme;
-extern char        *badreason;
 extern char        *e_machine_name;
 
 #ifdef HAS_XINERAMA
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/comms.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -3 -r1.48 -r1.49
--- comms.c     10 Feb 2004 20:25:17 -0000      1.48
+++ comms.c     11 Feb 2004 15:27:51 -0000      1.49
@@ -425,7 +425,7 @@
      {
        char               *buf;
 
-       buf = GetDefaultTheme();
+       buf = ThemeGetDefault();
        if (buf)
          {
             CommsSend(c, buf);
@@ -441,7 +441,7 @@
        word(s, 2, buf);
        if (exists(buf))
          {
-            SetDefaultTheme(buf);
+            ThemeSetDefault(buf);
             Esnprintf(sss, sizeof(sss), "restart_theme %s", buf);
             SessionExit(sss);
          }
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -3 -r1.85 -r1.86
--- config.c    6 Feb 2004 19:56:26 -0000       1.85
+++ config.c    11 Feb 2004 15:27:51 -0000      1.86
@@ -3671,7 +3671,6 @@
    FILE               *f;
 
    EDBUG(5, "LoadEConfig");
-   mustdel = 0;
 
    Esnprintf(s, sizeof(s), "%s/", UserEDir());
 #if USE_FNLIB
@@ -3703,7 +3702,7 @@
                  "This may be due to lack of disk space, quota or\n"
                  "filesystem permissions.\n"), ss);
      }
-   strcpy(themename, themelocation);
+
    theme = FindTheme(themelocation);
    if (!theme)
      {
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/file.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- file.c      19 Jan 2004 22:30:30 -0000      1.52
+++ file.c      11 Feb 2004 15:27:52 -0000      1.53
@@ -27,7 +27,6 @@
 #define chdir  _chdir2
 #define getcwd _getcwd2
 extern char        *__XOS2RedirRoot(const char *);
-
 #endif
 
 char               *
@@ -59,7 +58,7 @@
 }
 
 void
-md(char *s)
+md(const char *s)
 {
    EDBUG(9, "md");
    if ((!s) || (!*s))
@@ -69,7 +68,7 @@
 }
 
 int
-exists(char *s)
+exists(const char *s)
 {
    struct stat         st;
 
@@ -82,7 +81,7 @@
 }
 
 void
-mkdirs(char *s)
+mkdirs(const char *s)
 {
    char                ss[FILEPATH_LEN_MAX];
    int                 i, ii;
@@ -105,7 +104,7 @@
 }
 
 int
-isfile(char *s)
+isfile(const char *s)
 {
    struct stat         st;
 
@@ -120,7 +119,7 @@
 }
 
 int
-isdir(char *s)
+isdir(const char *s)
 {
    struct stat         st;
 
@@ -135,7 +134,7 @@
 }
 
 char              **
-ls(char *dir, int *num)
+ls(const char *dir, int *num)
 {
    int                 i, dirlen;
    int                 done = 0;
@@ -216,7 +215,7 @@
 }
 
 void
-rm(char *s)
+rm(const char *s)
 {
    EDBUG(9, "rm");
    if ((!s) || (!*s))
@@ -226,7 +225,7 @@
 }
 
 void
-mv(char *s, char *ss)
+mv(const char *s, const char *ss)
 {
    EDBUG(9, "mv");
    if ((!s) || (!ss) || (!*s) || (!*ss))
@@ -236,7 +235,7 @@
 }
 
 void
-cp(char *s, char *ss)
+cp(const char *s, const char *ss)
 {
    int                 i;
    FILE               *f, *ff;
@@ -265,7 +264,7 @@
 }
 
 time_t
-moddate(char *s)
+moddate(const char *s)
 {
    struct stat         st;
 
@@ -280,7 +279,7 @@
 }
 
 int
-filesize(char *s)
+filesize(const char *s)
 {
    struct stat         st;
 
@@ -293,7 +292,7 @@
 }
 
 int
-fileinode(char *s)
+fileinode(const char *s)
 {
 #ifndef __EMX__
    struct stat         st;
@@ -310,7 +309,7 @@
 }
 
 int
-filedev(char *s)
+filedev(const char *s)
 {
    struct stat         st;
 
@@ -323,7 +322,7 @@
 }
 
 void
-cd(char *s)
+cd(const char *s)
 {
    EDBUG(9, "cd");
    if ((!s) || (!*s))
@@ -345,7 +344,7 @@
 }
 
 int
-permissions(char *s)
+permissions(const char *s)
 {
    struct stat         st;
 
@@ -358,7 +357,7 @@
 }
 
 int
-owner(char *s)
+owner(const char *s)
 {
    struct stat         st;
 
@@ -371,7 +370,7 @@
 }
 
 int
-group(char *s)
+group(const char *s)
 {
    struct stat         st;
 
@@ -787,7 +786,7 @@
 }
 
 int
-canread(char *s)
+canread(const char *s)
 {
    EDBUG(9, "canread");
    if ((!s) || (!*s))
@@ -800,7 +799,7 @@
 }
 
 int
-canwrite(char *s)
+canwrite(const char *s)
 {
    EDBUG(9, "canwrite");
    if ((!s) || (!*s))
@@ -813,7 +812,7 @@
 }
 
 int
-canexec(char *s)
+canexec(const char *s)
 {
    EDBUG(9, "canexec");
    if ((!s) || (!*s))
@@ -826,7 +825,7 @@
 }
 
 char               *
-fileof(char *s)
+fileof(const char *s)
 {
    char                ss[1024];
    int                 i, p1, p2;
@@ -855,7 +854,7 @@
 }
 
 char               *
-fullfileof(char *s)
+fullfileof(const char *s)
 {
    char                ss[1024];
    int                 i, p1, p2;
@@ -878,7 +877,7 @@
 }
 
 char               *
-pathtoexec(char *file)
+pathtoexec(const char *file)
 {
    char               *p, *cp, *ep;
    char               *s;
@@ -994,7 +993,7 @@
 }
 
 char               *
-pathtofile(char *file)
+pathtofile(const char *file)
 {
    char               *p, *cp, *ep;
    char               *s;
@@ -1116,3 +1115,18 @@
 
    return 0;
 }
+
+#if 0 /* Not used */
+void
+rmrf(const char *path)
+{
+   char                s[FILEPATH_LEN_MAX];
+
+#ifndef __EMX__
+   Esnprintf(s, sizeof(s), "/bin/rm -rf %s", path);
+#else
+   Esnprintf(s, sizeof(s), "rm.exe -rf %s", path);
+#endif
+   system(s);
+}
+#endif
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/globals.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- globals.c   10 Feb 2004 18:29:46 -0000      1.28
+++ globals.c   11 Feb 2004 15:27:52 -0000      1.29
@@ -57,7 +57,6 @@
 char                themepath[FILEPATH_LEN_MAX];
 char                themename[FILEPATH_LEN_MAX];
 char               *command;
-char                mustdel;
 char                queue_up;
 char                no_overwrite = 0;
 char                clickmenu = 0;
@@ -68,8 +67,6 @@
 int                 mask_mod_combos[8];
 Group              *current_group;
 char               *dstr = NULL;
-char               *badtheme = NULL;
-char               *badreason = NULL;
 char               *e_machine_name = NULL;
 
 #ifdef DEBUG
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ipc.c,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -3 -r1.136 -r1.137
--- ipc.c       6 Feb 2004 19:56:26 -0000       1.136
+++ ipc.c       11 Feb 2004 15:27:52 -0000      1.137
@@ -4375,7 +4375,7 @@
 
    if (!strcmp(params, "?"))
      {
-       Esnprintf(buf, sizeof(buf), "%s", GetDefaultTheme());
+       Esnprintf(buf, sizeof(buf), "%s", ThemeGetDefault());
      }
    else
      {
@@ -4383,7 +4383,7 @@
          {
             char                restartcommand[FILEPATH_LEN_MAX];
 
-            SetDefaultTheme(params);
+            ThemeSetDefault(params);
             Esnprintf(restartcommand, sizeof(restartcommand),
                       "restart_theme %s", params);
             SessionExit(restartcommand);
@@ -4391,7 +4391,7 @@
        else
          {
             Esnprintf(buf, sizeof(buf), "Could not find theme: %s",
-                      GetDefaultTheme());
+                      ThemeGetDefault());
          }
      }
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/main.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -3 -r1.71 -r1.72
--- main.c      6 Feb 2004 19:56:26 -0000       1.71
+++ main.c      11 Feb 2004 15:27:53 -0000      1.72
@@ -217,7 +217,7 @@
          {
             char               *def;
 
-            def = GetDefaultTheme();
+            def = ThemeGetDefault();
             if (def)
               {
                  Esnprintf(themepath, sizeof(themepath), "%s", def);
@@ -369,7 +369,7 @@
    SpawnSnappedCmds();
    mode.startup = 0;
 
-   BadThemeDialog();
+   ThemeBadDialog();
    /* The primary event loop */
    for (;;)
       WaitEvent();
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/misc.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- misc.c      19 Jan 2004 22:30:32 -0000      1.39
+++ misc.c      11 Feb 2004 15:27:53 -0000      1.40
@@ -202,17 +202,7 @@
 
        exitcode = (long)code;
        SoundExit();
-       if (mustdel)
-         {
-            char                sss[FILEPATH_LEN_MAX];
-
-#ifndef __EMX__
-            Esnprintf(sss, sizeof(sss), "/bin/rm -rf %s", themepath);
-#else
-            Esnprintf(sss, sizeof(sss), "rm.exe -rf %s", themepath);
-#endif
-            system(sss);
-         }
+       ThemeCleanup();
        for (i = 0; i < child_count; i++)
           kill(e_children[i], SIGINT);
      }
@@ -413,108 +403,6 @@
    data = NULL;
 }
 
-/* be paranoid and check for files being in theme */
-char
-SanitiseThemeDir(char *dir)
-{
-   char                s[4096];
-
-   return 1;
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "borders.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a borders.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "buttons.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a buttons.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "colormodifiers.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a colormodifiers.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "cursors.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a cursors.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "desktops.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a desktops.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "imageclasses.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a imageclasses.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "init.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a init.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "menustyles.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a menustyles.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "slideouts.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a slideouts.cfg file\n");
-       return 0;
-     }
-#ifndef __EMX__                        /* OS/2 Team will compile ESound after XMMS 
project */
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "sound.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a sound.cfg file\n");
-       return 0;
-     }
-#endif
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "tooltips.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a tooltips.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "windowmatches.cfg");
-   if (!isfile(s))
-     {
-       badreason = _("Theme does not contain a windowmatches.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "menus.cfg");
-   if (isfile(s))
-     {
-       badreason = _("Theme contains a menus.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "control.cfg");
-   if (isfile(s))
-     {
-       badreason = _("Theme contains a control.cfg file\n");
-       return 0;
-     }
-   Esnprintf(s, sizeof(s), "%s/%s", dir, "keybindings.cfg");
-   if (isfile(s))
-     {
-       badreason = _("Theme contains a keybindings.cfg file\n");
-       return 0;
-     }
-   return 1;
-}
-
 /* This is a general quicksort algorithm, using median-of-three strategy.
  * 
  * Parameters:
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/session.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -3 -r1.50 -r1.51
--- session.c   19 Jan 2004 22:30:32 -0000      1.50
+++ session.c   11 Feb 2004 15:27:53 -0000      1.51
@@ -1133,15 +1133,8 @@
        setsid();
 #endif
        sscanf(params, "%1000s", s);
-       if (mustdel)
-         {
-#ifndef __EMX__
-            Esnprintf(sss, sizeof(sss), "/bin/rm -rf %s", themepath);
-#else
-            Esnprintf(sss, sizeof(sss), "rm.exe -rf %s", themepath);
-#endif
-            system(sss);
-         }
+       ThemeCleanup();
+
        if (!strcmp(s, "restart"))
          {
             SoundPlay("SOUND_WAIT");
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/theme.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- theme.c     19 Jan 2004 22:30:34 -0000      1.28
+++ theme.c     11 Feb 2004 15:27:54 -0000      1.29
@@ -21,17 +21,133 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "E.h"
+
 #ifdef __EMX__
 #include <process.h>
 extern char        *__XOS2RedirRoot(const char *);
+#endif
+
+#define ENABLE_THEME_SANITY_CHECKING 0
 
+static char        *badtheme = NULL;
+static char        *badreason = NULL;
+static char         mustdel = 0;
+
+#if ENABLE_THEME_SANITY_CHECKING
+
+/* be paranoid and check for files being in theme */
+static char
+SanitiseThemeDir(char *dir)
+{
+   char                s[4096];
+
+   return 1;
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "borders.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a borders.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "buttons.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a buttons.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "colormodifiers.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a colormodifiers.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "cursors.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a cursors.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "desktops.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a desktops.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "imageclasses.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a imageclasses.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "init.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a init.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "menustyles.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a menustyles.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "slideouts.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a slideouts.cfg file\n");
+       return 0;
+     }
+#ifndef __EMX__                        /* OS/2 Team will compile ESound after XMMS 
project */
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "sound.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a sound.cfg file\n");
+       return 0;
+     }
 #endif
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "tooltips.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a tooltips.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "windowmatches.cfg");
+   if (!isfile(s))
+     {
+       badreason = _("Theme does not contain a windowmatches.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "menus.cfg");
+   if (isfile(s))
+     {
+       badreason = _("Theme contains a menus.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "control.cfg");
+   if (isfile(s))
+     {
+       badreason = _("Theme contains a control.cfg file\n");
+       return 0;
+     }
+   Esnprintf(s, sizeof(s), "%s/%s", dir, "keybindings.cfg");
+   if (isfile(s))
+     {
+       badreason = _("Theme contains a keybindings.cfg file\n");
+       return 0;
+     }
+   return 1;
+}
 
-char               *
+#else
+
+#define SanitiseThemeDir(dir) 1
+
+#endif /* ENABLE_THEME_SANITY_CHECKING */
+
+static char        *
 append_merge_dir(char *dir, char ***list, int *count)
 {
-   char                s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX], **str =
-      NULL, *def = NULL;
+   char                s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX];
+   char              **str = NULL, *def = NULL;
    char                already, *tmp, *tmp2, ok;
    int                 i, j, num;
 
@@ -140,7 +256,7 @@
 }
 
 char               *
-GetDefaultTheme(void)
+ThemeGetDefault(void)
 {
    char                s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX];
    char               *def = NULL;
@@ -195,7 +311,7 @@
 }
 
 void
-SetDefaultTheme(char *theme)
+ThemeSetDefault(const char *theme)
 {
 #ifndef __EMX__
 /* os2 has no symlink,
@@ -211,91 +327,96 @@
 #endif
 }
 
-char               *
-ExtractTheme(char *theme)
+static char        *
+ThemeExtract(const char *theme)
 {
    char                s[FILEPATH_LEN_MAX];
    char                th[FILEPATH_LEN_MAX];
    FILE               *f;
    unsigned char       buf[320];
+   const char         *oktheme = NULL;
+   char               *name;
+
+   EDBUG(7, "ThemeExtract");
 
-   EDBUG(7, "ExtractTheme");
    mustdel = 0;
+
    /* its a directory - just use it "as is" */
    if (isdir(theme))
      {
-       if (SanitiseThemeDir(theme))
-         {
-            EDBUG_RETURN(duplicate(theme));
-         }
-       else
-         {
-            EDBUG_RETURN(NULL);
-         }
+       oktheme = theme;
+       goto exit;
      }
+
    /* its a file - check its type */
    if (isfile(theme))
      {
        f = fopen(theme, "r");
-       if (f)
-         {
-            char               *themename;
+       if (!f)
+          goto exit;
 
-            fread(buf, 1, 320, f);
-            fclose(f);
-            /* make the temp dir */
-
-            themename = fileof(theme);
-            Esnprintf(th, sizeof(th), "%s/themes/%s", UserEDir(), themename);
-            Efree(themename);
-            md(th);
-            /* check magic numbers */
-            if ((buf[0] == 31) && (buf[1] == 139))
-              {
-                 /*gzipped tarball */
-                 Esnprintf(s, sizeof(s),
-                           "gzip -d -c < %s | (cd %s ; tar -xf -)", theme, th);
-              }
-            else if ((buf[257] == 'u') && (buf[258] == 's')
-                     && (buf[259] == 't') && (buf[260] == 'a')
-                     && (buf[261] == 'r'))
-              {
-                 /*vanilla tarball */
-                 Esnprintf(s, sizeof(s), "(cd %s ; tar -xf %s)", th, theme);
-              }
-            /* exec the untar if tarred */
-            system(s);
-            /* we made a temp dir - flag for deletion */
-            if (SanitiseThemeDir(th))
-              {
-                 EDBUG_RETURN(duplicate(th));
-              }
-            else if (mustdel)
-              {
-                 char                sss[FILEPATH_LEN_MAX];
+       fread(buf, 1, 320, f);
+       fclose(f);
 
-#ifndef __EMX__
-                 Esnprintf(sss, sizeof(sss), "/bin/rm -rf %s", themepath);
-#else
-                 Esnprintf(sss, sizeof(sss), "rm.exe -rf %s", themepath);
-#endif
-                 system(sss);
-                 mustdel = 0;
-                 EDBUG_RETURN(NULL);
-              }
+       /* make the temp dir */
+       name = fileof(theme);
+       Esnprintf(th, sizeof(th), "%s/themes/%s", UserEDir(), name);
+       Efree(name);
+       md(th);
+
+       /* check magic numbers */
+       if ((buf[0] == 31) && (buf[1] == 139))
+         {
+            /* gzipped tarball */
+            Esnprintf(s, sizeof(s),
+                      "gzip -d -c < %s | (cd %s ; tar -xf -)", theme, th);
+         }
+       else if ((buf[257] == 'u') && (buf[258] == 's')
+                && (buf[259] == 't') && (buf[260] == 'a') && (buf[261] == 'r'))
+         {
+            /* vanilla tarball */
+            Esnprintf(s, sizeof(s), "(cd %s ; tar -xf %s)", th, theme);
          }
+
+       /* exec the untar if tarred */
+       system(s);
+
+       oktheme = th;
      }
+
+ exit:
+   if (oktheme && SanitiseThemeDir(oktheme))
+      EDBUG_RETURN(duplicate(oktheme));
+
+   /* failed */
+   ThemeCleanup();
+
    EDBUG_RETURN(NULL);
 }
 
+void
+ThemeCleanup(void)
+{
+   if (!mustdel)
+      return;
+
+   /* We don't ever get here because mustdel is never set */
+#if 0
+   rmrf(themepath);
+#endif
+}
+
 char               *
-FindTheme(char *theme)
+FindTheme(const char *theme)
 {
    char                s[FILEPATH_LEN_MAX];
    char               *ret = NULL;
 
    EDBUG(6, "FindTheme");
+
+   strcpy(themename, theme);
    badreason = _("Unknown\n");
+
    if (!theme[0])
      {
 #ifndef __EMX__
@@ -306,17 +427,18 @@
 #endif
        EDBUG_RETURN(duplicate(s));
      }
+
 #ifndef __EMX__
    if (theme[0] == '/')
 #else
    if (_fnisabs(theme))
 #endif
-      ret = ExtractTheme(theme);
+      ret = ThemeExtract(theme);
    if (!ret)
      {
        Esnprintf(s, sizeof(s), "%s/themes/%s", UserEDir(), theme);
        if (exists(s))
-          ret = ExtractTheme(s);
+          ret = ThemeExtract(s);
        else
           badreason = _("Theme file/directory does not exist\n");
        if (!ret)
@@ -328,12 +450,12 @@
                       __XOS2RedirRoot(ENLIGHTENMENT_ROOT), theme);
 #endif
             if (exists(s))
-               ret = ExtractTheme(s);
+               ret = ThemeExtract(s);
             else
                badreason = _("Theme file/directory does not exist\n");
             if (!ret)
               {
-                 ret = GetDefaultTheme();
+                 ret = ThemeGetDefault();
                  badtheme = duplicate(theme);
               }
          }
@@ -342,7 +464,7 @@
 }
 
 void
-BadThemeDialog(void)
+ThemeBadDialog(void)
 {
    if (!badtheme)
       return;




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to