Exemple #1
0
 def __init__(self):
     """
         Connect map signal
     """
     Popover.__init__(self)
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
 def __init__(self):
     """
         Init popover
     """
     Popover.__init__(self)
     self.__lastfm_signal_id = None
     self.__spotify_signal_id = None
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/SimilarsPopover.ui")
     self.__show_all = GLib.find_program_in_path("youtube-dl") is not None
     self.__added = []
     self.__cancellable = Gio.Cancellable()
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.__stack = builder.get_object("stack")
     self.__spinner = builder.get_object("spinner")
     self.__spinner.start()
     self.__listbox = Gtk.ListBox()
     self.__listbox.get_style_context().add_class("trackswidget")
     self.__listbox.set_vexpand(True)
     self.__listbox.set_selection_mode(Gtk.SelectionMode.NONE)
     self.__listbox.set_activate_on_single_click(True)
     self.__listbox.connect("row-activated", self.__on_row_activated)
     self.__listbox.show()
     self.__stack.add(self.__listbox)
     self.add(builder.get_object("widget"))
    def __init__(self):
        """
            Init Popover
        """
        Popover.__init__(self)
        self.set_position(Gtk.PositionType.BOTTOM)
        self.__last_drag_id = None
        self.connect("map", self.__on_map)
        self.connect("unmap", self.__on_unmap)

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/QueuePopover.ui")
        builder.connect_signals(self)

        self.__clear_button = builder.get_object("clear-button")

        self.__view = Gtk.ListBox()
        self.__view.get_style_context().add_class("trackswidget")
        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()

        builder.get_object("scrolled").add(self.__view)
        self.add(builder.get_object("widget"))
Exemple #4
0
    def __init__(self, track, menu):
        """
            Init widget
            @param track as Track
            @param menu as Gio.Menu
        """
        Popover.__init__(self)
        if menu is not None:
            self.bind_model(menu, None)

        if track.year is not None:
            year_label = Gtk.Label()
            year_label.set_text(str(track.year))
            dt = GLib.DateTime.new_from_unix_local(track.timestamp)
            year_label.set_tooltip_text(dt.format(_("%Y-%m-%d")))
            year_label.set_margin_end(5)
            year_label.get_style_context().add_class("dim-label")
            year_label.set_property("halign", Gtk.Align.END)
            year_label.set_property("hexpand", True)
            year_label.show()

        # Hack to add two widgets in popover
        grid = Gtk.Grid()
        grid.set_orientation(Gtk.Orientation.VERTICAL)

        stack = Gtk.Stack()
        stack.add_named(grid, "main")
        stack.show_all()

        menu_widget = self.get_child()
        if menu_widget is not None:
            self.remove(menu_widget)
            grid.add(menu_widget)

        hgrid = Gtk.Grid()
        hgrid.get_style_context().add_class("popover-rating-loved-grid")
        rating = RatingWidget(track)
        rating.set_property("halign", Gtk.Align.START)
        rating.set_margin_end(10)
        rating.show()

        loved = LovedWidget(track)
        loved.set_property("halign", Gtk.Align.START)
        loved.set_property("hexpand", True)
        loved.show()

        hgrid.add(rating)
        hgrid.add(loved)

        if track.year is not None:
            hgrid.add(year_label)
        hgrid.show()

        grid.add(hgrid)
        self.add(stack)
    def __init__(self, radio_id, radios):
        """
            Init Popover
            @param radio_id as int
            @param radios as Radios
        """
        Popover.__init__(self)
        self.connect("map", self.__on_map)
        self.__radio_id = radio_id
        self.__radios = radios
        self.__start = 0
        self.__orig_pixbufs = {}
        self.__cancellable = Gio.Cancellable()

        self.__stack = Gtk.Stack()
        self.__stack.set_transition_duration(1000)
        self.__stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self.__stack.show()

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/RadioPopover.ui")
        builder.connect_signals(self)

        self.__view = Gtk.FlowBox()
        self.__view.set_selection_mode(Gtk.SelectionMode.NONE)
        self.__view.connect("child-activated", self.__on_activate)
        self.__view.set_max_children_per_line(100)
        self.__view.set_property("row-spacing", 10)
        self.__view.show()

        builder.get_object("viewport").add(self.__view)

        self.__name_entry = builder.get_object("name")
        self.__uri_entry = builder.get_object("uri")
        self.__image_button = builder.get_object("image_button")
        self.__save_button = builder.get_object("save_button")
        self.__spinner = builder.get_object("spinner")
        self.__stack.add_named(builder.get_object("spinner-grid"), "spinner")
        self.__stack.add_named(builder.get_object("notfound"), "notfound")
        self.__stack.add_named(builder.get_object("logo"), "logo")
        self.__stack.add_named(builder.get_object("widget"), "widget")
        self.__stack.set_visible_child_name("widget")
        self.add(self.__stack)

        track = Track()
        if radio_id is not None:
            track.set_radio_id(radio_id)
            rating = RatingWidget(track)
            rating.show()
            builder.get_object("widget").attach(rating, 0, 2, 2, 1)
            builder.get_object("delete_button").show()
            self.__name_entry.set_text(radios.get_name(radio_id))
            uri = self.__radios.get_uri(radio_id)
            if uri:
                self.__uri_entry.set_text(uri)
Exemple #6
0
 def __init__(self, minimal=False):
     """
         Init artist infos
         @param minimal as bool
     """
     Popover.__init__(self)
     self.__minimal = minimal
     self.__view = InformationView(minimal)
     self.__view.show()
     self.connect("map", self.__on_map)
     self.add(self.__view)
 def __init__(self):
     """
         Init popover
     """
     Popover.__init__(self)
     self.__view = CurrentAlbumsView()
     self.__view.populate(App().player.albums)
     self.__view.show()
     self.set_position(Gtk.PositionType.BOTTOM)
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.add(self.__view)
Exemple #8
0
 def __init__(self, widget, rowid, mask):
     """
         Init menu
         @param widget as Gtk.Widget
         @param rowid as int
         @param mask as SelectionListMask
     """
     Popover.__init__(self)
     self.__widget = widget
     self.__rowid = rowid
     self.__mask = mask
     menu = Gio.Menu()
     self.bind_model(menu, None)
     # Startup menu
     if rowid in [Type.POPULARS, Type.RADIOS, Type.LOVED,
                  Type.ALL, Type.RECENTS, Type.YEARS,
                  Type.RANDOMS, Type.NEVER,
                  Type.PLAYLISTS, Type.ARTISTS] and\
             not App().settings.get_value("save-state"):
         startup_menu = Gio.Menu()
         if self.__mask & SelectionListMask.LIST_TWO:
             exists = rowid in App().settings.get_value("startup-two-ids")
         else:
             exists = rowid in App().settings.get_value("startup-one-ids")
         action = Gio.SimpleAction.new_stateful(
             "default_selection_id", None, GLib.Variant.new_boolean(exists))
         App().add_action(action)
         action.connect("change-state", self.__on_default_change_state,
                        rowid)
         item = Gio.MenuItem.new(_("Default on startup"),
                                 "app.default_selection_id")
         startup_menu.append_item(item)
         menu.insert_section(0, _("Startup"), startup_menu)
     # Shown menu
     shown_menu = Gio.Menu()
     if mask & SelectionListMask.PLAYLISTS:
         lists = ShownPlaylists.get(True)
         wanted = App().settings.get_value("shown-playlists")
     else:
         lists = ShownLists.get(mask, True)
         wanted = App().settings.get_value("shown-album-lists")
     for item in lists:
         exists = item[0] in wanted
         encoded = sha256(item[1].encode("utf-8")).hexdigest()
         action = Gio.SimpleAction.new_stateful(
             encoded, None, GLib.Variant.new_boolean(exists))
         action.connect("change-state", self.__on_shown_change_state,
                        item[0])
         App().add_action(action)
         shown_menu.append(item[1], "app.%s" % encoded)
     # Translators: shown => items
     menu.insert_section(1, _("Shown"), shown_menu)
 def __init__(self):
     """
         Init Popover
     """
     Popover.__init__(self)
     self.set_position(Gtk.PositionType.BOTTOM)
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.__view = PlaylistsView(App().player.playlist_ids,
                                 RowListType.DND | RowListType.POPOVER,
                                 False)
     self.__view.show()
     self.add(self.__view)
Exemple #10
0
 def __init__(self):
     """
         Init popover
     """
     Popover.__init__(self)
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/Appmenu.ui")
     self.add(builder.get_object("widget"))
     self.__volume = builder.get_object("volume")
     self.__volume.set_value(App().player.volume)
     builder.connect_signals(self)
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
 def __init__(self, playlist_id):
     """
         @param playlist_id as int
     """
     Popover.__init__(self)
     self.__playlist_id = playlist_id
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/PlaylistPopover.ui")
     builder.connect_signals(self)
     widget = builder.get_object("widget")
     self.__name_entry = builder.get_object("name")
     if playlist_id < 0:
         widget.set_sensitive(False)
     self.__name_entry.set_text(App().playlists.get_name(playlist_id))
     self.add(widget)
Exemple #12
0
 def __init__(self):
     """
         Init popover
     """
     Popover.__init__(self)
     # No DND until https://gitlab.gnome.org/GNOME/gtk/issues/2006 is fixed
     wayland = GLib.environ_getenv(GLib.get_environ(), "WAYLAND_DISPLAY")
     if wayland:
         view_type = ViewType.POPOVER
     else:
         view_type = ViewType.POPOVER | ViewType.DND
     self.__view = App().window.container.get_view_current(view_type)
     self.__view.show()
     self.set_position(Gtk.PositionType.BOTTOM)
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.add(self.__view)
 def __init__(self):
     """
         Init popover
     """
     Popover.__init__(self)
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/LastfmPopover.ui")
     self.connect("map", self.__on_map)
     self.__stack = builder.get_object("stack")
     self.__spinner = builder.get_object("spinner")
     self.__spinner.start()
     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.__stack.add(self.__view)
     self.add(builder.get_object("widget"))
Exemple #14
0
 def __init__(self, album, width):
     """
         Init popover
         @param album as Album
         @param width as int
         @param art size as int
     """
     Popover.__init__(self)
     self.__width = width
     self.get_style_context().add_class("box-shadow")
     view = ArtistAlbumsView(album.artist_ids, album.genre_ids, False)
     view.populate([album])
     window_width = App().window.get_allocated_width()
     window_height = App().window.get_allocated_height()
     wanted_width = min(900, window_width * 0.5)
     wanted_height = max(200,
                         min(window_height * 0.5,
                             view.children[0].requested_height[0]))
     view.set_property("width-request", wanted_width)
     view.set_property("height-request", wanted_height)
     view.show()
     self.add(view)