Merge lp:~dobey/ubuntuone-installer/install-pages into lp:ubuntuone-installer

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 5
Merged at revision: 6
Proposed branch: lp:~dobey/ubuntuone-installer/install-pages
Merge into: lp:ubuntuone-installer
Diff against target: 299 lines (+210/-37)
2 files modified
ubuntuone/installer/gui.py (+194/-29)
ubuntuone/installer/tests/test_gui.py (+16/-8)
To merge this branch: bzr merge lp:~dobey/ubuntuone-installer/install-pages
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+70346@code.launchpad.net

Commit message

Add the header image, and infrastructure for installing the Ubuntu One packages
Handle doing all the install work and updating the progress bar
Launch the control panel when installation is finished

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good

review: Approve
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'data'
=== added file 'data/header.png'
0Binary files data/header.png 1970-01-01 00:00:00 +0000 and data/header.png 2011-08-03 18:07:09 +0000 differ0Binary files data/header.png 1970-01-01 00:00:00 +0000 and data/header.png 2011-08-03 18:07:09 +0000 differ
=== modified file 'ubuntuone/installer/gui.py'
--- ubuntuone/installer/gui.py 2011-07-29 14:31:29 +0000
+++ ubuntuone/installer/gui.py 2011-08-03 18:07:09 +0000
@@ -15,51 +15,216 @@
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16"""The GUI of the Ubuntu One Installer."""16"""The GUI of the Ubuntu One Installer."""
1717
18from gi.repository import Gtk18import aptdaemon.gtk3widgets as aptgtk
1919import aptdaemon.client as aptclient
2020import os
21class Window(Gtk.Dialog):21
22from gi.repository import Gtk, GObject, GLib, Gdk
23
24# Some shenanigans to deal with pyflakes complaining
25inline_callbacks = None
26try:
27 from defer import inline_callbacks
28except ImportError:
29 from aptdaemon.defer import inline_callbacks as old_callbacks
30
31if inline_callbacks is None:
32 inline_callbacks = old_callbacks
33
34
35class Window(Gtk.Window):
22 """The main dialog to use."""36 """The main dialog to use."""
2337
38 __gsignals__ = {'response': (GObject.SIGNAL_RUN_LAST,
39 GObject.TYPE_NONE,
40 (GObject.TYPE_INT,)),
41 }
42
24 def __init__(self):43 def __init__(self):
25 Gtk.Dialog.__init__(self)44 Gtk.Window.__init__(self)
26 self.set_title('Ubuntu One')45 self.set_title('Ubuntu One')
27 self.set_default_size(800, 480)46 self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
28 self.notebook = Gtk.Notebook()47 self.set_position(Gtk.WindowPosition.CENTER)
29 self.notebook.set_show_tabs(False)48
30 self.notebook.set_show_border(False)49 vbox = Gtk.VBox()
31 self.notebook.set_scrollable(False)50 self.add(vbox)
32 self.notebook.popup_disable()51 vbox.show()
3352
34 self.get_content_area().add(self.notebook)53 self.__header = Gtk.Image()
35 self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,54 self.__header.set_size_request(734, 162)
36 "Install", Gtk.ResponseType.OK)55 vbox.pack_start(self.__header, False, False, 0)
3756 self.__header.show()
38 self.set_default_response(Gtk.ResponseType.OK)57
39 # No functionality yet.58 header = self.__find_data_file('header.png')
40 self.get_widget_for_response(Gtk.ResponseType.OK).set_sensitive(False)59 if header:
60 self.__header.set_from_file(header)
61
62 self.__notebook = Gtk.Notebook()
63 self.__notebook.set_show_tabs(False)
64 self.__notebook.set_show_border(False)
65 self.__notebook.set_scrollable(False)
66 self.__notebook.popup_disable()
67 self.__notebook.set_size_request(734, 240)
68
69 self.__info_page = self.__construct_info_page()
70 self.__notebook.append_page(self.__info_page, None)
71 self.__info_page.show()
72
73 # Our progressbar widget
74 self.__apt_progress = aptgtk.AptProgressBar()
75
76 self.__progress_page = self.__construct_progress_page()
77 self.__notebook.append_page(self.__progress_page, None)
78 self.__progress_page.show()
79
80 vbox.add(self.__notebook)
81 self.__notebook.show()
82
83 self.__action_area = Gtk.HButtonBox()
84 self.__action_area.set_border_width(12)
85 self.__action_area.set_spacing(12)
86 self.__action_area.set_layout(Gtk.ButtonBoxStyle.END)
87 vbox.pack_end(self.__action_area, False, True, 0)
88 self.__action_area.show()
89
90 self.__cancel_button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
91 self.__cancel_button.connect('clicked', lambda x: self.emit(
92 'response', Gtk.ResponseType.CANCEL))
93 self.__action_area.add(self.__cancel_button)
94 self.__cancel_button.show()
95
96 self.__main_button = Gtk.Button.new_with_mnemonic(
97 'I_nstall Ubuntu One')
98 self.__main_button.set_image(Gtk.Image.new_from_stock(
99 Gtk.STOCK_OK, Gtk.IconSize.BUTTON))
100 self.__main_button.connect('clicked', lambda x: self.emit(
101 'response', Gtk.ResponseType.OK))
102 self.__action_area.add(self.__main_button)
103 self.__main_button.grab_focus()
104 self.__main_button.show()
41105
42 self.connect('destroy', self.destroyed)106 self.connect('destroy', self.destroyed)
43 self.connect('response', self.__response)107 self.connect('response', self.__got_response)
44 self.notebook.connect('switch-page', self.__page_switched)108 self.connect('delete-event', lambda x, y: self.emit(
45109 'response', Gtk.ResponseType.DELETE_EVENT))
46 def __page_switched(self, notebook, page, page_num):110
47 """Handle the notebook page changing."""111 self.client = aptclient.AptClient()
48112
49 def __response(self, dialog, response):113 def __find_data_file(self, filename):
114 """Find the full path for the specified data file."""
115 path = os.path.join(os.getcwd(), 'data', filename)
116 if os.path.exists(path):
117 return path
118
119 path = os.path.join(os.getcwd(), os.path.pardir, 'data', filename)
120 if os.path.exists(path):
121 return os.path.abspath(path)
122
123 for folder in GLib.get_system_data_dirs():
124 path = os.path.join(folder, 'ubuntuone-installer', filename)
125 if os.path.exists(path):
126 return path
127
128 def __got_response(self, dialog, response):
50 """Handle the dialog response actions."""129 """Handle the dialog response actions."""
51 if response in [Gtk.ResponseType.CANCEL,130 if response in [Gtk.ResponseType.CANCEL,
52 Gtk.ResponseType.DELETE_EVENT]:131 Gtk.ResponseType.DELETE_EVENT]:
53 self.destroy()132 self.destroy()
54 Gtk.main_quit()133 Gtk.main_quit()
55 return134 return
56135 elif response == Gtk.ResponseType.OK:
57 self.notebook.next_page()136 self.__do_install()
137
138 def __construct_info_page(self):
139 """Build the initial info page."""
140 page = Gtk.VBox()
141 page.set_border_width(12)
142 page.show()
143
144 label = Gtk.Label('')
145 page.add(label)
146 label.show()
147
148 return page
149
150 def __construct_progress_page(self):
151 """Build the install progress page."""
152 page = Gtk.VBox()
153 page.set_border_width(12)
154 page.show()
155
156 page.pack_start(self.__apt_progress, True, False, 0)
157 self.__apt_progress.show()
158
159 return page
160
161 def __get_series(self):
162 """Get the series we're running on."""
163 return 'natty'
164
165 def __got_error(self, error):
166 """Got an error trying to set up Ubuntu One."""
167 Gtk.main_quit()
168
169 @inline_callbacks
170 def __install_u1(self, *args, **kwargs):
171 """Install the packages."""
172 self.__apt_progress.set_fraction(0.0)
173
174 def finished(*args, **kwargs):
175 GLib.spawn_command_line_async('ubuntuone-control-panel-gtk')
176 Gtk.main_quit()
177
178 transaction = yield self.client.install_packages(
179 package_names=['ubuntuone-control-panel-gtk',
180 ])
181 transaction.connect('finished', finished)
182 self.__apt_progress.set_transaction(transaction)
183 transaction.run()
184
185 @inline_callbacks
186 def __update_cache(self, *args, **kwargs):
187 """Update the cache."""
188 self.__apt_progress.set_fraction(0.0)
189 transaction = yield self.client.update_cache(
190 sources_list='ubuntuone-stable-ppa.list')
191 transaction.connect('finished', self.__install_u1)
192 self.__apt_progress.set_transaction(transaction)
193 transaction.run()
194
195 @inline_callbacks
196 def __add_stable_ppa(self):
197 """Add the Ubuntu One 'stable' PPA to apt."""
198 transaction = yield self.client.add_repository(
199 src_type='deb',
200 uri='http://ppa.launchpad.net/ubuntuone/stable/ubuntu',
201 dist=self.__get_series(),
202 comps=['main'],
203 comment='added by Ubuntu One installer',
204 sourcesfile='ubuntuone-stable-ppa.list')
205 transaction.connect('finished', self.__update_cache)
206 self.__apt_progress.set_transaction(transaction)
207 transaction.run()
208
209 def __do_install(self):
210 """Do the install."""
211 # Hide the buttons
212 self.__cancel_button.hide()
213 self.__main_button.hide()
214
215 # Switch to the progress page
216 self.__notebook.set_current_page(1)
217
218 self.__add_stable_ppa()
58219
59 @property220 @property
60 def active_page(self):221 def active_page(self):
61 """Get the active page."""222 """Get the active page."""
62 return self.notebook.get_current_page()223 return self.__notebook.get_current_page()
224
225 def response(self, response):
226 """Emit the response signal with the value response."""
227 self.emit('response', int(response))
63228
64 def run(self):229 def run(self):
65 """Show the dialog and do what's necessary."""230 """Show the dialog and do what's necessary."""
66231
=== modified file 'ubuntuone/installer/tests/test_gui.py'
--- ubuntuone/installer/tests/test_gui.py 2011-07-29 14:31:29 +0000
+++ ubuntuone/installer/tests/test_gui.py 2011-08-03 18:07:09 +0000
@@ -15,13 +15,12 @@
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16"""Tests for the GUI of the Ubuntu One Installer."""16"""Tests for the GUI of the Ubuntu One Installer."""
1717
18import unittest
19
20from gi.repository import Gtk18from gi.repository import Gtk
19from ubuntuone.devtools.testcase import DBusTestCase
21from ubuntuone.installer import gui20from ubuntuone.installer import gui
2221
2322
24class GUITestCase(unittest.TestCase):23class GUITestCase(DBusTestCase):
25 """Main class tests."""24 """Main class tests."""
2625
27 def setUp(self):26 def setUp(self):
@@ -32,12 +31,21 @@
32 def tearDown(self):31 def tearDown(self):
33 self.dlg.destroy()32 self.dlg.destroy()
3433
35 def test_response(self):34 def test_response_cancel(self):
36 """Test the response callback."""35 """Test the response callback."""
37 self.dlg.response(Gtk.ResponseType.CLOSE)36 self.dlg.response(Gtk.ResponseType.CANCEL)
3837
39 def test_page_switched(self):38 def test_page_switched(self):
40 """Test the page switching."""39 """Test the page switching."""
41 self.assertEquals(self.dlg.active_page, -1)40 #self.assertEquals(self.dlg.active_page, 0)
42 self.dlg.response(Gtk.ResponseType.OK)41 self.dlg.response(Gtk.ResponseType.OK)
43 self.assertEquals(self.dlg.active_page, -1)42 self.assertEquals(self.dlg.active_page, 1)
43
44 def test_initial_page(self):
45 """Test the initial info page."""
46 self.assertEquals(self.dlg.active_page, 0)
47
48 def test_progress_page(self):
49 """Test the install progresss page."""
50 self.dlg.response(Gtk.ResponseType.OK)
51 self.assertEquals(self.dlg.active_page, 1)

Subscribers

People subscribed via source and target branches

to all changes: