Merge lp:~gary-lasker/software-center/recommender-panel-visual-tweaks into lp:software-center

Proposed by Gary Lasker
Status: Merged
Merged at revision: 3129
Proposed branch: lp:~gary-lasker/software-center/recommender-panel-visual-tweaks
Merge into: lp:software-center
Diff against target: 99 lines (+38/-8)
3 files modified
softwarecenter/ui/gtk3/widgets/containers.py (+4/-2)
softwarecenter/ui/gtk3/widgets/spinner.py (+16/-6)
tests/gtk3/test_spinner.py (+18/-0)
To merge this branch: bzr merge lp:~gary-lasker/software-center/recommender-panel-visual-tweaks
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+121534@code.launchpad.net

Commit message

* lp:~gary-lasker/software-center/recommender-panel-visual-tweaks:
   - add support for two sizes of spinner to the spinner widget and use
     the smaller one for the lobby/category screen panels

Description of the change

Just a small tweak in the recommender panel UI before UI freeze. Adds support in the spinner widget for choosing between two sizes of spinner, and switch to use the smaller version in the lobby/category screen recommender panels as it looks much better there. The large spinner is still used for the full views as before.

Thanks!

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

Thanks for this branch. I like the size change, it does look nicer IMO with the smaller size.

The code is nice, I would have two suggestions:
- raise a ValueError is spinner_size is not in (Spinner.LARGE, SpinnerView.SMALL) as a user of the widget may pass "24" or "48" to it assuming size is in pixel
- add a small test as test_spinner.py has really good coverage already, should be as simple as:
    def test_spinner_notebook_size(self):
        notebook = spinner.SpinnerNotebook(self.content, "msg", spinner.SpinnerView.LARGE)
        self.assertEqual(notebook.spinner_view.spinner.get_size_request(), (48, 48))
plus a test that the exception is raised.

If you want to go wild, you can do it in enums.py as:

class SpinnerSize:
  LARGE = 48
  SMALL = 24

this way if the size ever changes or we need MEDIUM its trivial to add in enums.py. But thats not really
needed, just a thought I had while looking at the diff.

3128. By Gary Lasker

pep8 fix

3129. By Gary Lasker

add a ValueError check for the spinner_size attribute, add test to test_spinner.py to test a small spinner, a large spinner (default), and finally one for the ValueError case

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Hi Michael, thanks for your review and your suggestions! I added the check for spinner_size and raise a ValueError as you suggested, and I've added a test case to test_spinner.py that checks 1. the small spinner case, 2. the large spinner case (as default) and finally 3. a ValueError if a disallowed value for spinner_size is passed in.

I initially considered adding the actual sizes to enums.py as you suggested, or even letting them be specified directly in pixels, but I decided that I really don't forsee us needing any more than these two sizes - the large one for full views and the smaller one for subpanels. That, plus given that we really don't want to make it easy to create arbitrarily-sized spinner panels, I thought it best to keep it to the two useful choices and just embed the pixel details inside the class.

Thanks again!

Revision history for this message
Michael Vogt (mvo) wrote :

On Tue, Aug 28, 2012 at 04:42:20PM -0000, Gary Lasker wrote:
> Hi Michael, thanks for your review and your suggestions! I added the check for spinner_size and raise a ValueError as you suggested, and I've added a test case to test_spinner.py that checks 1. the small spinner case, 2. the large spinner case (as default) and finally 3. a ValueError if a disallowed value for spinner_size is passed in.

Great, thanks for the tests for this. I merged it into trunk now.

> I initially considered adding the actual sizes to enums.py as you suggested, or even letting them be specified directly in pixels, but I decided that I really don't forsee us needing any more than these two sizes - the large one for full views and the smaller one for subpanels. That, plus given that we really don't want to make it easy to create arbitrarily-sized spinner panels, I thought it best to keep it to the two useful choices and just embed the pixel details inside the class.

Ok, if we ever need to change it that will be straightfoward and until
then it stays as it is.

Cheers,
 Michael

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/ui/gtk3/widgets/containers.py'
--- softwarecenter/ui/gtk3/widgets/containers.py 2012-05-30 18:39:55 +0000
+++ softwarecenter/ui/gtk3/widgets/containers.py 2012-08-28 16:36:20 +0000
@@ -9,7 +9,8 @@
9from buttons import MoreLink9from buttons import MoreLink
10from softwarecenter.ui.gtk3.em import StockEms10from softwarecenter.ui.gtk3.em import StockEms
11from softwarecenter.ui.gtk3.drawing import rounded_rect11from softwarecenter.ui.gtk3.drawing import rounded_rect
12from softwarecenter.ui.gtk3.widgets.spinner import SpinnerNotebook12from softwarecenter.ui.gtk3.widgets.spinner import (SpinnerView,
13 SpinnerNotebook)
1314
1415
15class FlowableGrid(Gtk.Fixed):16class FlowableGrid(Gtk.Fixed):
@@ -450,7 +451,8 @@
450 self.content_box = Gtk.Box.new(orientation, spacing)451 self.content_box = Gtk.Box.new(orientation, spacing)
451 self.content_box.show()452 self.content_box.show()
452 # finally, a notebook for the spinner and the content box to share453 # finally, a notebook for the spinner and the content box to share
453 self.spinner_notebook = SpinnerNotebook(self.content_box)454 self.spinner_notebook = SpinnerNotebook(self.content_box,
455 spinner_size=SpinnerView.SMALL)
454 self.box.add(self.spinner_notebook)456 self.box.add(self.spinner_notebook)
455457
456 def on_draw(self, cr):458 def on_draw(self, cr):
457459
=== modified file 'softwarecenter/ui/gtk3/widgets/spinner.py'
--- softwarecenter/ui/gtk3/widgets/spinner.py 2012-05-30 18:39:55 +0000
+++ softwarecenter/ui/gtk3/widgets/spinner.py 2012-08-28 16:36:20 +0000
@@ -27,15 +27,25 @@
27class SpinnerView(Gtk.Viewport):27class SpinnerView(Gtk.Viewport):
28 """A panel that contains a spinner with an optional legend.28 """A panel that contains a spinner with an optional legend.
2929
30 The spinner is preset to a standard size and centered. An optional30 The spinner can be specified in one of two sizes, and defaults to
31 label_text value can be specified for display with the spinner.31 the larger size. An optional label_text value can be specified for
32 display with the spinner.
3233
33 """34 """
35 # define spinner size options
36 (LARGE,
37 SMALL) = range(2)
3438
35 def __init__(self, label_text=""):39 def __init__(self, label_text="", spinner_size=LARGE):
36 Gtk.Viewport.__init__(self)40 Gtk.Viewport.__init__(self)
37 self.spinner = Gtk.Spinner()41 self.spinner = Gtk.Spinner()
38 self.spinner.set_size_request(48, 48)42 if spinner_size not in (self.SMALL, self.LARGE):
43 raise ValueError('The value of spinner_size must be '
44 'one of SpinnerView.SMALL or SpinnerView.LARGE')
45 if spinner_size == self.LARGE:
46 self.spinner.set_size_request(48, 48)
47 else:
48 self.spinner.set_size_request(24, 24)
3949
40 # use a table for the spinner (otherwise the spinner is massive!)50 # use a table for the spinner (otherwise the spinner is massive!)
41 spinner_table = Gtk.Table(3, 3, False)51 spinner_table = Gtk.Table(3, 3, False)
@@ -77,10 +87,10 @@
77 (CONTENT_PAGE,87 (CONTENT_PAGE,
78 SPINNER_PAGE) = range(2)88 SPINNER_PAGE) = range(2)
7989
80 def __init__(self, content, msg=""):90 def __init__(self, content, msg="", spinner_size=SpinnerView.LARGE):
81 Gtk.Notebook.__init__(self)91 Gtk.Notebook.__init__(self)
82 self._last_timeout_id = None92 self._last_timeout_id = None
83 self.spinner_view = SpinnerView(msg)93 self.spinner_view = SpinnerView(msg, spinner_size)
84 # its critical to show() the spinner early as otherwise94 # its critical to show() the spinner early as otherwise
85 # gtk_notebook_set_active_page() will not switch to it95 # gtk_notebook_set_active_page() will not switch to it
86 self.spinner_view.show()96 self.spinner_view.show()
8797
=== modified file 'tests/gtk3/test_spinner.py'
--- tests/gtk3/test_spinner.py 2012-05-30 18:39:55 +0000
+++ tests/gtk3/test_spinner.py 2012-08-28 16:36:20 +0000
@@ -147,6 +147,24 @@
147 self.assertFalse(self.obj.spinner_view.spinner.get_property('active'))147 self.assertFalse(self.obj.spinner_view.spinner.get_property('active'))
148 self.assertFalse(self.obj.spinner_view.spinner.get_visible())148 self.assertFalse(self.obj.spinner_view.spinner.get_visible())
149149
150 def test_specify_spinner_size(self):
151 # check small spinner case
152 notebook = spinner.SpinnerNotebook(self.content,
153 "test spinner label",
154 spinner.SpinnerView.SMALL)
155 self.assertEqual(notebook.spinner_view.spinner.get_size_request(),
156 (24, 24))
157 # check large spinner case (default)
158 notebook = spinner.SpinnerNotebook(self.content,
159 "test spinner label")
160 self.assertEqual(notebook.spinner_view.spinner.get_size_request(),
161 (48, 48))
162 # check that specifying an invalid spinner_size value raises
163 # an exception
164 with self.assertRaises(ValueError):
165 notebook = spinner.SpinnerNotebook(self.content,
166 "test spinner label",
167 48)
150168
151if __name__ == "__main__":169if __name__ == "__main__":
152 unittest.main()170 unittest.main()

Subscribers

People subscribed via source and target branches