def do_impl_activate(self):
        '''
        Called by do_selected the first time the source is activated.
        It creates all the source ui and connects the necesary signals for it
        correct behavior.
        '''
        print("CoverArtBrowser DEBUG - do_impl_activate")

        # initialise some variables
        self.plugin = self.props.plugin
        self.shell = self.props.shell
        self.status = ''
        self.search_text = ''
        self.actiongroup = ActionGroup(self.shell, 'coverplaylist_submenu')
        self._browser_preferences = None
        self._search_preferences = None

        # indicate that the source was activated before
        self.hasActivated = True

        self._create_ui()
        self._setup_source()
        self._apply_settings()

        print("CoverArtBrowser DEBUG - end do_impl_activate")
    def do_impl_activate(self):
        '''
        Called by do_selected the first time the source is activated.
        It creates all the source ui and connects the necessary signals for it
        correct behavior.
        '''
        print('do_impl_activate')
        self.hasActivated = True

        self.entryview = CoverArtPlayEntryView(self.shell, self.source)
        self.entryview.props.hexpand = True
        self.entryview.props.vexpand = True
        grid = Gtk.Grid()
        grid.attach(self.entryview, 0, 1, 1, 1)

        self.entryview.set_model(self.source.source_query_model)

        # enable sorting on the entryview
        # entryview.set_columns_clickable(True)
        self.shell.props.library_source.get_entry_view().set_columns_clickable(
            True)

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
        location = rb.find_plugin_file(self.plugin, 'ui/playsource-toolbar.ui')
        ui = Gtk.Builder()
        ui.set_translation_domain(cl.Locale.RB)
        ui.add_from_file(location)
        toolbar_menu = ui.get_object('playsource-toolbar')
        app = self.shell.props.application
        app.link_shared_menus(toolbar_menu)
        bar = RB.ButtonBar.new(toolbar_menu, toolbar_menu)
        grid.attach(bar, 0, 0, 1, 1)

        grid.show_all()
        self.pack_start(grid, True, True, 0)

        appshell = ApplicationShell(self.shell)
        action_group = ActionGroup(self.shell, 'PlaySourceActions')
        action_group.add_action(func=self.clear_playsource,
                                action_name='playsource-clear', action_state=ActionGroup.STANDARD,
                                action_type='app')
        action_group.add_action(func=self.shuffle_playsource,
                                action_name='playsource-shuffle', action_state=ActionGroup.STANDARD,
                                action_type='app')
        appshell.insert_action_group(action_group)
    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.

        self.supported_plugins = []

        extplugins = rb.find_plugin_file(popup.plugin,
                                         'ui/coverart_external_plugins.xml')
        root = ET.parse(open(extplugins)).getroot()

        base = 'rb3/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)
    def __init__(self, shell, source):
        '''
        Initializes the entryview.
        '''
        self.shell = shell
        self.source = source
        self.plugin = self.source.props.plugin

        super(RB.EntryView,
              self).__init__(db=shell.props.db,
                             shell_player=shell.props.shell_player,
                             is_drag_source=True,
                             visible_columns=[])

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.RB)

        self.display_columns()

        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)

        self.define_menu()

        # connect signals to the shell to know when the playing state changes
        self.shell.props.shell_player.connect('playing-song-changed',
                                              self.playing_song_changed)
        self.shell.props.shell_player.connect('playing-changed',
                                              self.playing_changed)

        self.actiongroup = ActionGroup(self.shell,
                                       'coverentryplaylist_submenu')

        self.external_plugins = None

        self.source_query_model = self.source.source_query_model  # RB.RhythmDBQueryModel.new_empty(self.shell.props.db)
        self.qm = RB.RhythmDBQueryModel.new_empty(self.shell.props.db)
        self.set_model(self.qm)

        self.connect_library_signals()
        self.echonest_similar_playlist = None
        self.echonest_similar_genre_playlist = None
        self.lastfm_similar_playlist = None

        self.connect('selection-changed', self.selection_changed)

        self.artists = ""

        print("end constructor")
    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)
Exemple #6
0
    def do_impl_activate(self):
        '''
        Called by do_selected the first time the source is activated.
        It creates all the source ui and connects the necessary signals for it
        correct behavior.
        '''
        print('do_impl_activate')
        self.hasActivated = True

        self.entryview = CoverArtPlayEntryView(self.shell, self.source)
        self.entryview.props.hexpand = True
        self.entryview.props.vexpand = True
        grid = Gtk.Grid()
        grid.attach(self.entryview, 0, 1, 1, 1)

        self.entryview.set_model(self.source.source_query_model)

        # enable sorting on the entryview
        # entryview.set_columns_clickable(True)
        self.shell.props.library_source.get_entry_view().set_columns_clickable(
            True)

        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
        location = rb.find_plugin_file(self.plugin, 'ui/playsource-toolbar.ui')
        ui = Gtk.Builder()
        ui.set_translation_domain(cl.Locale.RB)
        ui.add_from_file(location)
        toolbar_menu = ui.get_object('playsource-toolbar')
        app = self.shell.props.application
        app.link_shared_menus(toolbar_menu)
        bar = RB.ButtonBar.new(toolbar_menu, toolbar_menu)
        grid.attach(bar, 0, 0, 1, 1)

        grid.show_all()
        self.pack_start(grid, True, True, 0)

        appshell = ApplicationShell(self.shell)
        action_group = ActionGroup(self.shell, 'PlaySourceActions')
        action_group.add_action(func=self.clear_playsource,
                                action_name='playsource-clear',
                                action_state=ActionGroup.STANDARD,
                                action_type='app')
        action_group.add_action(func=self.shuffle_playsource,
                                action_name='playsource-shuffle',
                                action_state=ActionGroup.STANDARD,
                                action_type='app')
        appshell.insert_action_group(action_group)
class CreateExternalPluginMenu(GObject.Object):
    '''
    This is the key class called to initialise all supported plugins
    
    :param section_name: `str` unique name of the section holding the menu items
    :param at_position: `int` position within the GtkMenu to create menu - ignored for RB2.99
    :param popup: `Menu` whole popupmenu including sub-menus
    '''

    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.

        self.supported_plugins = []

        extplugins = rb.find_plugin_file(popup.plugin, 'ui/coverart_external_plugins.xml')
        root = ET.parse(open(extplugins)).getroot()

        base = 'rb3/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)

    def create_menu(self, menu_name, for_album=False):
        '''
        method to create the menu items for all supported plugins

        :param menu_name: `str` unique name (GtkMenu) id for the menu to create
        :for_album: `bool` - create a menu applicable for Albums
          by default a menu is assumed to be applicable to a track in an
          EntryView
        '''
        self.menu_name = menu_name

        self._actiongroup.remove_actions()
        self.menu.remove_menu_items(self.menu_name, self.section_name)

        items_added = False

        for plugin in self.supported_plugins:
            new_menu_item = plugin.create_menu_item(self.menu_name, self.section_name,
                                                    self.at_position, self._actiongroup, self.menu, for_album)

            if (not items_added) and new_menu_item:
                items_added = True

        if items_added:
            self.menu.insert_separator(self.menu_name, self.at_position)
Exemple #8
0
    def do_impl_activate(self):
        '''
        Called by do_selected the first time the source is activated.
        It creates all the source ui and connects the necessary signals for it
        correct behavior.
        '''
        print('do_impl_activate')

        self.plugin = self.props.plugin
        self.shell = self.props.shell

        player = self.shell.props.shell_player
        player.set_playing_source(self)
        player.set_selected_source(self)

        # define a query model that we'll use for playing
        self.source_query_model = self.plugin.source_query_model

        grid = Gtk.Grid()

        self.entryview = self.get_entry_view()

        child = self.get_children()
        print(child)

        grid = child[0]
        self.rbsourcetoolbar = grid.get_children(
        )[1]  # need to remember the reference to stop crashes when python cleans up unlinked objects
        grid.remove(grid.get_children()[1])

        self.get_entry_view().set_model(self.source_query_model)
        '''
        # enable sorting on the entryview
         entryview.set_columns_clickable(True)
        self.shell.props.library_source.get_entry_view().set_columns_clickable(
            True)
        '''
        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
        location = rb.find_plugin_file(self.plugin, 'ui/playsource-toolbar.ui')
        ui = Gtk.Builder()
        ui.set_translation_domain(cl.Locale.RB)
        ui.add_from_file(location)
        toolbar_menu = ui.get_object('playsource-toolbar')
        app = self.shell.props.application
        app.link_shared_menus(toolbar_menu)
        self.toolbar = RB.ButtonBar.new(toolbar_menu, toolbar_menu)
        self.toolbar.props.hexpand_set = False
        grid.attach(self.toolbar, 0, 0, 1, 1)

        grid.show_all()

        appshell = ApplicationShell(self.shell)
        action_group = ActionGroup(self.shell, 'PlaySourceActions')
        action_group.add_action(func=self.clear_playsource,
                                action_name='playsource-clear',
                                action_state=ActionGroup.STANDARD,
                                action_type='app')
        action_group.add_action(func=self.shuffle_playsource,
                                action_name='playsource-shuffle',
                                action_state=ActionGroup.STANDARD,
                                action_type='app')
        appshell.insert_action_group(action_group)

        # if the alternative-toolbar is loaded then lets connect to the toolbar-visibility signal
        # to control our sources toolbar visibility

        #if hasattr(self.shell, 'alternative_toolbar'):
        #    self.shell.alternative_toolbar.connect('toolbar-visibility', self._visibility)

        self._load_model()

        self.source_query_model.connect('row-inserted',
                                        self.save_changed_model)
        self.source_query_model.connect('row-changed', self.save_changed_model)
        self.source_query_model.connect('row-deleted', self.save_changed_model)
class CreateExternalPluginMenu(GObject.Object):
    '''
    This is the key class called to initialise all supported plugins
    
    :param section_name: `str` unique name of the section holding the menu items
    :param at_position: `int` position within the GtkMenu to create menu - ignored for RB2.99
    :param popup: `Menu` whole popupmenu including sub-menus
    '''
    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.

        self.supported_plugins = []

        extplugins = rb.find_plugin_file(popup.plugin,
                                         'ui/coverart_external_plugins.xml')
        root = ET.parse(open(extplugins)).getroot()

        base = 'rb3/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)

    def create_menu(self, menu_name, for_album=False):
        '''
        method to create the menu items for all supported plugins

        :param menu_name: `str` unique name (GtkMenu) id for the menu to create
        :for_album: `bool` - create a menu applicable for Albums
          by default a menu is assumed to be applicable to a track in an
          EntryView
        '''
        self.menu_name = menu_name

        self._actiongroup.remove_actions()
        self.menu.remove_menu_items(self.menu_name, self.section_name)

        items_added = False

        for plugin in self.supported_plugins:
            new_menu_item = plugin.create_menu_item(self.menu_name,
                                                    self.section_name,
                                                    self.at_position,
                                                    self._actiongroup,
                                                    self.menu, for_album)

            if (not items_added) and new_menu_item:
                items_added = True

        if items_added:
            self.menu.insert_separator(self.menu_name, self.at_position)
    def do_impl_activate(self):
        '''
        Called by do_selected the first time the source is activated.
        It creates all the source ui and connects the necessary signals for it
        correct behavior.
        '''
        print('do_impl_activate')

        self.plugin = self.props.plugin
        self.shell = self.props.shell

        player = self.shell.props.shell_player
        player.set_playing_source(self)
        player.set_selected_source(self)


        # define a query model that we'll use for playing
        self.source_query_model = self.plugin.source_query_model

        grid = Gtk.Grid()

        self.entryview = self.get_entry_view()

        child = self.get_children()
        print (child)

        grid = child[0]
        self.rbsourcetoolbar = grid.get_children()[1] # need to remember the reference to stop crashes when python cleans up unlinked objects
        grid.remove(grid.get_children()[1])

        self.get_entry_view().set_model(self.source_query_model)
        '''
        # enable sorting on the entryview
         entryview.set_columns_clickable(True)
        self.shell.props.library_source.get_entry_view().set_columns_clickable(
            True)
        '''
        cl = CoverLocale()
        cl.switch_locale(cl.Locale.LOCALE_DOMAIN)
        location = rb.find_plugin_file(self.plugin, 'ui/playsource-toolbar.ui')
        ui = Gtk.Builder()
        ui.set_translation_domain(cl.Locale.RB)
        ui.add_from_file(location)
        toolbar_menu = ui.get_object('playsource-toolbar')
        app = self.shell.props.application
        app.link_shared_menus(toolbar_menu)
        self.toolbar = RB.ButtonBar.new(toolbar_menu, toolbar_menu)
        self.toolbar.props.hexpand_set = False
        grid.attach(self.toolbar, 0, 0, 1, 1)

        grid.show_all()

        appshell = ApplicationShell(self.shell)
        action_group = ActionGroup(self.shell, 'PlaySourceActions')
        action_group.add_action(func=self.clear_playsource,
                                action_name='playsource-clear', action_state=ActionGroup.STANDARD,
                                action_type='app')
        action_group.add_action(func=self.shuffle_playsource,
                                action_name='playsource-shuffle', action_state=ActionGroup.STANDARD,
                                action_type='app')
        appshell.insert_action_group(action_group)


        # if the alternative-toolbar is loaded then lets connect to the toolbar-visibility signal
        # to control our sources toolbar visibility

        #if hasattr(self.shell, 'alternative_toolbar'):
        #    self.shell.alternative_toolbar.connect('toolbar-visibility', self._visibility)

        self._load_model()

        self.source_query_model.connect('row-inserted', self.save_changed_model)
        self.source_query_model.connect('row-changed', self.save_changed_model)
        self.source_query_model.connect('row-deleted', self.save_changed_model)