Merge lp:~mvo/software-center/trivial-restore-state-fix into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3152
Proposed branch: lp:~mvo/software-center/trivial-restore-state-fix
Merge into: lp:software-center
Diff against target: 91 lines (+27/-13)
3 files modified
softwarecenter/config.py (+11/-5)
softwarecenter/ui/gtk3/app.py (+3/-3)
tests/test_config.py (+13/-5)
To merge this branch: bzr merge lp:~mvo/software-center/trivial-restore-state-fix
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+122897@code.launchpad.net

Description of the change

Fix the initial window size to be consistent with what we did with 5.2 again. Started trivial, is a little less trivial now and makes the config.app_window_size a property that supports tuples.

To post a comment you must log in.
3153. By Michael Vogt

small stylistic fixes

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

Very nice, thank you, mvo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/config.py'
2--- softwarecenter/config.py 2012-08-29 20:56:32 +0000
3+++ softwarecenter/config.py 2012-09-05 15:11:20 +0000
4@@ -99,11 +99,6 @@
5 lambda self, value: self._generic_setbool("add_to_launcher", value),
6 None,
7 "Defines if apps should get added to the unity launcher")
8- app_window_size = property(
9- lambda self: self._generic_get("size", default="-1, -1"),
10- lambda self, value: self._generic_set("size", value),
11- None,
12- "Defines the size of the application window")
13 app_window_maximized = property(
14 lambda self: self._generic_getbool("maximized", default=False),
15 lambda self, value: self._generic_setbool("maximized", value),
16@@ -155,6 +150,17 @@
17 None,
18 "The account id to use when sending via gwibber")
19
20+ # app_window_size is special as its a tuple
21+ def _app_window_size_get(self):
22+ size_as_string = self._generic_get("size", default="-1, -1")
23+ return [int(v) for v in size_as_string.split(",")]
24+ def _app_window_size_set(self, size_tuple):
25+ size_as_string = "%s, %s" % (size_tuple[0], size_tuple[1])
26+ self._generic_set("size", size_as_string)
27+ app_window_size = property(_app_window_size_get, _app_window_size_set,
28+ None,
29+ "Defines the size of the application window as a tuple (x,y)")
30+
31
32 # one global instance of the config
33 _software_center_config = None
34
35=== modified file 'softwarecenter/ui/gtk3/app.py'
36--- softwarecenter/ui/gtk3/app.py 2012-09-03 09:31:29 +0000
37+++ softwarecenter/ui/gtk3/app.py 2012-09-05 15:11:20 +0000
38@@ -1356,9 +1356,9 @@
39 self.view_manager.set_active_view(ViewPages.AVAILABLE)
40
41 def restore_state(self):
42- (x, y) = self.config.app_window_size.split(",")
43+ (x, y) = self.config.app_window_size
44 if x > 0 and y > 0:
45- self.window_main.set_default_size(int(x), int(y))
46+ self.window_main.set_default_size(x, y)
47 else:
48 # on first launch, specify the default window size to take
49 # advantage of the available screen real estate (but set a
50@@ -1382,7 +1382,7 @@
51 if not maximized:
52 # size only matters when non-maximized
53 size = self.window_main.get_size()
54- self.config.app_window_size = "%s, %s" % (size[0], size[1])
55+ self.config.app_window_size = [size[0], size[1]]
56 self.config.write()
57
58 def write_memory_dump(self, fname=None):
59
60=== modified file 'tests/test_config.py'
61--- tests/test_config.py 2012-08-29 07:27:51 +0000
62+++ tests/test_config.py 2012-09-05 15:11:20 +0000
63@@ -30,15 +30,23 @@
64 def test_properties_default_bool(self):
65 """ test default values for properties """
66 self.assertTrue(self.config.add_to_unity_launcher)
67- self.assertEqual(self.config.app_window_size, "-1, -1")
68+
69+ def test_properties_default_window_size(self):
70+ """ default value for window size tuple """
71+ self.assertEqual(self.config.app_window_size, [-1, -1])
72+
73+ def test_properties_window_size(self):
74+ """ test the app_window_size getter/setter """
75+ self.config.app_window_size = [10, 10]
76+ self.assertEqual(self.config.app_window_size, [10, 10])
77
78 def test_property_simple_string(self):
79 """ test a string property """
80- for value in [ "", "10, 10"]:
81- self.config.app_window_size = value
82- self.assertEqual(self.config.app_window_size, value)
83+ for value in [ "", "xxxyyy"]:
84+ self.config.recommender_uuid = value
85+ self.assertEqual(self.config.recommender_uuid, value)
86 self.assertEqual(
87- self.config.get("general", "size"), value)
88+ self.config.get("general", "recommender_uuid"), value)
89
90 def test_write(self):
91 """ test that write writes """

Subscribers

People subscribed via source and target branches