From 1b2de795a2e9b556817b7c1c08fefd6ca1f2b5ee Mon Sep 17 00:00:00 2001 From: DYefremov Date: Sun, 6 Mar 2022 12:19:54 +0300 Subject: [PATCH] minor rework of settings dialog --- app/ui/settings_dialog.glade | 505 ++++++++++++++--------------------- app/ui/settings_dialog.py | 61 +---- 2 files changed, 209 insertions(+), 357 deletions(-) diff --git a/app/ui/settings_dialog.glade b/app/ui/settings_dialog.glade index 0ec9a0c7..a034494a 100644 --- a/app/ui/settings_dialog.glade +++ b/app/ui/settings_dialog.glade @@ -168,7 +168,6 @@ Author: Dmitriy Yefremov True False - 5 0.05000000074505806 in @@ -372,7 +371,6 @@ Author: Dmitriy Yefremov True False - 5 0.019999999552965164 in @@ -399,11 +397,8 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 vertical - 2 + 5 True @@ -584,8 +579,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 0.019999999552965164 in @@ -637,7 +630,7 @@ Author: Dmitriy Yefremov - False + True True 3 @@ -653,11 +646,130 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 vertical 5 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + + + True + False + Use to play streams: + + + False + True + 0 + + + + + 175 + True + False + 0 + vlc + + VLC Player + GStreamer + MPV + + + + + False + True + end + 4 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Play streams mode: + + + False + True + 0 + + + + + 175 + True + False + 0 + Built-in player + + Built-in player + In a separate window + Only get m3u file + + + + + False + True + end + 4 + + + + + False + True + 1 + + + + + + + True + False + Playback + + + + + False + True + 0 + + True @@ -670,6 +782,7 @@ Author: Dmitriy Yefremov False 5 5 + 5 5 vertical 5 @@ -677,6 +790,8 @@ Author: Dmitriy Yefremov True False + 5 + 5 5 @@ -704,7 +819,7 @@ Author: Dmitriy Yefremov - True + False True 0 @@ -736,6 +851,7 @@ Author: Dmitriy Yefremov + 175 True False 720p TV/device @@ -746,7 +862,7 @@ Author: Dmitriy Yefremov - True + False True 1 @@ -791,7 +907,7 @@ Author: Dmitriy Yefremov - True + False True 1 @@ -801,6 +917,7 @@ Author: Dmitriy Yefremov True False False + 5 0.5 in @@ -932,6 +1049,7 @@ Author: Dmitriy Yefremov True False False + 5 0.5 in @@ -1084,169 +1202,11 @@ Author: Dmitriy Yefremov - False - True - 0 - - - - - True - False - 0.019999999552965164 - in - - - True - False - center - 5 - 5 - 5 - 5 - - - Built-in player - True - True - False - True - True - get_m3u_radio_button - - - - False - True - 0 - - - - - In a separate window - True - True - False - True - True - get_m3u_radio_button - - - False - True - 1 - - - - - Only get m3u file - True - True - False - True - True - - - False - True - 2 - - - - - - - True - False - Play streams mode: - - - - - False + True True 1 - - - True - False - 0.019999999552965164 - in - - - True - False - center - 5 - 5 - - - GStreamer - True - True - False - EXPERIMENTAL! - True - mpv_lib_button - - - - False - True - 0 - - - - - VLC Player - True - True - False - True - mpv_lib_button - - - - False - True - 1 - - - - - MPV - True - True - False - EXPERIMENTAL! - True - gst_lib_button - - - - False - True - 2 - - - - - - - True - False - Use to play streams: - - - - - False - True - 2 - - streaming @@ -1258,10 +1218,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 - 5 vertical 5 @@ -1292,7 +1248,7 @@ Author: Dmitriy Yefremov - 150 + 175 True False False @@ -1725,10 +1681,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 - 5 vertical 5 @@ -2477,11 +2429,8 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 vertical - 5 + 10 True @@ -2540,23 +2489,51 @@ Author: Dmitriy Yefremov True False - 0.019999999552965164 + 0.5 in - + True False 5 5 5 5 - 5 + vertical + 10 - + True False - start - Enable experimental features + 5 + + + True + False + start + Enable experimental features + + + False + True + 0 + + + + + True + True + end + center + + + + False + True + end + 2 + + False @@ -2564,66 +2541,11 @@ Author: Dmitriy Yefremov 0 - - - True - True - end - center - - - - False - True - end - 2 - - - - - - - - - - False - True - 3 - - - - - True - False - EXPERIMENTAL! - - - False - True - 4 - - - - - True - False - vertical - 10 - - - True - False - 0.019999999552965164 - in True False False - 5 - 5 - 5 - 5 True @@ -2652,32 +2574,19 @@ Author: Dmitriy Yefremov + + False + True + 1 + - - - - - - False - True - 0 - - - - - True - False - 0.019999999552965164 - in True False False - 5 - 5 - 5 - 5 + 10 + 10 vertical 5 @@ -2778,32 +2687,17 @@ Author: Dmitriy Yefremov + + False + True + 2 + - - - - - - False - True - 1 - - - - - True - False - 0 - in True False False - 5 - 5 - 5 - 5 True @@ -2833,22 +2727,26 @@ Author: Dmitriy Yefremov - - - + + False + True + 3 + - - False - True - 2 - + + + + True + False + EXPERIMENTAL! + - False + True True - 8 + 3 @@ -3005,8 +2903,8 @@ Author: Dmitriy Yefremov True False - 5 - 5 + 10 + 10 5 5 vertical @@ -3015,8 +2913,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 5 5 @@ -3538,8 +3434,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 5 @@ -3550,6 +3444,7 @@ Author: Dmitriy Yefremov FTP + 75 True True False @@ -3565,6 +3460,7 @@ Author: Dmitriy Yefremov HTTP + 75 True True False @@ -3580,6 +3476,7 @@ Author: Dmitriy Yefremov Telnet + 75 True True False diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index 3de55294..ec41f1f3 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -37,10 +37,6 @@ from .main_helper import update_entry_data, scroll_to, get_picon_pixbuf from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, FavClickMode, DEFAULT_ICON, APP_FONT, IS_GNOME_SESSION -def show_settings_dialog(transient, options): - return SettingsDialog(transient, options).show() - - class SettingsDialog: _DIGIT_ENTRY_NAME = "digit-entry" _DIGIT_PATTERN = re.compile("(?:^[\\s]*$|\\D)") @@ -151,12 +147,8 @@ class SettingsDialog: self._edit_preset_switch.bind_property("active", self._apply_presets_button, "sensitive") self._edit_preset_switch.bind_property("active", builder.get_object("video_options_frame"), "sensitive") self._edit_preset_switch.bind_property("active", builder.get_object("audio_options_frame"), "sensitive") - self._play_in_built_radio_button = builder.get_object("play_in_built_radio_button") - self._play_in_window_radio_button = builder.get_object("play_in_window_radio_button") - self._get_m3u_radio_button = builder.get_object("get_m3u_radio_button") - self._gst_lib_button = builder.get_object("gst_lib_button") - self._vlc_lib_button = builder.get_object("vlc_lib_button") - self._mpv_lib_button = builder.get_object("mpv_lib_button") + self._play_streams_combo_box = builder.get_object("play_streams_combo_box") + self._stream_lib_combo_box = builder.get_object("stream_lib_combo_box") # Program. self._before_save_switch = builder.get_object("before_save_switch") self._before_downloading_switch = builder.get_object("before_downloading_switch") @@ -324,8 +316,8 @@ class SettingsDialog: self._before_save_switch.set_active(self._settings.backup_before_save) self._before_downloading_switch.set_active(self._settings.backup_before_downloading) self.set_fav_click_mode(self._settings.fav_click_mode) - self.set_play_stream_mode(self._settings.play_streams_mode) - self.set_stream_lib(self._settings.stream_lib) + self._play_streams_combo_box.set_active(self._settings.play_streams_mode.value) + self._stream_lib_combo_box.set_active_id(self._settings.stream_lib) self._load_on_startup_switch.set_active(self._settings.load_last_config) self._bouquet_hints_switch.set_active(self._settings.show_bq_hints) self._services_hints_switch.set_active(self._settings.show_srv_hints) @@ -387,8 +379,8 @@ class SettingsDialog: self._ext_settings.backup_before_save = self._before_save_switch.get_active() self._ext_settings.backup_before_downloading = self._before_downloading_switch.get_active() self._ext_settings.fav_click_mode = self.get_fav_click_mode() - self._ext_settings.play_streams_mode = self.get_play_stream_mode() - self._ext_settings.stream_lib = self.get_stream_lib() + self._ext_settings.play_streams_mode = PlayStreamsMode(self._play_streams_combo_box.get_active()) + self._ext_settings.stream_lib = self._stream_lib_combo_box.get_active_id() self._ext_settings.language = self._lang_combo_box.get_active_id() self._ext_settings.load_last_config = self._load_on_startup_switch.get_active() self._ext_settings.show_bq_hints = self._bouquet_hints_switch.get_active() @@ -668,47 +660,10 @@ class SettingsDialog: return FavClickMode.DISABLED def on_play_mode_changed(self, button): - if self._main_stack.get_visible_child_name() != "streaming" or not button.get_active(): + if self._main_stack.get_visible_child_name() != "streaming": return - if self._settings.is_darwin: - is_gst = self._gst_lib_button.get_active() - self._play_in_built_radio_button.set_sensitive(is_gst) - self._play_in_window_radio_button.set_active(not is_gst and self._play_in_built_radio_button.get_active()) - - if button.get_active(): - self.show_info_message("Save and restart the program to apply the settings.", Gtk.MessageType.WARNING) - - @run_idle - def set_play_stream_mode(self, mode): - self._play_in_built_radio_button.set_active(mode is PlayStreamsMode.BUILT_IN) - self._play_in_window_radio_button.set_active(mode is PlayStreamsMode.WINDOW) - self._get_m3u_radio_button.set_active(mode is PlayStreamsMode.M3U) - - if self._settings.is_darwin and self._settings.stream_lib != "gst": - self._play_in_built_radio_button.set_sensitive(False) - - def get_play_stream_mode(self): - if self._play_in_built_radio_button.get_active(): - return PlayStreamsMode.BUILT_IN - if self._play_in_window_radio_button.get_active(): - return PlayStreamsMode.WINDOW - if self._get_m3u_radio_button.get_active(): - return PlayStreamsMode.M3U - - return self._settings.play_streams_mode - - def set_stream_lib(self, mode): - self._vlc_lib_button.set_active(mode == "vlc") - self._gst_lib_button.set_active(mode == "gst") - self._mpv_lib_button.set_active(mode == "mpv") - - def get_stream_lib(self): - if self._gst_lib_button.get_active(): - return "gst" - elif self._vlc_lib_button.get_active(): - return "vlc" - return "mpv" + self.show_info_message("Save and restart the program to apply the settings.", Gtk.MessageType.WARNING) def on_transcoding_preset_changed(self, button): presets = self._settings.transcoding_presets