usee eina_str_sufix() instead ?

Vincent

On Thu, 11 Aug 2011, Enlightenment SVN wrote:

> Log:
> ... allow non edj files as wallpapers... if u try. :)
>
>
>
> Author:       raster
> Date:         2011-08-11 03:39:37 -0700 (Thu, 11 Aug 2011)
> New Revision: 62340
> Trac:         http://trac.enlightenment.org/e/changeset/62340
>
> Modified:
>  trunk/e/src/bin/e_bg.c trunk/e/src/bin/e_icon.c 
> trunk/e/src/bin/e_widget_preview.c 
> trunk/e/src/modules/conf_theme/e_int_config_wallpaper.c
>
> Modified: trunk/e/src/bin/e_bg.c
> ===================================================================
> --- trunk/e/src/bin/e_bg.c    2011-08-11 10:30:35 UTC (rev 62339)
> +++ trunk/e/src/bin/e_bg.c    2011-08-11 10:39:37 UTC (rev 62340)
> @@ -118,7 +118,8 @@
>       EINA_LIST_FOREACH(e_config->desktop_backgrounds, l, cfbg)
>         {
>            int spec;
> -
> +             const char *ext;
> +
>            if (!cfbg) continue;
>            spec = 0;
>            if (cfbg->container == container_num) spec++;
> @@ -142,19 +143,28 @@
>                      if (bf) bgfile = bf;
>                   }
>              }
> -          entries = edje_file_collection_list(bgfile);
> -          if (entries)
> -            {
> -               EINA_LIST_FOREACH(entries, ll, entry)
> -                 {
> -                    if (!strcmp(entry, "e/desktop/background"))
> -                      {
> -                         bg = cfbg;
> -                         current_spec = spec;
> -                      }
> -                 }
> -               edje_file_collection_list_free(entries);
> -            }
> +             ext = strrchr(bgfile, '.');
> +             if ((ext) && (!strcasecmp(ext, ".edj")))
> +               {
> +                  entries = edje_file_collection_list(bgfile);
> +                  if (entries)
> +                    {
> +                       EINA_LIST_FOREACH(entries, ll, entry)
> +                         {
> +                            if (!strcmp(entry, "e/desktop/background"))
> +                              {
> +                                 bg = cfbg;
> +                                 current_spec = spec;
> +                              }
> +                         }
> +                       edje_file_collection_list_free(entries);
> +                    }
> +               }
> +             else
> +               {
> +                  bg = cfbg;
> +                  current_spec = spec;
> +               }
>         }
>      }
>    return bg;
> @@ -188,6 +198,8 @@
>      }
>    else
>      {
> +        const char *ext;
> +
>       bgfile = e_config->desktop_default_background;
>       if (bgfile)
>         {
> @@ -199,19 +211,24 @@
>                 if (bf) bgfile = bf;
>              }
>         }
> -     entries = edje_file_collection_list(bgfile);
> -     if (entries)
> -       {
> -          EINA_LIST_FOREACH(entries, l, entry)
> -            {
> -               if (!strcmp(entry, "e/desktop/background"))
> -                 {
> -                    ok = 1;
> -                    break;
> -                 }
> -            }
> -          edje_file_collection_list_free(entries);
> -       }
> +        ext = strrchr(bgfile, '.');
> +        if ((ext) && (!strcasecmp(ext, ".edj")))
> +          {
> +             entries = edje_file_collection_list(bgfile);
> +             if (entries)
> +               {
> +                  EINA_LIST_FOREACH(entries, l, entry)
> +                    {
> +                       if (!strcmp(entry, "e/desktop/background"))
> +                         {
> +                            ok = 1;
> +                            break;
> +                         }
> +                    }
> +                  edje_file_collection_list_free(entries);
> +               }
> +          }
> +        else ok = 1;
>       if (!ok)
>         bgfile = e_theme_edje_file_get("base/theme/background",
>                                        "e/desktop/background");
> @@ -226,6 +243,7 @@
>    Evas_Object *o;
>    const char *bgfile = "";
>    const char *trans = "";
> +   const char *ext;
>    E_Desk *desk;
>
>    if (transition == E_BG_TRANSITION_START) trans = 
> e_config->transition_start;
> @@ -283,10 +301,21 @@
>       evas_object_clip_set(o, zone->bg_clip_object);
>       evas_object_show(o);
>      }
> -   o = edje_object_add(zone->container->bg_evas);
> +   ext = strrchr(bgfile, '.');
> +   if ((ext) && (!strcasecmp(ext, ".edj")))
> +     {
> +        o = edje_object_add(zone->container->bg_evas);
> +        evas_object_data_set(o, "e_zone", zone);
> +        edje_object_file_set(o, bgfile, "e/desktop/background");
> +     }
> +   else
> +     {
> +        o = e_icon_add(zone->container->bg_evas);
> +        evas_object_data_set(o, "e_zone", zone);
> +        e_icon_file_key_set(o, bgfile, NULL);
> +        e_icon_fill_inside_set(o, 0);
> +     }
>    zone->bg_object = o;
> -   evas_object_data_set(o, "e_zone", zone);
> -   edje_object_file_set(o, bgfile, "e/desktop/background");
>    if (transition == E_BG_TRANSITION_NONE)
>      {
>       evas_object_move(o, zone->x, zone->y);
>
> Modified: trunk/e/src/bin/e_icon.c
> ===================================================================
> --- trunk/e/src/bin/e_icon.c  2011-08-11 10:30:35 UTC (rev 62339)
> +++ trunk/e/src/bin/e_icon.c  2011-08-11 10:39:37 UTC (rev 62340)
> @@ -7,7 +7,9 @@
>    Evas_Coord x, y, w, h;
>    Evas_Object *obj;
>    Evas_Object *eventarea;
> +   Ecore_Timer *timer;
>    int size;
> +   int frame, frame_count;
>    const char *fdo;
>    unsigned char fill_inside : 1;
>    unsigned char scale_up : 1;
> @@ -61,6 +63,47 @@
>      }
> }
>
> +static Eina_Bool
> +_frame_anim(void *data)
> +{
> +   E_Smart_Data *sd = data;
> +   double t;
> +   int fr;
> +
> +   sd->frame++;
> +   fr = (sd->frame % (sd->frame_count)) + 1;
> +   evas_object_image_animated_frame_set(sd->obj, fr);
> +   t = evas_object_image_animated_frame_duration_get(sd->obj, fr, 0);
> +   sd->timer = ecore_timer_add(t, _frame_anim, sd);
> +   return EINA_FALSE;
> +}
> +
> +static int
> +_handle_anim(E_Smart_Data *sd)
> +{
> +   double t;
> +
> +   if (sd->timer) ecore_timer_del(sd->timer);
> +   sd->timer = NULL;
> +   sd->frame = 0;
> +   sd->frame_count = 0;
> +   if (!evas_object_image_animated_get(sd->obj)) return 0;
> +   // FIXME: hack around jiyouns BUG!!!!!!!!
> +     {
> +        const char *file;
> +        char buf[256];
> +        snprintf(buf, sizeof(buf), "%ld", (long)sd);
> +        evas_object_image_file_get(sd->obj, &file, NULL);
> +        evas_object_image_file_set(sd->obj, file, buf);
> +     }
> +   sd->frame_count = evas_object_image_animated_frame_count_get(sd->obj);
> +   if (sd->frame_count < 2) return 0;
> +   evas_object_show(sd->obj);
> +   t = evas_object_image_animated_frame_duration_get(sd->obj, sd->frame, 0);
> +   sd->timer = ecore_timer_add(t, _frame_anim, sd);
> +   return 1;
> +}
> +
> EAPI Eina_Bool
> e_icon_file_set(Evas_Object *obj, const char *file)
> {
> @@ -85,19 +128,27 @@
>         sd->fdo = NULL;
>      }
>
> +   if (sd->timer) ecore_timer_del(sd->timer);
> +   sd->timer = NULL;
> +   sd->frame = 0;
> +   sd->frame_count = 0;
> +
>    if (sd->size != 0)
>      evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
>    if (sd->preload) evas_object_hide(sd->obj);
>    evas_object_image_file_set(sd->obj, file, NULL);
>    if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
>      return EINA_FALSE;
> -   if (sd->preload)
> +   if (!_handle_anim(sd))
>      {
> -        sd->loading = 1;
> -        evas_object_image_preload(sd->obj, EINA_FALSE);
> +        if (sd->preload)
> +          {
> +             sd->loading = 1;
> +             evas_object_image_preload(sd->obj, EINA_FALSE);
> +          }
> +        else if (evas_object_visible_get(obj))
> +           evas_object_show(sd->obj);
>      }
> -   else if (evas_object_visible_get(obj))
> -     evas_object_show(sd->obj);
>
>    _e_icon_smart_reconfigure(sd);
>    return EINA_TRUE;
> @@ -118,6 +169,12 @@
>         eina_stringshare_del(sd->fdo);
>         sd->fdo = NULL;
>      }
> +
> +   if (sd->timer) ecore_timer_del(sd->timer);
> +   sd->timer = NULL;
> +   sd->frame = 0;
> +   sd->frame_count = 0;
> +
>    _e_icon_obj_prepare(obj, sd);
>    if (sd->size != 0)
>      evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
> @@ -125,13 +182,16 @@
>    evas_object_image_file_set(sd->obj, file, key);
>    if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
>      return EINA_FALSE;
> -   if (sd->preload)
> +   if (!_handle_anim(sd))
>      {
> -        sd->loading = 1;
> -        evas_object_image_preload(sd->obj, 0);
> +        if (sd->preload)
> +          {
> +             sd->loading = 1;
> +             evas_object_image_preload(sd->obj, 0);
> +          }
> +        else if (evas_object_visible_get(obj))
> +           evas_object_show(sd->obj);
>      }
> -   else if (evas_object_visible_get(obj))
> -     evas_object_show(sd->obj);
>    _e_icon_smart_reconfigure(sd);
>    return EINA_TRUE;
> }
> @@ -152,6 +212,12 @@
>         eina_stringshare_del(sd->fdo);
>         sd->fdo = NULL;
>      }
> +
> +   if (sd->timer) ecore_timer_del(sd->timer);
> +   sd->timer = NULL;
> +   sd->frame = 0;
> +   sd->frame_count = 0;
> +
>    sd->obj = edje_object_add(evas_object_evas_get(obj));
>    edje_object_file_set(sd->obj, file, part);
>    if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
> @@ -175,6 +241,11 @@
>    if (!(sd = evas_object_smart_data_get(obj)))
>      return EINA_FALSE;
>
> +   if (sd->timer) ecore_timer_del(sd->timer);
> +   sd->timer = NULL;
> +   sd->frame = 0;
> +   sd->frame_count = 0;
> +
>    eina_stringshare_replace(&sd->fdo, icon);
>    if (!sd->fdo) return EINA_FALSE;
>
> @@ -212,6 +283,11 @@
>
>    if (!(sd = evas_object_smart_data_get(obj))) return;
>
> +   if (sd->timer) ecore_timer_del(sd->timer);
> +   sd->timer = NULL;
> +   sd->frame = 0;
> +   sd->frame_count = 0;
> +
>    /* smart code here */
>    if (sd->obj) evas_object_del(sd->obj);
>    sd->loading = 0;
> @@ -539,6 +615,7 @@
>    evas_object_del(sd->obj);
>    evas_object_del(sd->eventarea);
>    if (sd->fdo) eina_stringshare_del(sd->fdo);
> +   if (sd->timer) ecore_timer_del(sd->timer);
>    free(sd);
> }
>
>
> Modified: trunk/e/src/bin/e_widget_preview.c
> ===================================================================
> --- trunk/e/src/bin/e_widget_preview.c        2011-08-11 10:30:35 UTC (rev 
> 62339)
> +++ trunk/e/src/bin/e_widget_preview.c        2011-08-11 10:39:37 UTC (rev 
> 62340)
> @@ -78,6 +78,7 @@
>    if (wd->o_thumb) evas_object_del(wd->o_thumb);
>
>    wd->o_thumb = e_icon_add(e_livethumb_evas_get(wd->img));
> +   e_icon_fill_inside_set(wd->o_thumb, 0);
>    e_icon_file_key_set(wd->o_thumb, file, key);
>    evas_object_show(wd->o_thumb);
>    e_livethumb_thumb_set(wd->img, wd->o_thumb);
>
> Modified: trunk/e/src/modules/conf_theme/e_int_config_wallpaper.c
> ===================================================================
> --- trunk/e/src/modules/conf_theme/e_int_config_wallpaper.c   2011-08-11 
> 10:30:35 UTC (rev 62339)
> +++ trunk/e/src/modules/conf_theme/e_int_config_wallpaper.c   2011-08-11 
> 10:39:37 UTC (rev 62340)
> @@ -108,6 +108,32 @@
>    return cfd;
> }
>
> +static void
> +_bg_set(E_Config_Dialog_Data *cfdata)
> +{
> +   if (!cfdata->o_preview) return;
> +   if (cfdata->bg)
> +     {
> +        const char *ext = strrchr(cfdata->bg, '.');
> +
> +        if ((ext) && (!strcasecmp(ext, ".edj")))
> +           e_widget_preview_edje_set(cfdata->o_preview, cfdata->bg,
> +                                     "e/desktop/background");
> +        else
> +           e_widget_preview_file_set(cfdata->o_preview, cfdata->bg,
> +                                     NULL);
> +     }
> +   else
> +     {
> +        const char *f;
> +
> +        f = e_theme_edje_file_get("base/theme/backgrounds",
> +                                  "e/desktop/background");
> +        e_widget_preview_edje_set(cfdata->o_preview, f,
> +                                  "e/desktop/background");
> +     }
> +}
> +
> void
> e_int_config_wallpaper_update(E_Config_Dialog *dia, char *file)
> {
> @@ -124,9 +150,7 @@
>    if (cfdata->o_theme_bg)
>      e_widget_check_checked_set(cfdata->o_theme_bg, cfdata->use_theme_bg);
>    if (cfdata->o_fm) e_widget_flist_path_set(cfdata->o_fm, path, "/");
> -   if (cfdata->o_preview)
> -     e_widget_preview_edje_set(cfdata->o_preview, cfdata->bg,
> -                               "e/desktop/background");
> +   _bg_set(cfdata);
>    if (cfdata->o_fm) e_widget_change(cfdata->o_fm);
> }
>
> @@ -195,8 +219,7 @@
>    E_FREE(cfdata->bg);
>
>    cfdata->bg = strdup(buf);
> -   if (cfdata->o_preview)
> -     e_widget_preview_edje_set(cfdata->o_preview, buf, 
> "e/desktop/background");
> +   _bg_set(cfdata);
>    if (cfdata->o_theme_bg)
>      e_widget_check_checked_set(cfdata->o_theme_bg, 0);
>    cfdata->use_theme_bg = 0;
> @@ -281,20 +304,13 @@
>                                   "e/desktop/background");
>       E_FREE(cfdata->bg);
>       cfdata->bg = strdup(f);
> -     if (cfdata->o_preview)
> -       e_widget_preview_edje_set(cfdata->o_preview, f,
> -                                    "e/desktop/background");
> +        _bg_set(cfdata);
>      }
>    else
>      {
>       evas_object_smart_callback_call(cfdata->o_fm, "selection_change",
>                                         cfdata);
> -     if (cfdata->bg)
> -       {
> -          if (cfdata->o_preview)
> -            e_widget_preview_edje_set(cfdata->o_preview, cfdata->bg,
> -                                         "e/desktop/background");
> -       }
> +        _bg_set(cfdata);
>      }
> }
>
> @@ -434,7 +450,6 @@
>    E_Radio_Group *rg;
>    char path[PATH_MAX];
>    int mw, mh, online;
> -   const char *f;
>
>    online = ecore_file_download_protocol_available("http://";);
>
> @@ -506,11 +521,7 @@
>    oa = e_widget_aspect_add(evas, mw, mh);
>    ow = e_widget_preview_add(evas, mw, mh);
>    cfdata->o_preview = ow;
> -   if (cfdata->bg)
> -     f = cfdata->bg;
> -   else
> -     f = e_theme_edje_file_get("base/theme/backgrounds", 
> "e/desktop/background");
> -   e_widget_preview_edje_set(ow, f, "e/desktop/background");
> +   _bg_set(cfdata);
>    e_widget_aspect_child_set(oa, ow);
>    evas_object_show(ow);
>    evas_object_show(oa);
> @@ -564,7 +575,6 @@
>    E_Radio_Group *rg;
>    char path[PATH_MAX];
>    int mw, mh, online;
> -   const char *f;
>
>    online = ecore_file_download_protocol_available("http://";);
>
> @@ -634,11 +644,7 @@
>    oa = e_widget_aspect_add(evas, mw, mh);
>    ow = e_widget_preview_add(evas, mw, mh);
>    cfdata->o_preview = ow;
> -   if (cfdata->bg)
> -     f = cfdata->bg;
> -   else
> -     f = e_theme_edje_file_get("base/theme/backgrounds", 
> "e/desktop/background");
> -   e_widget_preview_edje_set(ow, f, "e/desktop/background");
> +   _bg_set(cfdata);
>    e_widget_aspect_child_set(oa, ow);
>    e_widget_table_object_append(ot, oa, 0, 2, 2 + online, 1, 1, 1, 1, 1);
>
>
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it.
> http://p.sf.net/sfu/wandisco-dev2dev
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>
>

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to