~thisfred/ubuntuone-client/lp-702055

« back to all changes in this revision

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

  • Committer: eric.casteleijn at canonical
  • Date: 2011-02-08 22:12:36 UTC
  • Revision ID: eric.casteleijn@canonical.com-20110208221236-rkoe17g24gx0bh04
moved the callback and the reference to the udf message up, to simplify the code a bit

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        indicator.hide()
44
44
 
45
45
 
 
46
# pylint: disable=W0613
 
47
def open_volumes(the_indicator, message_time=None):
 
48
    """Open the control panel to the shares tab."""
 
49
    subprocess.Popen(
 
50
        ['ubuntuone-control-panel-gtk', '--switch-to', 'volumes'])
 
51
    hide_message(the_indicator)
 
52
# pylint: enable=W0613
 
53
 
 
54
 
46
55
class Messaging(AbstractMessaging):
47
56
    """Notification of the end user."""
48
57
 
61
70
                     message_count=None, icon=None):
62
71
        """Show a message in the messaging menu."""
63
72
        if USE_INDICATE:
64
 
            if message_count and sender in self.indicators:
65
 
                self.update_count(sender, message_count)
66
 
                return
67
 
            indicator = self.indicators[sender] = indicate.Indicator()
 
73
            indicator = indicate.Indicator()
68
74
            indicator.set_property("subtype", "u1")
69
75
            indicator.set_property("name", sender)
70
76
            indicator.set_property("sender", sender)
71
77
 
72
 
            # pylint: disable=W0613
73
 
            def open_volumes(the_indicator, message_time=None):
74
 
                """Open the control panel to the shares tab."""
75
 
                hide_message(the_indicator)
76
 
                del self.indicators[sender]
77
 
                subprocess.Popen(
78
 
                    ['ubuntuone-control-panel-gtk', '--switch-to', 'volumes'])
79
 
            # pylint: enable=W0613
80
 
 
81
78
            if callback is None:
82
79
                callback = open_volumes
83
80
            indicator.connect("user-display", callback)
96
93
            return indicator
97
94
    # pylint: enable=R0913
98
95
 
99
 
    def update_count(self, sender, add_count):
 
96
    def update_count(self, indicator, add_count):
100
97
        """Update the count for an existing indicator."""
101
 
        indicator = self.indicators.get(sender)
102
 
        if indicator is not None:
103
 
            new_count = int(indicator.get_property("count")) + add_count
104
 
            indicator.set_property("count", str(new_count))
 
98
        if USE_INDICATE:
 
99
            new_count = int(indicator.get_property('count')) + add_count
 
100
            indicator.set_property('count', str(new_count))