You should not be using that dummy function. What a shame :-/

On Tuesday, August 28, 2012, Enlightenment SVN wrote:

> Log:
> ev now uses eio for startup file stats to reduce startup time,
> unfortunately this has the side effect of showcasing some weird genlist
> insert behavior: the jiggles
>
>
> Author:       discomfitor
> Date:         2012-08-28 02:57:45 -0700 (Tue, 28 Aug 2012)
> New Revision: 75772
> Trac:         http://trac.enlightenment.org/e/changeset/75772
>
> Modified:
>   trunk/PROTO/ev/Makefile trunk/PROTO/ev/ev.c
>
> Modified: trunk/PROTO/ev/Makefile
> ===================================================================
> --- trunk/PROTO/ev/Makefile     2012-08-28 09:53:35 UTC (rev 75771)
> +++ trunk/PROTO/ev/Makefile     2012-08-28 09:57:45 UTC (rev 75772)
> @@ -4,10 +4,10 @@
>  CC     ?= gcc
>  CFLAGS ?= -O0 -pipe -Wall -Wextra -g
>  SHELL   = /bin/sh
> -LIBS    = $(shell pkg-config --cflags --libs elementary)
> +LIBS    = $(shell pkg-config --cflags --libs elementary eio)
>
>  ev: ev.c
> -       $(CC) $(CFLAGS) $(LIBS) -o $@ $<
> +       $(CC) -o $@ $< $(CFLAGS) $(LIBS)
>
>  install: ev
>         mkdir -p $(DESTDIR)$(PREFIX)/bin
>
> Modified: trunk/PROTO/ev/ev.c
> ===================================================================
> --- trunk/PROTO/ev/ev.c 2012-08-28 09:53:35 UTC (rev 75771)
> +++ trunk/PROTO/ev/ev.c 2012-08-28 09:57:45 UTC (rev 75772)
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright 2011 Mike Blumenkrantz 
> <[email protected]<javascript:;>
> >
> + * Copyright 2011-2012 Mike Blumenkrantz 
> <[email protected]<javascript:;>
> >
>   *
>   * This program is free software: you can redistribute it and/or modify
>   * it under the terms of the GNU Lesser General Public License as
> published
> @@ -15,9 +15,8 @@
>   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include <Eio.h>
>  #include <Elementary.h>
> -#include <sys/stat.h>
> -#include <sys/types.h>
>
>  #ifndef __UNUSED__
>  # define __UNUSED__ __attribute__((unused))
> @@ -33,7 +32,13 @@
>  static Elm_Genlist_Item_Class itc;
>  static Evas_Object *img, *list = NULL;
>
> +static void stat_done(void *data, Eio_File *handler, const Eina_Stat *st);
> +
>  static void
> +dummy()
> +{}
> +
> +static void
>  _close(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void
> *event_info __UNUSED__)
>  {
>     ecore_main_loop_quit();
> @@ -60,8 +65,7 @@
>
>     evas_object_geometry_get(img, NULL, NULL, &ww, &wh);
>     elm_image_file_get(img, &f, NULL);
> -   s = strrchr(f, '/');
> -   s = s ? s + 1 : f;
> +   s = ecore_file_file_get(f);
>     snprintf(buf, sizeof(buf), "%s (%ux%u)", s, ww, wh);
>     elm_win_title_set(win, buf);
>  }
> @@ -141,44 +145,77 @@
>       evas_object_show(data);
>  }
>
> -static void
> -add_single(Evas_Object *list, const char *file)
> +static int
> +add_sort(void *a, void *b)
>  {
> -   elm_genlist_item_append(list, &itc, file, NULL, ELM_GENLIST_ITEM_NONE,
> NULL, NULL /*data*/);
> +   const char *x, *y;
> +
> +   x = elm_object_item_data_get(a);
> +   x = ecore_file_file_get(x);
> +   y = elm_object_item_data_get(b);
> +   y = ecore_file_file_get(y);
> +   return strcmp(x, y);
>  }
>
>  static void
> -add_dir(Evas_Object *list, const char *dir)
> +add_single(const char *file)
>  {
> -   Eina_Iterator *it;
> -   const char *str;
> +   static Eina_Bool first = EINA_TRUE;
>
> -   it = eina_file_ls(dir);
> -   if (!it) return;
> -   EINA_ITERATOR_FOREACH(it, str)
> -     add_single(list, str);
> -   eina_iterator_free(it);
> +   DBG("NEW: %s", file);
> +   elm_genlist_item_sorted_insert(list, &itc, file, NULL,
> ELM_GENLIST_ITEM_NONE, (Eina_Compare_Cb)add_sort, NULL, NULL /*data*/);
> +   elm_genlist_item_selected_set(elm_genlist_first_item_get(list),
> EINA_TRUE);
> +   if (first)
> +     {
> +        _pick(NULL, NULL, elm_genlist_selected_item_get(list));
> +        first = EINA_FALSE;
> +     }
>  }
>
>  static void
> -load_stuff(int argc, char **argv, Evas_Object *list)
> +ls_done(void *data __UNUSED__, Eio_File *handler __UNUSED__, const char
> *file)
>  {
> +   eio_file_direct_stat(file, stat_done, dummy,
> eina_stringshare_add(file));
> +}
> +
> +static Eina_Bool
> +ls_filter(void *data __UNUSED__, Eio_File *handler __UNUSED__, const char
> *file)
> +{
>     struct stat st;
> -   int x;
> +   if (stat(file, &st)) return EINA_FALSE;
> +   return S_ISREG(st.st_mode);
> +}
>
> -   for (x = 1; x < argc; x++)
> +static void
> +add_dir(const char *dir)
> +{
> +   eio_file_ls(dir, ls_filter, ls_done, dummy, dummy, NULL);
> +}
> +
> +static void
> +stat_done(void *data, Eio_File *handler __UNUSED__, const Eina_Stat *st)
> +{
> +   if (S_ISREG(st->mode))
>       {
> -        stat(argv[x], &st);
> -        if (S_ISREG(st.st_mode))
> -          add_single(list, eina_stringshare_add(argv[x]));
> -        else if (S_ISDIR(st.st_mode))
> -          add_dir(list, argv[x]);
> -        else
> -          ERR("wtf is this %s", argv[x]);
> +        add_single(data);
> +        return;
>       }
> -   elm_genlist_item_selected_set(elm_genlist_first_item_get(list),
> EINA_TRUE);
> +   if (S_ISDIR(st->mode))
> +     add_dir(data);
> +   else
> +     ERR("wtf is this %s", (char*)data);
> +   eina_stringshare_del(data);
>  }
>
> +static void
> +load_stuff(int argc, char **argv)
> +{
> +   int x;
> +
> +   for (x = 1; x < argc; x++)
> +     eio_file_direct_stat(argv[x], stat_done, dummy,
> eina_stringshare_add(argv[x]));
> +}
> +
>  int
>  main(int argc, char *argv[])
>  {
> @@ -253,10 +290,8 @@
>     evas_object_smart_callback_add(img, "clicked", (Evas_Smart_Cb)_show,
> listwin);
>     evas_object_smart_callback_add(win, "delete,request", _close, NULL);
>
> -   load_stuff(argc, argv, list);
> +   load_stuff(argc, argv);
>
> -   _pick(NULL, NULL, elm_genlist_selected_item_get(list));
> -
>     evas_object_resize(listwin, 450, 350);
>
>     elm_run();
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> enlightenment-svn mailing list
> [email protected] <javascript:;>
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to