コード例 #1
0
 def __init__(self):
     """
         Init view
     """
     View.__init__(self)
     InformationController.__init__(
         self, False,
         ArtBehaviour.BLUR_MAX | ArtBehaviour.CROP | ArtBehaviour.DARKER)
     self.__current_changed_id = None
     self.__size_allocate_timeout_id = None
     self.__lyrics_timeout_id = None
     self.__downloads_running = 0
     self.__lyrics_text = ""
     self.__size = 0
     self.__cancellable = Gio.Cancellable()
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/LyricsView.ui")
     builder.connect_signals(self)
     self._artwork = builder.get_object("cover")
     self.__lyrics_label = LyricsLabel()
     self.__lyrics_label.show()
     builder.get_object("viewport").add(self.__lyrics_label)
     self.__translate_button = builder.get_object("translate_button")
     # We do not use View scrolled window because it does not work with
     # an overlay
     self.add(builder.get_object("widget"))
     self.connect("size-allocate", self.__on_size_allocate)
     self.__sync_lyrics_helper = SyncLyricsHelper()
コード例 #2
0
    def __init__(self, width):
        """
            Init toolbar
            @param width as int
        """
        self.__width = width
        self.__height = 0
        Gtk.Bin.__init__(self)
        InformationController.__init__(self, True, ArtHelperEffect.BLUR)
        ProgressController.__init__(self)
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/MiniPlayer.ui")
        builder.connect_signals(self)

        self._progress = builder.get_object("progress_scale")
        self._progress.set_sensitive(False)
        self._progress.set_hexpand(True)
        self._timelabel = builder.get_object("playback")
        self._total_time_label = builder.get_object("duration")

        self.__grid = builder.get_object("grid")
        self._title_label = builder.get_object("title")
        self._artist_label = builder.get_object("artist")
        self._artwork = builder.get_object("cover")
        self.__signal_id1 = App().player.connect("current-changed",
                                                 self.__on_current_changed)
        self.__signal_id2 = App().player.connect("status-changed",
                                                 self.__on_status_changed)
        self.__on_current_changed(App().player)
        if App().player.current_track.id is not None:
            self.update_position()
            ProgressController.on_status_changed(self, App().player)
        self.add(builder.get_object("widget"))
        self.connect("size-allocate", self.__on_size_allocate)
コード例 #3
0
    def __init__(self):
        """
            Init toolbar
        """
        Gtk.Bin.__init__(self)
        InformationController.__init__(self, ArtHelperEffect.NONE)
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/ToolbarInfo.ui")
        builder.connect_signals(self)
        self.__timeout_id = None
        self.__width = 0

        self._infobox = builder.get_object("info")
        self.add(self._infobox)

        self._spinner = builder.get_object("spinner")

        self.__labels = builder.get_object("nowplaying_labels")
        self.__labels.connect("query-tooltip", self.__on_query_tooltip)
        self.__labels.set_property("has-tooltip", True)

        self._title_label = builder.get_object("title")
        self._artist_label = builder.get_object("artist")
        self._artwork = builder.get_object("artwork")
        self._artwork.set_property("has-tooltip", True)

        self.connect("realize", self.__on_realize)
        App().art.connect("album-artwork-changed", self.__update_cover)
        App().art.connect("radio-artwork-changed", self.__update_logo)
        self.connect("button-press-event", self.__on_button_press_event)
コード例 #4
0
    def __init__(self):
        """
            Init mini player
        """
        self.__size = 0
        self.__allocation_timeout_id = None
        self.__cover = None
        Gtk.Bin.__init__(self)
        InformationController.__init__(
            self, False, ArtBehaviour.BLUR_MAX | ArtBehaviour.DARKER)
        ProgressController.__init__(self)
        PlaybackController.__init__(self)
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/MiniPlayer.ui")
        builder.connect_signals(self)

        self.get_style_context().add_class("black")
        self.__grid = builder.get_object("grid")
        self.__revealer = builder.get_object("revealer")
        self.__revealer_box = builder.get_object("revealer_box")
        self.__eventbox = builder.get_object("eventbox")
        self.__eventbox.connect("realize", on_realize)

        self._progress = builder.get_object("progress_scale")
        self._progress.set_sensitive(False)
        self._progress.set_hexpand(True)
        self._timelabel = builder.get_object("playback")
        self._total_time_label = builder.get_object("duration")

        self._artist_label = builder.get_object("artist_label")
        self._title_label = builder.get_object("title_label")

        self._prev_button = builder.get_object("previous_button")
        self._play_button = builder.get_object("play_button")
        self._next_button = builder.get_object("next_button")
        self.__back_button = builder.get_object("back_button")
        self._play_image = builder.get_object("play_image")
        self._pause_image = builder.get_object("pause_image")

        self.__grid = builder.get_object("grid")
        self._artwork = builder.get_object("cover")
        self.__signal_id1 = App().player.connect("current-changed",
                                                 self.__on_current_changed)
        self.__signal_id2 = App().player.connect("status-changed",
                                                 self.__on_status_changed)
        self.__signal_id3 = App().player.connect("duration-changed",
                                                 self.on_duration_changed)
        self.__on_current_changed(App().player)
        if App().player.current_track.id is not None:
            PlaybackController.on_status_changed(self, App().player)
            self.update_position()
            ProgressController.on_status_changed(self, App().player)
        self.add(builder.get_object("widget"))
        self.connect("size-allocate", self.__on_size_allocate)
        self.connect("destroy", self.__on_destroy)
コード例 #5
0
 def __on_size_allocate(self, widget, allocation):
     """
         Update cover based on current height
         @param widget as Gtk.Widget
         @param allocation as Gdk.Rectangle
     """
     if self.__height == allocation.height:
         return
     self.__height = allocation.height
     if self.__height == widget.get_preferred_height()[0]:
         InformationController.__init__(self, True, ArtHelperEffect.BLUR)
     else:
         InformationController.__init__(self, True, ArtHelperEffect.NONE)
     InformationController.on_current_changed(self, self.__width, None)
コード例 #6
0
 def __setup_controller(self):
     """
         Setup controller
     """
     fs_type = App().settings.get_value("fullscreen-type").get_int32()
     context = self._artwork.get_style_context()
     behaviour = ArtBehaviour.CROP_SQUARE
     if fs_type & ArtBehaviour.ROUNDED:
         context.add_class("image-rotate")
         context.remove_class("cover-frame")
         behaviour |= ArtBehaviour.ROUNDED
     else:
         context.remove_class("image-rotate")
         context.add_class("cover-frame")
     InformationController.__init__(self, False, behaviour)
コード例 #7
0
 def _on_image_button_release_event(self, widget, event):
     """
         Change artwork type
         @param widget as Gtk.Widget
         @param event as Gdk.Event
     """
     rotate_album = not App().settings.get_value("rotate-fullscreen-album")
     App().settings.set_value("rotate-fullscreen-album",
                              GLib.Variant("b", rotate_album))
     context = self._artwork.get_style_context()
     if rotate_album:
         context.add_class("image-rotate")
         context.remove_class("cover-frame")
         InformationController.__init__(self, False,
                                        ArtHelperEffect.ROUNDED)
     else:
         context.remove_class("image-rotate")
         context.add_class("cover-frame")
         InformationController.__init__(self, False, ArtHelperEffect.NONE)
     InformationController.on_current_changed(self, self.__artsize,
                                              self.__font_size)
コード例 #8
0
    def __init__(self):
        """
            Init toolbar
        """
        Gtk.Bin.__init__(self)
        InformationController.__init__(self, True,
                                       ArtBehaviour.CROP_SQUARE |
                                       ArtBehaviour.CACHE)
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/ToolbarInfo.ui")
        builder.connect_signals(self)
        self.__timeout_id = None
        self.__width = 0

        self._infobox = builder.get_object("info")
        self.add(self._infobox)

        self._spinner = builder.get_object("spinner")

        self.__labels = builder.get_object("nowplaying_labels")
        self.__labels.connect("query-tooltip", self.__on_query_tooltip)
        self.__labels.set_property("has-tooltip", True)

        self._title_label = builder.get_object("title")
        self._artist_label = builder.get_object("artist")
        self._artwork = builder.get_object("artwork")
        self._artwork.set_property("has-tooltip", True)

        self.connect("realize", self.__on_realize)
        App().art.connect("album-artwork-changed", self.__update_cover)
        App().art.connect("radio-artwork-changed", self.__update_logo)
        self.connect("button-press-event", self.__on_button_press_event)
        self.connect("button-release-event", self.__on_button_release_event)
        self.__gesture = Gtk.GestureLongPress.new(self)
        self.__gesture.connect("pressed", self.__on_gesture_pressed)
        # We want to get release event after gesture
        self.__gesture.set_propagation_phase(Gtk.PropagationPhase.CAPTURE)
        self.__gesture.set_button(0)
コード例 #9
0
 def __init__(self):
     """
         Init view
     """
     View.__init__(self)
     InformationController.__init__(
         self, False, ArtHelperEffect.BLUR_HARD | ArtHelperEffect.NO_RATIO)
     self.__current_changed_id = None
     self.__size_allocate_timeout_id = None
     self.__downloads_running = 0
     self.__lyrics_text = ""
     self.__current_width = self.__current_height = 0
     self.__cancellable = Gio.Cancellable()
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/LyricsView.ui")
     builder.connect_signals(self)
     self._artwork = builder.get_object("cover")
     self.__lyrics_label = builder.get_object("lyrics_label")
     self.__translate_button = builder.get_object("translate_button")
     # We do not use View scrolled window because it does not work with
     # an overlay
     self.add(builder.get_object("widget"))
     self.connect("size-allocate", self.__on_size_allocate)
コード例 #10
0
    def __init__(self, app):
        """
            Init window for app
            @param app as Gio.Application
        """
        Gtk.Window.__init__(self)
        self.set_title("Lollypop")
        rotate_album = App().settings.get_value("rotate-fullscreen-album")
        PlaybackController.__init__(self)
        ProgressController.__init__(self)
        if rotate_album:
            InformationController.__init__(self, False,
                                           ArtHelperEffect.ROUNDED)
        else:
            InformationController.__init__(self, False, ArtHelperEffect.NONE)
        self.set_application(app)
        self.__timeout_id = None
        self.__signal1_id = self.__signal2_id = self.__signal3_id = None
        self.set_decorated(False)

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

        # Calculate cover size
        screen = Gdk.Screen.get_default()
        monitor = screen.get_monitor_at_window(App().window.get_window())
        geometry = screen.get_monitor_geometry(monitor)
        # We want 500 and 200 in full hd
        if geometry.width > geometry.height:
            self.__artsize = int(ArtSize.FULLSCREEN * geometry.height / 1080)
        else:
            self.__artsize = int(ArtSize.FULLSCREEN * geometry.width / 1920)
        self.__font_size = int(14 * geometry.height / 1080)
        widget = builder.get_object("widget")
        grid = builder.get_object("grid")
        self._play_button = builder.get_object("play_btn")
        self._next_button = builder.get_object("next_btn")
        self._prev_button = builder.get_object("prev_btn")
        self._play_image = builder.get_object("play_image")
        self._pause_image = builder.get_object("pause_image")
        close_btn = builder.get_object("close_btn")
        preferences = Gio.Settings.new("org.gnome.desktop.wm.preferences")
        layout = preferences.get_value("button-layout").get_string()
        if layout.split(":")[0] == "close":
            grid.attach(close_btn, 0, 0, 1, 1)
            close_btn.set_property("halign", Gtk.Align.START)
        else:
            grid.attach(close_btn, 2, 0, 1, 1)
            close_btn.set_property("halign", Gtk.Align.END)
        self._artwork = builder.get_object("cover")
        if rotate_album:
            self._artwork.get_style_context().add_class("image-rotate")
        else:
            self._artwork.get_style_context().add_class("cover-frame")
        self._title_label = builder.get_object("title")
        self._artist_label = builder.get_object("artist")
        self._album_label = builder.get_object("album")
        self.__revealer = builder.get_object("reveal")
        self._datetime = builder.get_object("datetime")
        self._progress = builder.get_object("progress_scale")
        self._timelabel = builder.get_object("playback")
        self._total_time_label = builder.get_object("duration")
        self.connect("key-release-event", self.__on_key_release_event)

        # Add an AlbumListView on the right
        self.__view = AlbumsListView(RowListType.DND)
        self.__view.get_style_context().add_class("background-opacity")
        self.__view.show()
        self.__revealer.add(self.__view)
        self.add(widget)