Merge lp:~mvo/software-center/lobby-visual-mvo-workaround-lp1048912 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3193
Proposed branch: lp:~mvo/software-center/lobby-visual-mvo-workaround-lp1048912
Merge into: lp:software-center
Diff against target: 150 lines (+51/-6)
6 files modified
softwarecenter/ui/gtk3/views/lobbyview.py (+13/-0)
softwarecenter/ui/gtk3/widgets/containers.py (+1/-1)
softwarecenter/ui/gtk3/widgets/spinner.py (+7/-4)
tests/gtk3/test_recommendations_widgets.py (+17/-0)
tests/gtk3/test_spinner.py (+12/-0)
tests/gtk3/windows.py (+1/-1)
To merge this branch: bzr merge lp:~mvo/software-center/lobby-visual-mvo-workaround-lp1048912
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+125119@code.launchpad.net

Description of the change

As discussed in the previous irc meeting this branch adds a workaround
for the visual corruption we see when recommendations are turned on.

Once the root cause for bug #1048912 the workaround can be removed,
this is documented in the code. The downside of this patch is additional
queue_draw() commands which is bad but the amount if not huge so the
tradeoff is worthwhile.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Thanks, Michael!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/views/lobbyview.py'
2--- softwarecenter/ui/gtk3/views/lobbyview.py 2012-09-17 15:17:48 +0000
3+++ softwarecenter/ui/gtk3/views/lobbyview.py 2012-09-19 07:42:38 +0000
4@@ -275,8 +275,21 @@
5 self.recommended_for_you_panel.connect(
6 'more-button-clicked',
7 self.on_category_clicked)
8+ # until bug #1048912 with the testcase in
9+ # tests/gtk3/test_lp1048912.py
10+ # is fixed this workaround for the drawing code in FramedHeaderBox
11+ # is needed
12+ self.recommended_for_you_panel.connect(
13+ "size-allocate", self._on_recommended_for_you_panel_size_allocate)
14 self.right_column.pack_start(self.recommended_for_you_panel,
15 True, True, 0)
16+
17+ def _on_recommended_for_you_panel_size_allocate(self, rec_panel, stuff):
18+ """This workaround can go once the root cause for bug #1048912 is
19+ found, see also tests/gtk3/test_lp1048912.py
20+ """
21+ #print ">>> called on_recommended_for_you_panel_size_allocate"
22+ self.queue_draw()
23
24 def _append_recommended_for_you(self):
25 # update will (re)create the widget from scratch
26
27=== modified file 'softwarecenter/ui/gtk3/widgets/containers.py'
28--- softwarecenter/ui/gtk3/widgets/containers.py 2012-09-12 02:21:03 +0000
29+++ softwarecenter/ui/gtk3/widgets/containers.py 2012-09-19 07:42:38 +0000
30@@ -82,7 +82,7 @@
31
32 # overrides
33 def do_get_request_mode(self):
34- return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH
35+ return Gtk.SizeRequestMode.WIDTH_FOR_HEIGHT
36
37 def do_get_preferred_height_for_width(self, width):
38 old = self.get_allocation()
39
40=== modified file 'softwarecenter/ui/gtk3/widgets/spinner.py'
41--- softwarecenter/ui/gtk3/widgets/spinner.py 2012-08-28 16:34:54 +0000
42+++ softwarecenter/ui/gtk3/widgets/spinner.py 2012-09-19 07:42:38 +0000
43@@ -2,6 +2,7 @@
44 #
45 # Authors:
46 # Gary Lasker
47+# Natalia Bidart
48 #
49 # This program is free software; you can redistribute it and/or modify it under
50 # the terms of the GNU General Public License as published by the Free Software
51@@ -111,11 +112,13 @@
52 """ show the spinner page with a alternative message """
53 if msg:
54 self.spinner_view.set_text(msg)
55- # "mask" the spinner view momentarily to prevent it from flashing into
56+ # delay showing the spinner view prevent it from flashing into
57 # view in the case of short delays where it isn't actually needed
58- self.spinner_view.stop_and_hide()
59- self._last_timeout_id = GObject.timeout_add(250,
60- self._unmask_view_spinner)
61+ # (but only if its not already visible anyway)
62+ if self.get_current_page() == self.CONTENT_PAGE:
63+ self.spinner_view.stop_and_hide()
64+ self._last_timeout_id = GObject.timeout_add(
65+ 250, self._unmask_view_spinner)
66
67 def hide_spinner(self):
68 """ hide the spinner page again and show the content page """
69
70=== modified file 'tests/gtk3/test_recommendations_widgets.py'
71--- tests/gtk3/test_recommendations_widgets.py 2012-05-30 18:39:55 +0000
72+++ tests/gtk3/test_recommendations_widgets.py 2012-09-19 07:42:38 +0000
73@@ -1,5 +1,10 @@
74 import unittest
75
76+from gi.repository import (
77+ GObject,
78+ Gtk,
79+ )
80+
81 from tests.utils import setup_test_env
82 setup_test_env()
83
84@@ -9,19 +14,31 @@
85 # FIXME: the code from test_catview that tests the lobby widget should
86 # move here as it should be fine to test it in isolation
87
88+TIMEOUT=300
89 class TestRecommendationsWidgets(unittest.TestCase):
90
91+ def _on_size_allocate(self, widget, allocation):
92+ print widget, allocation.width, allocation.height
93+
94 def test_recommendations_lobby(self):
95 win = get_test_window_recommendations(panel_type="lobby")
96+ child = win.get_children()[0]
97+ child.connect("size-allocate", self._on_size_allocate)
98 self.addCleanup(win.destroy)
99+ GObject.timeout_add(TIMEOUT, Gtk.main_quit)
100+ Gtk.main()
101
102 def test_recommendations_category(self):
103 win = get_test_window_recommendations(panel_type="category")
104 self.addCleanup(win.destroy)
105+ GObject.timeout_add(TIMEOUT, Gtk.main_quit)
106+ Gtk.main()
107
108 def test_recommendations_details(self):
109 win = get_test_window_recommendations(panel_type="details")
110 self.addCleanup(win.destroy)
111+ GObject.timeout_add(TIMEOUT, Gtk.main_quit)
112+ Gtk.main()
113
114
115 if __name__ == "__main__":
116
117=== modified file 'tests/gtk3/test_spinner.py'
118--- tests/gtk3/test_spinner.py 2012-08-28 16:34:54 +0000
119+++ tests/gtk3/test_spinner.py 2012-09-19 07:42:38 +0000
120@@ -99,6 +99,18 @@
121 self.assertTrue(self.obj.spinner_view.spinner.get_visible())
122 self.assertEqual(self.obj.get_current_page(), self.obj.SPINNER_PAGE)
123
124+ def test_show_spinner_twice(self):
125+ """The spinner is not hiden/shown if its already visible."""
126+ with patch.object(self.obj.spinner_view, "stop_and_hide") as m:
127+ with patch.object(spinner.GObject, 'timeout_add',
128+ lambda t,f: f()):
129+ self.obj.show_spinner("meep")
130+ self.obj.show_spinner("baap")
131+ # ensure that it only called the hide once
132+ self.assertEqual(m.call_count, 1)
133+ # and that it updated the text
134+ self.assertEqual(self.obj.spinner_view.get_text(), "baap")
135+
136 def test_show_spinner_with_msg(self):
137 """The spinner is shown with the given message."""
138 message = 'Something I want to show'
139
140=== modified file 'tests/gtk3/windows.py'
141--- tests/gtk3/windows.py 2012-09-18 04:37:10 +0000
142+++ tests/gtk3/windows.py 2012-09-19 07:42:38 +0000
143@@ -386,7 +386,7 @@
144 view = recommendations.RecommendationsPanelDetails(
145 db, properties_helper)
146
147- win = get_test_window(child=view)
148+ win = get_test_window(child=view, width=600, height=300)
149 win.set_data("rec_panel", view)
150 return win
151

Subscribers

People subscribed via source and target branches