Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_fm.c e_fm.h e_fm_prop.c 


Log Message:


add the start of metadata that is private to the user (so you can modify
icons or all sorts of visible info about a file - and can even do it for
files on read-only fs's)

===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -3 -r1.126 -r1.127
--- e_fm.c      7 Jan 2007 21:33:52 -0000       1.126
+++ e_fm.c      10 Jan 2007 18:50:52 -0000      1.127
@@ -316,6 +316,38 @@
 static Evas_List *_e_fm2_fop_list = NULL;
 
 /* externally accessible functions */
+EAPI E_Fm2_Custom_File *
+e_fm2_custom_file_get(const char *path)
+{
+   /* get any custom info for the path in our metadata - if non exists,
+    * return NULL. This may mean loading upa chunk of metadata off disk
+    * on demand and caching it */
+   return NULL;
+}
+
+EAPI void
+e_fm2_custom_file_set(const char *path, E_Fm2_Custom_File *cf)
+{
+   /* set custom metadata for a file path - save it to the metadata (or queue 
it) */
+}
+
+EAPI void e_fm2_custom_file_del(const char *path)
+{
+   /* delete a custom metadata entry for a path - save changes (or queue it) */
+}
+
+EAPI void e_fm2_custom_file_rename(const char *path, const char *new_path)
+{
+   /* rename file path a to file paht b in the metadata - if the path exists */
+}
+
+EAPI void e_fm2_custom_file_flush(void)
+{
+   /* free any loaded custom file data, sync changes to disk etc. */
+}
+
+/***/
+
 EAPI int
 e_fm2_init(void)
 {
@@ -959,7 +991,26 @@
      }
    else
      {
-       if (ici->mime)
+       if (ici->icon_type == 1)
+         {
+            if (ici->pseudo_link)
+              snprintf(buf, sizeof(buf), "%s/%s", ici->pseudo_dir, ici->file);
+            else
+              snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file);
+            
+            oic = e_thumb_icon_add(evas);
+            e_thumb_icon_file_set(oic, buf, NULL);
+            e_thumb_icon_size_set(oic, 128, 128);
+            if (gen_func) evas_object_smart_callback_add(oic, 
+                                                         "e_thumb_gen",
+                                                         gen_func, data);
+            if (!ic)
+              e_thumb_icon_begin(oic);
+            else
+              _e_fm2_icon_thumb(ic, oic, force_gen);
+            if (type_ret) *type_ret = "THUMB";
+         }
+       else if (ici->mime)
          {
             const char *icon;
             
@@ -1355,7 +1406,10 @@
      {
        sd->busy_count--;
        if (sd->busy_count == 0)
-         edje_object_signal_emit(sd->overlay, "e,state,busy,stop", "e");
+         {
+            edje_object_signal_emit(sd->overlay, "e,state,busy,stop", "e");
+            e_fm2_custom_file_flush();
+         }
      }
    /* stop the scan idler, the sort timer and free the queue */
    if (sd->dir)
@@ -1898,8 +1952,10 @@
    Evas_Object *obj, *obj2;
    char buf[4096], *lnk;
    const char *mime;
+   E_Fm2_Custom_File *cf;
    
    snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file);
+   cf = e_fm2_custom_file_get(buf);
    lnk = ecore_file_readlink(buf);
    if (stat(buf, &(ic->info.statinfo)) == -1)
      {
@@ -1952,6 +2008,21 @@
    if ((e_util_glob_case_match(ic->info.file, "*.desktop")) ||
        (e_util_glob_case_match(ic->info.file, "*.directory")))
      _e_fm2_icon_desktop_load(ic);
+
+   if (cf)
+     {
+       if (cf->icon.valid)
+         {
+            if (cf->icon.icon)
+              {
+                 if (ic->info.icon) evas_stringshare_del(ic->info.icon);
+                 ic->info.icon = NULL;
+                 ic->info.icon = evas_stringshare_add(cf->icon.icon);
+              }
+            ic->info.icon_type = cf->icon.type;
+         }
+     }
+   
    evas_event_freeze(evas_object_evas_get(ic->sd->obj));
    edje_freeze();
    switch (ic->sd->config->view.mode)
@@ -4232,6 +4303,7 @@
    if (sd->drop_handler) e_drop_handler_del(sd->drop_handler);
    _e_fm2_list = evas_list_remove(_e_fm2_list, sd->obj);
    free(sd);
+   e_fm2_custom_file_flush();
 }
 
 static void
@@ -4959,6 +5031,7 @@
             e_dialog_show(dialog);
             return;
          }
+       e_fm2_custom_file_rename(oldpath, newpath);
        _e_fm2_live_file_del(ic->sd->obj, ic->info.file);
        _e_fm2_live_file_add(ic->sd->obj, text, NULL, 0);
 //     evas_stringshare_del(ic->info.file);
@@ -5623,6 +5696,7 @@
             snprintf(buf, sizeof(buf), "%s/%s", fi->fop->dir, fi->file);
             if (ecore_file_unlink(buf))
               {
+                 e_fm2_custom_file_del(buf);
                  if ((fi->fop->obj) && (!strchr(fi->file, '/')))
                    _e_fm2_live_file_del(fi->fop->obj, fi->file);
               }
@@ -5664,6 +5738,7 @@
          {
             if (ecore_file_mv(fi->file, fi->file2))
               {
+                 e_fm2_custom_file_rename(fi->file, fi->file2);
                  if ((fi->fop->obj) && (fi->file_add))
                    _e_fm2_live_file_add(fi->fop->obj,
                                         fi->file, fi->file3, fi->after);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- e_fm.h      7 Jan 2007 09:01:47 -0000       1.36
+++ e_fm.h      10 Jan 2007 18:50:52 -0000      1.37
@@ -25,9 +25,10 @@
    E_FM2_MENU_NO_RENAME            = (1 << 5)
 } E_Fm2_Menu_Flags;
 
-typedef struct _E_Fm2_Config    E_Fm2_Config;
-typedef struct _E_Fm2_Icon      E_Fm2_Icon;
-typedef struct _E_Fm2_Icon_Info E_Fm2_Icon_Info;
+typedef struct _E_Fm2_Config      E_Fm2_Config;
+typedef struct _E_Fm2_Icon        E_Fm2_Icon;
+typedef struct _E_Fm2_Icon_Info   E_Fm2_Icon_Info;
+typedef struct _E_Fm2_Custom_File E_Fm2_Custom_File;
 
 #else
 #ifndef E_FM_H
@@ -102,11 +103,34 @@
    const char       *real_link;
    const char       *pseudo_dir;
    struct stat       statinfo;
+   unsigned char     icon_type;
    unsigned char     mount : 1;
    unsigned char     pseudo_link : 1;
    unsigned char     deleted : 1;
    unsigned char     broken_link : 1;
 };
+
+struct _E_Fm2_Custom_File
+{
+   struct {
+      int            x, y, w, h;
+      int            res_w, res_h;
+      unsigned char  valid;
+   } geom;
+   struct {
+      int            type;
+      const char    *icon;
+      unsigned char  valid;
+   } icon;
+   const char       *label;
+   /* FIXME: this will have more added */
+};
+
+EAPI E_Fm2_Custom_File    *e_fm2_custom_file_get(const char *path);
+EAPI void                  e_fm2_custom_file_set(const char *path, 
E_Fm2_Custom_File *cf);
+EAPI void                  e_fm2_custom_file_del(const char *path);
+EAPI void                  e_fm2_custom_file_rename(const char *path, const 
char *new_path);
+EAPI void                  e_fm2_custom_file_flush(void);
 
 EAPI int                   e_fm2_init(void);
 EAPI int                   e_fm2_shutdown(void);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_prop.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- e_fm_prop.c 10 Jan 2007 16:38:20 -0000      1.8
+++ e_fm_prop.c 10 Jan 2007 18:50:52 -0000      1.9
@@ -68,8 +68,12 @@
    int owner_write;
    int others_read;
    int others_write;
+   int picon_type;
+   int picon_mime;
+   int picon_changed;
    int icon_type;
    int icon_mime;
+   char *icon;
    /*- ADVANCED -*/
 };
 
@@ -87,8 +91,10 @@
    v->free_cfdata             = _free_data;
    v->basic.apply_cfdata      = _basic_apply_data;
    v->basic.create_widgets    = _basic_create_widgets;
-//   v->advanced.apply_cfdata   = _advanced_apply_data;
-//   v->advanced.create_widgets = _advanced_create_widgets;
+#if 0   
+   v->advanced.apply_cfdata   = _advanced_apply_data;
+   v->advanced.create_widgets = _advanced_create_widgets;
+#endif   
    /* create config diaolg for NULL object/data */
    cfd = e_config_dialog_new(con,
                             _("File Properties"),
@@ -139,6 +145,7 @@
    E_FREE(cfdata->mod_date);
    E_FREE(cfdata->mime);
    E_FREE(cfdata->owner);
+   E_FREE(cfdata->icon);
    free(cfdata);
 }
 
@@ -149,6 +156,8 @@
    char buf[4096];
    int fperm = 0;
    
+   snprintf(buf, sizeof(buf), "%s/%s", 
+           e_fm2_real_path_get(cfdata->fi->fm), cfdata->fi->file);
    if (((cfdata->fi->statinfo.st_mode & S_IRUSR) && (cfdata->owner_read)) ||
        ((!cfdata->fi->statinfo.st_mode & S_IRUSR) && (!cfdata->owner_read)))
      fperm = 1;
@@ -161,13 +170,57 @@
    if (((cfdata->fi->statinfo.st_mode & S_IWOTH) && (cfdata->others_write)) ||
        ((!cfdata->fi->statinfo.st_mode & S_IWOTH) && (!cfdata->others_write)))
      fperm = 1;
-   snprintf(buf, sizeof(buf), "%s/%s", 
-           e_fm2_real_path_get(cfdata->fi->fm), cfdata->fi->file);
    if (fperm)
      {
-       /* FIXME: modify st_mode */
-       chmod(buf, cfdata->fi->statinfo.st_mode);
+       mode_t pmode;
+       
+       pmode = cfdata->fi->statinfo.st_mode;
+       if (cfdata->owner_read) cfdata->fi->statinfo.st_mode |= S_IRUSR;
+       else cfdata->fi->statinfo.st_mode &= ~S_IRUSR;
+       if (cfdata->owner_write) cfdata->fi->statinfo.st_mode |= S_IWUSR;
+       else cfdata->fi->statinfo.st_mode &= ~S_IWUSR;
+       if (cfdata->others_read) cfdata->fi->statinfo.st_mode |= S_IROTH;
+       else cfdata->fi->statinfo.st_mode &= ~S_IROTH;
+       if (cfdata->others_write) cfdata->fi->statinfo.st_mode |= S_IWOTH;
+       else cfdata->fi->statinfo.st_mode &= ~S_IWOTH;
+       if (chmod(buf, cfdata->fi->statinfo.st_mode) == -1)
+         {
+            /* FIXME: error dialog */
+            cfdata->fi->statinfo.st_mode = pmode;
+         }
+     }
+   if ((cfdata->picon_type != cfdata->icon_type) ||
+       (cfdata->picon_mime != cfdata->icon_mime) ||
+       (cfdata->picon_changed))
+     {
+       if (cfdata->icon_mime) /* modify mimetype */
+         {
+            if (!cfdata->picon_mime) /* remove previous custom icon info */
+              e_fm2_custom_file_del(buf);
+            /* FIXME: modify mime info */
+         }
+       else /* custom for this file */
+         {
+            E_Fm2_Custom_File *cf, cf0;
+
+            cf = e_fm2_custom_file_get(buf);
+            if (!cf)
+              {
+                 memset(cf, 0, sizeof(E_Fm2_Custom_File));
+                 cf = &cf0;
+              }
+            cf->icon.type = cfdata->icon_type;
+            if (cf->icon.icon)
+              evas_stringshare_del(cf->icon.icon);
+            cf->icon.icon = NULL;
+            if (cfdata->icon)
+              cf->icon.icon = evas_stringshare_add(cfdata->icon);
+            cf->icon.valid = 1;
+            e_fm2_custom_file_set(buf, &cf);
+         }
+       e_fm2_all_icons_update();
      }
+         
    return 1; /* Apply was OK */
 }
 
@@ -204,7 +257,7 @@
    e_widget_entry_readonly_set(ob, 1);
    e_widget_table_object_append(ot, ob, 1, 0, 1, 1, 1, 0, 1, 0);
    
-   ob = e_widget_label_add(evas, _("Size:"));
+  ob = e_widget_label_add(evas, _("Size:"));
    e_widget_table_object_append(ot, ob, 0, 1, 1, 1, 1, 0, 1, 0);
    ob = e_widget_entry_add(evas, &(cfdata->size));
    e_widget_min_size_set(ob, 140, -1);
@@ -289,6 +342,7 @@
      }
    else
      cfdata->icon_type = 0;
+   cfdata->picon_type = cfdata->icon_type;
    
    rg = e_widget_radio_group_new(&cfdata->icon_type);
    ob = e_widget_radio_add(evas, _("Default"), 0, rg);
@@ -304,6 +358,7 @@
    cfdata->icon_mime = 1;
    if ((cfdata->fi->icon) || ((itype) && (!strcmp(itype, "DESKTOP"))))
      cfdata->icon_mime = 0;
+   cfdata->picon_mime = cfdata->icon_mime;
    ob = e_widget_check_add(evas, _("Use this icon for all files of this 
type"), &(cfdata->icon_mime));
    e_widget_frametable_object_append(ot, ob, 0, 3, 2, 1, 1, 1, 1, 1);
    



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to