Merge lp:~thisfred/ubuntuone-client/fix-server-show into lp:ubuntuone-client

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 892
Merged at revision: 890
Proposed branch: lp:~thisfred/ubuntuone-client/fix-server-show
Merge into: lp:ubuntuone-client
Diff against target: 191 lines (+46/-29)
3 files modified
tests/platform/linux/test_messaging.py (+19/-12)
ubuntuone/platform/linux/messaging.py (+23/-15)
ubuntuone/status/aggregator.py (+4/-2)
To merge this branch: bzr merge lp:~thisfred/ubuntuone-client/fix-server-show
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Alejandro J. Cura (community) Approve
Review via email: mp+50962@code.launchpad.net

Commit message

This adds the correct callback for the server entry in the messaging menu, and calls server.show() only once, rather than every time a message is added.

Description of the change

This adds the correct callback for the server entry in the messaging menu, and calls server.show() only once, rather than every time a message is added.

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Working for me as intended

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

This branch fixes the opening of the control panel when clicking in the messaging entry. I still have 2 entries when syncdaemon is not running.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (31.9 KiB)

The attempt to merge lp:~thisfred/ubuntuone-client/fix-server-show into lp:ubuntuone-client failed. Below is the output from the failed tests.

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
  testing autoconf2.50... not found.
  testing autoconf... found 2.67
checking for automake >= 1.10...
  testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
  testing libtoolize... found 2.2.6b
checking for intltool >= 0.30...
  testing intltoolize... found 0.41.1
checking for pkg-config >= 0.14.0...
  testing pkg-config... found 0.25
checking for gtk-doc >= 1.0...
  testing gtkdocize... found 1.16
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --enable-gtk-doc --enable-debug ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent lib...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/linux/test_messaging.py'
2--- tests/platform/linux/test_messaging.py 2011-02-08 22:12:36 +0000
3+++ tests/platform/linux/test_messaging.py 2011-02-23 23:47:32 +0000
4@@ -22,10 +22,10 @@
5 """
6
7
8-from mocker import Mocker
9+from mocker import Mocker, ANY
10 from twisted.trial.unittest import TestCase
11
12-from ubuntuone.platform.linux.messaging import Messaging, hide_message
13+from ubuntuone.platform.linux.messaging import Messaging, _server_callback
14
15 FAKE_TIME = 123
16 FAKE_TIME2 = 456
17@@ -51,22 +51,24 @@
18
19 # pylint: disable=R0913
20 def _show_message_setup(self, message_time=None, message_count=None,
21- icon=None, update_count=None, hide=False):
22+ icon=None, update_count=None, real_callback=False):
23 """Set up the mocker expectations for show_method."""
24 indicate = self.mocker.replace("indicate")
25 mock_server = self.mocker.mock()
26 indicate.indicate_server_ref_default()
27 self.mocker.result(mock_server)
28+ mock_server.connect('server-display', _server_callback)
29 mock_server.set_type("message.u1")
30 mock_server.set_desktop_file(
31 "/usr/share/applications/ubuntuone-control-panel-gtk.desktop")
32+ mock_server.show()
33 mock_indicator = self.mocker.mock()
34 indicate.Indicator()
35 self.mocker.result(mock_indicator)
36 mock_indicator.set_property("subtype", "u1")
37 mock_indicator.set_property("name", FAKE_SENDER)
38 mock_indicator.set_property("sender", FAKE_SENDER)
39- mock_indicator.connect("user-display", callback)
40+ mock_indicator.connect("user-display", ANY)
41 if icon is not None:
42 mock_indicator.set_property_icon("icon", icon)
43 if message_count is not None:
44@@ -80,15 +82,17 @@
45 else:
46 mock_indicator.set_property_time("time", message_time)
47 mock_indicator.set_property("draw-attention", "true")
48- mock_server.show()
49 if update_count:
50 mock_indicator.get_property("count")
51 self.mocker.result("1200")
52 mock_indicator.set_property("count", '2500')
53- if hide:
54+ mock_indicator.show()
55+ if real_callback:
56+ open_volumes = self.mocker.replace(
57+ "ubuntuone.platform.linux.messaging.open_volumes")
58+ open_volumes()
59 mock_indicator.set_property('draw-attention', 'false')
60 mock_indicator.hide()
61- mock_indicator.show()
62 self.mocker.replay()
63 # pylint: enable=R0913
64
65@@ -124,9 +128,12 @@
66 FAKE_SENDER, callback, message_count=1200)
67 messaging.update_count(indicator, 1300)
68
69- def test_hide_message(self):
70- """On message hide, libnotify receives the proper calls."""
71- self._show_message_setup(hide=True)
72+ def test_callback(self):
73+ """When the callback fires, libnotify receives the proper calls."""
74+ self._show_message_setup(real_callback=True)
75 messaging = Messaging()
76- mock_indicator = messaging.show_message(FAKE_SENDER, callback)
77- hide_message(mock_indicator)
78+ mock_indicator = messaging.show_message(FAKE_SENDER)
79+ self.assertEquals(1, len(messaging.indicators))
80+ actual_callback = messaging.create_callback()
81+ actual_callback(mock_indicator)
82+ self.assertEquals(0, len(messaging.indicators))
83
84=== modified file 'ubuntuone/platform/linux/messaging.py'
85--- ubuntuone/platform/linux/messaging.py 2011-02-08 22:12:36 +0000
86+++ ubuntuone/platform/linux/messaging.py 2011-02-23 23:47:32 +0000
87@@ -36,34 +36,31 @@
88 APPLICATION_NAME = 'Ubuntu One Client'
89
90
91-def hide_message(indicator):
92- """Remove the message once it has been dealt with."""
93- if USE_INDICATE:
94- indicator.set_property("draw-attention", "false")
95- indicator.hide()
96-
97-
98 # pylint: disable=W0613
99-def open_volumes(the_indicator, message_time=None):
100+def open_volumes():
101 """Open the control panel to the shares tab."""
102 subprocess.Popen(
103 ['ubuntuone-control-panel-gtk', '--switch-to', 'volumes'])
104- hide_message(the_indicator)
105+
106+
107+def _server_callback(the_indicator, message_time=None):
108+ """Open the control panel to the shares tab."""
109+ subprocess.Popen(['ubuntuone-control-panel-gtk'])
110 # pylint: enable=W0613
111
112
113 class Messaging(AbstractMessaging):
114 """Notification of the end user."""
115
116- def __init__(self, server_callback=None): # pylint: disable=W0231
117+ def __init__(self, server_callback=_server_callback):
118 if USE_INDICATE:
119- self.indicators = {}
120+ self.indicators = []
121 self.server = indicate.indicate_server_ref_default()
122- if server_callback is not None:
123- self.server.connect("server-display", server_callback)
124+ self.server.connect("server-display", server_callback)
125 self.server.set_type("message.u1")
126 self.server.set_desktop_file(
127 "/usr/share/applications/ubuntuone-control-panel-gtk.desktop")
128+ self.server.show()
129
130 # pylint: disable=R0913
131 def show_message(self, sender, callback=None, message_time=None,
132@@ -76,7 +73,7 @@
133 indicator.set_property("sender", sender)
134
135 if callback is None:
136- callback = open_volumes
137+ callback = self.create_callback()
138 indicator.connect("user-display", callback)
139
140 if icon is not None:
141@@ -88,11 +85,22 @@
142 message_time = time()
143 indicator.set_property_time("time", message_time)
144 indicator.set_property("draw-attention", "true")
145- self.server.show()
146 indicator.show()
147+ self.indicators.append(indicator)
148 return indicator
149 # pylint: enable=R0913
150
151+ def create_callback(self, ):
152+ """Create the callback to be used."""
153+
154+ def callback(indicator, message_time=None): # pylint: disable=W0613
155+ """Callback to be executed when message is clicked."""
156+ open_volumes()
157+ indicator.set_property("draw-attention", "false")
158+ indicator.hide()
159+ self.indicators.remove(indicator)
160+ return callback
161+
162 def update_count(self, indicator, add_count):
163 """Update the count for an existing indicator."""
164 if USE_INDICATE:
165
166=== modified file 'ubuntuone/status/aggregator.py'
167--- ubuntuone/status/aggregator.py 2011-02-23 00:11:12 +0000
168+++ ubuntuone/status/aggregator.py 2011-02-23 23:47:32 +0000
169@@ -30,7 +30,7 @@
170 from ubuntuone.logger import basic_formatter, logging
171 from ubuntuone.platform import session
172 from ubuntuone.platform.notification import Notification
173-from ubuntuone.platform.messaging import Messaging, open_volumes
174+from ubuntuone.platform.messaging import Messaging
175 from ubuntuone.platform.unity import UbuntuOneLauncher
176
177 Q_ = lambda string: gettext.dgettext(GETTEXT_PACKAGE, string)
178@@ -757,10 +757,12 @@
179 self.notification.send_notification(
180 UBUNTUONE_TITLE, UDFAvailableStatus(udf=udf).one())
181
182+ # pylint: disable=W0613
183 def _reset_udf_message_callback(self, indicator, message_time=None):
184 """A callback wrapper that resets the udf_message to None."""
185 self.udf_message = None
186- open_volumes(indicator, message_time=message_time)
187+ self.messaging.create_callback()()
188+ # pylint: enable=W0613
189
190 def server_connection_lost(self):
191 """The client lost the connection to the server."""

Subscribers

People subscribed via source and target branches