Permalink
Browse files

tidied up clicking on row actions to correct display of track & cover…

… pane together with ensure that we show the artist cover search when clicking on artists - issue #236
  • Loading branch information...
1 parent f60bf04 commit 767e2791cfa58ddd4e2c02575ae31646fe9bccb7 @fossfreedom committed Jan 4, 2014
Showing with 54 additions and 21 deletions.
  1. +36 −14 coverart_artistview.py
  2. +2 −7 coverart_browser_source.py
  3. +2 −0 coverart_search.py
  4. +14 −0 coverart_widgets.py
View
@@ -722,6 +722,7 @@ def __init__(self, *args, **kwargs):
self.show_policy = ArtistShowingPolicy(self)
self.view = self
self._has_initialised = False
+ self._last_row_was_artist = False
def initialise(self, source):
if self._has_initialised:
@@ -862,12 +863,18 @@ def _row_click(self, widget, event):
active_object = self.artist_manager.model.get_from_path(treepath)
if not isinstance(active_object, Album):
+ if self.icon_automatic:
+ # reset counter so that we get correct double click action for albums
+ self.source.click_count = 0
+
if treecolumn != self.get_expander_column():
- if self.row_expanded(treepath) and event.button == 1:
+ if self.row_expanded(treepath) and event.button == 1 and self._last_row_was_artist:
self.collapse_row(treepath)
else:
self.expand_row(treepath, False)
-
+
+ self._last_row_was_artist = True
+
if event.button ==3:
# on right click
# display popup
@@ -886,17 +893,17 @@ def _row_click(self, widget, event):
ctrl = event.state & Gdk.ModifierType.CONTROL_MASK
shift = event.state & Gdk.ModifierType.SHIFT_MASK
- if self.icon_automatic:
+ if self.icon_automatic and not self._last_row_was_artist:
self.source.click_count += 1 if not ctrl and not shift else 0
if self.source.click_count == 1:
Gdk.threads_add_timeout(GLib.PRIORITY_DEFAULT_IDLE, 250,
self.source.show_hide_pane, active_object)
-
+
elif event.button ==3:
# on right click
# display popup
-
+
if not self._external_plugins:
# initialise external plugin menu support
self._external_plugins = \
@@ -910,43 +917,58 @@ def _row_click(self, widget, event):
None,
3,
Gtk.get_current_event_time())
+
+ self._last_row_was_artist = False
def get_view_icon_name(self):
return "artistview.png"
def _selection_changed(self, *args):
- selected = self.get_selected_objects()
+ selected = self.get_selected_objects(just_artist=True)
+ print (selected)
if len(selected) == 0:
+ self.source.entry_view.clear()
return
if isinstance(selected[0], Artist):
+ print ("selected artist")
self.unset_rows_drag_source() # turn off drag-drop for artists
# clear the entry view
self.source.entry_view.clear()
cover_search_pane_visible = self.source.notebook.get_current_page() == \
self.source.notebook.page_num(self.source.cover_search_pane)
-
- if not selected:
- # clean cover tab if selected
- if cover_search_pane_visible:
- self.source.cover_search_pane.clear()
-
- return
-
+
# update the cover search pane with the first selected artist
if cover_search_pane_visible:
+ print ("update coversearch for artist")
+ print (selected[0])
self.source.cover_search_pane.do_search(selected[0],
self.artist_manager.cover_man.update_cover)
else:
+ print ("selected album")
self.source.update_with_selection()
# now turnon drag-drop for album.
self.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
[], Gdk.DragAction.COPY)
self.drag_source_set_target_list(self._targets)
+
+ def switch_to_coverpane(self, cover_search_pane):
+ '''
+ called from the source to update the coverpane when
+ it is switched from the track pane
+ This overrides the base method
+ '''
+
+ selected = self.get_selected_objects(just_artist=True)
+
+ if selected:
+ manager = self.get_default_manager()
+ cover_search_pane.do_search(selected[0],
+ manager.cover_man.update_cover)
def get_selected_objects(self, just_artist=False):
'''
@@ -693,13 +693,8 @@ def notebook_switch_page_callback(self, notebook, page, page_num):
print("CoverArtBrowser DEBUG - notebook_switch_page_callback")
if page_num == 1:
- selected = self.viewmgr.current_view.get_selected_objects()
-
- if selected:
- manager = self.viewmgr.current_view.get_default_manager()
- self.cover_search_pane.do_search(selected[0],
- manager.cover_man.update_cover)
-
+ self.viewmgr.current_view.switch_to_coverpane(self.cover_search_pane)
+
print("CoverArtBrowser DEBUG - end notebook_switch_page_callback")
def rating_changed_callback(self, widget):
View
@@ -143,6 +143,7 @@ def render_album_art_search(self, artist, album_name):
temp_file = self.template.render(artist=artist, album=album_name,
stylesheet=self.styles, selection_color=self.selection_color)
+ print ("here")
self.webview.load_string(temp_file, 'text/html', 'utf-8',
self.basepath)
@@ -153,6 +154,7 @@ def render_artist_art_search(self, artist):
temp_file = self.artist_template.render(artist=artist,
stylesheet=self.styles, selection_color=self.selection_color)
+ print ("here")
self.webview.load_string(temp_file, 'text/html', 'utf-8',
self.basepath)
View
@@ -1340,3 +1340,17 @@ def get_default_manager(self):
'''
return self.source.album_manager
+
+ def switch_to_coverpane(self, cover_search_pane):
+ '''
+ called from the source to update the coverpane when
+ it is switched from the track pane
+ '''
+
+ selected = self.get_selected_objects()
+
+ if selected:
+ manager = self.get_default_manager()
+ cover_search_pane.do_search(selected[0],
+ manager.cover_man.update_cover)
+

0 comments on commit 767e279

Please sign in to comment.