# Path: coverart_widgets.py
# class AbstractView(GObject.Object):
#     '''
#     intention is to document 'the must have' methods all views should define
#     N.B. this is preliminary and will change as and when
#     coverflow view is added with lessons learned
#     '''
#     view = None
#     panedposition = PanedCollapsible.Paned.DEFAULT
#     use_plugin_window = True
#     # signals - note - pygobject doesnt appear to support signal declaration
#     # in multiple inheritance - so these signals need to be defined in all view classes
#     # where abstractview is part of multiple inheritance
#     __gsignals__ = {
#         'update-toolbar': (GObject.SIGNAL_RUN_LAST, None, ())
#     }
# 
#     def __init__(self):
#         super(AbstractView, self).__init__()
# 
#     def initialise(self, source):
#         self.source = source
#         self.plugin = source.plugin
# 
#         self._notification_displayed = 0
#         Notify.init("coverart_browser")
# 
#         self.connect('update-toolbar', self.do_update_toolbar)
# 
#     def do_update_toolbar(self, *args):
#         '''
#             called when update-toolbar signal is emitted
#             by default the toolbar objects are made visible
#         '''
#         from coverart_toolbar import ToolbarObject
# 
#         self.source.toolbar_manager.set_enabled(True, ToolbarObject.SORT_BY)
#         self.source.toolbar_manager.set_enabled(True, ToolbarObject.SORT_ORDER)
#         self.source.toolbar_manager.set_enabled(False, ToolbarObject.SORT_BY_ARTIST)
#         self.source.toolbar_manager.set_enabled(False, ToolbarObject.SORT_ORDER_ARTIST)
# 
#     def display_notification(self, title, text, file):
# 
#         # first see if the notification plugin is enabled
#         # if it is, we use standard notifications
#         # if it is not, we use the infobar
# 
#         def hide_notification(*args):
#             if self._notification_displayed > 7:
#                 self.source.notification_infobar.response(0)
#                 self._notification_displayed = 0
#                 return False
# 
#             self._notification_displayed = self._notification_displayed + 1
#             return True
# 
#         notifyext = ExternalPlugin()
#         notifyext.appendattribute('plugin_name', 'notification')
# 
#         if notifyext.is_activated():
#             n = Notify.Notification.new(title, text, file)
#             n.show()
#         else:
#             self.source.notification_text.set_text(title + " : " + text)
#             # self.source.notification_infobar.set_visible(True)#reveal_notification.set_reveal_child(True)
#             self.source.notification_infobar.show()  #reveal_notification.set_reveal_child(True)
# 
#             if self._notification_displayed == 0:
#                 Gdk.threads_add_timeout_seconds(GLib.PRIORITY_DEFAULT_IDLE, 1,
#                                                 hide_notification, None)
#             else:
#                 self._notification_displayed = 1  # reset notification for new label
# 
# 
#     def resize_icon(self, cover_size):
#         '''
#         resize the view main picture icon
# 
#         :param cover_size: `int` icon size
#         '''
#         pass
# 
#     def get_selected_objects(self):
#         '''
#         finds what has been selected
# 
#         returns an array of `Album`
#         '''
#         pass
# 
#     def selectionchanged_callback(self, *args):
#         '''
#         callback when a selection has changed
#         '''
#         self.source.update_with_selection()
# 
#     def select_and_scroll_to_path(self, path):
#         '''
#         find a path and highlight (select) that object
#         '''
#         pass
# 
#     def scroll_to_album(self, album):
#         '''
#         scroll to the album in the view
#         '''
#         if album:
#             path = self.source.album_manager.model.get_path(album)
#             if path:
#                 self.select_and_scroll_to_path(path)
# 
#     def set_popup_menu(self, popup):
#         '''
#         define the popup menu (right click) used for the view
#         '''
#         self.popup = popup
# 
#     def grab_focus(self):
#         '''
#         ensures main view object retains the focus
#         '''
#         pass
# 
#     def switch_to_view(self, source, album):
#         '''
#         ensures that when the user toggles to a view stuff remains
#         consistent
#         '''
#         pass
# 
#     def get_view_icon_name(self):
#         '''
#         every view should have an icon - subject to removal
#         since we'll probably just have text buttons for the view
#         '''
#         return ""
# 
#     def get_default_manager(self):
#         '''
#         every view should have a default manager
#         for example an AlbumManager or ArtistManager
#         by default - use the AlbumManager from the source
#         '''
# 
#         return self.source.album_manager
# 
#     def switch_to_coverpane(self, cover_search_pane):
#         '''
#         called from the source to update the coverpane when
#         it is switched from the track pane
#         '''
# 
#         selected = self.get_selected_objects()
# 
#         if selected:
#             manager = self.get_default_manager()
#             cover_search_pane.do_search(selected[0],
#                                         manager.cover_man.update_cover)


from gi.repository import GObject
from gi.repository import GLib
from coverart_widgets import AbstractView
# 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 St, Fifth Floor, Boston, MA 02110-1301  USA.




class PlaySourceShowingPolicy(GObject.Object):
    '''
    Policy that mostly takes care of how and when things should be showed on
    the view that makes use of the `AlbumsModel`.
    '''

    def __init__(self, list_view):
        super(PlaySourceShowingPolicy, self).__init__()

        self.counter = 0
        self._has_initialised = False

    def initialise(self, album_manager):
        if self._has_initialised:
            return

        self._has_initialised = True



# Path: coverart_widgets.py
# class AbstractView(GObject.Object):
#     '''
#     intention is to document 'the must have' methods all views should define
#     N.B. this is preliminary and will change as and when
#     coverflow view is added with lessons learned
#     '''
#     view = None
#     panedposition = PanedCollapsible.Paned.DEFAULT
#     use_plugin_window = True
#     # signals - note - pygobject doesnt appear to support signal declaration
#     # in multiple inheritance - so these signals need to be defined in all view classes
#     # where abstractview is part of multiple inheritance
#     __gsignals__ = {
#         'update-toolbar': (GObject.SIGNAL_RUN_LAST, None, ())
#     }
# 
#     def __init__(self):
#         super(AbstractView, self).__init__()
# 
#     def initialise(self, source):
#         self.source = source
#         self.plugin = source.plugin
# 
#         self._notification_displayed = 0
#         Notify.init("coverart_browser")
# 
#         self.connect('update-toolbar', self.do_update_toolbar)
# 
#     def do_update_toolbar(self, *args):
#         '''
#             called when update-toolbar signal is emitted
#             by default the toolbar objects are made visible
#         '''
#         from coverart_toolbar import ToolbarObject
# 
#         self.source.toolbar_manager.set_enabled(True, ToolbarObject.SORT_BY)
#         self.source.toolbar_manager.set_enabled(True, ToolbarObject.SORT_ORDER)
#         self.source.toolbar_manager.set_enabled(False, ToolbarObject.SORT_BY_ARTIST)
#         self.source.toolbar_manager.set_enabled(False, ToolbarObject.SORT_ORDER_ARTIST)
# 
#     def display_notification(self, title, text, file):
# 
#         # first see if the notification plugin is enabled
#         # if it is, we use standard notifications
#         # if it is not, we use the infobar
# 
#         def hide_notification(*args):
#             if self._notification_displayed > 7:
#                 self.source.notification_infobar.response(0)
#                 self._notification_displayed = 0
#                 return False
# 
#             self._notification_displayed = self._notification_displayed + 1
#             return True
# 
#         notifyext = ExternalPlugin()
#         notifyext.appendattribute('plugin_name', 'notification')
# 
#         if notifyext.is_activated():
#             n = Notify.Notification.new(title, text, file)
#             n.show()
#         else:
#             self.source.notification_text.set_text(title + " : " + text)
#             # self.source.notification_infobar.set_visible(True)#reveal_notification.set_reveal_child(True)
#             self.source.notification_infobar.show()  #reveal_notification.set_reveal_child(True)
# 
#             if self._notification_displayed == 0:
#                 Gdk.threads_add_timeout_seconds(GLib.PRIORITY_DEFAULT_IDLE, 1,
#                                                 hide_notification, None)
#             else:
#                 self._notification_displayed = 1  # reset notification for new label
# 
# 
#     def resize_icon(self, cover_size):
#         '''
#         resize the view main picture icon
# 
#         :param cover_size: `int` icon size
#         '''
#         pass
# 
#     def get_selected_objects(self):
#         '''
#         finds what has been selected
# 
#         returns an array of `Album`
#         '''
#         pass
# 
#     def selectionchanged_callback(self, *args):
#         '''
#         callback when a selection has changed
#         '''
#         self.source.update_with_selection()
# 
#     def select_and_scroll_to_path(self, path):
#         '''
#         find a path and highlight (select) that object
#         '''
#         pass
# 
#     def scroll_to_album(self, album):
#         '''
#         scroll to the album in the view
#         '''
#         if album:
#             path = self.source.album_manager.model.get_path(album)
#             if path:
#                 self.select_and_scroll_to_path(path)
# 
#     def set_popup_menu(self, popup):
#         '''
#         define the popup menu (right click) used for the view
#         '''
#         self.popup = popup
# 
#     def grab_focus(self):
#         '''
#         ensures main view object retains the focus
#         '''
#         pass
# 
#     def switch_to_view(self, source, album):
#         '''
#         ensures that when the user toggles to a view stuff remains
#         consistent
#         '''
#         pass
# 
#     def get_view_icon_name(self):
#         '''
#         every view should have an icon - subject to removal
#         since we'll probably just have text buttons for the view
#         '''
#         return ""
# 
#     def get_default_manager(self):
#         '''
#         every view should have a default manager
#         for example an AlbumManager or ArtistManager
#         by default - use the AlbumManager from the source
#         '''
# 
#         return self.source.album_manager
# 
#     def switch_to_coverpane(self, cover_search_pane):
#         '''
#         called from the source to update the coverpane when
#         it is switched from the track pane
#         '''
# 
#         selected = self.get_selected_objects()
# 
#         if selected:
#             manager = self.get_default_manager()
#             cover_search_pane.do_search(selected[0],
#                                         manager.cover_man.update_cover)


# Path: coverart_playsourceview.py
from gi.repository import GObject
from gi.repository import GLib
from coverart_widgets import AbstractView

# 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 St, Fifth Floor, Boston, MA 02110-1301  USA.




class PlaySourceShowingPolicy(GObject.Object):
    '''
    Policy that mostly takes care of how and when things should be showed on
    the view that makes use of the `AlbumsModel`.
    '''

    def __init__(self, list_view):
        super(PlaySourceShowingPolicy, self).__init__()

        self.counter = 0
        self._has_initialised = False

    def initialise(self, album_manager):
        if self._has_initialised:
            return

        self._has_initialised = True



class PlaySourceView(AbstractView):