Merge lp:~nataliabidart/ubuntuone-control-panel/order-in-the-room into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 59
Merged at revision: 59
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/order-in-the-room
Merge into: lp:ubuntuone-control-panel
Diff against target: 257 lines (+102/-99)
1 file modified
ubuntuone/controlpanel/gtk/gui.py (+102/-99)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/order-in-the-room
Reviewer Review Type Date Requested Status
dobey (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+48641@code.launchpad.net

Commit message

- Use proper mechanism to define object's signals (LP: #713271).

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

works as promised

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
2--- ubuntuone/controlpanel/gtk/gui.py 2011-01-25 17:56:20 +0000
3+++ ubuntuone/controlpanel/gtk/gui.py 2011-02-04 18:59:53 +0000
4@@ -113,9 +113,6 @@
5 gtk.show_uri(None, uri, gtk.gdk.CURRENT_TIME)
6
7
8-gtk.link_button_set_uri_hook(uri_hook)
9-
10-
11 class ControlPanelMixin(object):
12 """The main interface for the Ubuntu One control panel."""
13
14@@ -150,10 +147,6 @@
15
16 logger.debug('%s: started.', self.__class__.__name__)
17
18- def debug(self, *args, **kwargs):
19- """Do some debug."""
20- print '\n', args, kwargs
21-
22 def humanize(self, int_bytes):
23 """Return a human readble string of 'int_bytes'."""
24 return GLib.format_size_for_display(int_bytes)
25@@ -164,89 +157,6 @@
26 label.show()
27
28
29-class ControlPanelWindow(gtk.Window):
30- """The main window for the Ubuntu One control panel."""
31-
32- TITLE = _('%(app_name)s Dashboard')
33-
34- def __init__(self, switch_to=None):
35- super(ControlPanelWindow, self).__init__()
36-
37- self.set_title(self.TITLE % {'app_name': U1_APP_NAME})
38- self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
39- self.set_icon_name('ubuntuone')
40- self.set_size_request(-1, 525) # bug #683164
41-
42- self.connect('delete-event', lambda w, e: gtk.main_quit())
43- self.show()
44-
45- self.control_panel = ControlPanel(main_window=self)
46- self.add(self.control_panel)
47-
48- logger.info('Starting %s pointing at panel: %r.',
49- self.__class__.__name__, switch_to)
50- if switch_to is not None:
51- button = getattr(self.control_panel.management,
52- '%s_button' % switch_to, None)
53- if button is not None:
54- button.clicked()
55- else:
56- logger.warning('Could not start at panel: %r.', switch_to)
57-
58- logger.debug('%s: started (window size %r).',
59- self.__class__.__name__, self.get_size_request())
60-
61- def main(self):
62- """Run the main loop of the widget toolkit."""
63- logger.debug('Starting GTK main loop.')
64- gtk.main()
65-
66-
67-class ControlPanel(gtk.Notebook):
68- """The control panel per se, can be added into any other widget."""
69-
70- # should not be any larger than 736x525
71-
72- def __init__(self, main_window):
73- gtk.Notebook.__init__(self)
74- self.main_window = main_window
75-
76- self.set_show_tabs(False)
77- self.set_show_border(False)
78-
79- self.overview = OverviewPanel(main_window=main_window)
80- self.insert_page(self.overview, position=0)
81-
82- self.management = ManagementPanel(main_window=main_window)
83- self.insert_page(self.management, position=1)
84-
85- self.overview.connect('credentials-found',
86- self.on_show_management_panel)
87- self.management.connect('local-device-removed',
88- self.on_show_overview_panel)
89-
90- self.show()
91- self.on_show_overview_panel()
92-
93- logger.debug('%s: started (window size %r).',
94- self.__class__.__name__, self.get_size_request())
95-
96- def on_show_overview_panel(self, widget=None):
97- """Show the overview panel."""
98- self.set_current_page(0)
99-
100- def on_show_management_panel(self, widget=None,
101- credentials_are_new=False, token=None):
102- """Show the notebook (main panel)."""
103- if self.get_current_page() == 0:
104- self.management.load()
105- if credentials_are_new:
106- # redirect user to volumes page to review subscription
107- self.management.volumes_button.clicked()
108-
109- self.next_page()
110-
111-
112 class UbuntuOneBin(gtk.VBox):
113 """A Ubuntu One bin."""
114
115@@ -305,6 +215,11 @@
116 class OverviewPanel(GreyableBin, ControlPanelMixin):
117 """The overview panel. Introduces Ubuntu One to the not logged user."""
118
119+ __gsignals__ = {
120+ 'credentials-found': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
121+ (gobject.TYPE_BOOLEAN, gobject.TYPE_PYOBJECT)),
122+ }
123+
124 CREDENTIALS_ERROR = _('There was a problem while retrieving the '
125 'credentials.')
126 AUTHORIZATION_DENIED = _('The authentication was cancelled. Please either '
127@@ -819,6 +734,11 @@
128 class DevicesPanel(UbuntuOneBin, ControlPanelMixin):
129 """The devices panel."""
130
131+ __gsignals__ = {
132+ 'local-device-removed': (gobject.SIGNAL_RUN_FIRST,
133+ gobject.TYPE_NONE, ()),
134+ }
135+
136 TITLE = _('The devices synced with your personal cloud are listed below.')
137 NO_DEVICES = _('No devices to show.')
138 CONFIRM_REMOVE = _('Are you sure you want to remove this device '
139@@ -898,6 +818,10 @@
140 class InstallPackage(gtk.VBox, ControlPanelMixin):
141 """A widget to process the install of a package."""
142
143+ __gsignals__ = {
144+ 'finished': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()),
145+ }
146+
147 INSTALL_PACKAGE = _('You need to install the package <i>%(package_name)s'
148 '</i> in order to enable replication.')
149 INSTALLING = _('The package <i>%(package_name)s</i> is being installed, '
150@@ -1340,6 +1264,11 @@
151
152 """
153
154+ __gsignals__ = {
155+ 'local-device-removed': (gobject.SIGNAL_RUN_FIRST,
156+ gobject.TYPE_NONE, ()),
157+ }
158+
159 QUOTA_LABEL = _('%(used)s used of %(total)s (%(percentage).1f%%)')
160
161 def __init__(self, main_window=None):
162@@ -1418,12 +1347,86 @@
163 self._update_quota(WARNING_MARKUP % VALUE_ERROR)
164
165
166-gobject.signal_new('credentials-found', OverviewPanel,
167- gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
168- (gobject.TYPE_BOOLEAN, gobject.TYPE_PYOBJECT))
169-
170-gobject.signal_new('local-device-removed', DevicesPanel,
171- gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
172-
173-gobject.signal_new('finished', InstallPackage,
174- gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
175+class ControlPanel(gtk.Notebook):
176+ """The control panel per se, can be added into any other widget."""
177+
178+ # should not be any larger than 736x525
179+
180+ def __init__(self, main_window):
181+ gtk.Notebook.__init__(self)
182+ gtk.link_button_set_uri_hook(uri_hook)
183+
184+ self.main_window = main_window
185+
186+ self.set_show_tabs(False)
187+ self.set_show_border(False)
188+
189+ self.overview = OverviewPanel(main_window=main_window)
190+ self.insert_page(self.overview, position=0)
191+
192+ self.management = ManagementPanel(main_window=main_window)
193+ self.insert_page(self.management, position=1)
194+
195+ self.overview.connect('credentials-found',
196+ self.on_show_management_panel)
197+ self.management.connect('local-device-removed',
198+ self.on_show_overview_panel)
199+
200+ self.show()
201+ self.on_show_overview_panel()
202+
203+ logger.debug('%s: started (window size %r).',
204+ self.__class__.__name__, self.get_size_request())
205+
206+ def on_show_overview_panel(self, widget=None):
207+ """Show the overview panel."""
208+ self.set_current_page(0)
209+
210+ def on_show_management_panel(self, widget=None,
211+ credentials_are_new=False, token=None):
212+ """Show the notebook (main panel)."""
213+ if self.get_current_page() == 0:
214+ self.management.load()
215+ if credentials_are_new:
216+ # redirect user to volumes page to review subscription
217+ self.management.volumes_button.clicked()
218+
219+ self.next_page()
220+
221+
222+class ControlPanelWindow(gtk.Window):
223+ """The main window for the Ubuntu One control panel."""
224+
225+ TITLE = _('%(app_name)s Dashboard')
226+
227+ def __init__(self, switch_to=None):
228+ super(ControlPanelWindow, self).__init__()
229+
230+ self.set_title(self.TITLE % {'app_name': U1_APP_NAME})
231+ self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
232+ self.set_icon_name('ubuntuone')
233+ self.set_size_request(-1, 525) # bug #683164
234+
235+ self.connect('delete-event', lambda w, e: gtk.main_quit())
236+ self.show()
237+
238+ self.control_panel = ControlPanel(main_window=self)
239+ self.add(self.control_panel)
240+
241+ logger.info('Starting %s pointing at panel: %r.',
242+ self.__class__.__name__, switch_to)
243+ if switch_to is not None:
244+ button = getattr(self.control_panel.management,
245+ '%s_button' % switch_to, None)
246+ if button is not None:
247+ button.clicked()
248+ else:
249+ logger.warning('Could not start at panel: %r.', switch_to)
250+
251+ logger.debug('%s: started (window size %r).',
252+ self.__class__.__name__, self.get_size_request())
253+
254+ def main(self):
255+ """Run the main loop of the widget toolkit."""
256+ logger.debug('Starting GTK main loop.')
257+ gtk.main()

Subscribers

People subscribed via source and target branches