1# Copyright (C) 2009-2010 Mathias Brodala
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2, or (at your option)
6# any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17import os.path
18
19from xl import providers
20from xl.nls import gettext as _
21from xlgui import icons
22from xlgui.preferences import widgets
23
24name = _('Mini Mode')
25basedir = os.path.dirname(os.path.realpath(__file__))
26ui = os.path.join(basedir, "minimode_preferences.ui")
27icons.MANAGER.add_icon_name_from_directory(
28    'exaile-minimode', os.path.join(basedir, 'icons')
29)
30icon = 'exaile-minimode'
31
32
33class AlwaysOnTopPreference(widgets.CheckPreference):
34    name = 'plugin/minimode/always_on_top'
35    default = True
36
37
38class ShowInPanelPreference(widgets.CheckPreference):
39    name = 'plugin/minimode/show_in_panel'
40    default = False
41
42
43class OnAllDesktopsPreference(widgets.CheckPreference):
44    name = 'plugin/minimode/on_all_desktops'
45    default = True
46
47
48class ButtonInMainWindowPreference(widgets.CheckPreference):
49    name = 'plugin/minimode/button_in_mainwindow'
50    default = False
51
52
53class DisplayWindowDecorationsPreference(widgets.CheckPreference):
54    name = 'plugin/minimode/display_window_decorations'
55    default = True
56
57
58class WindowDecorationTypePreference(widgets.ComboPreference, widgets.CheckConditional):
59    name = 'plugin/minimode/window_decoration_type'
60    default = 'full'
61    condition_preference_name = 'plugin/minimode/display_window_decorations'
62
63    def __init__(self, preferences, widget):
64        widgets.ComboPreference.__init__(self, preferences, widget)
65        widgets.CheckConditional.__init__(self)
66
67
68class UseAlphaTransparencyPreference(widgets.CheckPreference):
69    default = False
70    name = 'plugin/minimode/use_alpha'
71
72
73class TransparencyPreference(widgets.ScalePreference, widgets.CheckConditional):
74    default = 0.3
75    name = 'plugin/minimode/transparency'
76    condition_preference_name = 'plugin/minimode/use_alpha'
77
78    def __init__(self, preferences, widget):
79        widgets.ScalePreference.__init__(self, preferences, widget)
80        widgets.CheckConditional.__init__(self)
81
82
83class SelectedControlsPreference(widgets.SelectionListPreference):
84    name = 'plugin/minimode/selected_controls'
85    default = [
86        'previous',
87        'play_pause',
88        'next',
89        'playlist_button',
90        'progress_bar',
91        'restore',
92    ]
93
94    def __init__(self, preferences, widget):
95        self.items = [
96            self.Item(p.name, p.title, p.description, p.fixed)
97            for p in providers.get('minimode-controls')
98        ]
99        widgets.SelectionListPreference.__init__(self, preferences, widget)
100
101
102class TrackTitleFormatPreference(widgets.ComboEntryPreference):
103    name = 'plugin/minimode/track_title_format'
104    completion_items = {
105        '$tracknumber': _('Track number'),
106        '$title': _('Title'),
107        '$artist': _('Artist'),
108        '$composer': _('Composer'),
109        '$album': _('Album'),
110        '$__length': _('Length'),
111        '$discnumber': _('Disc number'),
112        '$__rating': _('Rating'),
113        '$date': _('Date'),
114        '$genre': _('Genre'),
115        '$bitrate': _('Bitrate'),
116        '$__loc': _('Location'),
117        '$filename': _('Filename'),
118        '$__playcount': _('Play count'),
119        '$__last_played': _('Last played'),
120        '$bpm': _('BPM'),
121    }
122    preset_items = [
123        # TRANSLATORS: Mini mode track selector title preset
124        _('$tracknumber - $title'),
125        # TRANSLATORS: Mini mode track selector title preset
126        _('$title by $artist'),
127        # TRANSLATORS: Mini mode track selector title preset
128        _('$title ($__length)'),
129    ]
130    default = _('$tracknumber - $title')
131