def activate(self, shell):
        '''
        method called to initiate the external plugin action
        the action is defined by defining the action_group_name, action_name and action_type
        '''

        action = ApplicationShell(shell).lookup_action(self.attributes['action_group_name'],
                                                         self.attributes['action_name'],
                                                         self.attributes['action_type'])

        if action:
            action.activate()
    def activate(self, shell):
        '''
        method called to initiate the external plugin action
        the action is defined by defining the action_group_name, action_name and action_type
        '''

        action = ApplicationShell(shell).lookup_action(
            self.attributes['action_group_name'],
            self.attributes['action_name'], self.attributes['action_type'])

        if action:
            action.activate()
Example #3
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)
    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 create_menu_item(self,
                         menubar,
                         section_name,
                         at_position,
                         save_actiongroup,
                         save_menu,
                         for_album=False):
        '''
        method to create the menu item appropriate to the plugin.
        A plugin can have many menu items - all menuitems are enclosed
        in a section.
        
        :param menubar: `str` name for the GtkMenu - ignored for RB2.99
        :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 save_actiongroup: `ActionGroup` container for all menu-item Actions
        :param save_menu: `Menu` whole popupmenu including sub-menus
        :param for_album: `bool` create the menu for the album - if not given
          then its assumed the menu item is appropriate just for tracks
        '''
        if for_album and not self.attributes['is_album_menu']:
            return False

        if not self.is_activated():
            return False

        action = ApplicationShell(save_menu.shell).lookup_action(
            self.attributes['action_group_name'],
            self.attributes['action_name'], self.attributes['action_type'])

        if action:
            self.attributes['action'] = action

            if self.attributes['new_menu_name'] != '':
                self.attributes['label'] = self.attributes['new_menu_name']
            else:
                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,
            action_name=self.attributes['action_name'],
            album=for_album,
            shell=save_menu.shell,
            label=self.attributes['label'])

        new_menu_item = save_menu.insert_menu_item(menubar, section_name,
                                                   at_position, action)
        return new_menu_item
Example #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.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)
    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)