Пример #1
0
    def __init__(self, genre_ids, artist_ids):
        """
            Init album view
            @param genre ids as [int]
            @param artist ids as [int]
        """
        LazyLoadingView.__init__(self)
        self._signal = None
        self._context_album_id = None
        self._genre_ids = genre_ids
        self._artist_ids = artist_ids
        self._press_rect = None

        self._albumbox = Gtk.FlowBox()
        self._albumbox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._albumbox.connect('child-activated', self._on_album_activated)
        self._albumbox.connect('button-press-event', self._on_button_press)
        self._albumbox.set_homogeneous(True)
        self._albumbox.set_max_children_per_line(1000)
        self._albumbox.show()

        self._viewport.set_property('valign', Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._scrolled.set_property('expand', True)
        self._scrolled.set_property('height-request', 10)
        self.add(self._scrolled)
 def __init__(self, list_type, artist_ids=[], genre_ids=[]):
     """
         Init widget
         @param list_type as RowListType
         @param artist_ids as int
         @param genre_ids as int
     """
     LazyLoadingView.__init__(self, True)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self.__list_type = list_type
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     self.__autoscroll_timeout_id = None
     self.__reveals = []
     self.__prev_animated_rows = []
     # Calculate default album height based on current pango context
     # We may need to listen to screen changes
     self.__height = AlbumRow.get_best_height(self)
     self._box = Gtk.ListBox()
     self._box.get_style_context().add_class("trackswidget")
     self._box.set_vexpand(True)
     self._box.set_selection_mode(Gtk.SelectionMode.NONE)
     self._box.set_activate_on_single_click(True)
     self._box.set_filter_func(self._filter_func)
     self._box.show()
     self._scrolled.set_property("expand", True)
     self.add(self._scrolled)
    def __init__(self, artist_ids, genre_ids, show_cover=True):
        """
            Init ArtistAlbumsView
            @param artist ids as [int]
            @param genre ids as [int]
            @param show cover as bool
        """
        LazyLoadingView.__init__(self, True)
        self._artist_ids = artist_ids
        self._genre_ids = genre_ids
        self.__show_cover = show_cover

        self.__spinner = Gtk.Spinner()
        self.__spinner.set_hexpand(True)
        self.__spinner.set_vexpand(True)
        spinner_size = int(ArtSize.BIG / 3)
        self.__spinner.set_size_request(spinner_size, spinner_size)
        self.__spinner.set_property('halign', Gtk.Align.CENTER)
        self.__spinner.set_property('valign', Gtk.Align.CENTER)
        self.__spinner.show()

        self._albumbox = Gtk.Grid()
        self._albumbox.set_row_spacing(5)
        self._albumbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self._albumbox.show()
        self._viewport.add(self._albumbox)

        self._albumbox.set_property("valign", Gtk.Align.START)
        self._overlay = Gtk.Overlay.new()
        self._overlay.add(self._scrolled)
        self._overlay.add_overlay(self.__spinner)
        self._overlay.show()
        self.add(self._overlay)
Пример #4
0
    def __init__(self, artist_ids, genre_ids, art_size):
        """
            Init ArtistAlbumsView
            @param artist ids as [int]
            @param genre ids as [int]
            @param art size as ArtSize
        """
        LazyLoadingView.__init__(self, True)
        self._artist_ids = artist_ids
        self._genre_ids = genre_ids
        self.__art_size = art_size
        self.__spinner = Gtk.Spinner()
        self.__spinner.set_hexpand(True)
        self.__spinner.set_vexpand(True)
        spinner_size = int(ArtSize.BIG / 3)
        self.__spinner.set_size_request(spinner_size, spinner_size)
        self.__spinner.set_property("halign", Gtk.Align.CENTER)
        self.__spinner.set_property("valign", Gtk.Align.CENTER)
        self.__spinner.show()

        self._albumbox = Gtk.Grid()
        self._albumbox.set_row_spacing(5)
        self._albumbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self._albumbox.show()
        self._viewport.add(self._albumbox)

        self._albumbox.set_property("valign", Gtk.Align.START)
        self._overlay = Gtk.Overlay.new()
        self._overlay.add(self._scrolled)
        self._overlay.add_overlay(self.__spinner)
        self._overlay.show()
        self.add(self._overlay)
 def __init__(self, genre_ids, artist_ids, view_type):
     """
         Init widget
         @param genre_ids as int
         @param artist_ids as int
         @param view_type as ViewType
     """
     LazyLoadingView.__init__(self, view_type | ViewType.FILTERED)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     if genre_ids and genre_ids[0] < 0:
         if genre_ids[0] == Type.WEB and\
                 GLib.find_program_in_path("youtube-dl") is None:
             self._empty_message = _("Missing youtube-dl command")
         self._empty_icon_name = get_icon_name(genre_ids[0])
     self.__autoscroll_timeout_id = None
     self.__reveals = []
     self.__prev_animated_rows = []
     # Calculate default album height based on current pango context
     # We may need to listen to screen changes
     self.__height = AlbumRow.get_best_height(self)
     self._box = Gtk.ListBox()
     self._box.set_margin_end(MARGIN)
     self._box.get_style_context().add_class("trackswidget")
     self._box.set_vexpand(True)
     self._box.set_selection_mode(Gtk.SelectionMode.NONE)
     self._box.set_activate_on_single_click(True)
     self._box.set_filter_func(self._filter_func)
     self._box.show()
     self._scrolled.set_property("expand", True)
     self.add(self._scrolled)
Пример #6
0
    def __init__(self, genre_ids, artist_ids):
        """
            Init album view
            @param genre ids as [int]
            @param artist ids as [int]
        """
        LazyLoadingView.__init__(self, True)
        self.__signal = None
        self.__current = None
        self.__context_album_id = None
        self.__genre_ids = genre_ids
        self.__artist_ids = artist_ids
        self.__press_rect = None

        self._box = Gtk.FlowBox()
        self._box.set_filter_func(self._filter_func)
        self._box.set_selection_mode(Gtk.SelectionMode.NONE)
        self._box.connect('child-activated', self.__on_album_activated)
        # Allow lazy loading to not jump up and down
        self._box.set_homogeneous(True)
        self._box.set_max_children_per_line(1000)
        self._box.show()

        self._viewport.set_property('valign', Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._scrolled.set_property('expand', True)

        self.add(self._scrolled)
Пример #7
0
 def __init__(self):
     """
         Init Popover
     """
     LazyLoadingView.__init__(self)
     # Calculate default album height based on current pango context
     # We may need to listen to screen changes
     self._height = AlbumRow.get_best_height(self)
     self.connect('map', self._on_map)
     self.connect('unmap', self._on_unmap)
     self._clear_button = Gtk.Button.new_from_icon_name(
                                                 'edit-clear-all-symbolic',
                                                 Gtk.IconSize.MENU)
     self._clear_button.set_relief(Gtk.ReliefStyle.NONE)
     self._clear_button.set_tooltip_text(_("Clear albums"))
     self._clear_button.set_sensitive(False)
     self._clear_button.connect('clicked', self._on_clear_clicked)
     self._jump_button = Gtk.Button.new_from_icon_name(
                                                 'go-jump-symbolic',
                                                 Gtk.IconSize.MENU)
     self._jump_button.set_relief(Gtk.ReliefStyle.NONE)
     self._jump_button.connect('clicked', self._on_jump_clicked)
     self._jump_button.set_tooltip_text(_("Go to current track"))
     label = Gtk.Label.new("<b>"+_("Playing albums")+"</b>")
     label.set_use_markup(True)
     label.set_hexpand(True)
     label.set_margin_start(2)
     label.get_style_context().add_class('dim-label')
     label.set_property('halign', Gtk.Align.START)
     self.set_row_spacing(2)
     grid = Gtk.Grid()
     grid.set_column_spacing(5)
     grid.add(label)
     grid.add(self._jump_button)
     grid.add(self._clear_button)
     grid.show_all()
     self._view = Gtk.ListBox()
     self._view.get_style_context().add_class('trackswidget')
     self._view.set_vexpand(True)
     self._view.set_selection_mode(Gtk.SelectionMode.NONE)
     self._view.set_activate_on_single_click(True)
     self._view.connect("row-activated", self._on_row_activated)
     self._view.show()
     self.add(grid)
     self._scrolled.set_property('expand', True)
     self.add(self._scrolled)
     self.drag_dest_set(Gtk.DestDefaults.DROP | Gtk.DestDefaults.MOTION,
                        [], Gdk.DragAction.MOVE)
     self.drag_dest_add_text_targets()
     self.connect('drag-data-received', self._on_drag_data_received)
Пример #8
0
 def __init__(self):
     """
         Init Popover
     """
     LazyLoadingView.__init__(self)
     # Calculate default album height based on current pango context
     # We may need to listen to screen changes
     self.__height = AlbumRow.get_best_height(self)
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.__clear_button = Gtk.Button.new_from_icon_name(
         "edit-clear-all-symbolic", Gtk.IconSize.MENU)
     self.__clear_button.set_relief(Gtk.ReliefStyle.NONE)
     self.__clear_button.set_tooltip_text(_("Clear albums"))
     self.__clear_button.set_sensitive(False)
     self.__clear_button.connect("clicked", self.__on_clear_clicked)
     self.__jump_button = Gtk.Button.new_from_icon_name(
         "go-jump-symbolic", Gtk.IconSize.MENU)
     self.__jump_button.set_relief(Gtk.ReliefStyle.NONE)
     self.__jump_button.connect("clicked", self.__on_jump_clicked)
     self.__jump_button.set_tooltip_text(_("Go to current track"))
     label = Gtk.Label.new("<b>" + _("Playing albums") + "</b>")
     label.set_use_markup(True)
     label.set_hexpand(True)
     label.set_margin_start(2)
     label.get_style_context().add_class("dim-label")
     label.set_property("halign", Gtk.Align.START)
     self.set_row_spacing(2)
     grid = Gtk.Grid()
     grid.set_column_spacing(5)
     grid.add(label)
     grid.add(self.__jump_button)
     grid.add(self.__clear_button)
     grid.show_all()
     self.__view = Gtk.ListBox()
     self.__view.get_style_context().add_class("trackswidget")
     self.__view.set_vexpand(True)
     self.__view.set_selection_mode(Gtk.SelectionMode.NONE)
     self.__view.set_activate_on_single_click(True)
     self.__view.connect("row-activated", self.__on_row_activated)
     self.__view.show()
     self.add(grid)
     self._scrolled.set_property("expand", True)
     self.add(self._scrolled)
     self.drag_dest_set(Gtk.DestDefaults.DROP | Gtk.DestDefaults.MOTION, [],
                        Gdk.DragAction.MOVE)
     self.drag_dest_add_text_targets()
     self.connect("drag-data-received", self.__on_drag_data_received)
Пример #9
0
 def __init__(self):
     """
         Init Popover
     """
     LazyLoadingView.__init__(self)
     # Calculate default album height based on current pango context
     # We may need to listen to screen changes
     self._height = AlbumRow.get_best_height(self)
     self.connect('map', self._on_map)
     self.connect('unmap', self._on_unmap)
     self._clear_button = Gtk.Button.new_from_icon_name(
         'edit-clear-all-symbolic', Gtk.IconSize.MENU)
     self._clear_button.set_relief(Gtk.ReliefStyle.NONE)
     self._clear_button.set_tooltip_text(_("Clear albums"))
     self._clear_button.set_sensitive(False)
     self._clear_button.connect('clicked', self._on_clear_clicked)
     self._jump_button = Gtk.Button.new_from_icon_name(
         'go-jump-symbolic', Gtk.IconSize.MENU)
     self._jump_button.set_relief(Gtk.ReliefStyle.NONE)
     self._jump_button.connect('clicked', self._on_jump_clicked)
     self._jump_button.set_tooltip_text(_("Go to current track"))
     label = Gtk.Label.new("<b>" + _("Playing albums") + "</b>")
     label.set_use_markup(True)
     label.set_hexpand(True)
     label.set_margin_start(2)
     label.get_style_context().add_class('dim-label')
     label.set_property('halign', Gtk.Align.START)
     self.set_row_spacing(2)
     grid = Gtk.Grid()
     grid.set_column_spacing(5)
     grid.add(label)
     grid.add(self._jump_button)
     grid.add(self._clear_button)
     grid.show_all()
     self._view = Gtk.ListBox()
     self._view.get_style_context().add_class('trackswidget')
     self._view.set_vexpand(True)
     self._view.set_selection_mode(Gtk.SelectionMode.NONE)
     self._view.set_activate_on_single_click(True)
     self._view.connect("row-activated", self._on_row_activated)
     self._view.show()
     self.add(grid)
     self._scrolled.set_property('expand', True)
     self.add(self._scrolled)
Пример #10
0
    def __init__(self, artist_ids, genre_ids):
        """
            Init ArtistAlbumsView
            @param artist ids as [int]
            @param genre ids as [int]
        """
        LazyLoadingView.__init__(self)
        self._artist_ids = artist_ids
        self._genre_ids = genre_ids
        self._albums_count = 0

        self._albumbox = Gtk.Grid()
        self._albumbox.set_row_spacing(20)
        self._albumbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self._albumbox.show()

        self._scrolled.set_property('expand', True)
        self._viewport.set_property("valign", Gtk.Align.START)
        self.attach(self._scrolled, 0, 1, 1, 1)
Пример #11
0
    def __init__(self, artist_ids, genre_ids):
        """
            Init ArtistAlbumsView
            @param artist ids as [int]
            @param genre ids as [int]
        """
        LazyLoadingView.__init__(self)
        self._artist_ids = artist_ids
        self._genre_ids = genre_ids
        self._albums_count = 0

        self._albumbox = Gtk.Grid()
        self._albumbox.set_row_spacing(20)
        self._albumbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self._albumbox.show()

        self._scrolled.set_property('expand', True)
        self._viewport.set_property("valign", Gtk.Align.START)
        self.attach(self._scrolled, 0, 1, 1, 1)
Пример #12
0
    def __init__(self):
        """
            Init view
        """
        LazyLoadingView.__init__(self)
        self._signal = Lp().art.connect('radio-artwork-changed',
                                        self._on_logo_changed)

        self._radios_manager = Radios()
        self._radios_manager.connect('radios-changed',
                                     self._on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
        builder.connect_signals(self)
        widget = builder.get_object('widget')
        self._empty = builder.get_object('empty')

        self._pop_tunein = TuneinPopover(self._radios_manager)
        self._pop_tunein.set_relative_to(builder.get_object('search_btn'))

        self._radiobox = Gtk.FlowBox()
        self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._radiobox.set_property('column-spacing', 5)
        self._radiobox.set_property('row-spacing', 5)
        self._radiobox.set_homogeneous(True)
        self._radiobox.set_max_children_per_line(1000)
        self._radiobox.show()

        self._stack = Gtk.Stack()
        self._stack.set_transition_duration(500)
        self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self._stack.add(self._scrolled)
        self._stack.add(self._empty)
        self._stack.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._scrolled.set_property('expand', True)

        self.add(widget)
        self.add(self._stack)
Пример #13
0
    def __init__(self):
        """
            Init view
        """
        LazyLoadingView.__init__(self, True)
        self.__signal = Lp().art.connect("radio-artwork-changed",
                                         self.__on_logo_changed)

        self.__radios_manager = Radios()
        self.__radios_manager.connect("radios-changed",
                                      self.__on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/RadiosView.ui")
        builder.connect_signals(self)
        widget = builder.get_object("widget")
        self.__empty = builder.get_object("empty")

        self.__pop_tunein = TuneinPopover(self.__radios_manager)
        self.__pop_tunein.set_relative_to(builder.get_object("search_btn"))

        self._box = Gtk.FlowBox()
        self._box.set_selection_mode(Gtk.SelectionMode.NONE)
        # Allow lazy loading to not jump up and down
        self._box.set_homogeneous(True)
        self._box.set_max_children_per_line(1000)
        self._box.set_filter_func(self._filter_func)
        self._box.show()

        self.__stack = Gtk.Stack()
        self.__stack.set_transition_duration(500)
        self.__stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self.__stack.add(self._scrolled)
        self.__stack.add(self.__empty)
        self.__stack.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property("margin", 5)
        self._scrolled.set_property("expand", True)

        self.add(widget)
        self.add(self.__stack)
Пример #14
0
 def __init__(self, artist_ids, genre_ids, view_type):
     """
         Init ArtistAlbumsView
         @param artist_ids as [int]
         @param genre_ids as [int]
         @param view_type as ViewType
     """
     LazyLoadingView.__init__(self, view_type | ViewType.FILTERED)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self._artist_ids = artist_ids
     self._genre_ids = genre_ids
     self._album_box = Gtk.Grid()
     self._album_box.set_row_spacing(50)
     self._album_box.set_orientation(Gtk.Orientation.VERTICAL)
     self._album_box.set_property("valign", Gtk.Align.START)
     self._album_box.show()
     self._viewport.add(self._album_box)
     self._overlay = Gtk.Overlay.new()
     self._overlay.add(self._scrolled)
     self._overlay.show()
     self.add(self._overlay)
Пример #15
0
    def __init__(self):
        """
            Init decade view
        """
        LazyLoadingView.__init__(self, True)
        self._widget_class = None
        self._items = []
        self._box = Gtk.FlowBox()
        self._box.set_filter_func(self._filter_func)
        self._box.set_selection_mode(Gtk.SelectionMode.NONE)
        # Allow lazy loading to not jump up and down
        self._box.set_homogeneous(True)
        self._box.set_max_children_per_line(1000)
        self._box.connect("child-activated", self._on_item_activated)
        self._box.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property("margin", 5)
        self._scrolled.set_property("expand", True)

        self.add(self._scrolled)
Пример #16
0
 def __init__(self, album, artist_ids, genre_ids, view_type):
     """
         Init ArtistView
         @param album as Album
         @param artist_ids as [int]
         @param genre_ids as [int]
         @param view_type as ViewType
     """
     LazyLoadingView.__init__(self, view_type)
     TracksView.__init__(self, view_type)
     ViewController.__init__(self, ViewControllerType.ALBUM)
     self._album = album
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     self.__grid = Gtk.Grid()
     self.__grid.set_property("vexpand", True)
     self.__grid.set_row_spacing(10)
     self.__grid.set_margin_start(MARGIN)
     self.__grid.set_margin_end(MARGIN)
     self.__grid.set_orientation(Gtk.Orientation.VERTICAL)
     self.__grid.show()
Пример #17
0
    def __init__(self):
        """
            Init view
        """
        LazyLoadingView.__init__(self)
        self._signal = Lp().art.connect('radio-artwork-changed',
                                        self._on_logo_changed)

        self._radios_manager = Radios()
        self._radios_manager.connect('radios-changed', self._on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
        builder.connect_signals(self)
        widget = builder.get_object('widget')
        self._empty = builder.get_object('empty')

        self._pop_tunein = TuneinPopover(self._radios_manager)
        self._pop_tunein.set_relative_to(builder.get_object('search_btn'))

        self._radiobox = Gtk.FlowBox()
        self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._radiobox.set_property('column-spacing', 5)
        self._radiobox.set_property('row-spacing', 5)
        self._radiobox.set_homogeneous(True)
        self._radiobox.set_max_children_per_line(1000)
        self._radiobox.show()

        self._stack = Gtk.Stack()
        self._stack.set_transition_duration(500)
        self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self._stack.add(self._scrolled)
        self._stack.add(self._empty)
        self._stack.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._scrolled.set_property('expand', True)

        self.add(widget)
        self.add(self._stack)
Пример #18
0
    def __init__(self, genre_ids, artist_ids):
        """
            Init album view
            @param genre ids as [int]
            @param artist ids as [int]
        """
        LazyLoadingView.__init__(self)
        self._signal = None
        self._context_album_id = None
        self._genre_ids = genre_ids
        self._artist_ids = artist_ids
        self._albumsongs = None
        self._context_widget = None
        self._press_rect = None

        self._albumbox = Gtk.FlowBox()
        self._albumbox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._albumbox.connect('child-activated', self._on_album_activated)
        self._albumbox.connect('button-press-event', self._on_button_press)
        self._albumbox.set_property('column-spacing', 5)
        self._albumbox.set_property('row-spacing', 5)
        self._albumbox.set_homogeneous(True)
        self._albumbox.set_max_children_per_line(1000)
        self._albumbox.show()

        self._viewport.set_property('valign', Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._scrolled.set_property('expand', True)
        self._scrolled.set_property('height-request', 10)
        self._context = ViewContainer(500)

        separator = Gtk.Separator()
        separator.show()

        self._paned = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
        self._paned.pack1(self._scrolled, True, False)
        self._paned.pack2(self._context, False, False)
        self._paned.connect('notify::position', self._on_position_notify)
        self._paned.show()
        self.add(self._paned)
Пример #19
0
    def __init__(self, genre_ids, artist_ids):
        """
            Init album view
            @param genre ids as [int]
            @param artist ids as [int]
        """
        LazyLoadingView.__init__(self)
        self._signal = None
        self._context_album_id = None
        self._genre_ids = genre_ids
        self._artist_ids = artist_ids
        self._albumsongs = None
        self._context_widget = None
        self._press_rect = None

        self._albumbox = Gtk.FlowBox()
        self._albumbox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._albumbox.connect('child-activated', self._on_album_activated)
        self._albumbox.connect('button-press-event', self._on_button_press)
        self._albumbox.set_property('column-spacing', 5)
        self._albumbox.set_property('row-spacing', 5)
        self._albumbox.set_homogeneous(True)
        self._albumbox.set_max_children_per_line(1000)
        self._albumbox.show()

        self._viewport.set_property('valign', Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._scrolled.set_property('expand', True)
        self._scrolled.set_property('height-request', 10)
        self._context = ViewContainer(500)

        separator = Gtk.Separator()
        separator.show()

        self._paned = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
        self._paned.pack1(self._scrolled, True, False)
        self._paned.pack2(self._context, False, False)
        self._paned.connect('notify::position', self._on_position_notify)
        self._paned.show()
        self.add(self._paned)
Пример #20
0
 def __init__(self, base_type):
     """
         Init Selection list ui
         @param base_type as SelectionListMask
     """
     LazyLoadingView.__init__(self, ViewType.NOT_ADAPTIVE)
     self.__base_type = base_type
     self.__sort = False
     self.__mask = 0
     self.__height = SelectionListRow.get_best_height(self)
     self._listbox = Gtk.ListBox()
     self._listbox.connect("button-release-event",
                           self.__on_button_release_event)
     self._listbox.connect("key-press-event",
                           self.__on_key_press_event)
     self._listbox.set_sort_func(self.__sort_func)
     self._listbox.set_selection_mode(Gtk.SelectionMode.MULTIPLE)
     self._listbox.set_filter_func(self._filter_func)
     self._listbox.show()
     self._viewport.add(self._listbox)
     overlay = Gtk.Overlay.new()
     overlay.set_hexpand(True)
     overlay.set_vexpand(True)
     overlay.show()
     overlay.add(self._scrolled)
     self.__fastscroll = FastScroll(self._listbox,
                                    self._scrolled)
     overlay.add_overlay(self.__fastscroll)
     self.add(overlay)
     self.get_style_context().add_class("sidebar")
     App().art.connect("artist-artwork-changed",
                       self.__on_artist_artwork_changed)
     self.__type_ahead_popover = TypeAheadPopover()
     self.__type_ahead_popover.set_relative_to(self._scrolled)
     self.__type_ahead_popover.entry.connect("activate",
                                             self.__on_type_ahead_activate)
     self.__type_ahead_popover.entry.connect("changed",
                                             self.__on_type_ahead_changed)
Пример #21
0
    def __init__(self, view_type=ViewType.SCROLLED):
        """
            Init flowbox view
            @param view_type as ViewType
        """
        LazyLoadingView.__init__(self, view_type | ViewType.FILTERED)
        self.__adaptive_signal_id = None
        self._widget_class = None
        self.__font_height = get_font_height()
        self._box = Gtk.FlowBox()
        self._box.set_filter_func(self._filter_func)
        self._box.set_selection_mode(Gtk.SelectionMode.NONE)
        # Allow lazy loading to not jump up and down
        self._box.set_homogeneous(True)
        self._box.set_max_children_per_line(1000)
        self._box.connect("child-activated", self._on_item_activated)
        self._box.show()

        if view_type & ViewType.SCROLLED:
            self._viewport.set_property("valign", Gtk.Align.START)
            self._viewport.set_property("margin", 5)
            self._scrolled.set_property("expand", True)
            self.add(self._scrolled)
Пример #22
0
    def __init__(self, artist_ids, genre_ids, show_covers):
        """
            Init ArtistAlbumsView
            @param artist ids as [int]
            @param genre ids as [int]
            @param show_covers as bool
        """
        LazyLoadingView.__init__(self, True)
        ViewController.__init__(self, ViewControllerType.ALBUM)
        self._artist_ids = artist_ids
        self._genre_ids = genre_ids
        self.__show_covers = show_covers
        self._album_box = Gtk.Grid()
        self._album_box.set_row_spacing(5)
        self._album_box.set_property("orientation", Gtk.Orientation.VERTICAL)
        self._album_box.show()
        self._viewport.add(self._album_box)

        self._album_box.set_property("valign", Gtk.Align.START)
        self._overlay = Gtk.Overlay.new()
        self._overlay.add(self._scrolled)
        self._overlay.show()
        self.add(self._overlay)
Пример #23
0
    def __init__(self, artist_ids, genre_ids, show_cover=True):
        """
            Init ArtistAlbumsView
            @param artist ids as [int]
            @param genre ids as [int]
            @param show cover as bool
        """
        LazyLoadingView.__init__(self)
        self._artist_ids = artist_ids
        self._genre_ids = genre_ids
        self._show_cover = show_cover
        self._albums_count = 0

        self._albumbox = Gtk.Grid()
        self._albumbox.set_row_spacing(20)
        self._albumbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self._albumbox.show()

        self._scrolled.set_property('expand', True)
        self._viewport.set_property("valign", Gtk.Align.START)
        self._overlay = Gtk.Overlay.new()
        self._overlay.add(self._scrolled)
        self._overlay.show()
        self.add(self._overlay)
    def __init__(self, playlist_ids, view_type):
        """
            Init PlaylistView
            @parma playlist ids as [int]
            @param view_type as ViewType
        """
        LazyLoadingView.__init__(self)
        ViewController.__init__(self, ViewControllerType.ALBUM)
        self.__view_type = view_type
        self.__playlist_ids = playlist_ids
        self.__signal_id1 = App().playlists.connect(
            "playlist-track-added", self.__on_playlist_track_added)
        self.__signal_id2 = App().playlists.connect(
            "playlist-track-removed", self.__on_playlist_track_removed)
        self.__signal_id3 = App().settings.connect(
            "changed::split-view", self.__on_split_view_changed)

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/PlaylistView.ui")
        self.__title_label = builder.get_object("title")
        self.__duration_label = builder.get_object("duration")
        self.__play_button = builder.get_object("play_button")
        self.__shuffle_button = builder.get_object("shuffle_button")
        self.__jump_button = builder.get_object("jump_button")
        self.__menu_button = builder.get_object("menu_button")
        self.__buttons = builder.get_object("box-buttons")
        self.__widget = builder.get_object("widget")
        self.__playlists_widget = PlaylistsWidget(playlist_ids, view_type)
        self.__playlists_widget.set_filter_func(self._filter_func)
        self.__playlists_widget.connect("populated", self.__on_populated)
        self.__playlists_widget.show()
        self._viewport.add(self.__playlists_widget)
        self.__title_label.set_margin_start(MARGIN)
        self.__buttons.set_margin_end(MARGIN)
        if self.__view_type & (ViewType.POPOVER | ViewType.FULLSCREEN):
            self.__title_label.get_style_context().add_class("dim-label")
            self.__duration_label.get_style_context().add_class("dim-label")
            self.__widget.add(self.__title_label)
            self.__jump_button = Gtk.Button.new_from_icon_name(
                "go-jump-symbolic", Gtk.IconSize.BUTTON)
            self.__jump_button.connect("clicked", self._on_jump_button_clicked)
            self.__jump_button.set_relief(Gtk.ReliefStyle.NONE)
            self.__jump_button.show()
            self.__jump_button.set_margin_end(MARGIN_SMALL)
            self.__widget.add(self.__duration_label)
            self.__widget.add(self.__jump_button)
            self.__widget.set_margin_bottom(MARGIN_SMALL)
            self.add(self.__widget)
            self.add(self._scrolled)
        else:
            self.__duration_label.set_margin_start(MARGIN)
            self._overlay = Gtk.Overlay.new()
            self._overlay.add(self._scrolled)
            self._overlay.show()
            self.__widget.attach(self.__title_label, 0, 0, 1, 1)
            self.__widget.attach(self.__duration_label, 0, 1, 1, 1)
            self.__widget.attach(self.__buttons, 1, 0, 1, 2)
            self.__widget.set_vexpand(True)
            self.__title_label.set_vexpand(True)
            self.__duration_label.set_vexpand(True)
            if App().window.is_adaptive:
                self.__title_label.get_style_context().add_class(
                    "text-x-large")
                self.__duration_label.get_style_context().add_class(
                    "text-large")
            else:
                self.__title_label.get_style_context().add_class(
                    "text-xx-large")
                self.__duration_label.get_style_context().add_class(
                    "text-x-large")
            self.__title_label.set_property("valign", Gtk.Align.END)
            self.__duration_label.set_property("valign", Gtk.Align.START)
            self.__banner = PlaylistBannerWidget(playlist_ids[0])
            self.__banner.show()
            self._overlay.add_overlay(self.__banner)
            self.__banner.add_overlay(self.__widget)
            self.__playlists_widget.set_margin_top(
                self.__banner.default_height + 15)
            self.add(self._overlay)
        self.__title_label.set_label(", ".join(
            App().playlists.get_names(playlist_ids)))
        self._scrolled.set_property("expand", True)
        builder.connect_signals(self)

        if len(playlist_ids) > 1:
            self.__menu_button.hide()

        # In DB duration calculation
        if playlist_ids[0] > 0 and\
                not App().playlists.get_smart(playlist_ids[0]):
            duration = 0
            for playlist_id in self.__playlist_ids:
                duration += App().playlists.get_duration(playlist_id)
            self.__set_duration(duration)
        # Ask widget after populated
        else:
            self.__playlists_widget.connect("populated",
                                            self.__on_playlist_populated)