lollypop.define.Lp

Here are the examples of the python api lollypop.define.Lp taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

199 Examples 7

Example 1

Project: lollypop Source File: pop_albums.py
Function: clear
    def __clear(self, clear_albums=False):
        """
            Clear the view
        """
        for child in self.__view.get_children():
            child.destroy()
        if clear_albums:
            Lp().player.clear_albums()
        self.__clear_button.set_sensitive(False)

Example 2

Project: lollypop Source File: pop_info.py
Function: set_autoload
    def __set_autoload(self, widget):
        """
            Mark as autoload
            @param widget as Gtk.Widget
        """
        self.__timeout_id = None
        if self.__signal_id is None:
            Lp().settings.set_value('inforeload', GLib.Variant('b', True))
            self.__signal_id = Lp().player.connect('current-changed',
                                                   self.__on_current_changed)
            widget.get_style_context().add_class('selected')
        else:
            Lp().player.disconnect(self.__signal_id)
            self.__signal_id = None
            Lp().settings.set_value('inforeload',
                                    GLib.Variant('b', False))
            widget.get_style_context().remove_class('selected')

Example 3

Project: lollypop Source File: inhibitor.py
Function: init
    def __init__(self):
        """
            Init dbus objects
        """
        # Bus to disable screenlock
        self.__bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
        self.__cookie = None
        self.__flags = []
        Lp().player.connect('status-changed', self.__on_status_changed)

Example 4

Project: lollypop Source File: player_bin.py
    def __update_current_duration(self, reader, track):
        """
            Update current track duration
            @param reader as TagReader
            @param track id as int
        """
        try:
            duration = reader.get_info(track.uri).get_duration() / 1000000000
            if duration != track.duration and duration > 0:
                Lp().tracks.set_duration(track.id, duration)
                # We modify mtime to be sure not looking for tags again
                Lp().tracks.set_mtime(track.id, 1)
                self.current_track.set_duration(duration)
                GLib.idle_add(self.emit, 'duration-changed', track.id)
        except:
            pass

Example 5

Project: lollypop Source File: miniplayer.py
    def _on_button_press(self, button, event):
        """
            Show track menu
            @param button as Gtk.Button
            @param event as Gdk.Event
        """
        if Lp().player.current_track.id is not None:
            if event.button != 1 and Lp().player.current_track.id >= 0:
                popover = TrackMenuPopover(
                            Lp().player.current_track,
                            PopToolbarMenu(Lp().player.current_track.id))
                popover.set_relative_to(self)
                press_rect = Gdk.Rectangle()
                press_rect.x = event.x
                press_rect.y = event.y
                press_rect.width = press_rect.height = 1
                popover.set_pointing_to(press_rect)
                popover.show()
        return True

Example 6

Project: lollypop Source File: controllers.py
Function: init
    def __init__(self):
        """
            Init progress controller (for toolbars)
        """
        # Prevent updating progress while seeking
        self.__seeking = False
        # Update pogress position
        self.__timeout_id = None
        # Show volume control
        self._show_volume_control = False
        Lp().player.connect('duration-changed', self.__on_duration_changed)

Example 7

Project: lollypop Source File: pop_artwork.py
Function: on_unmap
    def __on_unmap(self, widget):
        """
            Stop loading
            @param widget as Gtk.Widget
        """
        # FIXME Not needed with GTK >= 3.18
        Lp().window.enable_global_shortcuts(True)
        self._widget.stop()

Example 8

Project: lollypop Source File: art_widgets.py
    def _on_api_entry_changed(self, entry):
        """
            Save key
            @param entry as Gtk.Entry
        """
        value = entry.get_text().strip()
        Lp().settings.set_value('cs-api-key', GLib.Variant('s', value))

Example 9

Project: lollypop Source File: pop_menu.py
    def __set_artists_actions(self):
        """
            Set queue actions
        """
        go_artist_action = Gio.SimpleAction(name="go_artist_action")
        Lp().add_action(go_artist_action)
        go_artist_action.connect('activate',
                                 self.__go_to_artists)
        self.append(_("Show albums from artist"), 'app.go_artist_action')

Example 10

Project: lollypop Source File: collectionscanner.py
Function: update_progress
    def __update_progress(self, current, total):
        """
            Update progress bar status
            @param scanned items as int, total items as int
        """
        Lp().window.progress.set_fraction(current / total, self)

Example 11

Project: lollypop Source File: player.py
    def skip_album(self):
        """
            Skip current album
        """
        # In party or shuffle, just update next track
        if Lp().player.is_party or\
                Lp().settings.get_enum('shuffle') == Shuffle.TRACKS:
            Lp().player.set_next()
            # We send this signal to update next popover
            Lp().player.emit('queue-changed')
        elif self._current_track.id is not None:
            pos = self._albums.index(self._current_track.album.id)
            if pos + 1 >= len(self._albums):
                next_album = self._albums[0]
            else:
                next_album = self._albums[pos + 1]
            self.load(Album(next_album).tracks[0])

Example 12

Project: lollypop Source File: mpris_legacy.py
    def __init__(self, app):
        DBusGMainLoop(set_as_default=True)
        name = dbus.service.BusName(self.MPRIS_LOLLYPOP, dbus.SessionBus())
        dbus.service.Object.__init__(self, name, self.MPRIS_PATH)
        self._app = app
        self._metadata = {}
        Lp().player.connect('current-changed', self._on_current_changed)
        Lp().player.connect('seeked', self._on_seeked)
        Lp().player.connect('status-changed', self._on_status_changed)
        Lp().player.connect('volume-changed', self._on_volume_changed)

Example 13

Project: lollypop Source File: controllers.py
    def _on_prev_btn_clicked(self, button):
        """
            Previous track on prev button clicked
            @param button as Gtk.Button
        """
        Lp().player.prev()

Example 14

Project: lollypop Source File: player_shuffle.py
Function: init
    def __init__(self):
        """
            Init shuffle player
        """
        BasePlayer.__init__(self)
        self.reset_history()
        # Party mode
        self.__is_party = False
        Lp().settings.connect('changed::shuffle', self.__set_shuffle)

Example 15

Project: lollypop Source File: mpd.py
    def _on_party_changed(self, player, enabled):
        """
            Add options to idle
            @param player as Player
            @param enabled as bool
        """
        Lp().playlists.clear(Type.MPD, False)
        if "options" in self.idle_wanted_strings:
            self.idle_strings.append("options")
            self.event.set()

Example 16

Project: lollypop Source File: pop_albums.py
Function: on_unmap
    def __on_unmap(self, widget):
        """
            Disconnect signals
            @param widget as Gtk.Widget
        """
        self._stop = True
        self._lazy_queue = []
        GLib.idle_add(self.__clear)
        if self._signal_id1 is not None:
            Lp().player.disconnect(self._signal_id1)
            self._signal_id1 = None

Example 17

Project: lollypop Source File: controllers.py
    def _on_progress_release_button(self, scale, event):
        """
            Callback for scale release button
            Seek player to scale value
            @param scale as Gtk.Scale
            @param event as Gdk.Event
        """
        if self._show_volume_control or event.button != 1:
            return
        value = scale.get_value()
        Lp().player.seek(value/60)
        self.__seeking = False
        self._update_position(value)

Example 18

Project: lollypop Source File: pop_externals.py
    def __on_self_unmap(self, widget):
        """
            Disconnect signals and destroy
            @param widget as Gtk.Widget
        """
        if self.__signal_id is not None:
            Lp().player.disconnect(self.__signal_id)
        GLib.idle_add(self.destroy)

Example 19

Project: lollypop Source File: mpd.py
Function: random
    def _random(self, cmd_args):
        """
            Set player random, as MPD can't handle all lollypop random modes,
            set party mode
            @syntax random [1|0]
            @param args as str
            @return msg as str
        """
        args = self._get_args(cmd_args)
        GLib.idle_add(Lp().player.set_party, bool(int(args[0])))
        return ""

Example 20

Project: lollypop Source File: pop_lastfm.py
Function: on_row_activated
    def __on_row_activated(self, widget, row):
        """
            Play searched item when selected
            @param widget as Gtk.ListBox
            @param row as AlbumRow
        """
        Lp().window.toolbar.search(row.get_child().get_text())

Example 21

Project: lollypop Source File: inotify.py
    def __run_collection_update(self):
        """
            Run a collection update
        """
        self.__timeout = None
        Lp().window.update_db()

Example 22

Project: lollypop Source File: miniplayer.py
Function: do_hide
    def do_hide(self):
        """
            Remove signal
        """
        Gtk.Bin.do_hide(self)
        Lp().player.disconnect(self._signal_id)

Example 23

Project: lollypop Source File: mpd.py
Function: seek
    def _seek(self, cmd_args):
        """
           Seek current
           @syntax seek position
           @param args as str
           @return msg as str
        """
        args = self._get_args(cmd_args)
        seek = int(args[1])
        GLib.idle_add(Lp().player.seek, seek)
        return ""

Example 24

Project: lollypop Source File: mpris.py
Function: init
    def __init__(self, app):
        self.__app = app
        self.__metadata = {}
        self.__bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
        Gio.bus_own_name_on_connection(self.__bus,
                                       self.__MPRIS_LOLLYPOP,
                                       Gio.BusNameOwnerFlags.NONE,
                                       None,
                                       None)
        Server.__init__(self, self.__bus, self.__MPRIS_PATH)
        Lp().player.connect('current-changed', self.__on_current_changed)
        Lp().player.connect('seeked', self.__on_seeked)
        Lp().player.connect('status-changed', self.__on_status_changed)
        Lp().player.connect('volume-changed', self.__on_volume_changed)

Example 25

Project: lollypop Source File: collectionscanner.py
Function: finish
    def __finish(self):
        """
            Notify from main thread when scan finished
        """
        Lp().window.progress.set_fraction(1.0, self)
        self.stop()
        self.emit("scan-finished")
        if Lp().settings.get_value('artist-artwork'):
            Lp().art.cache_artists_info()

Example 26

Project: lollypop Source File: player.py
Function: init
    def __init__(self):
        """
            Init player
        """
        BinPlayer.__init__(self)
        QueuePlayer.__init__(self)
        LinearPlayer.__init__(self)
        ShufflePlayer.__init__(self)
        UserPlaylistPlayer.__init__(self)
        RadioPlayer.__init__(self)
        ExternalsPlayer.__init__(self)
        self.update_crossfading()
        self.__do_not_update_next = False
        Lp().settings.connect('changed::playback', self.__on_playback_changed)

Example 27

Project: lollypop Source File: mpris_legacy.py
    @dbus.service.method(dbus_interface=MPRIS_PLAYER_IFACE)
    def Play(self):
        if Lp().player.current_track.id is None:
            Lp().player.set_party(True)
        else:
            Lp().player.play()

Example 28

Project: lollypop Source File: container.py
Function: setup_scanner
    def __setup_scanner(self):
        """
            Run collection update if needed
            @return True if hard scan is running
        """
        Lp().scanner.connect('scan-finished', self.on_scan_finished)
        Lp().scanner.connect('genre-updated', self.__on_genre_updated)
        Lp().scanner.connect('artist-updated', self.__on_artist_updated)

Example 29

Project: lollypop Source File: player_bin.py
    def _on_stream_start(self, bus, message):
        """
            On stream start
            Emit "current-changed" to notify others components
            @param bus as Gst.Bus
            @param message as Gst.Message
        """
        self._start_time = time()
        debug("Player::_on_stream_start(): %s" % self.current_track.uri)
        self.emit('current-changed')
        # Update now playing on lastfm
        if Lp().lastfm is not None and self.current_track.id >= 0:
            artists = ", ".join(self.current_track.artists)
            Lp().lastfm.now_playing(artists,
                                    self.current_track.album_name,
                                    self.current_track.title,
                                    int(self.current_track.duration))
        if not Lp().scanner.is_locked():
            Lp().tracks.set_listened_at(self.current_track.id, int(time()))

Example 30

Project: lollypop Source File: mpd.py
Function: update
    def _update(self, cmd_args):
        """
            Update database
            @syntax update
            @param args as str
            @return msg as str
        """
        Lp().window.update_db()
        return ""

Example 31

Project: lollypop Source File: player_bin.py
    def __on_bus_error(self, bus, message):
        """
            Handle first bus error, ignore others
            @param bus as Gst.Bus
            @param message as Gst.Message
        """
        debug("Error playing: %s" % self.current_track.uri)
        Lp().window.pulse(False)
        if self.__codecs.is_missing_codec(message):
            self.__codecs.install()
            Lp().scanner.stop()
        elif Lp().notify is not None:
            Lp().notify.send(message.parse_error()[0].message)
        self.emit('current-changed')
        return True

Example 32

Project: lollypop Source File: controllers.py
    def _on_next_btn_clicked(self, button):
        """
            Next track on next button clicked
            @param button as Gtk.Button
        """
        Lp().player.next()

Example 33

Project: lollypop Source File: pop_albums.py
Function: on_delete_clicked
    def __on_delete_clicked(self, button):
        """
            Delete album
            @param button as Gtk.Button
        """
        if Lp().player.current_track.album.id == self.__album.id:
            # If not last album, skip it
            if len(Lp().player.get_albums()) > 1:
                Lp().player.skip_album()
                Lp().player.remove_album(self.__album)
            # remove it and stop playback by going to next track
            else:
                Lp().player.remove_album(self.__album)
                Lp().player.set_next()
                Lp().player.next()
        else:
            Lp().player.remove_album(self.__album)
        self.destroy()

Example 34

Project: lollypop Source File: mpd.py
    def _findadd(self, cmd_args):
        """
            Find tracks and add them to playlist
            @syntax findadd filter value
            @param args as str
            @return msg as str
        """
        tracks = []
        for track_id in self._find_tracks(cmd_args):
            tracks.append(Track(track_id))
        if tracks:
            Lp().playlists.add_tracks(Type.MPD, tracks, False)
        return ""

Example 35

Project: lollypop Source File: pop_albums.py
Function: add_items
    def __add_items(self, items, prev_album_id=None):
        """
            Add items to the view
            @param item ids as [int]
        """
        if items and not self._stop:
            album_id = items.pop(0)
            row = self.__row_for_album_id(album_id)
            row.show()
            self.__view.add(row)
            self._lazy_queue.append(row)
            GLib.idle_add(self.__add_items, items, album_id)
        else:
            GLib.idle_add(self.lazy_loading)
            if self._viewport.get_child() is None:
                self._viewport.add(self.__view)
            if Lp().player.current_track.album.id in Lp().player.get_albums():
                self.__jump_button.set_sensitive(True)

Example 36

Project: lollypop Source File: controllers.py
Function: on_value_changed
    def _on_value_changed(self, scale):
        """
            Adjust volume
        """
        if not self._show_volume_control:
            return
        Lp().player.set_volume(scale.get_value())
        self._update_position(scale.get_value())

Example 37

Project: lollypop Source File: pop_artwork.py
Function: on_map
    def __on_map(self, widget):
        """
            Resize
            @param widget as Gtk.Widget
        """
        # FIXME Not needed with GTK >= 3.18
        Lp().window.enable_global_shortcuts(False)
        size = Lp().window.get_size()
        self.set_size_request(size[0]*0.4,
                              size[1]*0.5)

Example 38

Project: lollypop Source File: art_widgets.py
    def _on_reset_confirm(self, button):
        """
            Reset cover
            @param button as Gtk.Button
        """
        self._infobar.hide()
        if self.__album is not None:
            Lp().art.remove_album_artwork(self.__album)
            Lp().art.clean_album_cache(self.__album)
            Lp().art.emit('album-artwork-changed', self.__album.id)
        else:
            for suffix in ["lastfm", "wikipedia", "spotify", "deezer"]:
                InfoCache.uncache_artwork(self.__artist, suffix,
                                          button.get_scale_factor())
                InfoCache.add(self.__artist, None, None, suffix)
                Lp().art.emit('artist-artwork-changed', self.__artist)
        self.__close_popover()

Example 39

Project: lollypop Source File: pop_externals.py
Function: on_row_activated
    def _on_row_activated(self, view, path, column):
        """
            Play selected track
            @param view as Gtk.TreeView
            @param path as Gtk.TreePath
            @param column as Gtk.TreeViewColumn
        """
        if path is not None:
            iterator = self.__model.get_iter(path)
            if iterator is not None:
                uri = self.__model.get_value(iterator, 0)
                Lp().player.play_this_external(uri)

Example 40

Project: lollypop Source File: downloader.py
    def _get_lastfm_artist_info(self, artist):
        """
            Return lastfm artist information
            @param artist as str
            @return (url as str/None, content as str)
        """
        if Lp().lastfm is not None:
            return Lp().lastfm.get_artist_info(artist)
        else:
            return (None, None)

Example 41

Project: lollypop Source File: pop_info.py
Function: should_be_shown
    def should_be_shown():
        """
            True if we can show popover
        """
        return Lp().lastfm is not None or\
            InfoPopover.Wikipedia is not None or\
            InfoPopover.WebView is not None

Example 42

Project: lollypop Source File: mpd.py
Function: current_song
    def _currentsong(self, cmd_args):
        """
            Send lollypop current song
            @syntax currentsong
            @param args as str

            @return msg as str
        """
        if Lp().player.current_track.id is not None:
            msg = self._string_for_track_id(Lp().player.current_track.id)
        else:
            msg = ""
        return msg

Example 43

Project: lollypop Source File: pop_info.py
Function: on_unmap
    def __on_unmap(self, widget):
        """
            Destroy self if needed and disconnect signals
            @param widget as Gtk.Widget
        """
        self.__current_track = Track()
        if self.__signal_id is not None:
            Lp().player.disconnect(self.__signal_id)
            self.__signal_id = None

Example 44

Project: lollypop Source File: inhibitor_legacy.py
    def __init__(self):
        """
            Init dbus objects
        """
        # Just to make pep8/flake8 happy
        GdkX11.x11_get_default_root_xwindow()
        # Dbus interface to disable screenlock
        bus = dbus.SessionBus()
        self._sm = None
        self._cookie = None
        self._flags = []
        try:
            bus_object = bus.get_object('org.gnome.SessionManager',
                                        '/org/gnome/SessionManager')
            self._sm = dbus.Interface(bus_object,
                                      'org.gnome.SessionManager')
        except:
            self._sm = None
        Lp().player.connect('status-changed', self._on_status_changed)

Example 45

Project: lollypop Source File: charts.py
Function: init
    def __init__(self):
        """
            Init charts
        """
        if Lp().settings.get_enum('charts') == ChartsProvider.ITUNES:
            self.__provider = ItunesCharts()
        else:
            self.__provider = SpotifyCharts()

Example 46

Project: lollypop Source File: mpd.py
    def _clear(self, cmd_args):
        """
            Clear mpd playlist
            @syntax clear
            @param args as str
            @return msg as str
        """
        Lp().playlists.clear(Type.MPD, False)
        Lp().player.populate_user_playlist_by_id(Type.NONE)
        GLib.idle_add(Lp().player.stop)
        Lp().player.current_track = Track()
        GLib.idle_add(Lp().player.emit, 'current-changed')
        return ""

Example 47

Project: lollypop Source File: mpd.py
    def _deleteid(self, cmd_args):
        """
            Delete track from playlist
            @syntax delete track_id
            @param args as str

            @return msg as str
        """
        arg = self._get_args(cmd_args)
        Lp().playlists.remove_tracks(Type.MPD, [Track(int(arg[0]))], False)
        return ""

Example 48

Project: lollypop Source File: mpd.py
Function: set_vol
    def _setvol(self, cmd_args):
        """
            Send stats about db
            @syntax setvol value
            @param args as str
            @return msg as str
        """
        args = self._get_args(cmd_args)
        vol = float(args[0])
        Lp().player.set_volume(vol/100)
        return ""

Example 49

Project: lollypop Source File: container.py
Function: save_view_state
    def save_view_state(self):
        """
            Save view state
        """
        Lp().settings.set_value(
                            "list-one-ids",
                            GLib.Variant('ai',
                                         self.__list_one.selected_ids))
        Lp().settings.set_value(
                            "list-two-ids",
                            GLib.Variant('ai',
                                         self.__list_two.selected_ids))

Example 50

Project: lollypop Source File: notification.py
Function: init
    def __init__(self):
        """
            Init notification object with lollypop infos
        """
        self.__caps = Notify.get_server_caps()
        self.__inhibitor = False
        self.__notification = Notify.Notification()
        self.__notification.set_category('x-gnome.music')
        self.__notification.set_hint('desktop-entry',
                                     GLib.Variant('s', 'lollypop'))
        self.__set_actions()
        Lp().player.connect('current-changed',
                            self.__on_current_changed)
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4