mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
removed libnotify dependency
This commit is contained in:
parent
bf32ef7a29
commit
1ca4761d75
@ -58,7 +58,7 @@ Dependencies:
|
|||||||
|
|
||||||
Python modules:
|
Python modules:
|
||||||
- mpd (python-mpd2 >=1.1)
|
- mpd (python-mpd2 >=1.1)
|
||||||
- gi (Gtk, Gio, Gdk, GdkPixbuf, Pango, GObject, GLib, Notify)
|
- gi (Gtk, Gio, Gdk, GdkPixbuf, Pango, GObject, GLib)
|
||||||
- requests
|
- requests
|
||||||
- bs4 (beautifulsoup)
|
- bs4 (beautifulsoup)
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
import gi
|
import gi
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
gi.require_version("Notify", "0.7")
|
from gi.repository import Gtk, Gio, Gdk, GdkPixbuf, Pango, GObject, GLib
|
||||||
from gi.repository import Gtk, Gio, Gdk, GdkPixbuf, Pango, GObject, GLib, Notify
|
|
||||||
from mpd import MPDClient, base as MPDBase
|
from mpd import MPDClient, base as MPDBase
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@ -3473,7 +3472,7 @@ class ConnectionNotify(Gtk.Revealer):
|
|||||||
self._client.reconnect()
|
self._client.reconnect()
|
||||||
|
|
||||||
class MainWindow(Gtk.ApplicationWindow):
|
class MainWindow(Gtk.ApplicationWindow):
|
||||||
def __init__(self, client, settings, notify, **kwargs):
|
def __init__(self, client, settings, **kwargs):
|
||||||
super().__init__(title=("mpdevil"), icon_name="org.mpdevil.mpdevil", **kwargs)
|
super().__init__(title=("mpdevil"), icon_name="org.mpdevil.mpdevil", **kwargs)
|
||||||
self.set_default_icon_name("org.mpdevil.mpdevil")
|
self.set_default_icon_name("org.mpdevil.mpdevil")
|
||||||
self.set_default_size(settings.get_int("width"), settings.get_int("height"))
|
self.set_default_size(settings.get_int("width"), settings.get_int("height"))
|
||||||
@ -3481,7 +3480,6 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||||||
self.maximize() # request maximize
|
self.maximize() # request maximize
|
||||||
self._client=client
|
self._client=client
|
||||||
self._settings=settings
|
self._settings=settings
|
||||||
self._notify=notify
|
|
||||||
self._use_csd=self._settings.get_boolean("use-csd")
|
self._use_csd=self._settings.get_boolean("use-csd")
|
||||||
self._size=None # needed for window size saving
|
self._size=None # needed for window size saving
|
||||||
|
|
||||||
@ -3721,10 +3719,14 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||||||
self.set_title(" • ".join(filter(None, (title, album))))
|
self.set_title(" • ".join(filter(None, (title, album))))
|
||||||
if self._settings.get_boolean("send-notify"):
|
if self._settings.get_boolean("send-notify"):
|
||||||
if not self.is_active() and self._client.status()["state"] == "play":
|
if not self.is_active() and self._client.status()["state"] == "play":
|
||||||
self._notify.update(str(song["title"]), f"{song['artist']}\n{album}")
|
notify=Gio.Notification()
|
||||||
pixbuf=self._client.get_cover(song).get_pixbuf(400)
|
notify.set_title(str(song["title"]))
|
||||||
self._notify.set_image_from_pixbuf(pixbuf)
|
notify.set_body(f"{song['artist']}\n{album}")
|
||||||
self._notify.show()
|
if (cover_path:=self._client.get_cover_path(song)) is not None:
|
||||||
|
notify.set_icon(Gio.FileIcon.new(Gio.File.new_for_path(cover_path)))
|
||||||
|
elif (cover_binary:=self._client.get_cover_binary(song["file"])) is not None:
|
||||||
|
notify.set_icon(Gio.BytesIcon.new(GLib.Bytes.new(cover_binary)))
|
||||||
|
self.get_application().send_notification("title-change", notify)
|
||||||
else:
|
else:
|
||||||
self.set_title("mpdevil")
|
self.set_title("mpdevil")
|
||||||
if self._use_csd:
|
if self._use_csd:
|
||||||
@ -3782,9 +3784,7 @@ class mpdevil(Gtk.Application):
|
|||||||
Gtk.Application.do_startup(self)
|
Gtk.Application.do_startup(self)
|
||||||
self._settings=Settings()
|
self._settings=Settings()
|
||||||
self._client=Client(self._settings)
|
self._client=Client(self._settings)
|
||||||
Notify.init("mpdevil")
|
self._window=MainWindow(self._client, self._settings, application=self)
|
||||||
self._notify=Notify.Notification()
|
|
||||||
self._window=MainWindow(self._client, self._settings, self._notify, application=self)
|
|
||||||
self._window.connect("delete-event", self._on_quit)
|
self._window.connect("delete-event", self._on_quit)
|
||||||
self._window.insert_action_group("mpd", MPDActionGroup(self._client))
|
self._window.insert_action_group("mpd", MPDActionGroup(self._client))
|
||||||
# MPRIS
|
# MPRIS
|
||||||
@ -3822,8 +3822,7 @@ class mpdevil(Gtk.Application):
|
|||||||
Gtk.Application.do_shutdown(self)
|
Gtk.Application.do_shutdown(self)
|
||||||
if self._settings.get_boolean("stop-on-quit") and self._client.connected():
|
if self._settings.get_boolean("stop-on-quit") and self._client.connected():
|
||||||
self._client.stop()
|
self._client.stop()
|
||||||
self._notify.close()
|
self.withdraw_notification("title-change")
|
||||||
Notify.uninit()
|
|
||||||
|
|
||||||
def do_command_line(self, command_line):
|
def do_command_line(self, command_line):
|
||||||
# convert GVariantDict -> GVariant -> dict
|
# convert GVariantDict -> GVariant -> dict
|
||||||
|
Loading…
Reference in New Issue
Block a user