1
# -*- coding: utf-8 -*-
2
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
4
###############################################################################
5
# OpenLP - Open Source Lyrics Projection #
6
# --------------------------------------------------------------------------- #
7
# Copyright (c) 2008-2016 OpenLP Developers #
8
# --------------------------------------------------------------------------- #
9
# This program is free software; you can redistribute it and/or modify it #
10
# under the terms of the GNU General Public License as published by the Free #
11
# Software Foundation; version 2 of the License. #
13
# This program is distributed in the hope that it will be useful, but WITHOUT #
14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
15
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
18
# You should have received a copy of the GNU General Public License along #
19
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
20
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21
###############################################################################
23
The media manager dock.
27
from openlp.core.lib import StringContent
29
log = logging.getLogger(__name__)
32
class MediaDockManager(object):
34
Provide a repository for MediaManagerItems
36
def __init__(self, media_dock):
38
Initialise the media dock
40
self.media_dock = media_dock
42
def add_item_to_dock(self, media_item):
44
Add a MediaManagerItem to the dock
45
If the item has been added before, it's silently skipped
47
:param media_item: The item to add to the dock
49
visible_title = media_item.plugin.get_string(StringContent.VisibleName)
50
log.debug('Inserting %s dock' % visible_title['title'])
52
for dock_index in range(self.media_dock.count()):
53
if self.media_dock.widget(dock_index).settings_section == media_item.plugin.name:
57
self.media_dock.addItem(media_item, visible_title['title'])
59
def remove_dock(self, media_item):
61
Removes a MediaManagerItem from the dock
63
:param media_item: The item to add to the dock
65
visible_title = media_item.plugin.get_string(StringContent.VisibleName)
66
log.debug('remove %s dock' % visible_title['title'])
67
for dock_index in range(self.media_dock.count()):
68
if self.media_dock.widget(dock_index):
69
if self.media_dock.widget(dock_index).settings_section == media_item.plugin.name:
70
self.media_dock.widget(dock_index).setVisible(False)
71
self.media_dock.removeItem(dock_index)