Merge lp:~mterry/update-manager/requires-restart into lp:update-manager

Proposed by Michael Terry
Status: Merged
Merged at revision: 2660
Proposed branch: lp:~mterry/update-manager/requires-restart
Merge into: lp:update-manager
Diff against target: 207 lines (+87/-20)
2 files modified
UpdateManager/UpdatesAvailable.py (+42/-15)
data/gtkbuilder/UpdateManager.ui (+45/-5)
To merge this branch: bzr merge lp:~mterry/update-manager/requires-restart
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+152723@code.launchpad.net

Description of the change

Add label to warn the user when a selected update will need a restart.

From https://wiki.ubuntu.com/SoftwareUpdates#Presenting_installable_updates

(No packages currently have the right metadata -- so you'll have to manually edit pkg_requires_restart() to return True for a given package to test it.)

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Looks good to me, nice use of "nonlocal "

review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :

hum, is there any reason that didn't get merged? it seems it needs to be rebased now, would be nice to get in for the LTS

2618. By Michael Terry

Merge from trunk

Revision history for this message
Michael Terry (mterry) wrote :

I think it didn't get in because it was too close to release at the time.

I've updated this again for trunk. Merge it in if you still like it!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/UpdatesAvailable.py'
2--- UpdateManager/UpdatesAvailable.py 2013-08-30 21:47:35 +0000
3+++ UpdateManager/UpdatesAvailable.py 2013-12-31 19:08:39 +0000
4@@ -261,6 +261,9 @@
5 self.store = Gtk.TreeStore(str, GObject.TYPE_PYOBJECT, str, bool)
6 self.treeview_update.set_model(None)
7
8+ self.image_restart.set_from_gicon(self.get_restart_icon(),
9+ Gtk.IconSize.BUTTON)
10+
11 restart_icon_renderer = Gtk.CellRendererPixbuf()
12 restart_icon_renderer.set_property("xpad", 4)
13 restart_icon_renderer.set_property("ypad", 2)
14@@ -381,36 +384,39 @@
15 self.select_all_upgrades(None)
16 self.on_button_install_clicked()
17
18+ def pkg_requires_restart(self, pkg):
19+ if pkg is None or pkg.candidate is None:
20+ return False
21+ restart_condition = pkg.candidate.record.get('XB-Restart-Required')
22+ return restart_condition == 'system'
23+
24+ def get_restart_icon(self):
25+ # FIXME: Non-standard, incorrect icon name (from app category).
26+ # Theme support for what we want seems to be lacking.
27+ restart_icon_names = ['view-refresh-symbolic',
28+ 'system-restart',
29+ 'system-reboot']
30+ return Gio.ThemedIcon.new_from_names(restart_icon_names)
31+
32 def restart_icon_renderer_data_func(self, cell_layout, renderer, model,
33 iter, user_data):
34- def pkg_requires_restart(pkg):
35- if pkg is None or pkg.candidate is None:
36- return False
37- restart_condition = pkg.candidate.record.get(
38- 'XB-Restart-Required')
39- return restart_condition == 'system'
40-
41 data = model.get_value(iter, LIST_UPDATE_DATA)
42 path = model.get_path(iter)
43
44 requires_restart = False
45 if data.item and data.item.pkg:
46- requires_restart = pkg_requires_restart(data.item.pkg)
47+ requires_restart = self.pkg_requires_restart(data.item.pkg)
48 elif data.group:
49 if not self.treeview_update.row_expanded(path):
50 # A package in the group requires restart
51 for group_item in data.group.items:
52- if group_item.pkg and pkg_requires_restart(group_item.pkg):
53+ if group_item.pkg and self.pkg_requires_restart(
54+ group_item.pkg):
55 requires_restart = True
56 break
57
58- # FIXME: Non-standard, incorrect icon name (from app category).
59- # Theme support for what we want seems to be lacking.
60 if requires_restart:
61- restart_icon_names = ['view-refresh-symbolic',
62- 'system-restart',
63- 'system-reboot']
64- gicon = Gio.ThemedIcon.new_from_names(restart_icon_names)
65+ gicon = self.get_restart_icon()
66 else:
67 gicon = None
68 renderer.set_property("gicon", gicon)
69@@ -694,6 +700,26 @@
70 model.set_value(iter, LIST_TOGGLE_ACTIVE, active)
71 self.store.foreach(foreach_cb, None)
72
73+ def _check_for_required_restart(self):
74+ requires_restart = False
75+
76+ def foreach_cb(model, path, iter, data):
77+ data = model.get_value(iter, LIST_UPDATE_DATA)
78+ active = model.get_value(iter, LIST_TOGGLE_ACTIVE)
79+ if not active:
80+ return
81+ pkg = None
82+ if data.item:
83+ pkg = data.item.pkg
84+ elif data.group and data.group.core_item:
85+ pkg = data.group.core_item.pkg
86+ if pkg and self.pkg_requires_restart(pkg):
87+ nonlocal requires_restart
88+ requires_restart = True
89+
90+ self.store.foreach(foreach_cb, None)
91+ self.hbox_restart.set_visible(requires_restart)
92+
93 def _refresh_updates_count(self):
94 self.button_install.set_sensitive(self.cache.install_count)
95 try:
96@@ -737,6 +763,7 @@
97
98 def updates_changed(self):
99 self._mark_selected_updates()
100+ self._check_for_required_restart()
101 self._refresh_updates_count()
102
103 def update_count(self):
104
105=== modified file 'data/gtkbuilder/UpdateManager.ui'
106--- data/gtkbuilder/UpdateManager.ui 2013-11-28 11:20:13 +0000
107+++ data/gtkbuilder/UpdateManager.ui 2013-12-31 19:08:39 +0000
108@@ -15,8 +15,8 @@
109 <object class="GtkVBox" id="vbox4">
110 <property name="visible">True</property>
111 <property name="can_focus">False</property>
112+ <property name="vexpand">True</property>
113 <property name="spacing">6</property>
114- <property name="vexpand">True</property>
115 <child>
116 <object class="GtkScrolledWindow" id="scrolledwindow_update">
117 <property name="visible">True</property>
118@@ -37,6 +37,9 @@
119 </child>
120 <signal name="cursor-changed" handler="on_treeview_update_cursor_changed" swapped="no"/>
121 <signal name="row-activated" handler="on_treeview_update_row_activated" swapped="no"/>
122+ <child internal-child="selection">
123+ <object class="GtkTreeSelection" id="treeview-selection1"/>
124+ </child>
125 </object>
126 </child>
127 </object>
128@@ -209,6 +212,43 @@
129 </packing>
130 </child>
131 <child>
132+ <object class="GtkHBox" id="hbox_restart">
133+ <property name="can_focus">False</property>
134+ <property name="spacing">12</property>
135+ <child>
136+ <object class="GtkImage" id="image_restart">
137+ <property name="visible">True</property>
138+ <property name="can_focus">False</property>
139+ <property name="icon_name">gtk-refresh</property>
140+ </object>
141+ <packing>
142+ <property name="expand">False</property>
143+ <property name="fill">True</property>
144+ <property name="position">0</property>
145+ </packing>
146+ </child>
147+ <child>
148+ <object class="GtkLabel" id="label_restart">
149+ <property name="visible">True</property>
150+ <property name="can_focus">False</property>
151+ <property name="xalign">0</property>
152+ <property name="label" translatable="yes">The computer will need to restart.</property>
153+ <property name="wrap">True</property>
154+ </object>
155+ <packing>
156+ <property name="expand">True</property>
157+ <property name="fill">True</property>
158+ <property name="position">1</property>
159+ </packing>
160+ </child>
161+ </object>
162+ <packing>
163+ <property name="expand">False</property>
164+ <property name="fill">False</property>
165+ <property name="position">1</property>
166+ </packing>
167+ </child>
168+ <child>
169 <object class="GtkHBox" id="hbox_roaming">
170 <property name="can_focus">False</property>
171 <property name="spacing">12</property>
172@@ -242,7 +282,7 @@
173 <packing>
174 <property name="expand">False</property>
175 <property name="fill">False</property>
176- <property name="position">1</property>
177+ <property name="position">2</property>
178 </packing>
179 </child>
180 <child>
181@@ -279,7 +319,7 @@
182 <packing>
183 <property name="expand">False</property>
184 <property name="fill">False</property>
185- <property name="position">2</property>
186+ <property name="position">3</property>
187 </packing>
188 </child>
189 <child>
190@@ -316,7 +356,7 @@
191 <packing>
192 <property name="expand">False</property>
193 <property name="fill">False</property>
194- <property name="position">3</property>
195+ <property name="position">4</property>
196 </packing>
197 </child>
198 <child>
199@@ -352,7 +392,7 @@
200 <packing>
201 <property name="expand">False</property>
202 <property name="fill">False</property>
203- <property name="position">4</property>
204+ <property name="position">5</property>
205 </packing>
206 </child>
207 </object>

Subscribers

People subscribed via source and target branches

to status/vote changes: