Merge lp:~mblayman/entertainer/preview-problem into lp:entertainer

Proposed by Matt Layman
Status: Merged
Approved by: Matt Layman
Approved revision: 360
Merged at revision: not available
Proposed branch: lp:~mblayman/entertainer/preview-problem
Merge into: lp:entertainer
Diff against target: None lines
To merge this branch: bzr merge lp:~mblayman/entertainer/preview-problem
Reviewer Review Type Date Requested Status
Jamie Bennett (community) Approve
Samuel Buffet (community) Approve
Review via email: mp+5325@code.launchpad.net

Commit message

The main menu now keeps focus appropriately for left and right directions and all previews now fade in. (Matt Layman)

To post a comment you must log in.
Revision history for this message
Matt Layman (mblayman) wrote :

I was reviewing Samuel's branch on the main menu focus issue (Bug 357056) and thought the problem was bigger than branch submitted. I decided to hack on it because my brain was having some trouble spelling out the problems with the branch (aside from how to break the patch).

I was left with two results:
1) A fix for the problem that doesn't break. Samuel, it turns out you just had the item.get_name() check in the wrong if statement.
2) The preview menu code on the main screen has been cleaned up quite a bit. Now the preview will fade in for either the RSS or the Now Playing preview.

A note on the second point. I changed some method names because they were fairly deceptive. I changed the "show_playing_preview" and "show_rss_preview" because they weren't really showing those previews. They actually recreate the menus and display them again. I changed "show" to "_create" so that it's clear what they are doing. Maybe someone will want to change them in the future to save calls to the feed library or prevent recreating a video texture, but it will at least be clear what they'll have to change.

In summary, I probably went way overboard to fix the bug in the branch that I was supposed to be reviewing for Samuel, but I think that the result is quite nice anyway.

Revision history for this message
Samuel Buffet (samuel-buffet) wrote :

Good Matt,

I approve those changes.

FYI, I've found the idea so good that I've merged those changes in *new-scrollmenu* to be able to continue modifications/improvements to take care of this issue in the context of the new signal based menu.

Thanks

Samuel-

review: Approve
Revision history for this message
Jamie Bennett (jamiebennett) wrote :

Good work Matt. Thorough and good code reuse.

 review approve

On Wed, 2009-04-08 at 02:55 +0000, Matt Layman wrote:
> Matt Layman has proposed merging lp:~laymansterms/entertainer/preview-problem into lp:entertainer.
>
> Requested reviews:
> Entertainer Release Team (entertainer-releases)
>
> I was reviewing Samuel's branch on the main menu focus issue (Bug 357056) and thought the problem was bigger than branch submitted. I decided to hack on it because my brain was having some trouble spelling out the problems with the branch (aside from how to break the patch).
>
> I was left with two results:
> 1) A fix for the problem that doesn't break. Samuel, it turns out you just had the item.get_name() check in the wrong if statement.
> 2) The preview menu code on the main screen has been cleaned up quite a bit. Now the preview will fade in for either the RSS or the Now Playing preview.
>
> A note on the second point. I changed some method names because they were fairly deceptive. I changed the "show_playing_preview" and "show_rss_preview" because they weren't really showing those previews. They actually recreate the menus and display them again. I changed "show" to "_create" so that it's clear what they are doing. Maybe someone will want to change them in the future to save calls to the feed library or prevent recreating a video texture, but it will at least be clear what they'll have to change.
>
> In summary, I probably went way overboard to fix the bug in the branch that I was supposed to be reviewing for Samuel, but I think that the result is quite nice anyway.

review: Approve
Revision history for this message
Matt Layman (mblayman) wrote :

Commit Message: The main menu now keeps focus appropriately for left and right directions and all previews now fade in. (Matt Layman)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'entertainerlib/frontend/gui/screens/main.py'
--- entertainerlib/frontend/gui/screens/main.py 2009-03-02 03:11:24 +0000
+++ entertainerlib/frontend/gui/screens/main.py 2009-04-08 02:31:06 +0000
@@ -44,10 +44,12 @@
44 self.preview = clutter.Group() # Group that contains preview actors44 self.preview = clutter.Group() # Group that contains preview actors
45 self.preview.set_position(self.get_abs_x(0.07), self.get_abs_y(0.1))45 self.preview.set_position(self.get_abs_x(0.07), self.get_abs_y(0.1))
46 self.preview.show()46 self.preview.show()
47 self.preview.set_opacity(0x00)
47 self.add(self.preview)48 self.add(self.preview)
4849
49 self.active_menu = "main"50 self.active_menu = "main"
50 self.rss_preview_menu = None # Pointer to the current preview menu51 self.rss_preview_menu = self._create_rss_preview_menu()
52 self.preview.add(self.rss_preview_menu)
5153
52 self.menu = None54 self.menu = None
53 self.playing_item = None55 self.playing_item = None
@@ -56,6 +58,32 @@
56 clock = ClockLabel(0.13, "screentitle", 0, 0.87)58 clock = ClockLabel(0.13, "screentitle", 0, 0.87)
57 self.add(clock)59 self.add(clock)
5860
61 def _create_rss_preview_menu(self):
62 '''Create the RSS preview menu that will show feed highlights. An
63 uninitialized menu will be returned to prevent move errors if there
64 is nothing in the feed library.'''
65 menu = TextMenu(self.theme, self.config.show_effects())
66
67 if self.feed_library.is_empty() is False:
68 menu.set_row_count(1)
69 menu.set_position(self.get_abs_x(0.035), self.get_abs_y(0.12))
70 menu.set_item_size(self.get_abs_x(0.549), self.get_abs_y(0.078))
71
72 # List of latest entries. pack = (Feed object, Entry object)
73 entries = self.feed_library.get_latest_entries(5)
74 for pack in entries:
75 text = pack[0].get_title() + " - " + pack[1].get_title()
76 item = TextMenuItem(0.549, 0.078,
77 FeedEntryParser().strip_tags(text),
78 pack[1].get_date())
79 kwargs = { 'feed' : pack[0], 'entry' : pack[1] }
80 item.set_userdata(kwargs)
81 menu.add_actor(item)
82
83 menu.set_active(False)
84
85 return menu
86
59 def create_main_menu(self):87 def create_main_menu(self):
60 """Create main menu of the home screen"""88 """Create main menu of the home screen"""
61 self.menu = ScrollMenu(10, 60, self.config.show_effects())89 self.menu = ScrollMenu(10, 60, self.config.show_effects())
@@ -101,8 +129,10 @@
101129
102 self.add(self.menu)130 self.add(self.menu)
103131
104 def show_playing_preview(self):132 def _create_playing_preview(self):
105 """Create a group that displays information on current media."""133 '''Create the Now Playing preview sidebar.'''
134 preview = clutter.Group()
135
106 # Video preview of current media136 # Video preview of current media
107 video_texture = self.media_player.get_texture()137 video_texture = self.media_player.get_texture()
108 if video_texture == None:138 if video_texture == None:
@@ -141,67 +171,40 @@
141 rect.set_size(int(new_width + 6), int(new_height + 6))171 rect.set_size(int(new_width + 6), int(new_height + 6))
142 rect.set_position(rect_x, rect_y)172 rect.set_position(rect_x, rect_y)
143 rect.set_color((128, 128, 128, 192))173 rect.set_color((128, 128, 128, 192))
144 self.preview.add(rect)174 preview.add(rect)
145175
146 self.preview.add(video_texture)176 preview.add(video_texture)
147177
148 title_text = _("Now Playing: %(title)s") % \178 title_text = _("Now Playing: %(title)s") % \
149 {'title': self.media_player.get_media_title()}179 {'title': self.media_player.get_media_title()}
150 title = Label(0.03, "text", 0.03, 0.74, title_text)180 title = Label(0.03, "text", 0.03, 0.74, title_text)
151 self.preview.add(title)181 preview.add(title)
152182
153 def show_rss_preview(self):183 return preview
154 """Rss preview"""184
185 def _create_rss_preview(self):
186 '''Create the RSS preview sidebar.'''
187 preview = clutter.Group()
188
189 # RSS Icon
190 icon = Texture(self.theme.getImage("rss_icon"), 0, 0.04)
191 icon.set_scale(0.6, 0.6)
192 preview.add(icon)
193
194 # RSS Feed Title
195 title = Label(0.075, "title", 0.045, 0.03, _("Recent headlines"))
196 preview.add(title)
155197
156 if self.feed_library.is_empty() is False:198 if self.feed_library.is_empty() is False:
157 # RSS Icon199 menu = self._create_rss_preview_menu()
158 icon = Texture(self.theme.getImage("rss_icon"), 0, 0.04)200 preview.add(menu)
159 icon.set_scale(0.6, 0.6)
160
161 # RSS Feed Title
162 title = Label(0.075, "title", 0.045, 0.03, _("Recent headlines"))
163
164 menu = TextMenu(self.theme, self.config.show_effects())
165 menu.set_row_count(1)
166 menu.set_position(self.get_abs_x(0.035), self.get_abs_y(0.12))
167 menu.set_item_size(self.get_abs_x(0.549), self.get_abs_y(0.078))
168
169 # List of latest entries. pack = (Feed object, Entry object)
170 entries = self.feed_library.get_latest_entries(5)
171 for pack in entries:
172 text = pack[0].get_title() + " - " + pack[1].get_title()
173 item = TextMenuItem(0.549, 0.078,
174 FeedEntryParser().strip_tags(text),
175 pack[1].get_date())
176 kwargs = { 'feed' : pack[0], 'entry' : pack[1] }
177 item.set_userdata(kwargs)
178 menu.add_actor(item)
179
180 menu.set_active(False)
181
182 # Fade in timeline
183 fade_in = clutter.Timeline(20, 60)
184 alpha_in = clutter.Alpha(fade_in, clutter.smoothstep_inc_func)
185 self.in_behaviour = clutter.BehaviourOpacity(0x00, 0xff, alpha_in)
186 self.in_behaviour.apply(menu)
187 self.in_behaviour.apply(title)
188 self.in_behaviour.apply(icon)
189
190 self.preview.add(icon)
191 self.preview.add(title)
192 self.rss_preview_menu = menu201 self.rss_preview_menu = menu
193 self.preview.add(menu)
194
195 menu.set_opacity(0x00)
196 icon.set_opacity(0x00)
197 title.set_opacity(0x00)
198
199 fade_in.start()
200
201 else:202 else:
202 # No headlines available in the library203 # No headlines available in the library
203 info = Label(0.07, "title", 0.1, 0.35, _("No headlines available"))204 info = Label(0.05, "title", 0.1, 0.35, _("No headlines available"))
204 self.preview.add(info)205 preview.add(info)
206
207 return preview
205208
206 def get_type(self):209 def get_type(self):
207 """Return screen type."""210 """Return screen type."""
@@ -227,20 +230,28 @@
227230
228 self.menu.update()231 self.menu.update()
229232
230 self.update_preview_area(self.menu.get_selected())233 self._update_preview_area(self.menu.get_selected())
231234
232 def update_preview_area(self, item):235 def _update_preview_area(self, item):
233 """236 '''Update the preview area to display the current menu item.'''
234 Update preview area. This area displayes information of currently
235 selected menuitem.
236 @param item: Menuitem (clutter.Actor)
237 """
238 self.preview.remove_all()237 self.preview.remove_all()
238 self.preview.set_opacity(0x00)
239
240 update = True
239 if item.get_name() == "playing":241 if item.get_name() == "playing":
240 self.show_playing_preview()242 self.preview.add(self._create_playing_preview())
241 #only show the rss menu if it has entries
242 elif item.get_name() == "rss":243 elif item.get_name() == "rss":
243 self.show_rss_preview()244 self.preview.add(self._create_rss_preview())
245 else:
246 update = False
247
248 # If the preview was updated fade it in
249 if update:
250 fade_in = clutter.Timeline(20, 60)
251 alpha_in = clutter.Alpha(fade_in, clutter.smoothstep_inc_func)
252 self.behaviour = clutter.BehaviourOpacity(0x00, 0xff, alpha_in)
253 self.behaviour.apply(self.preview)
254 fade_in.start()
244255
245 def _move_menu(self, menu_direction):256 def _move_menu(self, menu_direction):
246 '''Move the menu in the given direction.'''257 '''Move the menu in the given direction.'''
@@ -258,7 +269,7 @@
258 if selected.get_name() == None:269 if selected.get_name() == None:
259 scroll_direction()270 scroll_direction()
260 selected = self.menu.get_selected()271 selected = self.menu.get_selected()
261 self.update_preview_area(selected)272 self._update_preview_area(selected)
262 else:273 else:
263 self.rss_preview_menu.move(preview_direction)274 self.rss_preview_menu.move(preview_direction)
264275
@@ -270,9 +281,17 @@
270 '''Handle UserEvent.NAVIGATE_DOWN.'''281 '''Handle UserEvent.NAVIGATE_DOWN.'''
271 self._move_menu(self.DOWN)282 self._move_menu(self.DOWN)
272283
284 def _can_move_horizontally(self):
285 '''Return a boolean indicating if horizontal movement is allowed.'''
286 item = self.menu.get_selected()
287 if self.feed_library.is_empty() or item.get_name() != 'rss':
288 return False
289 else:
290 return True
291
273 def _handle_left(self):292 def _handle_left(self):
274 '''Handle UserEvent.NAVIGATE_LEFT.'''293 '''Handle UserEvent.NAVIGATE_LEFT.'''
275 if self.feed_library.is_empty():294 if not self._can_move_horizontally():
276 return295 return
277296
278 if self.active_menu == "main":297 if self.active_menu == "main":
@@ -282,7 +301,7 @@
282301
283 def _handle_right(self):302 def _handle_right(self):
284 '''Handle UserEvent.NAVIGATE_RIGHT.'''303 '''Handle UserEvent.NAVIGATE_RIGHT.'''
285 if self.feed_library.is_empty():304 if not self._can_move_horizontally():
286 return305 return
287306
288 if self.active_menu == "preview":307 if self.active_menu == "preview":

Subscribers

People subscribed via source and target branches