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

Add a dummy artist listing

parent eadf121c
......@@ -29,6 +29,7 @@
#include "media_controller.h"
#include "media_library_controller.h"
#include "media_library_controller_private.h"
#include "media/artist_item.h"
#include "ui/views/video_view.h"
#include "ui/views/audio_view.h"
......@@ -46,6 +47,13 @@ audio_controller_accept_item( const void* p_item )
return p_media_item->i_type == MEDIA_ITEM_TYPE_AUDIO;
}
static bool
artist_controller_accept_item( const void* p_item )
{
(void)p_item;
return true;
}
media_library_controller*
video_controller_create(application* p_app, list_view* p_list_view)
{
......@@ -71,3 +79,16 @@ audio_controller_create(application* p_app, list_view* p_list_view)
p_ctrl->pf_accept_item = &audio_controller_accept_item;
return p_ctrl;
}
media_library_controller*
artist_controller_create(application* p_app, list_view* p_list_view)
{
media_library_controller* p_ctrl = media_library_controller_create( p_app, p_list_view );
if ( p_ctrl == NULL )
return NULL;
p_ctrl->pf_media_library_get_content = (pf_media_library_get_content_cb)&media_library_get_artists;
p_ctrl->pf_item_duplicate = (pf_item_duplicate_cb)&artist_item_copy;
p_ctrl->pf_item_compare = (pf_item_compare_cb)&artist_item_identical;
p_ctrl->pf_accept_item = &artist_controller_accept_item;
return p_ctrl;
}
......@@ -130,3 +130,13 @@ albumToAlbumItem( AlbumPtr album )
p_item->i_release_date = album->releaseDate();
return p_item;
}
artist_item*
artistToArtistItem( ArtistPtr artist )
{
auto p_item = artist_item_create(artist->name().c_str());
if (p_item == nullptr)
return nullptr;
return p_item;
}
......@@ -276,6 +276,27 @@ media_library_get_albums(media_library* p_ml, media_library_list_cb cb, void* p_
}, nullptr, nullptr, ctx );
}
void
media_library_get_artists( media_library* p_ml, media_library_list_cb cb, void* p_user_data )
{
auto ctx = new ml_callback_context( p_ml, cb, p_user_data );
ecore_thread_run( [](void* data, Ecore_Thread* ) {
auto ctx = reinterpret_cast<ml_callback_context*>( data );
auto artists = ctx->p_ml->ml->artists();
Eina_List *list = nullptr;
for ( auto& a : artists )
{
auto elem = artistToArtistItem( a );
if ( elem == nullptr )
continue;
list = eina_list_append( list, elem );
}
ctx->list = list;
ecore_main_loop_thread_safe_call_async( intermediate_list_callback, ctx );
}, nullptr, nullptr, ctx );
}
void
media_library_register_on_change(media_library* ml, media_library_file_list_changed_cb cb, void* p_data)
{
......
......@@ -67,6 +67,9 @@ media_library_get_audio_files( media_library* p_ml, media_library_list_cb cb, vo
void
media_library_get_albums( media_library* p_ml, media_library_list_cb cb, void* p_user_data );
void
media_library_get_artists( media_library* p_ml, media_library_list_cb cb, void* p_user_data );
void
media_library_register_on_change(media_library* ml, media_library_file_list_changed_cb cb, void* p_data);
......
......@@ -32,9 +32,11 @@
#include "media_library.hpp"
#include "media/media_item.h"
#include "media/album_item.h"
#include "media/artist_item.h"
media_item* fileToMediaItem( FilePtr file );
album_item* albumToAlbumItem( AlbumPtr album );
artist_item* artistToArtistItem( ArtistPtr album );
class TizenLogger : public ILogger
{
......
/*****************************************************************************
* Copyright © 2015 VideoLAN, VideoLabs SAS
*****************************************************************************
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
* By committing to this project, you allow VideoLAN and VideoLabs to relicense
* the code to a different OSI approved license, in case it is required for
* compatibility with the Store
*****************************************************************************/
#include "audio_list_artist_view.h"
#include "media/artist_item.h"
#include "controller/media_controller.h"
struct list_sys
{
Evas_Object* p_list;
media_library_controller* p_ctrl;
interface* p_intf;
Elm_Genlist_Item_Class* p_default_item_class;
};
struct list_view_item
{
const list_sys* p_list;
const Elm_Genlist_Item_Class* itc;
artist_item* p_artist_item;
Elm_Object_Item* p_object_item;
};
static void
free_list_item_data(void *data, Evas_Object *obj, void *event_info)
{
list_view_item *p_view_item = data;
artist_item_destroy(p_view_item->p_artist_item);
free(p_view_item);
}
static char *
genlist_text_get_cb(void *data, Evas_Object *obj, const char *part)
{
list_view_item *p_view_item = data;
const Elm_Genlist_Item_Class *itc = p_view_item->itc;
char *buf;
if (itc->item_style && !strcmp(itc->item_style, "2line.top.3")) {
if (part && !strcmp(part, "elm.text.main.left.top")) {
asprintf(&buf, "<b>%s</b>", p_view_item->p_artist_item->psz_name);
return buf;
}
}
return NULL;
}
static const void*
audio_list_artist_item_get_media_item(list_view_item* p_item)
{
return p_item->p_artist_item;
}
static void
audio_list_artist_item_set_media_item(list_view_item* p_item, void* p_data)
{
artist_item* p_media_item = (artist_item*)p_data;
p_item->p_artist_item = p_media_item;
ecore_main_loop_thread_safe_call_async((Ecore_Cb)elm_genlist_item_update, p_item->p_object_item);
}
static list_view_item*
audio_list_artist_view_append_item(list_sys *p_sys, void* p_data)
{
artist_item* p_artist_item = (artist_item*)p_data;
list_view_item *ali = calloc(1, sizeof(*ali));
ali->p_list = p_sys;
ali->itc = p_sys->p_default_item_class;
ali->p_artist_item = p_artist_item;
/* Set and append new item in the genlist */
Elm_Object_Item *it = elm_genlist_item_append(p_sys->p_list,
p_sys->p_default_item_class, /* genlist item class */
ali, /* genlist item class user data */
NULL, /* genlist parent item */
ELM_GENLIST_ITEM_NONE, /* genlist item type */
NULL, /* genlist select smart callback */
ali); /* genlist smart callback user data */
/* */
elm_object_item_del_cb_set(it, free_list_item_data);
return ali;
}
static void
audio_list_artist_view_clear(list_sys* p_list)
{
elm_genlist_clear(p_list->p_list);
}
static void
audio_list_artist_view_show(list_sys* p_sys, Evas_Object* p_parent)
{
Elm_Object_Item *it = elm_naviframe_item_push(p_parent, "", NULL, NULL, p_sys->p_list, NULL);
elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
evas_object_show(p_sys->p_list);
}
static void
audio_list_artist_view_destroy(list_sys* p_list)
{
media_library_controller_destroy(p_list->p_ctrl);
elm_genlist_item_class_free(p_list->p_default_item_class);
free(p_list);
}
list_view*
audio_list_artist_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent)
{
list_view* p_view = calloc(1, sizeof(*p_view));
if (p_view == NULL)
return NULL;
list_sys* p_sys = p_view->p_sys = calloc(1, sizeof(*p_sys));
if (p_sys == NULL)
return NULL;
/* Create genlist */
p_sys->p_list = elm_genlist_add(p_parent);
elm_scroller_single_direction_set(p_sys->p_list, ELM_SCROLLER_SINGLE_DIRECTION_HARD);
elm_genlist_homogeneous_set(p_sys->p_list, EINA_TRUE);
elm_genlist_mode_set(p_sys->p_list, ELM_LIST_COMPRESS);
evas_object_size_hint_weight_set(p_sys->p_list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(p_sys->p_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
/* Item Class */
p_sys->p_default_item_class = elm_genlist_item_class_new();
p_sys->p_default_item_class->item_style = "2line.top.3";
p_sys->p_default_item_class->func.text_get = genlist_text_get_cb;
p_sys->p_intf = p_intf;
p_view->pf_show = &audio_list_artist_view_show;
p_view->pf_del = &audio_list_artist_view_destroy;
p_view->pf_append_item = &audio_list_artist_view_append_item;
p_view->pf_clear = &audio_list_artist_view_clear;
p_view->pf_get_item = &audio_list_artist_item_get_media_item;
p_view->pf_set_item = &audio_list_artist_item_set_media_item;
p_sys->p_ctrl = artist_controller_create(p_app, p_view);
media_library_controller_refresh( p_sys->p_ctrl );
return p_view;
}
/*****************************************************************************
* Copyright © 2015 VideoLAN, VideoLabs SAS
*****************************************************************************
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
* By committing to this project, you allow VideoLAN and VideoLabs to relicense
* the code to a different OSI approved license, in case it is required for
* compatibility with the Store
*****************************************************************************/
#ifndef AUDIO_LIST_ARTIST_VIEW_H_
# define AUDIO_LIST_ARTIST_VIEW_H_
#include "ui/interface.h"
list_view*
audio_list_artist_view_create(application* p_app, interface* p_intf, Evas_Object* p_parent);
#endif // AUDIO_LIST_ARTIST_VIEW_H_
......@@ -30,6 +30,7 @@
#include "ui/interface.h"
#include "ui/views/audio_view.h"
#include "ui/views/audio_list_song_view.h"
#include "ui/views/audio_list_artist_view.h"
#include "ui/audio_player.h"
#include "ui/menu/popup_menu.h"
......@@ -71,6 +72,10 @@ create_audio_list_type(view_sys *av, audio_view_type type )
case AUDIO_VIEW_SONG:
default:
p_view = audio_list_song_view_create(av->p_app, av->p_intf, av->nf_toolbar);
break;
case AUDIO_VIEW_ARTIST:
p_view = audio_list_artist_view_create(av->p_app, av->p_intf, av->nf_toolbar);
break;
}
av->p_lists[type] = p_view;
}
......
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