global update settings from the download dialog

This commit is contained in:
DYefremov
2019-05-14 22:12:36 +03:00
parent 9eee9ac424
commit 61bcb85bbc
3 changed files with 24 additions and 19 deletions

View File

@@ -11,10 +11,11 @@ from .dialogs import show_dialog, DialogType, get_message
class DownloadDialog:
def __init__(self, transient, properties, open_data_callback, profile=Profile.ENIGMA_2):
def __init__(self, transient, properties, open_data_callback, update_settings_callback, profile=Profile.ENIGMA_2):
self._profile_properties = properties.get(profile.value)
self._properties = properties
self._open_data_callback = open_data_callback
self._update_settings_callback = update_settings_callback
self._profile = profile
handlers = {"on_receive": self.on_receive,
@@ -50,20 +51,21 @@ class DownloadDialog:
self._timeout_entry = builder.get_object("timeout_entry")
self._settings_buttons_box = builder.get_object("settings_buttons_box")
self._use_http_switch = builder.get_object("use_http_switch")
self._http_radio_button = builder.get_object("http_radio_button")
self._use_http_box = builder.get_object("use_http_box")
self.init_properties()
if profile is Profile.NEUTRINO_MP:
self._webtv_radio_button.set_visible(True)
builder.get_object("http_radio_button").set_visible(False)
builder.get_object("use_http_box").set_visible(False)
self._use_http_switch.set_active(False)
def show(self):
self._dialog_window.show()
def init_properties(self):
self._host_entry.set_text(self._profile_properties["host"])
self._data_path_entry.set_text(self._profile_properties["data_dir_path"])
is_enigma = self._profile is Profile.ENIGMA_2
self._webtv_radio_button.set_visible(not is_enigma)
self._http_radio_button.set_visible(is_enigma)
self._use_http_box.set_visible(is_enigma)
self._use_http_switch.set_active(is_enigma)
@run_idle
def on_receive(self, item):
@@ -114,12 +116,14 @@ class DownloadDialog:
def on_preferences(self, item):
show_settings_dialog(self._dialog_window, self._properties)
self._profile = Profile(self._properties.get("profile", Profile.ENIGMA_2.value))
self._profile_properties = get_config().get(self._profile.value)
self.init_properties()
self._update_settings_callback()
for button in self._settings_buttons_box.get_children():
if button.get_active():
self.on_settings_button(button)
self.init_properties()
break
def on_info_bar_close(self, bar=None, resp=None):

View File

@@ -774,6 +774,7 @@ class Application(Gtk.Application):
DownloadDialog(transient=self._main_window,
properties=self._options,
open_data_callback=self.open_data,
update_settings_callback=self.update_options,
profile=Profile(self._profile)).show()
@run_task
@@ -1095,17 +1096,18 @@ class Application(Gtk.Application):
def on_preferences(self, item):
response = show_settings_dialog(self._main_window, self._options)
if response != Gtk.ResponseType.CANCEL:
profile = self._options.get("profile")
self._ip_label.set_text(self._options.get(profile).get("host"))
self.update_options()
if profile != self._profile:
self._profile = profile
self.clear_current_data()
self.update_services_counts()
self.update_profile_label()
self.init_colors(True)
self.init_http_api()
def update_options(self):
profile = self._options.get("profile")
self._ip_label.set_text(self._options.get(profile).get("host"))
if profile != self._profile:
self._profile = profile
self.clear_current_data()
self.update_services_counts()
self.update_profile_label()
self.init_colors(True)
self.init_http_api()
def on_tree_view_key_press(self, view, event):
""" Handling keystrokes on press """

View File

@@ -3,7 +3,6 @@ from enum import Enum
from app.commons import run_task, run_idle
from app.connections import test_telnet, test_ftp, TestException, test_http
from app.properties import write_config, Profile, get_default_settings
from app.ui.dialogs import get_message
from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TEXT_DOMAIN, NEW_COLOR, EXTRA_COLOR, FavClickMode
from .main_helper import update_entry_data