Example #1
0
    def on_drag_data_received(self, widget, drag_context, x, y, data, info,
        time):
        '''
        Callback called when the drag source has prepared the data (pixbuf)
        for us to use.
        '''

        # stop the propagation of the signal (deactivates superclass callback)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-data-received')
        else:
            widget.stop_emission('drag-data-received')

        # get the artist and the info and ask the loader to update the cover
        path, position = self.get_dest_row_at_pos(x, y)
        artist_album = widget.get_model()[path][2]

        pixbuf = data.get_pixbuf()  

        if isinstance(artist_album, Album):
            manager = self.album_manager
        else:
            manager = self.artist_manager
            
        if pixbuf:
            manager.cover_man.update_cover(artist_album, pixbuf)
        else:
            uri = data.get_text()
            manager.cover_man.update_cover(artist_album, uri=uri)

        # call the context drag_finished to inform the source about it
        drag_context.finish(True, False, time)
    def __init__(self, plugin, album_model):
        super(PlaylistPopupController, self).__init__()

        self._album_model = album_model

        shell = plugin.shell
        self.plugin = plugin

        # get the library name and initialize the superclass with it
        self._library_name = shell.props.library_source.props.name

        # get the queue name
        self._queue_name = shell.props.queue_source.props.name

        if " (" in self._queue_name:
            self._queue_name = self._queue_name[0:self._queue_name.find(" (")]

        self._spritesheet = None
        self._update_options(shell)
        
        # get the playlist model so we can monitor changes
        if rb3compat.is_rb3(shell):
            playlist_model = shell.props.display_page_model
        else:
            playlist_manager = shell.props.playlist_manager
            playlist_model = playlist_manager.props.display_page_model

        # connect signals to update playlists
        playlist_model.connect('row-inserted', self._update_options, shell)
        playlist_model.connect('row-deleted', self._update_options, shell)
        playlist_model.connect('row-changed', self._update_options, shell)
Example #3
0
    def on_drag_drop(self, widget, context, x, y, time):
        '''
        Callback called when a drag operation finishes over the view
        of the source. It decides if the dropped item can be processed as
        an image to use as a cover.
        '''

        # stop the propagation of the signal (deactivates superclass callback)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-drop')
        else:
            widget.stop_emission('drag-drop')

        # obtain the path of the icon over which the drag operation finished
        drop_info = self.get_dest_row_at_pos(x, y)
        path = None
        if drop_info:
            path, position = drop_info
            
        result = path is not None

        if result:
            target = self.drag_dest_find_target(context, None)
            widget.drag_get_data(context, target, time)

        return result
    def on_drag_data_received(self, widget, drag_context, x, y, data, info,
        time):
        '''
        Callback called when the drag source has prepared the data (pixbuf)
        for us to use.
        '''

        # stop the propagation of the signal (deactivates superclass callback)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-data-received')
        else:
            widget.stop_emission('drag-data-received')

        # get the album and the info and ask the loader to update the cover
        path, pos = widget.get_dest_item_at_pos(x, y)
        album = widget.get_model()[path][2]

        pixbuf = data.get_pixbuf()

        if pixbuf:
            self.album_manager.cover_man.update_cover(album, pixbuf)
        else:
            uri = data.get_text()
            self.album_manager.cover_man.update_cover(album, uri=uri)

        # call the context drag_finished to inform the source about it
        drag_context.finish(True, False, time)
    def on_drag_drop(self, widget, context, x, y, time):
        '''
        Callback called when a drag operation finishes over the view
        of the source. It decides if the dropped item can be processed as
        an image to use as a cover.
        '''

        # stop the propagation of the signal (deactivates superclass callback)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-drop')
        else:
            widget.stop_emission('drag-drop')

        # obtain the path of the icon over which the drag operation finished
        drop_info = self.get_dest_row_at_pos(x, y)
        path = None
        if drop_info:
            path, position = drop_info
            
        result = path is not None

        if result:
            target = self.drag_dest_find_target(context, None)
            widget.drag_get_data(context, target, time)

        return result
    def __init__(self, plugin, album_model):
        super(PlaylistPopupController, self).__init__()

        self._album_model = album_model

        shell = plugin.shell
        self.plugin = plugin

        # get the library name and initialize the superclass with it
        self._library_name = shell.props.library_source.props.name

        # get the queue name
        self._queue_name = shell.props.queue_source.props.name

        if " (" in self._queue_name:
            self._queue_name = self._queue_name[0:self._queue_name.find(" (")]

        self._spritesheet = None
        self._update_options(shell)

        # get the playlist model so we can monitor changes
        if rb3compat.is_rb3(shell):
            playlist_model = shell.props.display_page_model
        else:
            playlist_manager = shell.props.playlist_manager
            playlist_model = playlist_manager.props.display_page_model

        # connect signals to update playlists
        playlist_model.connect('row-inserted', self._update_options, shell)
        playlist_model.connect('row-deleted', self._update_options, shell)
        playlist_model.connect('row-changed', self._update_options, shell)
Example #7
0
    def on_drag_begin(self, widget, context):
        '''
        Callback called when the drag-drop from coverview has started
        Changes the drag icon as appropriate
        '''
        album_number = len(widget.get_selected_objects())

        if album_number == 1:
            item = Gtk.STOCK_DND
        else:
            item = Gtk.STOCK_DND_MULTIPLE

        widget.drag_source_set_icon_stock(item)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-begin')
        else:
            widget.stop_emission('drag-begin')
Example #8
0
    def on_drag_data_get(self, widget, drag_context, data, info, time):
        '''
        Callback called when the drag destination (playlist) has
        requested what album (icon) has been dragged
        '''

        uris = []
        for album in widget.get_selected_objects():
            for track in album.get_tracks():
                uris.append(track.location)

        data.set_uris(uris)
        # stop the propagation of the signal (deactivates superclass callback)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-data-get')
        else:
            widget.stop_emission('drag-data-get')
    def on_drag_begin(self, widget, context):
        '''
        Callback called when the drag-drop from coverview has started
        Changes the drag icon as appropriate
        '''
        album_number = len(widget.get_selected_objects())

        if album_number == 1:
            item = Gtk.STOCK_DND
        else:
            item = Gtk.STOCK_DND_MULTIPLE

        widget.drag_source_set_icon_stock(item)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-begin')
        else:
            widget.stop_emission('drag-begin')
    def on_drag_data_get(self, widget, drag_context, data, info, time):
        '''
        Callback called when the drag destination (playlist) has
        requested what album (icon) has been dragged
        '''

        uris = []
        for album in widget.get_selected_objects():
            for track in album.get_tracks():
                uris.append(track.location)

        sel = data.set_uris(uris)
        # stop the propagation of the signal (deactivates superclass callback)
        if rb3compat.is_rb3(self.shell):
            widget.stop_emission_by_name('drag-data-get')
        else:
            widget.stop_emission('drag-data-get')
    def __init__(self, section_name, at_position, popup, **kargs):
        super(CreateExternalPluginMenu, self).__init__(**kargs)

        self.menu = popup
        self.section_name = section_name
        self.at_position = at_position
        
        self._actiongroup = ActionGroup(popup.shell, section_name + '_externalplugins')
        
        # all supported plugins will be defined in the following array by parsing
        # the plugins XML file for the definition.  Supported plugins are split between
        # rb2.99 and later and rb2.98 and earlier due to the likelihood that earlier
        # plugins may never be updated by their authors
        
        self.supported_plugins = []
        
        extplugins = rb.find_plugin_file(popup.plugin, 'ui/coverart_external_plugins.xml')
        root = ET.parse(open(extplugins)).getroot()

        if rb3compat.is_rb3(popup.shell):
            base = 'rb3/plugin'
        else:
            base = 'rb2/plugin'

        for elem in root.xpath(base):
            pluginname = elem.attrib['name']

            basemenu = base + "[@name='" + pluginname + "']/menu"
            
            for menuelem in root.xpath(basemenu):
                ext = ExternalPlugin()
                ext.appendattribute('plugin_name', pluginname)

                label = menuelem.attrib['label']
                if label != "":
                    ext.appendattribute('new_menu_name', label)
                    baseattrib = basemenu + "[@label='" + label + "']/attribute"
                else:
                    baseattrib = basemenu + "/attribute"

                for attribelem in root.xpath(baseattrib):
                    key = attribelem.attrib['name']
                    val = attribelem.text
                    ext.appendattribute(key, val)

                self.supported_plugins.append(ext)
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.

from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import RB
from gi.repository import Gdk
from gi.repository import Peas
from coverart_rb3compat import is_rb3

import gi
if is_rb3():
    gi.require_version('Gst', '1.0')
else:
    gi.require_version('Gst', '0.10')
from gi.repository import Gst

from coverart_album import Album
import rb
import shutil
import coverart_rb3compat as rb3compat
import os.path
import os
import sys
import subprocess
from coverart_utils import NaturalString