Enlightenment CVS committal

Author  : atmosphere
Project : e17
Module  : apps/entice

Dir     : e17/apps/entice/src/bin


Modified Files:
        entice.c entice.h image.c image.h main.c prefs.c prefs.h 
        signals_image.c signals_image.h 


Log Message:
- Added functions to catch EnticeSaveCurrent signals
- Added saving functionality to images modified inside of entice
   - I've only tested this with jpg's, it could use some more testing
- Fixed a silly typo preventing images from loading
- Check return values of rotation and flip routines
- Added image flipping routines
   - Defaults to Up/Down keys to flip vertically/horizontally
- Made font and image caches configurable via ~/.entice.db
- Using edje_thaw/edje_freeze in the modification routines, i'm not 100%
  sure if these are necessary, but I don't want signal emissions during
  those times


===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/entice.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- entice.c    14 Oct 2003 14:12:06 -0000      1.4
+++ entice.c    14 Oct 2003 18:33:29 -0000      1.5
@@ -49,7 +49,7 @@
       "EnticeImageScrollEastStart", "EnticeImageScrollWestStart",
       "EnticeImageScrollNorthStart", "EnticeImageScrollSouthStart",
       "EnticeImageScrollStop", "EnticeImageModified",
-      "EnticeQuit"
+      "EnticeSaveCurrent", "EnticeQuit"
    };
    edje_callbacks funcs[] = { _entice_delete_current, _entice_remove_current,
       _entice_image_next, _entice_image_prev,
@@ -64,7 +64,7 @@
       _entice_image_scroll_east_start, _entice_image_scroll_west_start,
       _entice_image_scroll_north_start, _entice_image_scroll_south_start,
       _entice_image_scroll_stop, _entice_image_modified,
-      _entice_quit, NULL
+      _entice_image_save, _entice_quit, NULL
    };
    count = sizeof(signals) / sizeof(char *);
    for (i = 0; i < count; i++)
@@ -183,6 +183,7 @@
    {
       int iw, ih;
       double w, h;
+      int should_fit = 0;
       char buf[PATH_MAX];
 
       if ((entice->current) && entice_image_file_get(entice->current)
@@ -193,6 +194,7 @@
       tmp = e_thumb_evas_object_get(o);
       new_current = entice_image_new(tmp);
       entice_image_file_set(new_current, e_thumb_file_get(o));
+      entice_image_format_set(new_current, e_thumb_format_get(o));
 
       new_scroller =
          e_thumb_new(evas_object_evas_get(o), e_thumb_file_get(o));
@@ -213,7 +215,7 @@
          entice_image_zoom_set(new_current,
                                entice_image_zoom_get(entice->current));
          if (entice_image_zoom_fit_get(entice->current))
-            entice_image_zoom_fit(new_current);
+            should_fit = 1;
          evas_object_del(entice->current);
          entice->current = NULL;
 
@@ -258,6 +260,9 @@
       edje_object_part_swallow(entice->edje, "EnticeImageScroller",
                                new_scroller);
 
+      if (should_fit)
+         entice_image_zoom_fit(new_current);
+
       /* let the app know it's ready to be displayed */
       edje_object_signal_emit(entice->edje, "EnticeImageDisplay", "");
    }
@@ -330,7 +335,7 @@
       {
          if (file[0] == '/')
             snprintf(buf, PATH_MAX, "%s", file);
-         else if ((strlen(file) > 7) && strncmp(file, "http://";, 7))
+         else if ((strlen(file) > 7) && !strncmp(file, "http://";, 7))
          {
             fprintf(stderr, "http file request\n");
          }
@@ -603,6 +608,8 @@
       if ((newpreview =
            e_thumb_new(evas_object_evas_get(o), e_thumb_file_get(o))))
       {
+
+         edje_object_signal_emit(entice->edje, "EnticeImagePreviewPrep", "");
          edje_object_part_geometry_get(entice->edje, "EnticeImagePreview", &x,
                                        &y, &w, &h);
 
@@ -629,8 +636,10 @@
 {
    if (entice && entice->current)
    {
-      entice_image_rotate(entice->current, 1);
-      edje_object_signal_emit(entice->edje, "EnticeImageModified", "");
+      edje_freeze();
+      if (entice_image_rotate(entice->current, 1))
+         edje_object_signal_emit(entice->edje, "EnticeImageModified", "");
+      edje_thaw();
    }
 }
 void
@@ -638,7 +647,43 @@
 {
    if (entice && entice->current)
    {
-      entice_image_rotate(entice->current, 3);
-      edje_object_signal_emit(entice->edje, "EnticeImageModified", "");
+      edje_freeze();
+      if (entice_image_rotate(entice->current, 3))
+         edje_object_signal_emit(entice->edje, "EnticeImageModified", "");
+      edje_thaw();
+   }
+}
+void
+entice_flip_vertical(void)
+{
+   if (entice && entice->current)
+   {
+      edje_freeze();
+      if (entice_image_flip(entice->current, 1))
+         edje_object_signal_emit(entice->edje, "EnticeImageModified", "");
+      edje_thaw();
+   }
+}
+void
+entice_flip_horizontal(void)
+{
+   if (entice && entice->current)
+   {
+      edje_freeze();
+      if (entice_image_flip(entice->current, 0))
+         edje_object_signal_emit(entice->edje, "EnticeImageModified", "");
+      edje_thaw();
+   }
+}
+void
+entice_save_image(void)
+{
+   if (entice && entice->current)
+   {
+      edje_freeze();
+      if(entice_image_save(entice->current))
+         fprintf(stderr, "Saving was successul\n");
+      /* FIXME: Emit a EnticeSaveOk or something signal */
+      edje_thaw();
    }
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/entice.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- entice.h    11 Oct 2003 22:54:12 -0000      1.9
+++ entice.h    14 Oct 2003 18:33:29 -0000      1.10
@@ -60,6 +60,11 @@
 void entice_zoom_reset(void);
 void entice_fullscreen_toggle(void);
 
+void entice_rotate_image_right(void);
+void entice_rotate_image_left(void);
+void entice_flip_vertical(void);
+void entice_flip_horizontal(void);
+
 void entice_preview_thumb(Evas_Object * o);
 
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- image.c     14 Oct 2003 14:12:07 -0000      1.23
+++ image.c     14 Oct 2003 18:33:29 -0000      1.24
@@ -16,7 +16,38 @@
 static void entice_image_resize(Evas_Object * o, double w, double h);
 static int _entice_image_scroll_timer(void *data);
 
+const char *
+entice_image_format_get(Evas_Object * o)
+{
+   char *result = NULL;
+   Entice_Image *im = NULL;
+
+   if ((im = evas_object_smart_data_get(o)))
+      result = im->format;
+   return (result);
+}
+
 void
+entice_image_format_set(Evas_Object * o, const char *format)
+{
+   char buf[PATH_MAX];
+   Entice_Image *im = NULL;
+
+   if ((im = evas_object_smart_data_get(o)))
+   {
+      if (im->format)
+         free(im->format);
+      snprintf(buf, PATH_MAX, "%s", format);
+      im->format = strdup(buf);
+   }
+}
+
+/**
+ * entice_image_rotate - rotate the image using imlib2
+ * @o - the Entice Image Object
+ * @direction - 1 to flip clockwise, 3 to flip counter clockwise
+ */
+int
 entice_image_rotate(Evas_Object * o, int orientation)
 {
    int iw, ih;
@@ -48,12 +79,97 @@
          if (entice_image_zoom_fit_get(o))
             entice_image_zoom_fit(o);
          imlib_free_image();
+         return (1);
+      }
+   }
+   return (0);
+}
+
+/**
+ * entice_image_flip - flip the image using imlib2
+ * @o - the Entice Image Object
+ * @direction - non-zero to flip vertical, zero to flip horizontal
+ */
+int
+entice_image_flip(Evas_Object * o, int orientation)
+{
+   int iw, ih;
+   double w, h;
+   Entice_Image *im = NULL;
+   Imlib_Image imlib_im = NULL;
+
+   if ((im = evas_object_smart_data_get(o)))
+   {
+      evas_object_image_size_get(im->obj, &iw, &ih);
+      evas_object_geometry_get(o, NULL, NULL, &w, &h);
+
+      if (imlib_im =
+          imlib_create_image_using_copied_data(iw, ih,
+                                               evas_object_image_data_get(im->
+                                                                          obj,
+                                                                          1)))
+      {
+         imlib_context_set_image(imlib_im);
+         if (orientation)
+            imlib_image_flip_horizontal();
+         else
+            imlib_image_flip_vertical();
+
+         im->iw = imlib_image_get_width();
+         im->ih = imlib_image_get_height();
+         evas_object_image_size_set(im->obj, im->iw, im->ih);
+         evas_object_image_data_copy_set(im->obj,
+                                         imlib_image_get_data_for_reading_only
+                                         ());
+         evas_object_resize(o, w, h);
+         /* if we're fitting, it'll need to be recalculated */
+         if (entice_image_zoom_fit_get(o))
+            entice_image_zoom_fit(o);
+         imlib_free_image();
+         return (1);
+      }
+   }
+   return (0);
+}
+
+/**
+ * entice_image_save - save the image using imlib2
+ * @o - the Entice Image Object
+ */
+int
+entice_image_save(Evas_Object * o)
+{
+   int iw, ih;
+   double w, h;
+   Entice_Image *im = NULL;
+   Imlib_Image imlib_im = NULL;
+
+   if ((im = evas_object_smart_data_get(o)))
+   {
+      evas_object_image_size_get(im->obj, &iw, &ih);
+      evas_object_geometry_get(o, NULL, NULL, &w, &h);
+
+      if (imlib_im =
+          imlib_create_image_using_copied_data(iw, ih,
+                                               evas_object_image_data_get(im->
+                                                                          obj,
+                                                                          1)))
+      {
+         imlib_context_set_image(imlib_im);
+         if (im->format && im->filename)
+         {
+            imlib_image_set_format(im->format);
+            imlib_save_image(im->filename);
+         }
+         imlib_free_image();
+         return (1);
       }
    }
+   return (0);
 }
 
 void
-entice_image_file_set(Evas_Object * o, char *filename)
+entice_image_file_set(Evas_Object * o, const char *filename)
 {
    char buf[PATH_MAX];
    Entice_Image *im = NULL;
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- image.h     14 Oct 2003 14:12:07 -0000      1.14
+++ image.h     14 Oct 2003 18:33:29 -0000      1.15
@@ -34,6 +34,7 @@
       Entice_Scroll_Direction direction;
    } scroll;
    char *filename;              /* we need to keep track of this */
+   char *format;                /* we need to keep track of this too */
    int x, y, w, h, iw, ih;      /* geometry */
    Evas_Object *obj;            /* the image object */
    Evas_Object *clip;           /* clip to this area when we swallow */
@@ -63,6 +64,11 @@
 void entice_image_scroll_start(Evas_Object * o, Entice_Scroll_Direction d);
 void entice_image_scroll(Evas_Object * o, Entice_Scroll_Direction d, int val);
 const char *entice_image_file_get(Evas_Object * o);
-void entice_image_rotate(Evas_Object * o, int orientation);
+const char *entice_image_format_get(Evas_Object * o);
+int entice_image_rotate(Evas_Object * o, int direction);
+int entice_image_flip(Evas_Object * o, int direction);
+int entice_image_save(Evas_Object * o);
+void entice_image_file_set(Evas_Object * o, const char *filename);
+void entice_image_format_set(Evas_Object * o, const char *format);
 
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/main.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- main.c      12 Oct 2003 01:56:47 -0000      1.13
+++ main.c      14 Oct 2003 18:33:29 -0000      1.14
@@ -160,8 +160,10 @@
          ecore_evas_borderless_set(ee, 0);
          ecore_evas_shaped_set(ee, 0);
 
-         evas_font_cache_set(ecore_evas_get(ee), 1 * 1024 * 1024);
-         evas_image_cache_set(ecore_evas_get(ee), 8 * 1024 * 1024);
+         evas_font_cache_set(ecore_evas_get(ee),
+                             entice_config_font_cache_get() * 1024 * 1024);
+         evas_image_cache_set(ecore_evas_get(ee),
+                              entice_config_image_cache_get() * 1024 * 1024);
 
          evas_font_path_append(ecore_evas_get(ee), PACKAGE_DATA_DIR "/fonts");
          o = evas_object_rectangle_add(ecore_evas_get(ee));
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/prefs.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- prefs.c     14 Oct 2003 14:12:07 -0000      1.3
+++ prefs.c     14 Oct 2003 18:33:29 -0000      1.4
@@ -18,6 +18,34 @@
 static void entice_config_generate_original_db(char *filename);
 
 /**
+ * entice_config_font_cache_get - Get the font cache size in megabytes
+ * Returns - value should always be > 0
+ */
+int
+entice_config_font_cache_get(void)
+{
+   int result = 1;
+
+   if ((econfig) && (econfig->cache.font > 0))
+      result = econfig->cache.font;
+   return (result);
+}
+
+/**
+ * entice_config_image_cache_get - Get the font cache size in megabytes
+ * Returns - value should always be > 0
+ */
+int
+entice_config_image_cache_get(void)
+{
+   int result = 4;
+
+   if ((econfig) && (econfig->cache.image > 0))
+      result = econfig->cache.image;
+   return (result);
+}
+
+/**
  * entice_config_theme_get - get the theme name, DO NOT FREE THIS
  * Returns - absolute path to the theme's eet
  */
@@ -162,6 +190,12 @@
                   }
                }
             }
+            if (!e_db_int_get(db, "/entice/cache/font", &econfig->cache.font))
+               econfig->cache.font = 1;
+            if (!e_db_int_get
+                (db, "/entice/cache/image", &econfig->cache.image))
+               econfig->cache.image = 4;
+
             e_db_close(db);
          }
       }
@@ -176,13 +210,13 @@
    E_DB_File *db = NULL;
 
    char *signals[] = { "EnticeZoomIn", "EnticeZoomOut", "EnticeFullScreen",
-      "EnticeImageNext", "EnticeImagePrev",
-      "EnticeZoomDefault", "EnticeZoomFit",
-      "EnticeQuit", "EnticeRotateLeft", "EnticeRotateRight"
+      "EnticeImageNext", "EnticeImagePrev", "EnticeZoomDefault",
+      "EnticeZoomFit", "EnticeQuit", "EnticeRotateLeft",
+      "EnticeRotateRight", "EnticeFlipH", "EnticeFlipV"
    };
    char *keys[] =
       { "equal", "minus", "f", "space", "BackSpace", "n", "w", "q", "Left",
-      "Right"
+      "Right", "Up", "Down"
    };
    count = sizeof(signals) / sizeof(char *);
 
@@ -201,6 +235,9 @@
             e_db_str_set(db, buf, signals[i]);
          }
          e_db_int_set(db, "/entice/keys/up/count", count);
+         e_db_int_set(db, "/entice/cache/font", 1);
+         e_db_int_set(db, "/entice/cache/image", 8);
+
          e_db_close(db);
          e_db_flush();
       }
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/prefs.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- prefs.h     11 Oct 2003 22:54:12 -0000      1.1
+++ prefs.h     14 Oct 2003 18:33:29 -0000      1.2
@@ -13,6 +13,10 @@
 {
    char *theme;
    int engine;
+   struct
+   {
+      int image, font;
+   } cache;
 };
 typedef struct _Entice_Config Entice_Config;
 
@@ -21,5 +25,7 @@
 /* Accessors */
 const char *entice_config_theme_get(void);
 int entice_config_engine_get(void);
+int entice_config_font_cache_get(void);
+int entice_config_image_cache_get(void);
 
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/signals_image.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- signals_image.c     14 Oct 2003 14:12:07 -0000      1.3
+++ signals_image.c     14 Oct 2003 18:33:29 -0000      1.4
@@ -179,6 +179,7 @@
 _entice_flip_horizontal(void *data, Evas_Object * o, const char *emission,
                         const char *source)
 {
+   entice_flip_horizontal();
    return;
    data = NULL;
    o = NULL;
@@ -191,6 +192,7 @@
 _entice_flip_vertical(void *data, Evas_Object * o, const char *emission,
                       const char *source)
 {
+   entice_flip_vertical();
    return;
    data = NULL;
    o = NULL;
@@ -348,6 +350,22 @@
 #if DEBUG
    fprintf(stderr, "Image has been modified !!! :)\n");
 #endif
+   return;
+   data = NULL;
+   o = NULL;
+   emission = NULL;
+   source = NULL;
+}
+
+/* EnticeSaveCurrent */
+void
+_entice_image_save(void *data, Evas_Object * o, const char *emission,
+                   const char *source)
+{
+#if DEBUG
+   fprintf(stderr, "Image Save Request !!! :)\n");
+#endif
+   entice_save_image();
    return;
    data = NULL;
    o = NULL;
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/signals_image.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- signals_image.h     14 Oct 2003 14:12:07 -0000      1.2
+++ signals_image.h     14 Oct 2003 18:33:29 -0000      1.3
@@ -70,4 +70,6 @@
                   const char *source);
 void _entice_image_modified(void *data, Evas_Object * o, const char *emission,
                             const char *source);
+void _entice_image_save(void *data, Evas_Object * o, const char *emission,
+                        const char *source);
 #endif




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to