Commit de41b5b2 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Introduce a view_sys_cb

It allows the list_view* to trigger updates on the view_sys*
parent c111228c
......@@ -48,6 +48,11 @@ intf_destroy(interface *);
/* Views */
typedef struct view_sys view_sys;
typedef struct view_sys_cb {
view_sys* p_sys;
void (*pf_updated)( view_sys* p_sys );
} view_sys_cb;
typedef enum interface_view_event {
INTERFACE_VIEW_EVENT_NONE,
INTERFACE_VIEW_EVENT_BACK,
......@@ -76,7 +81,6 @@ typedef struct interface_view {
} interface_view;
void
intf_show_view(interface *, view_e);
......
......@@ -34,6 +34,7 @@ struct list_sys
media_library_controller* p_ctrl;
interface* p_intf;
Elm_Genlist_Item_Class* p_default_item_class;
view_sys_cb* p_view_cb;
};
struct list_view_item
......@@ -130,7 +131,7 @@ audio_list_artist_view_destroy(list_sys* p_list)
}
list_view*
audio_list_artist_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent)
audio_list_artist_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent, view_sys_cb* p_view_cb)
{
list_view* p_view = calloc(1, sizeof(*p_view));
if (p_view == NULL)
......@@ -154,6 +155,7 @@ audio_list_artist_view_create(application* p_app, interface* p_intf, Evas_Object
p_sys->p_default_item_class->func.text_get = genlist_text_get_cb;
p_sys->p_intf = p_intf;
p_sys->p_view_cb = p_view_cb;
p_view->pf_show = &audio_list_artist_view_show;
p_view->pf_del = &audio_list_artist_view_destroy;
......
......@@ -30,6 +30,6 @@
#include "ui/interface.h"
list_view*
audio_list_artist_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent);
audio_list_artist_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent, view_sys_cb* p_view_cb);
#endif // AUDIO_LIST_ARTIST_VIEW_H_
......@@ -40,6 +40,7 @@ struct list_sys
media_library_controller* p_ctrl;
interface* p_intf;
Elm_Genlist_Item_Class* p_default_item_class;
view_sys_cb* p_view_cb;
};
struct list_view_item
......@@ -199,7 +200,7 @@ audio_list_song_view_destroy(list_sys* p_list)
}
list_view*
audio_list_song_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent)
audio_list_song_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent, view_sys_cb* p_view_cb)
{
list_view* p_view = calloc(1, sizeof(*p_view));
if (p_view == NULL)
......@@ -234,6 +235,7 @@ audio_list_song_view_create(application* p_app, interface* p_intf, Evas_Object*
p_sys->p_default_item_class->func.content_get = genlist_content_get_cb;
p_sys->p_intf = p_intf;
p_sys->p_view_cb = p_view_cb;
p_view->pf_show = &audio_list_song_view_show;
p_view->pf_del = &audio_list_song_view_destroy;
......
......@@ -31,6 +31,6 @@
#include "ui/interface.h"
list_view*
audio_list_song_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent);
audio_list_song_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent, view_sys_cb* p_view_cb);
#endif // AUDIO_LIST_SONG_ITEM_H_
......@@ -59,6 +59,7 @@ struct view_sys
Evas_Object* p_overflow_menu;
list_view* p_lists[AUDIO_VIEW_MAX];
audio_view_type p_current_tab;
view_sys_cb* p_view_cb;
};
typedef struct toolbar_tab {
......@@ -77,10 +78,10 @@ create_audio_list_type(view_sys *av, audio_view_type type )
{
case AUDIO_VIEW_SONG:
default:
p_view = audio_list_song_view_create(p_app, av->p_intf, av->nf_toolbar);
p_view = audio_list_song_view_create(p_app, av->p_intf, av->nf_toolbar, av->p_view_cb);
break;
case AUDIO_VIEW_ARTIST:
p_view = audio_list_artist_view_create(p_app, av->p_intf, av->nf_toolbar);
p_view = audio_list_artist_view_create(p_app, av->p_intf, av->nf_toolbar, av->p_view_cb);
break;
}
av->p_lists[type] = p_view;
......@@ -211,6 +212,12 @@ audio_view_has_menu(view_sys *p_view_sys)
return true;
}
static void
audio_view_content_changed_cb(view_sys* p_view_sys)
{
}
interface_view *
create_audio_view(interface *intf, Evas_Object *parent)
{
......@@ -220,6 +227,9 @@ create_audio_view(interface *intf, Evas_Object *parent)
view_sys *audio_view_sys = calloc(1, sizeof(*audio_view_sys));
audio_view_sys->p_intf = intf;
audio_view_sys->p_parent = parent;
view_sys_cb* p_view_cb = audio_view_sys->p_view_cb = calloc(1, sizeof(*p_view_cb));
p_view_cb->pf_updated = &audio_view_content_changed_cb;
p_view_cb->p_sys = audio_view_sys;
view->pf_event = audio_view_callback;
view->p_view_sys = audio_view_sys;
......@@ -264,6 +274,7 @@ destroy_audio_view(interface_view *view)
free(p_sys->p_lists[i]);
}
}
free(p_sys->p_view_cb);
free(p_sys);
free(view);
}
......@@ -41,7 +41,7 @@ struct view_sys
interface* p_intf;
Evas_Object *p_parent;
list_view* p_list;
view_sys_cb* p_view_cb;
Evas_Object *p_overflow_menu;
};
......@@ -99,6 +99,11 @@ video_view_has_menu(view_sys *p_view_sys)
return true;
}
static void
video_video_content_updated_cb(view_sys* p_view_sys)
{
}
interface_view*
create_video_view(interface *intf, Evas_Object *parent)
{
......@@ -108,6 +113,9 @@ create_video_view(interface *intf, Evas_Object *parent)
p_sys->p_intf = intf;
p_sys->p_parent = parent;
p_sys->p_overflow_menu = NULL;
view_sys_cb* p_view_cb = p_sys->p_view_cb = calloc(1, sizeof(*p_view_cb));
p_view_cb->pf_updated = &video_video_content_updated_cb;
p_view_cb->p_sys = p_sys;
view->pf_event = video_view_callback;
view->pf_has_menu = video_view_has_menu;
......@@ -119,7 +127,7 @@ create_video_view(interface *intf, Evas_Object *parent)
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(box);
p_sys->p_list = video_view_list_create(intf, box);
p_sys->p_list = video_view_list_create(intf, box, p_sys->p_view_cb);
view->view = box;
......@@ -133,6 +141,7 @@ destroy_video_view(interface_view *view)
list_view* p_list_view = view->p_view_sys->p_list;
p_list_view->pf_del(p_list_view->p_sys);
free(p_list_view);
free(view->p_view_sys->p_view_cb);
free(view->p_view_sys);
free(view);
}
......@@ -53,6 +53,7 @@ struct list_sys
interface* p_intf;
Evas_Object* p_box;
Evas_Object* p_empty_label;
view_sys_cb* p_view_cb;
};
static void
......@@ -236,7 +237,7 @@ video_view_list_destroy(list_sys* p_list)
}
list_view*
video_view_list_create(interface *p_intf, Evas_Object *p_parent)
video_view_list_create(interface *p_intf, Evas_Object *p_parent, view_sys_cb* p_view_cb)
{
list_view* p_view = calloc(1, sizeof(*p_view));
if (p_view == NULL)
......@@ -277,6 +278,7 @@ video_view_list_create(interface *p_intf, Evas_Object *p_parent)
evas_object_smart_callback_add(p_genlist, "contracted", genlist_contracted_cb, NULL);
p_sys->p_intf = p_intf;
p_sys->p_view_cb = p_view_cb;
p_view->pf_del = &video_view_list_destroy;
......
......@@ -31,6 +31,6 @@
#include "ui/interface.h"
list_view*
video_view_list_create(interface *intf, Evas_Object *p_genlist);
video_view_list_create(interface *intf, Evas_Object *p_genlist, view_sys_cb* p_view_cb);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment