Patch 1 and 2 were committed and 3rd patch was committed with a small
change. Png files are not being opened with elm_photocam as in
original patch. Because of this change it was not easy to apply patch
5.
I am sending a new patch for that. And patch number 4 was not applied yet.
2010/9/29 Nicolas Aguirre <[email protected]>:
> 2010/9/29 Otávio Pontes <[email protected]>:
>> Hello,
>> I have done some changes to ephoto to add some nice features and to
>> fix some bugs. The major features i implemented was adding new
>> shortcuts to ephoto and making it possible to see and enter in
>> directories in thumb_browser. When I was implementing that I have
>> found and fixed some bugs. I am sending the patches i have done.
>>
>> First patch fixes one warning about integer comparison. The second
>> patch fixes on bug related to an invalid memory access that was
>> causing segmentation fault in my computer (valgrind was complaining
>> about it too). The third patch Fixes a bug in checking for success
>> when showing images in flow browser and changes the way it display an
>> image in thumb_browser.
>> The forth patch adds new keyboard shortcuts to slideshow, flow_browser
>> and thumb_browser. Also adds zoom to flowbrowser and fullscreen mode
>> to slideshow.
>> And the fifty patch makes it possible to see and enter in directories
>> in thumb browser.
>>
>> Otávio Pontes
>>
> 1st and 2nd patch are in svn.
>
> For the 3rd, I disagree. Actually only jpeg images are handled by elm
> photocam object. Following the photocam documentation it seems that
> only jpeg is supported. But if you try to load a png it woks with
> strange results at least for me. I guess it's why okra have 2 objects
> image1 and image2. image1 is for jpg and photocam, and image2 is for
> png. I agree to add an elm_image instead of elm_background but for
> both object the image is only shown after you resized the window. So
> the bug is still open for me, and this patch is not a solution. If you
> have better idea ...
>
>
> --
> Nicolas Aguirre
> Mail: [email protected]
> Web: http://www.digital-corner.org
>
From d9e939afb10a23f5b9dc2bb2fdbc257ef86fb3ea Mon Sep 17 00:00:00 2001
From: Otavio Pontes <[email protected]>
Date: Mon, 27 Sep 2010 15:26:55 -0300
Subject: [PATCH 5/5] Displaying directories in thumb browser
To: [email protected]
It is possible also to open an directory to see images in it.
---
ephoto/data/themes/default/ephoto.edc | 70 ++++++++++
ephoto/src/bin/ephoto_thumb_browser.c | 235 ++++++++++++++++++++++++---------
2 files changed, 242 insertions(+), 63 deletions(-)
diff --git a/ephoto/data/themes/default/ephoto.edc b/ephoto/data/themes/default/ephoto.edc
index 6f00faa..d1b95bf 100644
--- a/ephoto/data/themes/default/ephoto.edc
+++ b/ephoto/data/themes/default/ephoto.edc
@@ -95,6 +95,76 @@ collections
}
}
}
+ group
+ {
+ name: "/ephoto/thumb/no_border";
+ parts
+ {
+ part
+ {
+ name: "border";
+ type: RECT;
+ mouse_events: 0;
+ description
+ {
+ state: "default" 0.0;
+ color: 255 255 255 255;
+ rel1.offset: 16 16;
+ rel2.offset: -15 -15;
+ }
+ }
+ part
+ {
+ name: "clipper";
+ type: RECT;
+ mouse_events: 0;
+ description
+ {
+ state: "default" 0.0;
+ visible: 1;
+ rel1.to: "border";
+ rel1.offset: 8 8;
+ rel2.to: "border";
+ rel2.offset: -9 -9;
+ color: 255 255 255 255;
+ }
+ }
+ part
+ {
+ name: "ephoto.swallow.content";
+ type: SWALLOW;
+ mouse_events: 1;
+ clip_to: "clipper";
+ description
+ {
+ state: "default" 0.0;
+ visible: 1;
+ rel1.to: "clipper";
+ rel1.relative: 0.0 0.0;
+ rel2.to: "clipper";
+ rel2.relative: 1.0 1.0;
+ color: 255 255 255 255;
+ }
+ }
+ part
+ {
+ name: "event_area";
+ type: RECT;
+ mouse_events: 1;
+ description
+ {
+ state: "default" 0.0;
+ color: 255 255 255 0;
+ rel1.to: "clipper";
+ rel1.relative: 0.0 0.0;
+ rel1.offset: 0 0;
+ rel2.to: "clipper";
+ rel2.relative: 1.0 1.0;
+ rel2.offset: -1 -1;
+ }
+ }
+ }
+ }
group
{
name: "elm/gengrid/item/ephoto/default";
diff --git a/ephoto/src/bin/ephoto_thumb_browser.c b/ephoto/src/bin/ephoto_thumb_browser.c
index dca06a9..02ea296 100644
--- a/ephoto/src/bin/ephoto_thumb_browser.c
+++ b/ephoto/src/bin/ephoto_thumb_browser.c
@@ -2,6 +2,9 @@
#define SLIDER_MAX 300
#define SLIDER_MIN 80
+
+#define PARENT_DIR "top"
+
typedef struct _Ephoto_Thumb_Data Ephoto_Thumb_Data;
typedef struct _Ephoto_Thumb_Browser Ephoto_Thumb_Browser;
@@ -9,6 +12,7 @@ struct _Ephoto_Thumb_Data
{
const char *thumb_path;
const char *file;
+ Eina_Bool isDirectory;
};
struct _Ephoto_Thumb_Browser
@@ -21,6 +25,7 @@ struct _Ephoto_Thumb_Browser
Evas_Object *thbox;
Evas_Object *fsel_win;
Elm_Gengrid_Item_Class eg;
+ Elm_Toolbar_Item *view_large;
Ethumb_Client *ec;
Eio_File *list;
};
@@ -40,8 +45,9 @@ static Eina_Bool _ephoto_get_state(void *data, Evas_Object *obj, const char *par
static void _ephoto_grid_del(void *data, Evas_Object *obj);
static void _ephoto_thumb_clicked_job(void *data);
static void _ephoto_thumb_clicked(void *data, Evas_Object *obj, void *event_info);
+static void _ephoto_thumb_selected(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_view_large(void *data, Evas_Object *obj, void *event_info);
-static void _ephoto_change_directory(void *data, Evas_Object *obj, void *event_info);
+static void _ephoto_change_directory_window(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_view_slideshow(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_preferences(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
@@ -49,6 +55,9 @@ static void _ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_i
static void _ephoto_zoom_in(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_zoom_out(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_zoom_regular_size(void *data, Evas_Object *obj, void *event_info);
+static void _ephoto_thumbnail_directory(Ephoto_Thumb_Browser *tb, const char *path);
+static void _ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory);
+static void _ephoto_populate_images(Ephoto_Thumb_Browser *tb);
/*A key has been pressed*/
static const struct
@@ -58,7 +67,7 @@ static const struct
void (*func)(void *data, Evas_Object *obj, void *event_info);
} keys[] = {
{ "F5", NULL, _ephoto_view_slideshow },
- { "d", "Control", _ephoto_change_directory},
+ { "d", "Control", _ephoto_change_directory_window},
{ "p", "Control", _ephoto_preferences},
{ "plus", "Control", _ephoto_zoom_in},
{ "minus", "Control", _ephoto_zoom_out},
@@ -93,6 +102,18 @@ _ephoto_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_data)
}
}
+static void
+_ephoto_set_title(const char *file)
+{
+ char *buffer;
+ int length;
+
+ length = strlen(file) + strlen("Ephoto - ") + 1;
+ buffer = alloca(length);
+ snprintf(buffer, length, "Ephoto - %s", file);
+ elm_win_title_set(em->win, buffer);
+}
+
/*Create the thumbnail browser object*/
Evas_Object *
ephoto_create_thumb_browser(Evas_Object *parent)
@@ -148,6 +169,7 @@ ephoto_create_thumb_browser(Evas_Object *parent)
evas_object_size_hint_fill_set(tb->thumb_browser, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_style_set(tb->thumb_browser, "ephoto");
+ evas_object_smart_callback_add(tb->thumb_browser, "selected", _ephoto_thumb_selected, tb);
evas_object_smart_callback_add(tb->thumb_browser, "clicked", _ephoto_thumb_clicked, tb);
elm_layout_content_set(tb->layout, "ephoto.thumb.swallow", tb->thumb_browser);
@@ -163,7 +185,7 @@ ephoto_create_thumb_browser(Evas_Object *parent)
o = elm_icon_add(tb->toolbar);
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/change_directory.png", NULL);
- elm_toolbar_item_add(tb->toolbar, o, "Change Directory", _ephoto_change_directory, tb);
+ elm_toolbar_item_add(tb->toolbar, o, "Change Directory", _ephoto_change_directory_window, tb);
o = elm_icon_add(tb->toolbar);
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/filter.png", NULL);
@@ -171,7 +193,7 @@ ephoto_create_thumb_browser(Evas_Object *parent)
o = elm_icon_add(tb->toolbar);
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/view_presentation.png", NULL);
- elm_toolbar_item_add(tb->toolbar, o, "View Large", _ephoto_view_large, tb);
+ tb->view_large = elm_toolbar_item_add(tb->toolbar, o, "View Large", _ephoto_view_large, tb);
o = elm_icon_add(tb->toolbar);
elm_icon_file_set(o, PACKAGE_DATA_DIR "/images/play_slideshow.png", NULL);
@@ -203,9 +225,6 @@ static void
_ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- char *buffer;
- int length;
-
/* Ephoto_Thumb_Browser *tb = evas_object_data_get(obj, "thumb_browser"); */
/* evas_object_show(tb->toolbar); */
@@ -213,18 +232,28 @@ _ephoto_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
/* evas_object_show(tb->dir_label); */
/* evas_object_show(tb->thumb_slider); */
/* evas_object_show(tb->thbox); */
-
- length = strlen(em->config->directory) + strlen("Ephoto - ") + 1;
- buffer = alloca(length);
- snprintf(buffer, length, "Ephoto - %s", em->config->directory);
- elm_win_title_set(em->win, buffer);
+ _ephoto_set_title(em->config->directory);
}
/* Use ecore thread facility to avoid lock completly */
+/* Check directory type from another thread */
+static Eina_Bool
+_ephoto_populate_filter_directory(void *data, const char *file)
+{
+ const char *type;
+
+ if (!(type = efreet_mime_type_get(file)))
+ return EINA_FALSE;
+ if (!strncmp(type, "inode/directory", 15))
+ return EINA_TRUE;
+
+ return EINA_FALSE;
+}
+
/* Check image type from another thread */
static Eina_Bool
-_ephoto_populate_filter(void *data, const char *file)
+_ephoto_populate_filter_image(void *data, const char *file)
{
const char *type;
@@ -236,9 +265,17 @@ _ephoto_populate_filter(void *data, const char *file)
return EINA_FALSE;
}
+/*Done populating directories*/
+static void
+_ephoto_populate_end_directory(void *data)
+{
+ Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser *)data;
+ _ephoto_populate_images(tb);
+}
+
/*Done populating images*/
static void
-_ephoto_populate_end(void *data)
+_ephoto_populate_end_image(void *data)
{
Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser *)data;
@@ -258,28 +295,58 @@ _ephoto_populate_error(int error, void *data)
/* Build the interface component after detection from main thread */
static void
-_ephoto_populate_main(void *data, const char *file)
+_ephoto_populate_main_directory(void *data, const char *file)
{
- Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data;
+ Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data;
+ _ephoto_thumbnail_directory(tb, file);
+}
+
+/* Build the interface component after detection from main thread */
+static void
+_ephoto_populate_main_image(void *data, const char *file)
+{
+ Ephoto_Thumb_Browser *tb = (Ephoto_Thumb_Browser*)data;
const char *thumb;
+ const char *type;
file = eina_stringshare_ref(file);
- em->images = eina_list_append(em->images, file);
- ethumb_client_file_set(tb->ec, file, NULL);
- if (!ethumb_client_thumb_exists(tb->ec))
+ if (!(type = efreet_mime_type_get(file)))
+ return;
+ if (!strncmp(type, "image", 5))
{
- ethumb_client_generate(tb->ec, _ephoto_thumbnail_generated, tb, NULL);
+ em->images = eina_list_append(em->images, file);
+ ethumb_client_file_set(tb->ec, file, NULL);
+ if (!ethumb_client_thumb_exists(tb->ec))
+ {
+ ethumb_client_generate(tb->ec, _ephoto_thumbnail_generated, tb, NULL);
+ }
+ else
+ {
+ ethumb_client_thumb_path_get(tb->ec, &thumb, NULL);
+ _ephoto_thumbnail_generated(tb, tb->ec, 0, file, NULL,
+ thumb, NULL, EINA_TRUE);
+ }
}
else
{
- ethumb_client_thumb_path_get(tb->ec, &thumb, NULL);
- _ephoto_thumbnail_generated(tb, tb->ec, 0, file, NULL,
- thumb, NULL, EINA_TRUE);
+ _ephoto_thumbnail_directory(tb, file);
}
}
-/* Start a thread to list images in a directory without locking the interface */
+/*Create a thread to populate images*/
+static void
+_ephoto_populate_images(Ephoto_Thumb_Browser *tb)
+{
+ tb->list = eio_file_ls(em->config->directory,
+ _ephoto_populate_filter_image,
+ _ephoto_populate_main_image,
+ _ephoto_populate_end_image,
+ _ephoto_populate_error,
+ tb);
+}
+
+/* Start a thread to list images and directories in a directory without locking the interface */
void
ephoto_populate_thumbnails(Evas_Object *obj)
{
@@ -288,10 +355,11 @@ ephoto_populate_thumbnails(Evas_Object *obj)
if (!efreet_mime_init())
fprintf(stderr, "Could not init efreet_mime!\n");
+ _ephoto_thumbnail_directory(tb, PARENT_DIR);
tb->list = eio_file_ls(em->config->directory,
- _ephoto_populate_filter,
- _ephoto_populate_main,
- _ephoto_populate_end,
+ _ephoto_populate_filter_directory,
+ _ephoto_populate_main_directory,
+ _ephoto_populate_end_directory,
_ephoto_populate_error,
tb);
}
@@ -362,6 +430,7 @@ static void _ephoto_thumber_connected(void *data, Ethumb_Client *client, Eina_Bo
ethumb_client_format_set(tb->ec, ETHUMB_THUMB_FDO);
ethumb_client_aspect_set(tb->ec, ETHUMB_THUMB_KEEP_ASPECT);
ephoto_populate_thumbnails(tb->layout);
+ _ephoto_set_title(em->config->directory);
}
else
{
@@ -389,6 +458,20 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id,
}
}
+/* Called when adding a directory to elm_gengrid */
+static void
+_ephoto_thumbnail_directory(Ephoto_Thumb_Browser *tb, const char *path)
+{
+ Ephoto_Thumb_Data *etd;
+
+ etd = calloc(1, sizeof(*etd));
+ etd->thumb_path = eina_stringshare_add(PACKAGE_DATA_DIR "/images/change_directory.png");
+ etd->file = eina_stringshare_add(path);
+ etd->isDirectory = EINA_TRUE;
+
+ elm_gengrid_item_append(tb->thumb_browser, &tb->eg, etd, NULL, NULL);
+}
+
/*Get the label for the icon in the grid*/
static char *
_ephoto_get_label(void *data, Evas_Object *obj, const char *part)
@@ -415,7 +498,11 @@ _ephoto_get_icon(void *data, Evas_Object *obj, const char *part)
if (!strcmp(part, "elm.swallow.icon"))
{
thumb = elm_layout_add(obj);
- elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
+ if (etd->isDirectory)
+ elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
+ "/ephoto/thumb/no_border");
+ else
+ elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"/ephoto/thumb");
evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(thumb);
@@ -451,6 +538,7 @@ static void
_ephoto_thumb_clicked_job(void *data)
{
const Eina_List *selected;
+ char *parent_dir;
Ephoto_Thumb_Data *etd;
Evas_Object *o;
Ephoto_Thumb_Browser *tb = data;
@@ -458,7 +546,60 @@ _ephoto_thumb_clicked_job(void *data)
selected = elm_gengrid_selected_items_get(tb->thumb_browser);
o = eina_list_data_get(selected);
etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get((Elm_Gengrid_Item *)o);
- evas_object_smart_callback_call(tb->layout, "selected", (char *)etd->file);
+ if (etd->isDirectory)
+ {
+ if (!strcmp(etd->file, PARENT_DIR))
+ {
+ parent_dir = ecore_file_dir_get(em->config->directory);
+ _ephoto_change_directory(tb, parent_dir);
+ free(parent_dir);
+ }
+ else
+ _ephoto_change_directory(tb, etd->file);
+ }
+ else
+ evas_object_smart_callback_call(tb->layout, "selected", (char *)etd->file);
+}
+
+/* Change the current directory showed in thumb browser. */
+static void
+_ephoto_change_directory(Ephoto_Thumb_Browser *tb, const char *directory)
+{
+ const Eina_List *l, *iter;
+ Elm_Gengrid_Item *item;
+ Ephoto_Thumb_Data *etd;
+
+ if ((directory) && (eina_stringshare_replace(&em->config->directory, directory)))
+ {
+ l = elm_gengrid_items_get(tb->thumb_browser);
+ EINA_LIST_FOREACH(l, iter, item)
+ {
+ etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get(item);
+ eina_stringshare_del(etd->thumb_path);
+ eina_stringshare_del(etd->file);
+ free(etd);
+ }
+ elm_gengrid_clear(tb->thumb_browser);
+ eina_list_free(em->images);
+ em->images = NULL;
+ ephoto_populate_thumbnails(tb->layout);
+ elm_label_label_set(tb->dir_label, em->config->directory);
+ _ephoto_set_title(em->config->directory);
+ }
+
+ evas_object_smart_callback_call(tb->layout, "directory,changed", (char *) em->config->directory);
+}
+
+/*Called when an item is selected in gengrid*/
+static void
+_ephoto_thumb_selected(void *data, Evas_Object *obj, void *event_info)
+{
+ Ephoto_Thumb_Browser *tb = data;
+ Ephoto_Thumb_Data *etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get((Elm_Gengrid_Item *)event_info);
+ if (etd->isDirectory)
+ elm_toolbar_item_disabled_set(tb->view_large, EINA_TRUE);
+ else
+ elm_toolbar_item_disabled_set(tb->view_large, EINA_FALSE);
}
/*Check to see if the thumbnail was double clicked*/
@@ -480,41 +621,9 @@ _ephoto_fileselector_shown(void *data, Evas *e, Evas_Object *obj, void *event_in
static void
_ephoto_directory_chosen(void *data, Evas_Object *obj, void *event_info)
{
- const Eina_List *l, *iter;
- Elm_Gengrid_Item *item;
- Ephoto_Thumb_Data *etd;
- const char *directory;
Ephoto_Thumb_Browser *tb = data;
- directory = elm_fileselector_selected_get(obj);
-
- if ((directory) && (eina_stringshare_replace(&em->config->directory, directory)))
- {
- char *buffer;
- int length;
-
- l = elm_gengrid_items_get(tb->thumb_browser);
- EINA_LIST_FOREACH(l, iter, item)
- {
- etd = (Ephoto_Thumb_Data *)elm_gengrid_item_data_get(item);
- eina_stringshare_del(etd->thumb_path);
- eina_stringshare_del(etd->file);
- free(etd);
- }
- elm_gengrid_clear(tb->thumb_browser);
- eina_list_free(em->images);
- em->images = NULL;
- ephoto_populate_thumbnails(tb->layout);
- elm_label_label_set(tb->dir_label, em->config->directory);
-
- length = strlen(em->config->directory) + strlen("Ephoto - ") + 1;
- buffer = alloca(length);
- snprintf(buffer, length, "Ephoto - %s", em->config->directory);
- elm_win_title_set(em->win, buffer);
- }
-
- evas_object_smart_callback_call(tb->layout, "directory,changed", (char *) em->config->directory);
-
+ _ephoto_change_directory(tb, elm_fileselector_selected_get(obj));
evas_object_del(tb->fsel_win);
elm_toolbar_item_unselect_all(tb->toolbar);
}
@@ -552,7 +661,7 @@ _ephoto_view_large(void *data, Evas_Object *obj, void *event_info)
/*Change directory*/
static void
-_ephoto_change_directory(void *data, Evas_Object *obj, void *event_info)
+_ephoto_change_directory_window(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *fsel;
Ephoto_Thumb_Browser *tb = data;
--
1.7.3
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel