~didrocks/ubuntuone-client/use_result_var

« back to all changes in this revision

Viewing changes to ubuntuone/platform/linux/unity.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-02-23 18:34:09 UTC
  • mfrom: (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110223183409-535o7yo165wbjmca
Tags: 1.5.5-0ubuntu1
* New upstream release.
  - Subscribing to a RO share will not download content (LP: #712528)
  - Can't synchronize "~/Ubuntu One Music" (LP: #714976)
  - Syncdaemon needs to show progress in Unity launcher (LP: #702116)
  - Notifications say "your cloud" (LP: #715887)
  - No longer requires python-libproxy
  - Recommend unity and indicator libs by default

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ubuntuone.platform.linux.unity
 
2
#
 
3
# Author: Alejandro J. Cura <alecu@canonical.com>
 
4
#
 
5
# Copyright 2011 Canonical Ltd.
 
6
#
 
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.
 
10
#
 
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.
 
15
#
 
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."""
 
19
 
 
20
import gio
 
21
 
 
22
try:
 
23
    from gi.repository import Unity
 
24
    use_libunity = True
 
25
except ImportError:
 
26
    use_libunity = False
 
27
 
 
28
U1_DOTDESKTOP = "ubuntuone-control-panel-gtk.desktop"
 
29
EMBLEM_IMPORTANT = "emblem-important"
 
30
 
 
31
 
 
32
class UbuntuOneLauncherUnity(object):
 
33
    """The Ubuntu One launcher icon."""
 
34
 
 
35
    def __init__(self):
 
36
        """Initialize this instance."""
 
37
        self.entry = Unity.LauncherEntry.get_for_desktop_id(U1_DOTDESKTOP)
 
38
 
 
39
    def show_progressbar(self):
 
40
        """The progressbar is shown."""
 
41
        self.entry.props.progress_visible = True
 
42
 
 
43
    def hide_progressbar(self):
 
44
        """The progressbar is hidden."""
 
45
        self.entry.props.progress_visible = False
 
46
 
 
47
    def set_progress(self, value):
 
48
        """The progressbar value is changed."""
 
49
        self.entry.props.progress = value
 
50
 
 
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
 
55
 
 
56
    def hide_emblem(self):
 
57
        """Hide the current emblem."""
 
58
        self.entry.props.emblem_visible = False
 
59
 
 
60
 
 
61
class DummyLauncher(object):
 
62
    """A dummy launcher icon."""
 
63
 
 
64
    def __init__(self):
 
65
        """Initialize this instance."""
 
66
 
 
67
    def show_progressbar(self):
 
68
        """The progressbar is shown."""
 
69
 
 
70
    def hide_progressbar(self):
 
71
        """The progressbar is hidden."""
 
72
 
 
73
    def set_progress(self, value):
 
74
        """The progressbar value is changed."""
 
75
 
 
76
    def show_warning_emblem(self):
 
77
        """Show a warning emblem."""
 
78
 
 
79
    def hide_emblem(self):
 
80
        """Hide the current emblem."""
 
81
 
 
82
 
 
83
UbuntuOneLauncher = UbuntuOneLauncherUnity if use_libunity else DummyLauncher