1
# ubuntuone.platform.linux.unity
3
# Author: Alejandro J. Cura <alecu@canonical.com>
5
# Copyright 2011 Canonical Ltd.
7
# This program is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License version 3, as published
9
# by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
# PURPOSE. See the GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License along
17
# with this program. If not, see <http://www.gnu.org/licenses/>.
18
"""Use libunity to show a progressbar and emblems on the launcher icon."""
23
from gi.repository import Unity
28
U1_DOTDESKTOP = "ubuntuone-control-panel-gtk.desktop"
29
EMBLEM_IMPORTANT = "emblem-important"
32
class UbuntuOneLauncherUnity(object):
33
"""The Ubuntu One launcher icon."""
36
"""Initialize this instance."""
37
self.entry = Unity.LauncherEntry.get_for_desktop_id(U1_DOTDESKTOP)
39
def show_progressbar(self):
40
"""The progressbar is shown."""
41
self.entry.props.progress_visible = True
43
def hide_progressbar(self):
44
"""The progressbar is hidden."""
45
self.entry.props.progress_visible = False
47
def set_progress(self, value):
48
"""The progressbar value is changed."""
49
self.entry.props.progress = value
51
def show_warning_emblem(self):
52
"""Show a warning emblem."""
53
self.entry.props.emblem = gio.ThemedIcon(EMBLEM_IMPORTANT)
54
self.entry.props.emblem_visible = True
56
def hide_emblem(self):
57
"""Hide the current emblem."""
58
self.entry.props.emblem_visible = False
61
class DummyLauncher(object):
62
"""A dummy launcher icon."""
65
"""Initialize this instance."""
67
def show_progressbar(self):
68
"""The progressbar is shown."""
70
def hide_progressbar(self):
71
"""The progressbar is hidden."""
73
def set_progress(self, value):
74
"""The progressbar value is changed."""
76
def show_warning_emblem(self):
77
"""Show a warning emblem."""
79
def hide_emblem(self):
80
"""Hide the current emblem."""
83
UbuntuOneLauncher = UbuntuOneLauncherUnity if use_libunity else DummyLauncher