Permalink
Browse files

tidy up after merge

  • Loading branch information...
1 parent 645fc54 commit 961cf2a989ca4a7f74e3c615e9a672c479f6f92c @fossfreedom committed Feb 14, 2014
View
32 coverart_artistview.py
@@ -17,7 +17,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-from coverart_external_plugins import CreateExternalPluginMenu
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GLib
@@ -38,7 +37,6 @@
from coverart_utils import idle_iterator
from coverart_utils import dumpstack
from coverart_utils import create_pixbuf_from_file_at_size
-from coverart_external_plugins import CreateExternalPluginMenu
from coverart_extdb import CoverArtExtDB
import coverart_rb3compat as rb3compat
from coverart_rb3compat import Menu
@@ -787,7 +785,6 @@ class ArtistView(Gtk.TreeView, AbstractView):
def __init__(self, *args, **kwargs):
super(ArtistView, self).__init__(*args, **kwargs)
- self.ext_menu_pos = 0
self._external_plugins = None
self.gs = GSetting()
self.show_policy = ArtistShowingPolicy(self)
@@ -805,7 +802,6 @@ def initialise(self, source):
super(ArtistView, self).initialise(source)
self.album_manager = source.album_manager
self.shell = source.shell
- self.ext_menu_pos = 6
self.props.has_tooltip = True
self.set_enable_tree_lines(True)
@@ -858,12 +854,12 @@ def initialise(self, source):
signals = \
{ 'play_album_menu_item': self.source.play_album_menu_item_callback,
'queue_album_menu_item': self.source.queue_album_menu_item_callback,
- 'playlist_menu_item': self.source.playlist_menu_item_callback,
'new_playlist': self.source.add_playlist_menu_item_callback,
'artist_cover_search_menu_item': self.cover_search_menu_item_callback
}
self.artist_popup_menu.connect_signals(signals)
+ self.artist_popup_menu.connect('pre-popup', self.add_external_menu)
# connect properties and signals
self._connect_properties()
@@ -945,6 +941,13 @@ def _row_activated(self, treeview, treepath, treeviewcolumn):
#we need to play this album
self.source.play_selected_album(self.source.favourites)
+ def add_external_menu(self, *args):
+ '''
+ callback when artist popup menu is about to be displayed
+ '''
+
+ self.source.playlist_menu_item_callback()
+
def _row_click(self, widget, event):
'''
event called when clicking on a row
@@ -974,11 +977,7 @@ def _row_click(self, widget, event):
# on right click
# display popup
- self.artist_popup_menu.get_gtkmenu(self.source, 'popup_menu').popup(None,
- None,
- None,
- None,
- 3,
+ self.artist_popup_menu.popup(self.source, 'popup_menu', 3,
Gtk.get_current_event_time())
return
@@ -999,18 +998,7 @@ def _row_click(self, widget, event):
# on right click
# display popup
- if not self._external_plugins:
- # initialise external plugin menu support
- self._external_plugins = \
- CreateExternalPluginMenu("ca_covers_view",
- self.ext_menu_pos, self.popup)
- self._external_plugins.create_menu('popup_menu', True)
-
- self.popup.get_gtkmenu(self.source, 'popup_menu').popup(None,
- None,
- None,
- None,
- 3,
+ self.popup.popup(self.source, 'popup_menu', 3,
Gtk.get_current_event_time())
self._last_row_was_artist = False
View
19 coverart_browser_source.py
@@ -44,6 +44,7 @@
from coverart_artistview import ArtistView
from coverart_listview import ListView
from coverart_toolbar import ToolbarManager
+from coverart_external_plugins import CreateExternalPluginMenu
import coverart_rb3compat as rb3compat
import random
@@ -212,16 +213,18 @@ def _create_ui(self):
self.popup_menu = Menu(self.plugin, self.shell)
self.popup_menu.load_from_file('ui/coverart_browser_pop_rb2.ui',
'ui/coverart_browser_pop_rb3.ui')
+ self._external_plugins = None
+
signals = \
{ 'play_album_menu_item': self.play_album_menu_item_callback,
'queue_album_menu_item': self.queue_album_menu_item_callback,
- 'playlist_menu_item': self.playlist_menu_item_callback,
'new_playlist': self.add_playlist_menu_item_callback,
'cover_search_menu_item': self.cover_search_menu_item_callback,
'export_embed_menu_item': self.export_embed_menu_item_callback,
'show_properties_menu_item': self.show_properties_menu_item_callback}
self.popup_menu.connect_signals(signals)
+ self.popup_menu.connect('pre-popup', self.add_external_menu)
self.status_label = ui.get_object('status_label')
self.request_status_box = ui.get_object('request_status_box')
@@ -333,6 +336,20 @@ def _setup_source(self):
print("CoverArtBrowser DEBUG - end _setup_source")
+ def add_external_menu(self, *args):
+ '''
+ Callback when the popup menu is about to be displayed
+ '''
+
+ if not self._external_plugins:
+ # initialise external plugin menu support
+ self._external_plugins = \
+ CreateExternalPluginMenu("ca_covers_view",
+ 6, self.popup_menu)
+ self._external_plugins.create_menu('popup_menu', True)
+
+ self.playlist_menu_item_callback()
+
def artist_paned_button_release_callback(self, *args):
'''
Callback when the artist paned handle is released from its mouse click.
View
17 coverart_coverflowview.py
@@ -17,7 +17,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-from coverart_external_plugins import CreateExternalPluginMenu
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GLib
@@ -74,8 +73,6 @@ class CoverFlowView(AbstractView):
def __init__(self):
super(CoverFlowView, self).__init__()
- self.ext_menu_pos = 0
- self._external_plugins = None
self.show_policy = FlowShowingPolicy(self)
if webkit_support():
from gi.repository import WebKit
@@ -264,20 +261,8 @@ def last_album(self, new_album):
self.selectionchanged_callback()
def item_rightclicked_callback(self, album):
- if not self._external_plugins:
- # initialise external plugin menu support
- self._external_plugins = \
- CreateExternalPluginMenu("ca_covers_view",
- self.ext_menu_pos, self.popup)
- self._external_plugins.create_menu('popup_menu', True)
-
self.last_album = album
- self.popup.get_gtkmenu(self.source, 'popup_menu').popup(None,
- None,
- None,
- None,
- 3,
- Gtk.get_current_event_time())
+ self.popup.popup(self.source, 'popup_menu', 3, Gtk.get_current_event_time())
def item_clicked_callback(self, album):
'''
View
14 coverart_covericonview.py
@@ -28,7 +28,6 @@
from gi.repository import RB
from gi.repository.GdkPixbuf import Pixbuf
from coverart_widgets import EnhancedIconView
-from coverart_external_plugins import CreateExternalPluginMenu
from coverart_browser_prefs import GSetting
from coverart_album import AlbumsModel
from coverart_widgets import AbstractView
@@ -241,8 +240,6 @@ def __init__(self, *args, **kwargs):
super(CoverIconView, self).__init__(*args, **kwargs)
self.props.cell_area = AlbumArtCellArea()
- self.ext_menu_pos = 0
- self._external_plugins = None
self.gs = GSetting()
# custom text renderer
self._text_renderer = None
@@ -264,8 +261,7 @@ def initialise(self, source):
self.shell = source.shell
self.album_manager = source.album_manager
- self.ext_menu_pos = 6
-
+
# setup iconview drag&drop support
# first drag and drop on the coverart view to receive coverart
self.enable_model_drag_dest([], Gdk.DragAction.COPY)
@@ -361,14 +357,6 @@ def resize_icon(self, cover_size):
'''
self.set_item_width(cover_size)
- def pre_display_popup(self):
- if not self._external_plugins:
- # initialise external plugin menu support
- self._external_plugins = \
- CreateExternalPluginMenu("ca_covers_view",
- self.ext_menu_pos, self.popup)
- self._external_plugins.create_menu('popup_menu', True)
-
def on_drag_drop(self, widget, context, x, y, time):
'''
Callback called when a drag operation finishes over the cover view
View
23 coverart_entryview.py
@@ -89,11 +89,11 @@ def __init__(self, shell, source):
signals = {
'ev_play_track_menu_item': self.play_track_menu_item_callback,
'ev_queue_track_menu_item': self.queue_track_menu_item_callback,
- 'ev_playlist_menu_item': self.playlist_menu_item_callback,
'ev_new_playlist': self.add_playlist_menu_item_callback,
'ev_show_properties_menu_item': self.show_properties_menu_item_callback }
popup.connect_signals(signals)
+ popup.connect('pre-popup', self.add_external_menu)
self.popup = popup
# connect signals to the shell to know when the playing state changes
@@ -171,17 +171,24 @@ def do_entry_activated(self, entry):
self.play_track_menu_item_callback(entry)
print("CoverArtBrowser DEBUG - do_entry_activated()")
return True
+
+ def add_external_menu(self, *args):
+ '''
+ Callback when the popup menu is about to be displayed
+ '''
+ if not self.external_plugins:
+ self.external_plugins = \
+ CreateExternalPluginMenu("ev_entryview", 3, self.popup)
+ self.external_plugins.create_menu('entryview_popup_menu')
+
+ self.playlist_menu_item_callback()
def do_show_popup(self, over_entry):
if over_entry:
print("CoverArtBrowser DEBUG - do_show_popup()")
- if not self.external_plugins:
- self.external_plugins = \
- CreateExternalPluginMenu("ev_entryview", 3, self.popup)
- self.external_plugins.create_menu('entryview_popup_menu')
- self.popup.get_gtkmenu(self.source,
- 'entryview_popup_menu').popup(None, None, None, None, 0,
- Gtk.get_current_event_time())
+
+ self.popup.popup(self.source,
+ 'entryview_popup_menu', 0, Gtk.get_current_event_time())
return over_entry
View
2 coverart_external_plugins.py
@@ -108,6 +108,8 @@ def create_menu_item(self, menubar, section_name, at_position,
self.attributes['label']=action.label
#self.attributes['sensitive']=action.get_sensitive()
else:
+ print ("action not found")
+ print (self.attributes)
return False
action = save_actiongroup.add_action(func=self.menuitem_callback,
View
17 coverart_rb3compat.py
@@ -153,14 +153,19 @@ def is_rb3(*args):
else:
return True
-class Menu(object):
+class Menu(GObject.Object):
'''
Menu object used to create window popup menus
'''
+ __gsignals__ = {
+ 'pre-popup': (GObject.SIGNAL_RUN_LAST, None, ())
+ }
+
def __init__(self, plugin, shell):
'''
Initializes the menu.
'''
+ super(Menu, self).__init__()
self.plugin = plugin
self.shell = shell
self._unique_num = 0
@@ -290,7 +295,7 @@ def load_from_file(self, rb2_ui_filename, rb3_ui_filename ):
def _connect_rb3_signals(self, signals):
def _menu_connect(action_name, func):
- action = Gio.SimpleAction(name=action_name)
+ action = Gio.SimpleAction.new(name=action_name)
action.connect('activate', func)
action.set_enabled(True)
self.shell.props.window.add_action(action)
@@ -374,6 +379,14 @@ def set_sensitive(self, menu_or_action_item, enable):
item = self.get_menu_object(menu_or_action_item)
item.set_sensitive(enable)
+ def popup(self, source, menu_name, button, time):
+ '''
+ utility function to show the popup menu
+ '''
+ self.emit('pre-popup')
+ menu = self.get_gtkmenu(source, menu_name)
+ menu.popup(None, None, None, None, button, time)
+
class ActionGroup(object):
'''
container for all Actions used to associate with menu items
View
10 coverart_widgets.py
@@ -965,12 +965,6 @@ def _reallocate_columns(self, *args):
self.set_columns(0)
self.set_columns(-1)
- def pre_display_popup(self):
- '''
- called just before popup is displayed
- '''
- pass
-
def do_button_press_event(self, event):
'''
Other than the default behavior, adds an event firing when the mouse
@@ -993,9 +987,7 @@ def do_button_press_event(self, event):
self.set_cursor(current_path, None, False)
if self.popup:
- self.pre_display_popup()
- self.popup.get_gtkmenu(self.source, 'popup_menu').popup(None,
- None, None, None, event.button, event.time)
+ self.popup.popup(self.source, 'popup_menu', event.button, event.time)
else:
self.emit('item-clicked', event, current_path)
View
3 ui/coverart_artist_pop_rb3.ui
@@ -31,8 +31,5 @@
<attribute name="action">win.artist_cover_search_menu_item</attribute>
</item>
</section>
- <section>
- <attribute name="rb-plugin-menu-link">ca_covers_view</attribute>
- </section>
</menu>
</interface>
View
4 ui/coverart_external_plugins.xml
@@ -86,8 +86,8 @@
</plugin>
<plugin name="opencontainingfolder">
<menu label="Open Containing Folder">
- <attribute name="action_type">win</attribute>
- <attribute name="action_name">OpenContainingFolder</attribute>
+ <attribute name="action_type">app</attribute>
+ <attribute name="action_name">open-containing-folder</attribute>
<attribute name="new_menu_name">Open Containing Folder</attribute>
<attribute name="is_album_menu">yes</attribute>
</menu>

0 comments on commit 961cf2a

Please sign in to comment.