mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
removed unnecessary 'self.'
This commit is contained in:
parent
2a4f402e5d
commit
393496e3e3
226
bin/mpdevil.py
226
bin/mpdevil.py
@ -596,11 +596,13 @@ class FocusFrame(Gtk.Overlay):
|
|||||||
|
|
||||||
self.frame=Gtk.Frame()
|
self.frame=Gtk.Frame()
|
||||||
self.frame.set_no_show_all(True)
|
self.frame.set_no_show_all(True)
|
||||||
self.style_context=self.frame.get_style_context()
|
|
||||||
self.provider=Gtk.CssProvider()
|
# css
|
||||||
|
style_context=self.frame.get_style_context()
|
||||||
|
provider=Gtk.CssProvider()
|
||||||
css=b"""* {border-color: @theme_selected_bg_color; border-width: 2px;}"""
|
css=b"""* {border-color: @theme_selected_bg_color; border-width: 2px;}"""
|
||||||
self.provider.load_from_data(css)
|
provider.load_from_data(css)
|
||||||
self.style_context.add_provider(self.provider, 800)
|
style_context.add_provider(provider, 800)
|
||||||
|
|
||||||
self.add_overlay(self.frame)
|
self.add_overlay(self.frame)
|
||||||
self.set_overlay_pass_through(self.frame, True)
|
self.set_overlay_pass_through(self.frame, True)
|
||||||
@ -629,32 +631,32 @@ class SongPopover(Gtk.Popover):
|
|||||||
|
|
||||||
# Store
|
# Store
|
||||||
# (tag, display-value, tooltip)
|
# (tag, display-value, tooltip)
|
||||||
self.store=Gtk.ListStore(str, str, str)
|
store=Gtk.ListStore(str, str, str)
|
||||||
|
|
||||||
# TreeView
|
# TreeView
|
||||||
self.treeview=Gtk.TreeView(model=self.store)
|
treeview=Gtk.TreeView(model=store)
|
||||||
self.treeview.set_can_focus(False)
|
treeview.set_can_focus(False)
|
||||||
self.treeview.set_search_column(-1)
|
treeview.set_search_column(-1)
|
||||||
self.treeview.set_tooltip_column(2)
|
treeview.set_tooltip_column(2)
|
||||||
self.treeview.set_headers_visible(False)
|
treeview.set_headers_visible(False)
|
||||||
sel=self.treeview.get_selection()
|
sel=treeview.get_selection()
|
||||||
sel.set_mode(Gtk.SelectionMode.NONE)
|
sel.set_mode(Gtk.SelectionMode.NONE)
|
||||||
|
|
||||||
frame=Gtk.Frame()
|
frame=Gtk.Frame()
|
||||||
frame.add(self.treeview)
|
frame.add(treeview)
|
||||||
frame.set_property("border-width", 3)
|
frame.set_property("border-width", 3)
|
||||||
|
|
||||||
# Column
|
# Column
|
||||||
renderer_text=Gtk.CellRendererText(width_chars=50, ellipsize=Pango.EllipsizeMode.MIDDLE, ellipsize_set=True)
|
renderer_text=Gtk.CellRendererText(width_chars=50, ellipsize=Pango.EllipsizeMode.MIDDLE, ellipsize_set=True)
|
||||||
renderer_text_ralign=Gtk.CellRendererText(xalign=1.0)
|
renderer_text_ralign=Gtk.CellRendererText(xalign=1.0)
|
||||||
|
|
||||||
self.column_tag=Gtk.TreeViewColumn(_("MPD-Tag"), renderer_text_ralign, text=0)
|
column_tag=Gtk.TreeViewColumn(_("MPD-Tag"), renderer_text_ralign, text=0)
|
||||||
self.column_tag.set_property("resizable", False)
|
column_tag.set_property("resizable", False)
|
||||||
self.treeview.append_column(self.column_tag)
|
treeview.append_column(column_tag)
|
||||||
|
|
||||||
self.column_value=Gtk.TreeViewColumn(_("Value"), renderer_text, text=1)
|
column_value=Gtk.TreeViewColumn(_("Value"), renderer_text, text=1)
|
||||||
self.column_value.set_property("resizable", False)
|
column_value.set_property("resizable", False)
|
||||||
self.treeview.append_column(self.column_value)
|
treeview.append_column(column_value)
|
||||||
|
|
||||||
# packing
|
# packing
|
||||||
self.add(frame)
|
self.add(frame)
|
||||||
@ -663,12 +665,12 @@ class SongPopover(Gtk.Popover):
|
|||||||
for tag, value in song.items():
|
for tag, value in song.items():
|
||||||
tooltip=value.replace("&", "&")
|
tooltip=value.replace("&", "&")
|
||||||
if tag == "time":
|
if tag == "time":
|
||||||
self.store.append([tag+":", str(datetime.timedelta(seconds=int(value))), tooltip])
|
store.append([tag+":", str(datetime.timedelta(seconds=int(value))), tooltip])
|
||||||
elif tag == "last-modified":
|
elif tag == "last-modified":
|
||||||
time=datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')
|
time=datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
self.store.append([tag+":", time.strftime('%a %d %B %Y, %H:%M UTC'), tooltip])
|
store.append([tag+":", time.strftime('%a %d %B %Y, %H:%M UTC'), tooltip])
|
||||||
else:
|
else:
|
||||||
self.store.append([tag+":", value, tooltip])
|
store.append([tag+":", value, tooltip])
|
||||||
frame.show_all()
|
frame.show_all()
|
||||||
|
|
||||||
class Cover(object):
|
class Cover(object):
|
||||||
@ -679,11 +681,11 @@ class Cover(object):
|
|||||||
|
|
||||||
active_profile=settings.get_int("active-profile")
|
active_profile=settings.get_int("active-profile")
|
||||||
|
|
||||||
self.lib_path=settings.get_value("paths")[active_profile]
|
lib_path=settings.get_value("paths")[active_profile]
|
||||||
regex_str=settings.get_value("regex")[active_profile]
|
regex_str=settings.get_value("regex")[active_profile]
|
||||||
|
|
||||||
if regex_str == "":
|
if regex_str == "":
|
||||||
self.regex=re.compile(r''+COVER_REGEX+'', flags=re.IGNORECASE)
|
regex=re.compile(r''+COVER_REGEX+'', flags=re.IGNORECASE)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
artist=song["albumartist"]
|
artist=song["albumartist"]
|
||||||
@ -696,16 +698,16 @@ class Cover(object):
|
|||||||
regex_str=regex_str.replace("%AlbumArtist%", artist)
|
regex_str=regex_str.replace("%AlbumArtist%", artist)
|
||||||
regex_str=regex_str.replace("%Album%", album)
|
regex_str=regex_str.replace("%Album%", album)
|
||||||
try:
|
try:
|
||||||
self.regex=re.compile(r''+regex_str+'', flags=re.IGNORECASE)
|
regex=re.compile(r''+regex_str+'', flags=re.IGNORECASE)
|
||||||
except:
|
except:
|
||||||
print("illegal regex:", regex_str)
|
print("illegal regex:", regex_str)
|
||||||
|
|
||||||
if song_file is not None:
|
if song_file is not None:
|
||||||
head, tail=os.path.split(song_file)
|
head, tail=os.path.split(song_file)
|
||||||
song_dir=os.path.join(self.lib_path, head)
|
song_dir=os.path.join(lib_path, head)
|
||||||
if os.path.exists(song_dir):
|
if os.path.exists(song_dir):
|
||||||
for f in os.listdir(song_dir):
|
for f in os.listdir(song_dir):
|
||||||
if self.regex.match(f):
|
if regex.match(f):
|
||||||
self.path=os.path.join(song_dir, f)
|
self.path=os.path.join(song_dir, f)
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -1217,7 +1219,6 @@ class SongsWindow(Gtk.Box):
|
|||||||
|
|
||||||
# adding vars
|
# adding vars
|
||||||
self.client=client
|
self.client=client
|
||||||
self.store=store
|
|
||||||
|
|
||||||
# treeview
|
# treeview
|
||||||
self.songs_view=SongsView(client, store, file_column_id)
|
self.songs_view=SongsView(client, store, file_column_id)
|
||||||
@ -1228,12 +1229,12 @@ class SongsWindow(Gtk.Box):
|
|||||||
scroll.add(self.songs_view)
|
scroll.add(self.songs_view)
|
||||||
|
|
||||||
# buttons
|
# buttons
|
||||||
self.append_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("list-add", Gtk.IconSize.BUTTON), label=_("Append"))
|
append_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("list-add", Gtk.IconSize.BUTTON), label=_("Append"))
|
||||||
self.append_button.set_tooltip_text(_("Add all titles to playlist"))
|
append_button.set_tooltip_text(_("Add all titles to playlist"))
|
||||||
self.play_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("media-playback-start", Gtk.IconSize.BUTTON), label=_("Play"))
|
play_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("media-playback-start", Gtk.IconSize.BUTTON), label=_("Play"))
|
||||||
self.play_button.set_tooltip_text(_("Directly play all titles"))
|
play_button.set_tooltip_text(_("Directly play all titles"))
|
||||||
self.enqueue_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("insert-object", Gtk.IconSize.BUTTON), label=_("Enqueue"))
|
enqueue_button=Gtk.Button(image=Gtk.Image.new_from_icon_name("insert-object", Gtk.IconSize.BUTTON), label=_("Enqueue"))
|
||||||
self.enqueue_button.set_tooltip_text(_("Append all titles after the currently playing track and clear the playlist from all other songs"))
|
enqueue_button.set_tooltip_text(_("Append all titles after the currently playing track and clear the playlist from all other songs"))
|
||||||
|
|
||||||
# button box
|
# button box
|
||||||
button_box=Gtk.ButtonBox()
|
button_box=Gtk.ButtonBox()
|
||||||
@ -1243,18 +1244,18 @@ class SongsWindow(Gtk.Box):
|
|||||||
self.action_bar=Gtk.ActionBar()
|
self.action_bar=Gtk.ActionBar()
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
self.append_button.connect("clicked", self.on_append_button_clicked)
|
append_button.connect("clicked", self.on_append_button_clicked)
|
||||||
self.play_button.connect("clicked", self.on_play_button_clicked)
|
play_button.connect("clicked", self.on_play_button_clicked)
|
||||||
self.enqueue_button.connect("clicked", self.on_enqueue_button_clicked)
|
enqueue_button.connect("clicked", self.on_enqueue_button_clicked)
|
||||||
|
|
||||||
# packing
|
# packing
|
||||||
frame=FocusFrame()
|
frame=FocusFrame()
|
||||||
frame.set_widget(self.songs_view)
|
frame.set_widget(self.songs_view)
|
||||||
frame.add(scroll)
|
frame.add(scroll)
|
||||||
self.pack_start(frame, True, True, 0)
|
self.pack_start(frame, True, True, 0)
|
||||||
button_box.pack_start(self.append_button, True, True, 0)
|
button_box.pack_start(append_button, True, True, 0)
|
||||||
button_box.pack_start(self.play_button, True, True, 0)
|
button_box.pack_start(play_button, True, True, 0)
|
||||||
button_box.pack_start(self.enqueue_button, True, True, 0)
|
button_box.pack_start(enqueue_button, True, True, 0)
|
||||||
self.action_bar.pack_start(button_box)
|
self.action_bar.pack_start(button_box)
|
||||||
self.pack_start(self.action_bar, False, False, 0)
|
self.pack_start(self.action_bar, False, False, 0)
|
||||||
|
|
||||||
@ -1274,7 +1275,7 @@ class SongsWindow(Gtk.Box):
|
|||||||
self.client.wrapped_call("files_to_playlist", self.songs_view.get_files(), "enqueue")
|
self.client.wrapped_call("files_to_playlist", self.songs_view.get_files(), "enqueue")
|
||||||
|
|
||||||
class AlbumDialog(Gtk.Dialog):
|
class AlbumDialog(Gtk.Dialog):
|
||||||
def __init__(self, parent, client, settings, album, artist, year):
|
def __init__(self, parent, client, settings, album, album_artist, year):
|
||||||
use_csd=settings.get_boolean("use-csd")
|
use_csd=settings.get_boolean("use-csd")
|
||||||
if use_csd:
|
if use_csd:
|
||||||
Gtk.Dialog.__init__(self, transient_for=parent, use_header_bar=True)
|
Gtk.Dialog.__init__(self, transient_for=parent, use_header_bar=True)
|
||||||
@ -1291,15 +1292,10 @@ class AlbumDialog(Gtk.Dialog):
|
|||||||
provider.load_from_data(css)
|
provider.load_from_data(css)
|
||||||
style_context.add_provider(provider, 800)
|
style_context.add_provider(provider, 800)
|
||||||
|
|
||||||
# metadata
|
|
||||||
self.album=album
|
|
||||||
self.artist=artist
|
|
||||||
self.year=year
|
|
||||||
|
|
||||||
# adding vars
|
# adding vars
|
||||||
self.client=client
|
self.client=client
|
||||||
self.settings=settings
|
self.settings=settings
|
||||||
songs=self.client.wrapped_call("find", "album", self.album, "date", self.year, self.settings.get_artist_type(), self.artist)
|
songs=self.client.wrapped_call("find", "album", album, "date", year, self.settings.get_artist_type(), album_artist)
|
||||||
|
|
||||||
# determine size
|
# determine size
|
||||||
size=parent.get_size()
|
size=parent.get_size()
|
||||||
@ -1311,13 +1307,13 @@ class AlbumDialog(Gtk.Dialog):
|
|||||||
# title
|
# title
|
||||||
album_duration=ClientHelper.calc_display_length(songs)
|
album_duration=ClientHelper.calc_display_length(songs)
|
||||||
if year == "":
|
if year == "":
|
||||||
self.set_title(artist+" - "+album+" ("+album_duration+")")
|
self.set_title(album_artist+" - "+album+" ("+album_duration+")")
|
||||||
else:
|
else:
|
||||||
self.set_title(artist+" - "+album+" ("+year+") ("+album_duration+")")
|
self.set_title(album_artist+" - "+album+" ("+year+") ("+album_duration+")")
|
||||||
|
|
||||||
# store
|
# store
|
||||||
# (track, title (artist), duration, file)
|
# (track, title (artist), duration, file)
|
||||||
self.store=Gtk.ListStore(int, str, str, str)
|
store=Gtk.ListStore(int, str, str, str)
|
||||||
for s in songs:
|
for s in songs:
|
||||||
song=ClientHelper.extend_song_for_display(s)
|
song=ClientHelper.extend_song_for_display(s)
|
||||||
if type(song["title"]) == list: # could be impossible
|
if type(song["title"]) == list: # could be impossible
|
||||||
@ -1326,58 +1322,58 @@ class AlbumDialog(Gtk.Dialog):
|
|||||||
title=song["title"]
|
title=song["title"]
|
||||||
if type(song["artist"]) == list:
|
if type(song["artist"]) == list:
|
||||||
try:
|
try:
|
||||||
song["artist"].remove(self.artist)
|
song["artist"].remove(album_artist)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
artist=(', '.join(song["artist"]))
|
artist=(', '.join(song["artist"]))
|
||||||
else:
|
else:
|
||||||
artist=song["artist"]
|
artist=song["artist"]
|
||||||
if artist == self.artist:
|
if artist == album_artist:
|
||||||
title_artist="<b>"+title+"</b>"
|
title_artist="<b>"+title+"</b>"
|
||||||
else:
|
else:
|
||||||
title_artist="<b>"+title+"</b> - "+artist
|
title_artist="<b>"+title+"</b> - "+artist
|
||||||
|
|
||||||
title_artist=title_artist.replace("&", "&")
|
title_artist=title_artist.replace("&", "&")
|
||||||
self.store.append([int(song["track"]), title_artist, song["human_duration"], song["file"]])
|
store.append([int(song["track"]), title_artist, song["human_duration"], song["file"]])
|
||||||
|
|
||||||
# songs window
|
# songs window
|
||||||
self.songs_window=SongsWindow(self.client, self.store, 3)
|
songs_window=SongsWindow(self.client, store, 3)
|
||||||
|
|
||||||
# songs view
|
# songs view
|
||||||
self.songs_view=self.songs_window.get_treeview()
|
songs_view=songs_window.get_treeview()
|
||||||
|
|
||||||
# columns
|
# columns
|
||||||
renderer_text=Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END, ellipsize_set=True)
|
renderer_text=Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END, ellipsize_set=True)
|
||||||
renderer_text_ralign=Gtk.CellRendererText(xalign=1.0)
|
renderer_text_ralign=Gtk.CellRendererText(xalign=1.0)
|
||||||
|
|
||||||
self.column_track=Gtk.TreeViewColumn(_("No"), renderer_text_ralign, text=0)
|
column_track=Gtk.TreeViewColumn(_("No"), renderer_text_ralign, text=0)
|
||||||
self.column_track.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
|
column_track.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
|
||||||
self.column_track.set_property("resizable", False)
|
column_track.set_property("resizable", False)
|
||||||
self.songs_view.append_column(self.column_track)
|
songs_view.append_column(column_track)
|
||||||
|
|
||||||
self.column_title=Gtk.TreeViewColumn(_("Title"), renderer_text, markup=1)
|
column_title=Gtk.TreeViewColumn(_("Title"), renderer_text, markup=1)
|
||||||
self.column_title.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
|
column_title.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
|
||||||
self.column_title.set_property("resizable", False)
|
column_title.set_property("resizable", False)
|
||||||
self.column_title.set_property("expand", True)
|
column_title.set_property("expand", True)
|
||||||
self.songs_view.append_column(self.column_title)
|
songs_view.append_column(column_title)
|
||||||
|
|
||||||
self.column_time=Gtk.TreeViewColumn(_("Length"), renderer_text, text=2)
|
column_time=Gtk.TreeViewColumn(_("Length"), renderer_text, text=2)
|
||||||
self.column_time.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
|
column_time.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
|
||||||
self.column_time.set_property("resizable", False)
|
column_time.set_property("resizable", False)
|
||||||
self.songs_view.append_column(self.column_time)
|
songs_view.append_column(column_time)
|
||||||
|
|
||||||
# close button
|
# close button
|
||||||
close_button=Gtk.ToggleButton(image=Gtk.Image.new_from_icon_name("window-close", Gtk.IconSize.BUTTON), label=_("Close"))
|
close_button=Gtk.ToggleButton(image=Gtk.Image.new_from_icon_name("window-close", Gtk.IconSize.BUTTON), label=_("Close"))
|
||||||
|
|
||||||
# action bar
|
# action bar
|
||||||
action_bar=self.songs_window.get_action_bar()
|
action_bar=songs_window.get_action_bar()
|
||||||
action_bar.pack_end(close_button)
|
action_bar.pack_end(close_button)
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
close_button.connect("clicked", self.on_close_button_clicked)
|
close_button.connect("clicked", self.on_close_button_clicked)
|
||||||
|
|
||||||
# packing
|
# packing
|
||||||
self.vbox.pack_start(self.songs_window, True, True, 0) # vbox default widget of dialogs
|
self.vbox.pack_start(songs_window, True, True, 0) # vbox default widget of dialogs
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
@ -1387,18 +1383,17 @@ class AlbumDialog(Gtk.Dialog):
|
|||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
class GenreSelect(Gtk.ComboBoxText):
|
class GenreSelect(Gtk.ComboBoxText):
|
||||||
def __init__(self, client, settings):
|
def __init__(self, client):
|
||||||
Gtk.ComboBoxText.__init__(self)
|
Gtk.ComboBoxText.__init__(self)
|
||||||
|
|
||||||
# adding vars
|
# adding vars
|
||||||
self.client=client
|
self.client=client
|
||||||
self.settings=settings
|
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
self.changed=self.connect("changed", self.on_changed)
|
self.changed=self.connect("changed", self.on_changed)
|
||||||
self.client.emitter.connect("disconnected", self.on_disconnected)
|
self.client.emitter.connect("disconnected", self.on_disconnected)
|
||||||
self.client.emitter.connect("reconnected", self.on_reconnected)
|
self.client.emitter.connect("reconnected", self.on_reconnected)
|
||||||
self.update_signal=self.client.emitter.connect("update", self.refresh)
|
self.client.emitter.connect("update", self.refresh)
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
self.set_active(0)
|
self.set_active(0)
|
||||||
@ -1457,7 +1452,7 @@ class ArtistWindow(FocusFrame):
|
|||||||
self.treeview.columns_autosize()
|
self.treeview.columns_autosize()
|
||||||
self.treeview.set_property("activate-on-single-click", True)
|
self.treeview.set_property("activate-on-single-click", True)
|
||||||
|
|
||||||
# artistSelection
|
# Selection
|
||||||
self.selection=self.treeview.get_selection()
|
self.selection=self.treeview.get_selection()
|
||||||
self.selection.set_mode(Gtk.SelectionMode.SINGLE)
|
self.selection.set_mode(Gtk.SelectionMode.SINGLE)
|
||||||
|
|
||||||
@ -1766,14 +1761,12 @@ class AlbumWindow(FocusFrame):
|
|||||||
# adding vars
|
# adding vars
|
||||||
self.settings=settings
|
self.settings=settings
|
||||||
self.client=client
|
self.client=client
|
||||||
self.genre_select=genre_select
|
|
||||||
self.window=window
|
|
||||||
self.artists=[]
|
self.artists=[]
|
||||||
self.done=True
|
self.done=True
|
||||||
self.pending=[]
|
self.pending=[]
|
||||||
|
|
||||||
# iconview
|
# iconview
|
||||||
self.iconview=AlbumView(self.client, self.settings, self.genre_select, self.window)
|
self.iconview=AlbumView(client, settings, genre_select, window)
|
||||||
|
|
||||||
# scroll
|
# scroll
|
||||||
scroll=Gtk.ScrolledWindow()
|
scroll=Gtk.ScrolledWindow()
|
||||||
@ -1781,11 +1774,11 @@ class AlbumWindow(FocusFrame):
|
|||||||
scroll.add(self.iconview)
|
scroll.add(self.iconview)
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
self.settings.connect("changed::album-cover", self.on_settings_changed)
|
|
||||||
self.iconview.connect("done", self.on_done)
|
self.iconview.connect("done", self.on_done)
|
||||||
|
genre_select.connect("genre_changed", self.clear)
|
||||||
self.client.emitter.connect("update", self.clear)
|
self.client.emitter.connect("update", self.clear)
|
||||||
self.client.emitter.connect("disconnected", self.clear)
|
self.client.emitter.connect("disconnected", self.clear)
|
||||||
self.genre_select.connect("genre_changed", self.clear)
|
self.settings.connect("changed::album-cover", self.on_settings_changed)
|
||||||
self.settings.connect("changed::use-album-artist", self.clear)
|
self.settings.connect("changed::use-album-artist", self.clear)
|
||||||
|
|
||||||
self.set_widget(self.iconview)
|
self.set_widget(self.iconview)
|
||||||
@ -1838,7 +1831,6 @@ class Browser(Gtk.Paned):
|
|||||||
# adding vars
|
# adding vars
|
||||||
self.client=client
|
self.client=client
|
||||||
self.settings=settings
|
self.settings=settings
|
||||||
self.window=window
|
|
||||||
self.use_csd=self.settings.get_boolean("use-csd")
|
self.use_csd=self.settings.get_boolean("use-csd")
|
||||||
|
|
||||||
if self.use_csd:
|
if self.use_csd:
|
||||||
@ -1856,10 +1848,10 @@ class Browser(Gtk.Paned):
|
|||||||
self.back_to_album_button.set_tooltip_text(_("Back to current album"))
|
self.back_to_album_button.set_tooltip_text(_("Back to current album"))
|
||||||
self.search_button=Gtk.ToggleButton(image=self.icons["system-search-symbolic"])
|
self.search_button=Gtk.ToggleButton(image=self.icons["system-search-symbolic"])
|
||||||
self.search_button.set_tooltip_text(_("Search"))
|
self.search_button.set_tooltip_text(_("Search"))
|
||||||
self.genre_select=GenreSelect(self.client, self.settings)
|
self.genre_select=GenreSelect(self.client)
|
||||||
self.artist_window=ArtistWindow(self.client, self.settings, self.genre_select)
|
self.artist_window=ArtistWindow(self.client, self.settings, self.genre_select)
|
||||||
self.search_window=SearchWindow(self.client)
|
self.search_window=SearchWindow(self.client)
|
||||||
self.album_window=AlbumWindow(self.client, self.settings, self.genre_select, self.window)
|
self.album_window=AlbumWindow(self.client, self.settings, self.genre_select, window)
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
self.back_to_album_button.connect("clicked", self.back_to_album)
|
self.back_to_album_button.connect("clicked", self.back_to_album)
|
||||||
@ -1972,23 +1964,23 @@ class LyricsWindow(Gtk.Overlay):
|
|||||||
self.client=client
|
self.client=client
|
||||||
|
|
||||||
# widgets
|
# widgets
|
||||||
self.text_view=Gtk.TextView()
|
text_view=Gtk.TextView()
|
||||||
self.text_view.set_editable(False)
|
text_view.set_editable(False)
|
||||||
self.text_view.set_left_margin(5)
|
text_view.set_left_margin(5)
|
||||||
self.text_view.set_bottom_margin(5)
|
text_view.set_bottom_margin(5)
|
||||||
self.text_view.set_cursor_visible(False)
|
text_view.set_cursor_visible(False)
|
||||||
self.text_view.set_wrap_mode(Gtk.WrapMode.WORD)
|
text_view.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||||
self.text_view.set_justification(Gtk.Justification.CENTER)
|
text_view.set_justification(Gtk.Justification.CENTER)
|
||||||
self.text_buffer=self.text_view.get_buffer()
|
self.text_buffer=text_view.get_buffer()
|
||||||
|
|
||||||
# scroll
|
# scroll
|
||||||
self.scroll=Gtk.ScrolledWindow()
|
scroll=Gtk.ScrolledWindow()
|
||||||
self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||||
self.scroll.add(self.text_view)
|
scroll.add(text_view)
|
||||||
|
|
||||||
# frame
|
# frame
|
||||||
frame=FocusFrame()
|
frame=FocusFrame()
|
||||||
frame.set_widget(self.text_view)
|
frame.set_widget(text_view)
|
||||||
style_context=frame.get_style_context()
|
style_context=frame.get_style_context()
|
||||||
provider=Gtk.CssProvider()
|
provider=Gtk.CssProvider()
|
||||||
css=b"""* {border: 0px; background-color: @theme_base_color; opacity: 0.9;}"""
|
css=b"""* {border: 0px; background-color: @theme_base_color; opacity: 0.9;}"""
|
||||||
@ -2011,13 +2003,13 @@ class LyricsWindow(Gtk.Overlay):
|
|||||||
close_button.connect("clicked", self.on_close_button_clicked)
|
close_button.connect("clicked", self.on_close_button_clicked)
|
||||||
|
|
||||||
# packing
|
# packing
|
||||||
frame.add(self.scroll)
|
frame.add(scroll)
|
||||||
self.add(frame)
|
self.add(frame)
|
||||||
self.add_overlay(close_button)
|
self.add_overlay(close_button)
|
||||||
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
self.refresh()
|
self.refresh()
|
||||||
GLib.idle_add(self.text_view.grab_focus) # focus textview
|
GLib.idle_add(text_view.grab_focus) # focus textview
|
||||||
|
|
||||||
def remove_handlers(self, *args):
|
def remove_handlers(self, *args):
|
||||||
self.client.emitter.disconnect(self.song_changed)
|
self.client.emitter.disconnect(self.song_changed)
|
||||||
@ -2484,12 +2476,8 @@ class CoverLyricsOSD(Gtk.Overlay):
|
|||||||
self.revealer.set_margin_end(6)
|
self.revealer.set_margin_end(6)
|
||||||
self.revealer.add(self.lyrics_button)
|
self.revealer.add(self.lyrics_button)
|
||||||
|
|
||||||
# event box
|
|
||||||
self.event_box=Gtk.EventBox()
|
|
||||||
self.event_box.add(self.cover)
|
|
||||||
|
|
||||||
# packing
|
# packing
|
||||||
self.add(self.event_box)
|
self.add(self.cover)
|
||||||
self.add_overlay(self.revealer)
|
self.add_overlay(self.revealer)
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
@ -2536,10 +2524,9 @@ class CoverPlaylistWindow(Gtk.Paned):
|
|||||||
# adding vars
|
# adding vars
|
||||||
self.client=client
|
self.client=client
|
||||||
self.settings=settings
|
self.settings=settings
|
||||||
self.window=window
|
|
||||||
|
|
||||||
# widgets
|
# widgets
|
||||||
self.cover=CoverLyricsOSD(self.client, self.settings, self.window)
|
self.cover=CoverLyricsOSD(self.client, self.settings, window)
|
||||||
self.playlist_window=PlaylistWindow(self.client, self.settings)
|
self.playlist_window=PlaylistWindow(self.client, self.settings)
|
||||||
|
|
||||||
# packing
|
# packing
|
||||||
@ -3440,46 +3427,43 @@ class ServerStats(Gtk.Dialog):
|
|||||||
self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
|
self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
|
||||||
self.set_resizable(False)
|
self.set_resizable(False)
|
||||||
|
|
||||||
# adding vars
|
|
||||||
self.client=client
|
|
||||||
|
|
||||||
# Store
|
# Store
|
||||||
# (tag, value)
|
# (tag, value)
|
||||||
self.store=Gtk.ListStore(str, str)
|
store=Gtk.ListStore(str, str)
|
||||||
|
|
||||||
# TreeView
|
# TreeView
|
||||||
self.treeview=Gtk.TreeView(model=self.store)
|
treeview=Gtk.TreeView(model=store)
|
||||||
self.treeview.set_can_focus(False)
|
treeview.set_can_focus(False)
|
||||||
self.treeview.set_search_column(-1)
|
treeview.set_search_column(-1)
|
||||||
self.treeview.set_headers_visible(False)
|
treeview.set_headers_visible(False)
|
||||||
|
|
||||||
# selection
|
# selection
|
||||||
sel=self.treeview.get_selection()
|
sel=treeview.get_selection()
|
||||||
sel.set_mode(Gtk.SelectionMode.NONE)
|
sel.set_mode(Gtk.SelectionMode.NONE)
|
||||||
|
|
||||||
# Column
|
# Column
|
||||||
renderer_text=Gtk.CellRendererText()
|
renderer_text=Gtk.CellRendererText()
|
||||||
renderer_text_ralign=Gtk.CellRendererText(xalign=1.0)
|
renderer_text_ralign=Gtk.CellRendererText(xalign=1.0)
|
||||||
|
|
||||||
self.column_tag=Gtk.TreeViewColumn("", renderer_text_ralign, text=0)
|
column_tag=Gtk.TreeViewColumn("", renderer_text_ralign, text=0)
|
||||||
self.treeview.append_column(self.column_tag)
|
treeview.append_column(column_tag)
|
||||||
|
|
||||||
self.column_value=Gtk.TreeViewColumn("", renderer_text, text=1)
|
column_value=Gtk.TreeViewColumn("", renderer_text, text=1)
|
||||||
self.treeview.append_column(self.column_value)
|
treeview.append_column(column_value)
|
||||||
|
|
||||||
self.store.append(["protocol:", str(self.client.mpd_version)])
|
store.append(["protocol:", str(client.mpd_version)])
|
||||||
|
|
||||||
stats=self.client.wrapped_call("stats")
|
stats=client.wrapped_call("stats")
|
||||||
for key in stats:
|
for key in stats:
|
||||||
print_key=key+":"
|
print_key=key+":"
|
||||||
if key == "uptime" or key == "playtime" or key == "db_playtime":
|
if key == "uptime" or key == "playtime" or key == "db_playtime":
|
||||||
self.store.append([print_key, str(datetime.timedelta(seconds=int(stats[key])))])
|
store.append([print_key, str(datetime.timedelta(seconds=int(stats[key])))])
|
||||||
elif key == "db_update":
|
elif key == "db_update":
|
||||||
self.store.append([print_key, str(datetime.datetime.fromtimestamp(int(stats[key])))])
|
store.append([print_key, str(datetime.datetime.fromtimestamp(int(stats[key])))])
|
||||||
else:
|
else:
|
||||||
self.store.append([print_key, stats[key]])
|
store.append([print_key, stats[key]])
|
||||||
frame=Gtk.Frame()
|
frame=Gtk.Frame()
|
||||||
frame.add(self.treeview)
|
frame.add(treeview)
|
||||||
self.vbox.pack_start(frame, True, True, 0)
|
self.vbox.pack_start(frame, True, True, 0)
|
||||||
self.vbox.set_spacing(6)
|
self.vbox.set_spacing(6)
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
Loading…
Reference in New Issue
Block a user