eina_stringshare instead of strdup. Slider now works for thumb size!

SVN revision: 50008
This commit is contained in:
titan 2010-07-03 04:42:22 +00:00 committed by titan
parent 6926304983
commit 83b038d947
2 changed files with 17 additions and 12 deletions

View File

@ -5,13 +5,12 @@ Ephoto *em;
/*Inline Callbacks*/ /*Inline Callbacks*/
static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info); static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_free_hash(void *data);
/*Create the main ephoto window*/ /*Create the main ephoto window*/
void ephoto_create_main_window(void) void ephoto_create_main_window(void)
{ {
em = calloc(1, sizeof(Ephoto)); em = calloc(1, sizeof(Ephoto));
em->thumbs_images = eina_hash_string_superfast_new(_ephoto_free_hash); em->thumbs_images = eina_hash_string_superfast_new((Eina_Free_Cb)eina_stringshare_del);
/*Setup the main window*/ /*Setup the main window*/
em->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC); em->win = elm_win_add(NULL, "ephoto", ELM_WIN_BASIC);
@ -56,12 +55,3 @@ static void _ephoto_delete_main_window(void *data, Evas_Object *obj, void *event
elm_exit(); elm_exit();
} }
/*Free the eina hash*/
static void _ephoto_free_hash(void *data)
{
char *item;
item = data;
free(item);
}

View File

@ -214,7 +214,22 @@ ephoto_populate_thumbnails(void)
static void static void
_ephoto_slider_changed(void *data, Evas_Object *obj, void *event) _ephoto_slider_changed(void *data, Evas_Object *obj, void *event)
{ {
int w, h, val;
val = elm_slider_value_get(em->thumb_slider);
elm_gengrid_item_size_get(em->thumb_browser, &w, &h);
if (val < cur_val)
{
w -= cur_val-val;
h -= cur_val-val;
}
else if (val > cur_val)
{
w += val-cur_val;
h += val-cur_val;
}
elm_gengrid_item_size_set(em->thumb_browser, w, h);
cur_val = val;
} }
/*Callback when the client is connected*/ /*Callback when the client is connected*/
@ -242,7 +257,7 @@ _ephoto_thumbnail_generated(void *data, Ethumb_Client *client, int id,
{ {
if (success) if (success)
{ {
eina_hash_add(em->thumbs_images, strdup(file), strdup(thumb_path)); eina_hash_add(em->thumbs_images, file, eina_stringshare_ref(thumb_path));
elm_gengrid_item_append(em->thumb_browser, &eg, file, NULL, NULL); elm_gengrid_item_append(em->thumb_browser, &eg, file, NULL, NULL);
} }
} }