|
From: <do...@us...> - 2009-01-28 18:46:18
|
Revision: 543
http://enna.svn.sourceforge.net/enna/?rev=543&view=rev
Author: doursse
Date: 2009-01-28 18:46:15 +0000 (Wed, 28 Jan 2009)
Log Message:
-----------
add notification: when you add an image file to the directory,
that file is automatically added to the wall
Modified Paths:
--------------
trunk/wall-e/src/bin/wall-e.h
trunk/wall-e/src/bin/walle.c
Modified: trunk/wall-e/src/bin/wall-e.h
===================================================================
--- trunk/wall-e/src/bin/wall-e.h 2009-01-28 18:27:07 UTC (rev 542)
+++ trunk/wall-e/src/bin/wall-e.h 2009-01-28 18:46:15 UTC (rev 543)
@@ -18,6 +18,7 @@
Evas_Object *o_scroll;
Evas_Object *o_toolbar;
Eina_List *pictures;
+ Ecore_File_Monitor *monitor;
};
Walle *walle_init(int argc, char **argv);
Modified: trunk/wall-e/src/bin/walle.c
===================================================================
--- trunk/wall-e/src/bin/walle.c 2009-01-28 18:27:07 UTC (rev 542)
+++ trunk/wall-e/src/bin/walle.c 2009-01-28 18:46:15 UTC (rev 543)
@@ -60,7 +60,6 @@
/* callback when a picture is resized */
evas_object_geometry_get(o_pict, NULL, NULL, &width, &height);
evas_object_image_fill_set(o_pict, 0, 0, width, height);
-
}
static void _walle_wall_populate(Walle *walle, const char *directory, const char *theme)
@@ -80,7 +79,6 @@
file = ecore_list_first_goto(files);
while ((file = (char *)ecore_list_next(files)) != NULL)
{
-
sprintf(filename, "%s/%s", directory, file);
o = evas_object_image_add(walle->evas);
evas_object_image_file_set(o, filename, NULL);
@@ -103,11 +101,50 @@
default:
evas_object_del(o);
break;
+ }
+ }
+ ecore_list_destroy(files);
+}
+static void
+_walle_monitor_cb(void *data,
+ Ecore_File_Monitor *em,
+ Ecore_File_Event event,
+ const char *path)
+{
+ Walle *walle;
+
+ walle = (Walle *)data;
+
+ if (event == ECORE_FILE_EVENT_CREATED_FILE)
+ {
+ Evas_Object *o;
+ Evas_Coord ow, oh, w, h;
+
+ o = evas_object_image_add(walle->evas);
+ evas_object_image_file_set(o, path, NULL);
+ switch(evas_object_image_load_error_get(o))
+ {
+ case EVAS_LOAD_ERROR_NONE:
+ {
+ evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _walle_picture_cb_resize, o);
+ evas_object_image_size_get(o, &w, &h);
+ oh = 200;
+ ow = oh * (float)w/(float)h;
+ evas_object_image_load_size_set(o, ow, oh);
+ evas_object_image_fill_set(o, 0, 0, ow, oh);
+ evas_object_resize(o, ow, oh);
+ evas_object_size_hint_min_set(o, ow, oh);
+ walle_wall_append(walle->o_wall, o);
+ walle->pictures = eina_list_append(walle->pictures, o);
}
+ break;
+ default:
+ evas_object_del(o);
+ break;
+ }
}
- ecore_list_destroy(files);
}
@@ -230,6 +267,7 @@
free(walle->config.engine);
free(walle->config.path);
free(walle->config.theme);
+ ecore_file_monitor_del(walle->monitor);
free(walle);
}
@@ -238,10 +276,20 @@
{
Evas_Object *o;
+ /* monitoring */
+ walle->monitor = ecore_file_monitor_add(walle->config.path,
+ _walle_monitor_cb,
+ walle);
+ if (!walle->monitor)
+ return 0;
+
/* main window */
o = elm_win_add(NULL, "Wall-E", ELM_WIN_BASIC);
if (!o)
+ {
+ ecore_file_monitor_del(walle->monitor);
return 0;
+ }
elm_win_title_set(o, "Wall-E");
evas_object_smart_callback_add(o, "delete-request", _walle_win_del_cb, NULL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|