Exemple #1
0
    def __init__(self, parent, playlist_manager, smart_manager, collection,
                 name):
        """
            Intializes the playlists panel

            @param playlist_manager:  The playlist manager
        """
        panel.Panel.__init__(self, parent, name, _('Playlists'))
        BasePlaylistPanelMixin.__init__(self)
        self.playlist_manager = playlist_manager
        self.smart_manager = smart_manager
        self.collection = collection
        self.box = self.builder.get_object('PlaylistsPanel')

        self.playlist_name_info = 500
        self.track_target = Gtk.TargetEntry.new("text/uri-list", 0, 0)
        self.playlist_target = Gtk.TargetEntry.new("playlist_name",
                                                   Gtk.TargetFlags.SAME_WIDGET,
                                                   self.playlist_name_info)
        self.deny_targets = [Gtk.TargetEntry.new('', 0, 0)]

        self.tree = PlaylistDragTreeView(self)
        self.tree.connect('row-activated', self.open_item)
        self.tree.set_headers_visible(False)
        self.tree.connect('drag-motion', self.drag_motion)
        self.tree.drag_source_set(
            Gdk.ModifierType.BUTTON1_MASK,
            [self.track_target, self.playlist_target],
            Gdk.DragAction.COPY | Gdk.DragAction.MOVE,
        )

        self.scroll = Gtk.ScrolledWindow()
        self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
                               Gtk.PolicyType.AUTOMATIC)
        self.scroll.add(self.tree)
        self.scroll.set_shadow_type(Gtk.ShadowType.IN)
        self.box.pack_start(self.scroll, True, True, 0)
        self.box.show_all()

        pb = Gtk.CellRendererPixbuf()
        cell = Gtk.CellRendererText()
        if settings.get_option('gui/ellipsize_text_in_panels', False):
            from gi.repository import Pango

            cell.set_property('ellipsize-set', True)
            cell.set_property('ellipsize', Pango.EllipsizeMode.END)
        col = Gtk.TreeViewColumn('Text')
        col.pack_start(pb, False)
        col.pack_start(cell, True)
        col.set_attributes(pb, pixbuf=0)
        col.set_attributes(cell, text=1)
        self.tree.append_column(col)
        self.model = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, object)
        self.tree.set_model(self.model)

        # icons
        self.folder = icons.MANAGER.pixbuf_from_icon_name(
            'folder', Gtk.IconSize.SMALL_TOOLBAR)
        self.playlist_image = icons.MANAGER.pixbuf_from_icon_name(
            'music-library', Gtk.IconSize.SMALL_TOOLBAR)

        # menus
        self.playlist_menu = menus.PlaylistsPanelPlaylistMenu(self)
        self.smart_menu = menus.PlaylistsPanelPlaylistMenu(self)
        self.default_menu = menus.PlaylistPanelMenu(self)

        self.track_menu = menus.TrackPanelMenu(self)

        self._connect_events()
        self._load_playlists()
Exemple #2
0
    def __init__(self, parent, playlist_manager,
        smart_manager, collection, name):
        """
            Intializes the playlists panel

            @param playlist_manager:  The playlist manager
        """
        panel.Panel.__init__(self, parent, name)
        BasePlaylistPanelMixin.__init__(self)
        self.playlist_manager = playlist_manager
        self.smart_manager = smart_manager
        self.collection = collection
        self.box = self.builder.get_object('playlists_box')

        self._refresh_id = None
        self.playlist_name_info = 500
        self.track_target = ("text/uri-list", 0, 0)
        self.playlist_target = ("playlist_name", gtk.TARGET_SAME_WIDGET, 
            self.playlist_name_info)
        self.deny_targets = [('',0,0)]

        self.tree = PlaylistDragTreeView(self)
        self.tree.connect('row-activated', self.open_item)
        self.tree.set_headers_visible(False)
        self.tree.connect('drag-motion', self.drag_motion)
        self.tree.drag_source_set(
                gtk.gdk.BUTTON1_MASK, [self.track_target, self.playlist_target],
                gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE)

        self.scroll = gtk.ScrolledWindow()
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll.add(self.tree)
        self.scroll.set_shadow_type(gtk.SHADOW_IN)
        self.box.pack_start(self.scroll, True, True)
        self.box.show_all()

        pb = gtk.CellRendererPixbuf()
        cell = gtk.CellRendererText()
        if settings.get_option('gui/ellipsize_text_in_panels', False):
            import pango
            cell.set_property( 'ellipsize-set', True)
            cell.set_property( 'ellipsize', pango.ELLIPSIZE_END)
        col = gtk.TreeViewColumn('Text')
        col.pack_start(pb, False)
        col.pack_start(cell, True)
        col.set_attributes(pb, pixbuf=0)
        col.set_attributes(cell, text=1)
        self.tree.append_column(col)
        self.model = gtk.TreeStore(gtk.gdk.Pixbuf, str, object)
        self.tree.set_model(self.model)

        # icons
        self.folder = self.tree.render_icon(
            gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_SMALL_TOOLBAR)
        self.playlist_image = icons.MANAGER.pixbuf_from_icon_name(
            'music-library', gtk.ICON_SIZE_SMALL_TOOLBAR)

        # menus
        self.playlist_menu = menus.PlaylistsPanelPlaylistMenu(self)
        self.smart_menu = menus.PlaylistsPanelPlaylistMenu(self)
        self.default_menu = menus.PlaylistPanelMenu(self)
        
        self.track_menu = menus.TrackPanelMenu(self)
        
        self._connect_events()
        self._load_playlists()