Enlightenment CVS committal

Author  : onefang
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_apps.c e_apps.h e_int_config_apps.c 


Log Message:
* 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.


===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_apps.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -3 -r1.183 -r1.184
--- e_apps.c    14 Sep 2006 15:16:27 -0000      1.183
+++ e_apps.c    15 Sep 2006 17:44:23 -0000      1.184
@@ -199,10 +199,28 @@
 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 @@
           {
              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;
@@ -950,6 +974,31 @@
                       return a;
                    }
               }
+         }
+     }
+   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;
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_apps.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -3 -r1.41 -r1.42
--- e_apps.h    7 Sep 2006 08:53:09 -0000       1.41
+++ e_apps.h    15 Sep 2006 17:44:23 -0000      1.42
@@ -65,6 +65,9 @@
    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 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);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_int_config_apps.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- e_int_config_apps.c 12 Sep 2006 13:16:21 -0000      1.25
+++ e_int_config_apps.c 15 Sep 2006 17:44:23 -0000      1.26
@@ -22,6 +22,7 @@
 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 @@
    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 @@
       {
          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);
@@ -769,6 +776,61 @@
          last = NULL;
       }
    fclose(f);
+
+   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;
+}
+
+
+
+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);



-------------------------------------------------------------------------
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-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to