raster pushed a commit to branch master.

http://git.enlightenment.org/apps/rage.git/commit/?id=622cba151e63c9fd5f6b3531b0def17d9a88973c

commit 622cba151e63c9fd5f6b3531b0def17d9a88973c
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Thu Nov 12 22:23:21 2015 +0900

    rage browser - improve looksa and layout to use file posters if possible
    
    1. guess if it's a move by aspectr ratio and lenght.
    2. if it meets this - search for a file poster online instead of
    generating thumbnails.
    3. make thumbs now taller than wide to accomodate poster sizes
    
    looks nicer now.
---
 data/themes/default.edc        |  40 ++---------
 data/themes/images/Makefile.mk |   1 +
 data/themes/images/dimmer.png  | Bin 0 -> 1360 bytes
 src/bin/albumart.c             |  12 ++++
 src/bin/albumart.h             |   1 +
 src/bin/browser.c              |   4 +-
 src/bin/thumb.c                | 156 ++++++++++++++++++++++++-----------------
 src/bin/videothumb.c           |  30 +++-----
 src/bin/win.c                  |   4 +-
 9 files changed, 124 insertions(+), 124 deletions(-)

diff --git a/data/themes/default.edc b/data/themes/default.edc
index 8ba5c1c..534b182 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -2147,8 +2147,7 @@ collections {
    group { name: "rage/browser/item";
       images.image: "win_shadow.png" COMP;
       images.image: "win_glow.png" COMP;
-      images.image: "bg_shine.png" COMP;
-      images.image: "bg_glint.png" COMP;
+      images.image: "dimmer.png" COMP;
 
       parts {
          part { name: "shadow"; mouse_events: 0;
@@ -2209,13 +2208,6 @@ collections {
                rel2.offset: -5 -5;
             }
          }
-         part { name: "glintclip"; type: RECT;
-            description { state: "default" 0.0;
-               rel1.to: "clip";
-               rel2.to: "clip";
-               rel1.offset: 0 -10;
-            }
-         }
          part { name: "rage.content"; type: SWALLOW;
             clip_to: "clip";
             description { state: "default" 0.0;
@@ -2223,35 +2215,13 @@ collections {
                rel2.to: "clip";
             }
          }
-         part { name: "shine"; mouse_events: 0;
+         part { name: "dimmer"; mouse_events: 0;
             clip_to: "clip";
             description { state: "default" 0.0;
-               image.normal: "bg_shine.png";
+               image.normal: "dimmer.png";
                fill.smooth: 0;
                rel1.to: "clip";
                rel2.to: "clip";
-               align: 0.5 0.0;
-               aspect: (255/120) (255/120);
-               aspect_preference: HORIZONTAL;
-            }
-         }
-         part { name: "glint"; mouse_events: 0;
-            clip_to: "glintclip";
-            description { state: "default" 0.0;
-               fixed: 1 1;
-               min: 79 5;
-               max: 79 5;
-               rel1 {
-                 relative: 0.0 0.0;
-                 offset: 0 0;
-                 to: "clip";
-               }
-               rel2 {
-                 relative: 1.0 0.0;
-                 offset: -1 0;
-                 to: "clip";
-               }
-               image.normal: "bg_glint.png";
             }
          }
          part { name: "rage.title"; type: TEXT; mouse_events: 0;
@@ -2259,8 +2229,8 @@ collections {
             description { state: "default" 0.0;
                fixed: 1 1;
                align: 0.0 1.0;
-               rel1.offset: 4 4;
-               rel2.offset: -5 -5;
+               rel1.offset: 8 8;
+               rel2.offset: -9 -9;
                color: 255 255 255 255;
                text { font: "Sans"; size: 12;
                   align: 0.0 1.0;
diff --git a/data/themes/images/Makefile.mk b/data/themes/images/Makefile.mk
index f29153e..7205cd3 100644
--- a/data/themes/images/Makefile.mk
+++ b/data/themes/images/Makefile.mk
@@ -3,6 +3,7 @@ data/themes/images/bevel_dark_out.png \
 data/themes/images/bg_bevel.png \
 data/themes/images/bg_glint.png \
 data/themes/images/bg_shine.png \
+data/themes/images/dimmer.png \
 data/themes/images/glow_exclam.png \
 data/themes/images/icon_arrow_right.png \
 data/themes/images/icon_close2.png \
diff --git a/data/themes/images/dimmer.png b/data/themes/images/dimmer.png
new file mode 100644
index 0000000..2f424fd
Binary files /dev/null and b/data/themes/images/dimmer.png differ
diff --git a/src/bin/albumart.c b/src/bin/albumart.c
index 9faf4fa..e04abb2 100644
--- a/src/bin/albumart.c
+++ b/src/bin/albumart.c
@@ -16,6 +16,7 @@ static Ecore_Event_Handler *handle_complete = NULL;
 static Eina_Strbuf *sb_result = NULL;
 static Eina_Bool fetch_image = EINA_FALSE;
 static char *fetchfile = NULL;
+static char *fetchpath = NULL;
 static FILE *fout = NULL;
 static void (*_fetch_done) (void *data) = NULL;
 static void *_fetch_data = NULL;
@@ -112,6 +113,12 @@ _cb_http_complete(void *data EINA_UNUSED, int type 
EINA_UNUSED, void *event)
         fetch_image = EINA_FALSE;
         fclose(fout);
         fout = NULL;
+        if (ecore_file_size(fetchpath) < 0)
+          {
+             ecore_file_unlink(fetchpath);
+          }
+        free(fetchpath);
+        fetchpath = NULL;
         if (_fetch_done) _fetch_done(_fetch_data);
      }
    else
@@ -166,6 +173,8 @@ _cb_http_complete(void *data EINA_UNUSED, int type 
EINA_UNUSED, void *event)
                               {
                                  fetch_image = EINA_TRUE;
                                  fetch = _fetch(sb);
+                                 free(fetchpath);
+                                 fetchpath = strdup(path);
                               }
                             free(path);
                          }
@@ -225,6 +234,7 @@ _search_append(Eina_Strbuf *sb, const char *str, Eina_Bool 
hadword)
 void
 albumart_find(const char *file,
               const char *artist, const char *album, const char *title,
+              const char *extrastr,
               void (*fetch_done) (void *data), void *fetch_data)
 {
    Eina_Strbuf *sb;
@@ -293,6 +303,8 @@ albumart_find(const char *file,
    else
      _search_append(sb, ecore_file_file_get(fetchfile), EINA_FALSE);
 
+   if (extrastr) _search_append(sb, extrastr, EINA_TRUE);
+
    eina_strbuf_append(sb, Q_END);
 
    if (sb_result) eina_strbuf_free(sb_result);
diff --git a/src/bin/albumart.h b/src/bin/albumart.h
index d19bb73..43415ce 100644
--- a/src/bin/albumart.h
+++ b/src/bin/albumart.h
@@ -3,6 +3,7 @@
 
 void albumart_find(const char *file,
                    const char *artist, const char *album, const char *title,
+                   const char *extrastr,
                    void (*fetch_done) (void *data), void *fetch_data);
 char *albumart_file_get(const char *file);
 
diff --git a/src/bin/browser.c b/src/bin/browser.c
index 4652f56..fbd22e3 100644
--- a/src/bin/browser.c
+++ b/src/bin/browser.c
@@ -58,7 +58,7 @@ _item_size_get(Evas_Object *win, Evas_Coord *w, Evas_Coord *h)
 
    elm_coords_finger_size_adjust(1, &sz, 1, &sz);
    evas_object_geometry_get(win, NULL, NULL, w, h);
-   *w = *w / 5;
+   *w = *w / 15;
    *h = *h / 5;
    if (*w < sz) *w = sz;
    if (*h < sz) *h = sz;
@@ -190,7 +190,7 @@ _cb_vidthumb_data(void *data EINA_UNUSED, Evas_Object *obj, 
void *event EINA_UNU
    int w, h;
 
    videothumb_size_get(obj, &w, &h);
-   evas_object_size_hint_aspect_set(obj, EVAS_ASPECT_CONTROL_BOTH, w, h);
+   evas_object_size_hint_aspect_set(obj, EVAS_ASPECT_CONTROL_NEITHER, w, h);
 }
 
 static void
diff --git a/src/bin/thumb.c b/src/bin/thumb.c
index 4c07a64..630380b 100644
--- a/src/bin/thumb.c
+++ b/src/bin/thumb.c
@@ -3,12 +3,16 @@
 #include "sha1.h"
 #include "albumart.h"
 
-static Evas_Object *win = NULL, *subwin = NULL, *image = NULL;
+
+static Evas_Object *win = NULL, *subwin = NULL, *image = NULL, *vid = NULL;
 static Evas_Object *vidimage = NULL;
-static int iw, ih;
-static unsigned char sum[20];
 static Eet_File *ef = NULL;
 static Ecore_Timer *vid_timeout = NULL;
+static Eina_Bool is_audio = EINA_FALSE;
+static Eina_Bool is_movie = EINA_FALSE;
+static int iw, ih, incr = 0;
+static unsigned char sum[20];
+static const char *file = NULL;
 
 static void
 _cb_fetched(void *data EINA_UNUSED)
@@ -26,67 +30,38 @@ _cb_loaded(void *data, Evas_Object *obj, void *info 
EINA_UNUSED)
    artist = emotion_object_meta_info_get(obj, EMOTION_META_INFO_TRACK_ARTIST);
    album = emotion_object_meta_info_get(obj, EMOTION_META_INFO_TRACK_ALBUM);
 
-   albumart_find(file, title, artist, album, _cb_fetched, (void *)file);
-}
-
-static Eina_Bool
-_cb_timeout(void *data EINA_UNUSED)
-{
-   vid_timeout = NULL;
-   elm_exit();
-   return EINA_FALSE;
-}
-
-EAPI_MAIN int
-elm_main(int argc, char **argv)
-{
-   Eina_Bool is_audio = EINA_FALSE;
-
-   if (argc < 3) exit(1);
-   elm_need_efreet();
-
-   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
-   elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
-   elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
-   elm_app_info_set(elm_main, "rage", "themes/default.edj");
-
-   elm_config_preferred_engine_set("buffer");
-   win = elm_win_add(NULL, "Rage", ELM_WIN_BASIC);
-   subwin = elm_win_add(win, "inlined", ELM_WIN_INLINED_IMAGE);
-   image = elm_win_inlined_image_object_get(subwin);
-
-   evas_object_show(subwin);
-   evas_object_show(win);
+   if ((!emotion_object_video_handled_get(obj)) &&
+       (emotion_object_audio_handled_get(obj)))
+     is_audio = EINA_TRUE;
 
-   elm_win_norender_push(subwin);
-   elm_win_norender_push(win);
-
-   const char *extn = strchr(argv[1], '.');
-   if (extn)
+   if (is_audio)
      {
-        if ((!strcasecmp(extn, ".mp3")) ||
-            (!strcasecmp(extn, ".m4a")) ||
-            (!strcasecmp(extn, ".oga")) ||
-            (!strcasecmp(extn, ".aac")) ||
-            (!strcasecmp(extn, ".flac")) ||
-            (!strcasecmp(extn, ".wav")))
-          {
-             is_audio = EINA_TRUE;
-          }
+        albumart_find(file, title, artist, album, NULL,
+                      _cb_fetched, (void *)file);
+        return;
      }
-   if (is_audio)
+   else
      {
-        Evas_Object *vid;
+        double len = emotion_object_play_length_get(obj);
+        double ratio = emotion_object_ratio_get(obj);
+        int iw, ih;
+
+        emotion_object_size_get(obj, &iw, &ih);
+        if (ratio > 0.0) iw = (ih * ratio);
+        else ratio = iw / ih;
+        printf("ratio: %1.3f len: %1.1f\n", ratio, len);
+        if ((ratio >= (4.0 / 3.0)) &&
+            (ratio <= (3.0 / 1.0)) &&
+            (len >= (75.0 * 60.0)) &&
+            (len <= (5.0 * 60.0 * 60.0)))
+          is_movie = EINA_TRUE;
+     }
 
-        vid = emotion_object_add(evas_object_evas_get(win));
-        if (emotion_object_init(vid, NULL))
-          {
-             evas_object_smart_callback_add(vid, "open_done",
-                                            _cb_loaded, argv[1]);
-             emotion_object_file_set(vid, argv[1]);
-             vid_timeout = ecore_timer_add(2.0, _cb_timeout, NULL);
-             elm_run();
-          }
+   if (is_movie)
+     {
+        albumart_find(file, NULL, NULL, NULL, "film poster",
+                      _cb_fetched, (void *)file);
+        return;
      }
    else
      {
@@ -97,9 +72,9 @@ elm_main(int argc, char **argv)
         vidimage = evas_object_image_filled_add(evas_object_evas_get(subwin));
         evas_object_show(vidimage);
 
-        evas_object_image_file_set(vidimage, argv[1], NULL);
+        evas_object_image_file_set(vidimage, file, NULL);
         evas_object_image_size_get(vidimage, &iw, &ih);
-        if (!sha1((unsigned char *)argv[1], strlen(argv[1]), sum)) exit(2);
+        if (!sha1((unsigned char *)file, strlen(file), sum)) exit(2);
         if (!efreet_cache_home_get()) exit(3);
         snprintf(buf_base, sizeof(buf_base), "%s/rage/thumb/%02x",
                  efreet_cache_home_get(), sum[0]);
@@ -116,7 +91,6 @@ elm_main(int argc, char **argv)
         ef = eet_open(buf_file, EET_FILE_MODE_WRITE);
         if (!ef) exit(5);
         pos = 0;
-        incr = atoi(argv[2]);
         for (pos = 0; ; pos += incr)
           {
              int w, h;
@@ -124,7 +98,7 @@ elm_main(int argc, char **argv)
              char key[128];
 
              snprintf(key, sizeof(key), "%i", pos);
-             evas_object_image_file_set(vidimage, argv[1], key);
+             evas_object_image_file_set(vidimage, file, key);
              evas_object_image_size_get(vidimage, &iw, &ih);
              if ((iw <= 0) || (ih <= 0)) break;
              w = 160;
@@ -143,6 +117,62 @@ elm_main(int argc, char **argv)
           }
         eet_close(ef);
      }
+}
+
+static Eina_Bool
+_cb_timeout(void *data EINA_UNUSED)
+{
+   vid_timeout = NULL;
+   elm_exit();
+   return EINA_FALSE;
+}
+
+EAPI_MAIN int
+elm_main(int argc, char **argv)
+{
+   if (argc < 3) exit(1);
+   elm_need_efreet();
+
+   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+   elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
+   elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
+   elm_app_info_set(elm_main, "rage", "themes/default.edj");
+
+   elm_config_preferred_engine_set("buffer");
+   win = elm_win_add(NULL, "Rage", ELM_WIN_BASIC);
+   subwin = elm_win_add(win, "inlined", ELM_WIN_INLINED_IMAGE);
+   image = elm_win_inlined_image_object_get(subwin);
+
+   evas_object_show(subwin);
+   evas_object_show(win);
+
+   elm_win_norender_push(subwin);
+   elm_win_norender_push(win);
+
+   vid = emotion_object_add(evas_object_evas_get(win));
+   file = argv[1];
+   incr = atoi(argv[2]);
+
+   const char *extn = strchr(file, '.');
+   if (extn)
+     {
+        if ((!strcasecmp(extn, ".mp3")) ||
+            (!strcasecmp(extn, ".m4a")) ||
+            (!strcasecmp(extn, ".oga")) ||
+            (!strcasecmp(extn, ".aac")) ||
+            (!strcasecmp(extn, ".flac")) ||
+            (!strcasecmp(extn, ".wav")))
+          {
+             is_audio = EINA_TRUE;
+          }
+     }
+   if (emotion_object_init(vid, NULL))
+     {
+        evas_object_smart_callback_add(vid, "open_done", _cb_loaded, file);
+        emotion_object_file_set(vid, file);
+        vid_timeout = ecore_timer_add(2.0, _cb_timeout, NULL);
+        elm_run();
+     }
    elm_shutdown();
    return 0;
 }
diff --git a/src/bin/videothumb.c b/src/bin/videothumb.c
index 222fde6..cc430c8 100644
--- a/src/bin/videothumb.c
+++ b/src/bin/videothumb.c
@@ -234,36 +234,22 @@ _videothumb_image_load(Evas_Object *obj)
    char buf_base[PATH_MAX];
    char buf_file[PATH_MAX];
    char buf[PATH_MAX];
+   char *artfile;
    unsigned char sum[20];
-   Eina_Bool is_audio = EINA_FALSE;
+   Eina_Bool found = EINA_FALSE;
 
    if (!sd) return;
    if (!sd->file) return;
    sd->o_img2 = evas_object_image_filled_add(evas_object_evas_get(obj));
    evas_object_smart_member_add(sd->o_img2, obj);
-   const char *extn = strchr(sd->realpath, '.');
-   if (extn)
+   artfile = albumart_file_get(sd->realpath);
+   if (artfile)
      {
-        if ((!strcasecmp(extn, ".mp3")) ||
-            (!strcasecmp(extn, ".m4a")) ||
-            (!strcasecmp(extn, ".oga")) ||
-            (!strcasecmp(extn, ".aac")) ||
-            (!strcasecmp(extn, ".flac")) ||
-            (!strcasecmp(extn, ".wav")))
-          {
-             is_audio = EINA_TRUE;
-          }
+        sd->realfile = eina_stringshare_add(artfile);
+        free(artfile);
+        found = EINA_TRUE;
      }
-   if (is_audio)
-     {
-        char *artfile = albumart_file_get(sd->realpath);
-        if (artfile)
-          {
-             sd->realfile = eina_stringshare_add(artfile);
-             free(artfile);
-          }
-     }
-   else
+   if (!found)
      {
         if (!sha1((unsigned char *)sd->realpath, strlen(sd->realpath), sum))
           return;
diff --git a/src/bin/win.c b/src/bin/win.c
index 69151ca..fe34ecb 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -136,9 +136,9 @@ _cb_albumart_delay(void *data)
         const char *artist = video_meta_artist_get(inf->vid);
         const char *album = video_meta_album_get(inf->vid);
 
-        albumart_find(file, title, artist, album, _cb_fetched, win);
+        albumart_find(file, title, artist, album, NULL, _cb_fetched, win);
      }
-   else albumart_find(NULL, NULL, NULL, NULL, NULL, NULL);
+   else albumart_find(NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    return EINA_FALSE;
 }
 

-- 


Reply via email to