From 7e1fd49b852e367d64a0e496160e835b8e119735 Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Sat, 21 Aug 2021 14:33:15 +0200 Subject: [PATCH] removed unneeded "mini-player" property of "Settings" --- bin/mpdevil | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/bin/mpdevil b/bin/mpdevil index 71638bd..548944a 100755 --- a/bin/mpdevil +++ b/bin/mpdevil @@ -924,7 +924,6 @@ class Client(MPDClient): class Settings(Gio.Settings): BASE_KEY="org.mpdevil.mpdevil" # temp settings - mini_player=GObject.Property(type=bool, default=False) cursor_watch=GObject.Property(type=bool, default=False) def __init__(self): super().__init__(schema=self.BASE_KEY) @@ -2453,7 +2452,7 @@ class Browser(Gtk.Paned): self._genres_button.connect("toggled", self._on_genres_toggled) self._genre_select.connect("item-selected", self._on_genre_chnaged) self._artist_window.connect("item-selected", self._on_artists_changed) - self._settings.connect("notify::mini-player", self._on_mini_player) + self._settings.connect("changed::mini-player", self._on_mini_player) self._client.emitter.connect("disconnected", self._on_disconnected) self._client.emitter.connect("reconnected", self._on_reconnected) @@ -2531,8 +2530,8 @@ class Browser(Gtk.Paned): def _on_artists_changed(self, *args): self.search_button.set_active(False) - def _on_mini_player(self, obj, typestring): - state=obj.get_property("mini-player") + def _on_mini_player(self, settings, key): + state=settings.get_boolean(key) self.set_property("no-show-all", state) self.back_to_current_album_button.set_property("no-show-all", state) self.search_button.set_property("no-show-all", state) @@ -2662,7 +2661,7 @@ class CoverEventBox(Gtk.EventBox): self._client.emitter.connect("disconnected", self._on_disconnected) def _on_button_press_event(self, widget, event): - if self._settings.get_property("mini-player"): + if self._settings.get_boolean("mini-player"): if event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS: window=self.get_toplevel() window.begin_move_drag(1, event.x_root, event.y_root, Gdk.CURRENT_TIME) @@ -2804,7 +2803,7 @@ class PlaylistWindow(Gtk.Overlay): self._client.emitter.connect("reconnected", self._on_reconnected) self._client.emitter.connect("show-info", self._on_show_info) - self._settings.connect("notify::mini-player", self._on_mini_player) + self._settings.connect("changed::mini-player", self._on_mini_player) self._settings.connect("changed::column-visibilities", self._load_settings) self._settings.connect("changed::column-permutation", self._load_settings) @@ -3013,8 +3012,8 @@ class PlaylistWindow(Gtk.Overlay): cell=self._treeview.get_cell_area(path, None) self._song_popover.open(self._store[path][8], self._treeview, int(cell.x), int(cell.y)) - def _on_mini_player(self, obj, typestring): - if obj.get_property("mini-player"): + def _on_mini_player(self, settings, key): + if settings.get_boolean(key): self.set_property("no-show-all", True) self.set_property("visible", False) else: @@ -3116,7 +3115,7 @@ class PlaybackControl(Gtk.ButtonBox): self._next_button.set_can_focus(False) # connect - self._settings.connect("notify::mini-player", self._on_mini_player) + self._settings.connect("changed::mini-player", self._on_mini_player) self._settings.connect("changed::show-stop", self._on_show_stop_changed) self._client.emitter.connect("state", self._on_state) self._client.emitter.connect("playlist_changed", self._refresh_tooltips) @@ -3154,11 +3153,11 @@ class PlaybackControl(Gtk.ButtonBox): self._prev_button.set_tooltip_text("") self._next_button.set_tooltip_text("") - def _on_mini_player(self, obj, typestring): + def _on_mini_player(self, settings, key): self._on_show_stop_changed() def _on_show_stop_changed(self, *args): - visibility=(self._settings.get_boolean("show-stop") and not self._settings.get_property("mini-player")) + visibility=(self._settings.get_boolean("show-stop") and not self._settings.get_boolean("mini-player")) self._stop_button.set_property("visible", visibility) self._stop_button.set_property("no-show-all", not(visibility)) @@ -3293,7 +3292,7 @@ class AudioFormat(Gtk.Box): self.set_property("no-show-all", not(self._settings.get_boolean("show-audio-format"))) # connect - self._settings.connect("notify::mini-player", self._on_mini_player) + self._settings.connect("changed::mini-player", self._on_mini_player) self._settings.connect("changed::show-audio-format", self._on_show_audio_format_changed) self._client.emitter.connect("audio", self._on_audio) self._client.emitter.connect("bitrate", self._on_bitrate) @@ -3337,11 +3336,11 @@ class AudioFormat(Gtk.Box): self._separator_label.set_text(" kb∕s") self._format_label.set_markup(" ") - def _on_mini_player(self, obj, typestring): + def _on_mini_player(self, settings, key): self._on_show_audio_format_changed() def _on_show_audio_format_changed(self, *args): - visibility=(self._settings.get_boolean("show-audio-format") and not self._settings.get_property("mini-player")) + visibility=(self._settings.get_boolean("show-audio-format") and not self._settings.get_boolean("mini-player")) self.set_property("no-show-all", not(visibility)) if visibility: self.show_all() @@ -3389,7 +3388,7 @@ class PlaybackOptions(Gtk.ButtonBox): self._buttons["single"][0].connect("button-press-event", self._on_single_button_press_event) self._client.emitter.connect("disconnected", self._on_disconnected) self._client.emitter.connect("reconnected", self._on_reconnected) - self._settings.connect("notify::mini-player", self._on_mini_player) + self._settings.connect("changed::mini-player", self._on_mini_player) def _set_option(self, widget, option): func=getattr(self._client, option) @@ -3429,8 +3428,8 @@ class PlaybackOptions(Gtk.ButtonBox): def _on_reconnected(self, *args): self.set_sensitive(True) - def _on_mini_player(self, obj, typestring): - if obj.get_property("mini-player"): + def _on_mini_player(self, settings, key): + if settings.get_boolean(key): self.set_property("no-show-all", True) self.set_property("visible", False) else: @@ -3713,8 +3712,7 @@ class MainWindow(Gtk.ApplicationWindow): action=Gio.SimpleAction.new(name, None) action.connect("activate", getattr(self, ("_on_"+name.replace("-","_")))) self.add_action(action) - mini_player_action=Gio.PropertyAction.new("mini-player", self._settings, "mini-player") - self.add_action(mini_player_action) + self.add_action(self._settings.create_action("mini-player")) self.add_action(self._settings.create_action("active-profile")) # shortcuts @@ -3774,7 +3772,7 @@ class MainWindow(Gtk.ApplicationWindow): action_bar.pack_start(volume_button) # connect - self._settings.connect_after("notify::mini-player", self._on_mini_player) + self._settings.connect_after("changed::mini-player", self._on_mini_player) self._settings.connect_after("notify::cursor-watch", self._on_cursor_watch) self._settings.connect("changed::playlist-right", self._on_playlist_pos_changed) self._client.emitter.connect("current_song_changed", self._on_song_changed) @@ -3783,8 +3781,6 @@ class MainWindow(Gtk.ApplicationWindow): # auto save window state and size self.connect("size-allocate", self._on_size_allocate) self._settings.bind("maximize", self, "is-maximized", Gio.SettingsBindFlags.SET) - # save and restore mini player - self._settings.bind("mini-player", self._settings, "mini-player", Gio.SettingsBindFlags.DEFAULT) # packing self._on_playlist_pos_changed() # set orientation @@ -3806,7 +3802,9 @@ class MainWindow(Gtk.ApplicationWindow): else: action_bar.pack_start(self._menu_button) self.add(overlay) - self._client.emitter.emit("disconnected") # bring player in defined state + # bring player in consistent state + self._client.emitter.emit("disconnected") + self._settings.emit("changed::mini-player", "mini-player") # indicate connection process in window title if self._use_csd: self._header_bar.set_subtitle(_("connecting…")) @@ -3916,7 +3914,7 @@ class MainWindow(Gtk.ApplicationWindow): self.lookup_action(action).set_enabled(False) def _on_size_allocate(self, widget, rect): - if not self.is_maximized() and not self._settings.get_property("mini-player"): + if not self.is_maximized() and not self._settings.get_boolean("mini-player"): size=self.get_size() if size != self._size: # prevent unneeded write operations self._settings.set_int("width", size[0]) @@ -3926,8 +3924,8 @@ class MainWindow(Gtk.ApplicationWindow): def _on_paned_position(self, obj, typestring, key): self._settings.set_int(key, obj.get_position()) - def _on_mini_player(self, obj, typestring): - if obj.get_property("mini-player"): + def _on_mini_player(self, settings, key): + if settings.get_boolean(key): if self.is_maximized(): self.unmaximize() self.resize(1,1)