示例#1
0
 def __init__(self, show_loved):
     """
         Init row widgets
         @param show loved as bool
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.ListBoxRow.__init__(self)
     self._indicator = IndicatorWidget()
     self._show_loved = show_loved
     self._object_id = None
     self._number = 0
     self._row_widget = Gtk.EventBox()
     self._grid = Gtk.Grid()
     self._grid.set_column_spacing(5)
     self._row_widget.add(self._grid)
     self._title_label = Gtk.Label()
     self._title_label.set_property('has-tooltip', True)
     self._title_label.set_property('hexpand', True)
     self._title_label.set_property('halign', Gtk.Align.START)
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._duration_label = Gtk.Label()
     self._duration_label.get_style_context().add_class('dim-label')
     self._num_label = Gtk.Label()
     self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._num_label.set_width_chars(4)
     self._num_label.get_style_context().add_class('dim-label')
     self._grid.add(self._num_label)
     self._grid.add(self._title_label)
     self._grid.add(self._duration_label)
     self.add(self._row_widget)
     self.get_style_context().add_class('trackrow')
示例#2
0
 def __init__(self, rowid, num):
     """
         Init row widgets
         @param rowid as int
         @param num as int
         @param show loved as bool
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.ListBoxRow.__init__(self)
     self.set_sensitive(False)
     self._track = Track(rowid)
     self._number = num
     self._indicator = IndicatorWidget(self._track.id)
     self.set_indicator(Lp().player.current_track.id == self._track.id,
                        utils.is_loved(self._track.id))
     self.set_sensitive(True)
     self._row_widget = Gtk.EventBox()
     self._row_widget.connect('button-press-event', self._on_button_press)
     self._row_widget.connect('enter-notify-event', self._on_enter_notify)
     self._grid = Gtk.Grid()
     self._grid.set_column_spacing(5)
     self._row_widget.add(self._grid)
     self._title_label = Gtk.Label.new(self._track.formated_name())
     self._title_label.set_use_markup(True)
     self._title_label.set_property('has-tooltip', True)
     self._title_label.connect('query-tooltip',
                               self._on_title_query_tooltip)
     self._title_label.set_property('hexpand', True)
     self._title_label.set_property('halign', Gtk.Align.START)
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._duration_label = Gtk.Label.new(
         seconds_to_string(self._track.duration))
     self._duration_label.get_style_context().add_class('dim-label')
     self._num_label = Gtk.Label()
     self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._num_label.set_property('valign', Gtk.Align.CENTER)
     self._num_label.set_width_chars(4)
     self._num_label.get_style_context().add_class('dim-label')
     self.update_num_label()
     self._menu_image = Gtk.Image.new()
     self._menu_image.set_opacity(0.2)
     self._menu_button = Gtk.Button.new()
     self._menu_button.set_relief(Gtk.ReliefStyle.NONE)
     self._menu_button.get_style_context().add_class('menu-button')
     self._menu_button.get_style_context().add_class('track-menu-button')
     self._menu_button.set_image(self._menu_image)
     self._menu_button.connect('clicked', self._on_button_clicked)
     self._grid.add(self._num_label)
     self._grid.add(self._title_label)
     self._grid.add(self._duration_label)
     # TODO Remove this later
     if Gtk.get_minor_version() > 16:
         self._grid.add(self._menu_button)
     else:
         self.connect('map', self._on_map)
     self.add(self._row_widget)
     self.get_style_context().add_class('trackrow')
示例#3
0
 def __init__(self, show_loved):
     """
         Init row widget
     """
     self._builder = Gtk.Builder()
     self._builder.add_from_resource('/org/gnome/Lollypop/AlbumRow.ui')
     self._builder.connect_signals(self)
     self._indicator = IndicatorWidget()
     self._builder.get_object('row').attach(self._indicator, 1, 1, 1, 2)
     self._cover = self._builder.get_object('cover')
     self._cover_frame = self._builder.get_object('frame')
     self._header = self._builder.get_object('header')
     self._artist = self._builder.get_object('artist')
     self._album = self._builder.get_object('album')
     Row.__init__(self, show_loved)
示例#4
0
 def __init__(self, show_menu, show_loved):
     """
         Init row widget
         @parma show menu as bool
         @param show loved as bool
     """
     self._builder = Gtk.Builder()
     self._builder.add_from_resource('/org/gnome/Lollypop/TrackRow.ui')
     self._builder.connect_signals(self)
     self._indicator = IndicatorWidget()
     self._builder.get_object('grid').attach(self._indicator, 0, 0, 1, 1)
     menu_btn = self._builder.get_object('menu')
     self._show_menu = show_menu
     # TODO: Remove this test later
     if show_menu or Gtk.get_minor_version() > 16:
         menu_btn.show()
     else:
         menu_btn.hide()
     Row.__init__(self, show_loved)
示例#5
0
 def __init__(self, rowid, num):
     """
         Init row widgets
         @param rowid as int
         @param num as int
         @param show loved as bool
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.ListBoxRow.__init__(self)
     self._artists_label = None
     self._track = Track(rowid)
     self.__number = num
     self.__preview_timeout_id = None
     self.__context_timeout_id = None
     self.__context = None
     self._indicator = IndicatorWidget(self._track.id)
     self.set_indicator(Lp().player.current_track.id == self._track.id,
                        utils.is_loved(self._track.id))
     self._row_widget = Gtk.EventBox()
     self._row_widget.connect("button-press-event", self.__on_button_press)
     self._row_widget.connect("enter-notify-event", self.__on_enter_notify)
     self._row_widget.connect("leave-notify-event", self.__on_leave_notify)
     self._grid = Gtk.Grid()
     self._grid.set_column_spacing(5)
     self._row_widget.add(self._grid)
     self._title_label = Gtk.Label.new(self._track.name)
     self._title_label.set_property("has-tooltip", True)
     self._title_label.connect("query-tooltip", self.__on_query_tooltip)
     self._title_label.set_property("hexpand", True)
     self._title_label.set_property("halign", Gtk.Align.START)
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     if self._track.non_album_artists:
         self._artists_label = Gtk.Label.new(
             GLib.markup_escape_text(", ".join(
                 self._track.non_album_artists)))
         self._artists_label.set_use_markup(True)
         self._artists_label.set_property("has-tooltip", True)
         self._artists_label.connect("query-tooltip",
                                     self.__on_query_tooltip)
         self._artists_label.set_property("hexpand", True)
         self._artists_label.set_property("halign", Gtk.Align.END)
         self._artists_label.set_ellipsize(Pango.EllipsizeMode.END)
         self._artists_label.set_opacity(0.3)
         self._artists_label.set_margin_end(5)
         self._artists_label.show()
     self._duration_label = Gtk.Label.new(
         seconds_to_string(self._track.duration))
     self._duration_label.get_style_context().add_class("dim-label")
     self._num_label = Gtk.Label()
     self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._num_label.set_property("valign", Gtk.Align.CENTER)
     self._num_label.set_width_chars(4)
     self._num_label.get_style_context().add_class("dim-label")
     self.update_num_label()
     self.__menu_button = Gtk.Button.new()
     # Here a hack to make old Gtk version support min-height css attribute
     # min-height = 24px, borders = 2px, we set directly on stack
     # min-width = 24px, borders = 2px, padding = 8px
     self.__menu_button.set_size_request(34, 26)
     self.__menu_button.set_relief(Gtk.ReliefStyle.NONE)
     self.__menu_button.get_style_context().add_class("menu-button")
     self.__menu_button.get_style_context().add_class("track-menu-button")
     self._grid.add(self._num_label)
     self._grid.add(self._title_label)
     if self._artists_label is not None:
         self._grid.add(self._artists_label)
     self._grid.add(self._duration_label)
     self._grid.add(self.__menu_button)
     self.add(self._row_widget)
     self.get_style_context().add_class("trackrow")
示例#6
0
 def __init__(self, track, list_type):
     """
         Init row widgets
         @param track as Track
         @param list_type as RowListType
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.ListBoxRow.__init__(self)
     self._list_type = list_type
     self._artists_label = None
     self._track = track
     self.__preview_timeout_id = None
     self.__context_timeout_id = None
     self.__context = None
     self._indicator = IndicatorWidget(self, list_type)
     # We do not use set_indicator() here, we do not want widget to be
     # populated
     if App().player.current_track.id == self._track.id:
         self._indicator.play()
     elif self._track.loved:
         self._indicator.loved(self._track.loved)
     self._row_widget = Gtk.EventBox()
     self._row_widget.connect("destroy", self._on_destroy)
     self._row_widget.connect("button-release-event",
                              self.__on_button_release_event)
     self._row_widget.connect("enter-notify-event",
                              self.__on_enter_notify_event)
     self._row_widget.connect("leave-notify-event",
                              self.__on_leave_notify_event)
     self._grid = Gtk.Grid()
     self._grid.set_column_spacing(5)
     self._row_widget.add(self._grid)
     self._title_label = Gtk.Label.new(self._track.name)
     self._title_label.set_property("has-tooltip", True)
     self._title_label.connect("query-tooltip",
                               self.__on_query_tooltip)
     self._title_label.set_property("hexpand", True)
     self._title_label.set_property("halign", Gtk.Align.START)
     self._title_label.set_property("xalign", 0)
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     featuring_artist_ids = track.featuring_artist_ids
     if featuring_artist_ids:
         artists = []
         for artist_id in featuring_artist_ids:
             artists.append(App().artists.get_name(artist_id))
         self._artists_label = Gtk.Label.new(GLib.markup_escape_text(
             ", ".join(artists)))
         self._artists_label.set_use_markup(True)
         self._artists_label.set_property("has-tooltip", True)
         self._artists_label.connect("query-tooltip",
                                     self.__on_query_tooltip)
         self._artists_label.set_property("hexpand", True)
         self._artists_label.set_property("halign", Gtk.Align.END)
         self._artists_label.set_ellipsize(Pango.EllipsizeMode.END)
         self._artists_label.set_opacity(0.3)
         self._artists_label.set_margin_end(5)
         self._artists_label.show()
     self._duration_label = Gtk.Label.new(
         seconds_to_string(self._track.duration))
     self._duration_label.get_style_context().add_class("dim-label")
     self._num_label = Gtk.Label()
     self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._num_label.set_property("valign", Gtk.Align.CENTER)
     self._num_label.set_width_chars(4)
     self._num_label.get_style_context().add_class("dim-label")
     self.update_number_label()
     self.__menu_button = Gtk.Button.new()
     self.__menu_button.set_relief(Gtk.ReliefStyle.NONE)
     self.__menu_button.get_style_context().add_class("menu-button")
     self.__menu_button.get_style_context().add_class("track-menu-button")
     if list_type & (RowListType.READ_ONLY | RowListType.POPOVER):
         self.__menu_button.set_opacity(0)
         self.__menu_button.set_sensitive(False)
     self._grid.add(self._num_label)
     self._grid.add(self._title_label)
     if self._artists_label is not None:
         self._grid.add(self._artists_label)
     self._grid.add(self._duration_label)
     self._grid.add(self.__menu_button)
     self.add(self._row_widget)
     self.get_style_context().add_class("trackrow")
 def __init__(self, track, album_artist_ids, view_type):
     """
         Init row widgets
         @param track as Track
         @param album_artist_ids as [int]
         @param view_type as ViewType
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.ListBoxRow.__init__(self)
     self.__view_type = view_type
     self._track = track
     self._grid = Gtk.Grid()
     self._grid.set_property("valign", Gtk.Align.CENTER)
     self._grid.set_column_spacing(5)
     self._grid.show()
     self._indicator = IndicatorWidget(self, view_type)
     self._indicator.show()
     self._grid.add(self._indicator)
     self._num_label = Gtk.Label.new()
     self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._num_label.set_width_chars(4)
     self._num_label.get_style_context().add_class("dim-label")
     self.update_number_label()
     self._grid.add(self._num_label)
     self.__title_label = Gtk.Label.new(
         GLib.markup_escape_text(self._track.name))
     self.__title_label.set_use_markup(True)
     self.__title_label.set_property("has-tooltip", True)
     self.__title_label.connect("query-tooltip", on_query_tooltip)
     self.__title_label.set_property("hexpand", True)
     self.__title_label.set_property("halign", Gtk.Align.START)
     self.__title_label.set_property("xalign", 0)
     self.__title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self.__title_label.show()
     self._grid.add(self.__title_label)
     featuring_artist_ids = track.get_featuring_artist_ids(album_artist_ids)
     if featuring_artist_ids:
         artists = []
         for artist_id in featuring_artist_ids:
             artists.append(App().artists.get_name(artist_id))
         artists_label = Gtk.Label.new(
             GLib.markup_escape_text(", ".join(artists)))
         artists_label.set_use_markup(True)
         artists_label.set_property("has-tooltip", True)
         artists_label.connect("query-tooltip", on_query_tooltip)
         artists_label.set_property("hexpand", True)
         artists_label.set_property("halign", Gtk.Align.END)
         artists_label.set_ellipsize(Pango.EllipsizeMode.END)
         artists_label.set_opacity(0.3)
         artists_label.set_margin_end(5)
         artists_label.show()
         self._grid.add(artists_label)
     duration = ms_to_string(self._track.duration)
     self.__duration_label = Gtk.Label.new(duration)
     self.__duration_label.get_style_context().add_class("dim-label")
     self.__duration_label.show()
     self._grid.add(self.__duration_label)
     self.__action_button = None
     if self.__view_type & (ViewType.PLAYBACK | ViewType.PLAYLISTS):
         self.__action_button = Gtk.Button.new_from_icon_name(
             "list-remove-symbolic", Gtk.IconSize.MENU)
         self.__action_button.set_tooltip_text(_("Remove from playlist"))
     elif self.__view_type & (ViewType.ALBUM | ViewType.ARTIST):
         self.__action_button = Gtk.Button.new_from_icon_name(
             "view-more-symbolic", Gtk.IconSize.MENU)
     if self.__action_button is None:
         self.__duration_label.set_margin_end(MARGIN_SMALL)
     else:
         self.__action_button.show()
         self.__action_button.connect("clicked",
                                      self.__on_action_button_clicked)
         self.__action_button.set_margin_end(MARGIN_SMALL)
         self.__action_button.set_relief(Gtk.ReliefStyle.NONE)
         context = self.__action_button.get_style_context()
         context.add_class("menu-button")
         self._grid.add(self.__action_button)
     self.add(self._grid)
     self.set_indicator(self._get_indicator_type())
     self.update_duration()
     self.get_style_context().add_class("trackrow")
示例#8
0
 def __init__(self, track, album_artist_ids, view_type):
     """
         Init row widgets
         @param track as Track
         @param album_artist_ids as [int]
         @param view_type as ViewType
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.ListBoxRow.__init__(self)
     self._view_type = view_type
     self._artists_label = None
     self._track = track
     self.__filtered = False
     self.__next_row = None
     self.__previous_row = None
     self._indicator = IndicatorWidget(self, view_type)
     self._row_widget = Gtk.EventBox()
     self._row_widget.connect("destroy", self._on_destroy)
     self.__gesture = Gtk.GestureLongPress.new(self._row_widget)
     self.__gesture.connect("pressed", self.__on_gesture_pressed)
     self.__gesture.connect("end", self.__on_gesture_end)
     # We want to get release event after gesture
     self.__gesture.set_propagation_phase(Gtk.PropagationPhase.CAPTURE)
     self.__gesture.set_button(0)
     self._grid = Gtk.Grid()
     self._grid.set_property("valign", Gtk.Align.CENTER)
     self._grid.set_column_spacing(5)
     self._row_widget.add(self._grid)
     self._title_label = Gtk.Label.new(
         GLib.markup_escape_text(self._track.name))
     self._title_label.set_use_markup(True)
     self._title_label.set_property("has-tooltip", True)
     self._title_label.connect("query-tooltip", on_query_tooltip)
     self._title_label.set_property("hexpand", True)
     self._title_label.set_property("halign", Gtk.Align.START)
     self._title_label.set_property("xalign", 0)
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     featuring_artist_ids = track.get_featuring_artist_ids(album_artist_ids)
     if featuring_artist_ids:
         artists = []
         for artist_id in featuring_artist_ids:
             artists.append(App().artists.get_name(artist_id))
         self._artists_label = Gtk.Label.new(
             GLib.markup_escape_text(", ".join(artists)))
         self._artists_label.set_use_markup(True)
         self._artists_label.set_property("has-tooltip", True)
         self._artists_label.connect("query-tooltip", on_query_tooltip)
         self._artists_label.set_property("hexpand", True)
         self._artists_label.set_property("halign", Gtk.Align.END)
         self._artists_label.set_ellipsize(Pango.EllipsizeMode.END)
         self._artists_label.set_opacity(0.3)
         self._artists_label.set_margin_end(5)
         self._artists_label.show()
     duration = seconds_to_string(self._track.duration)
     self._duration_label = Gtk.Label.new(duration)
     self._duration_label.get_style_context().add_class("dim-label")
     self._num_label = Gtk.Label.new()
     self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._num_label.set_width_chars(4)
     self._num_label.get_style_context().add_class("dim-label")
     self.update_number_label()
     self._grid.add(self._num_label)
     self._grid.add(self._title_label)
     if self._artists_label is not None:
         self._grid.add(self._artists_label)
     self._grid.add(self._duration_label)
     if self._view_type & ViewType.DND and\
             self._view_type & ViewType.POPOVER:
         self.__action_button = Gtk.Button.new_from_icon_name(
             "list-remove-symbolic", Gtk.IconSize.MENU)
         self.__action_button.set_tooltip_text(_("Remove from playback"))
     elif not self._view_type & (ViewType.POPOVER | ViewType.SEARCH):
         self.__action_button = Gtk.Button.new_from_icon_name(
             "view-more-symbolic", Gtk.IconSize.MENU)
     else:
         self.__action_button = None
     if self.__action_button is not None:
         self.__action_button.set_margin_end(MARGIN_SMALL)
         self.__action_button.connect("button-release-event",
                                      self.__on_action_button_release_event)
         self.__action_button.set_relief(Gtk.ReliefStyle.NONE)
         context = self.__action_button.get_style_context()
         context.add_class("menu-button")
         context.add_class("track-menu-button")
         self._grid.add(self.__action_button)
     else:
         self._duration_label.set_margin_end(MARGIN_SMALL)
     self.add(self._row_widget)
     self.set_indicator(self._get_indicator_type())
     self.update_duration()