diff --git a/app/ui/dialogs.py b/app/ui/dialogs.py
index a36b4a3b..c971ec77 100644
--- a/app/ui/dialogs.py
+++ b/app/ui/dialogs.py
@@ -1,12 +1,10 @@
""" Common module for showing dialogs """
import locale
-import os
from enum import Enum
+from functools import lru_cache
from app.commons import run_idle
-from .uicommons import Gtk, UI_RESOURCES_PATH, TEXT_DOMAIN
-
-_IS_GNOME_SESSION = int(bool(os.environ.get("GNOME_DESKTOP_SESSION_ID")))
+from .uicommons import Gtk, UI_RESOURCES_PATH, TEXT_DOMAIN, IS_GNOME_SESSION
class Button(Enum):
@@ -187,7 +185,7 @@ def get_file_chooser_dialog(transient, text, options, action_type, file_filter):
dialog = Gtk.FileChooserDialog(get_message(text) if text else "", transient,
action_type if action_type is not None else Gtk.FileChooserAction.SELECT_FOLDER,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK),
- use_header_bar=_IS_GNOME_SESSION)
+ use_header_bar=IS_GNOME_SESSION)
if file_filter is not None:
dialog.add_filter(file_filter)
@@ -207,7 +205,7 @@ def get_file_chooser_dialog(transient, text, options, action_type, file_filter):
def get_input_dialog(transient, text):
builder = Gtk.Builder()
- builder.add_from_string(Dialog.INPUT.value.format(use_header=_IS_GNOME_SESSION, title="",
+ builder.add_from_string(Dialog.INPUT.value.format(use_header=IS_GNOME_SESSION, title="",
ok_button=Button.OK, cancel_button=Button.CANCEL,
cancel_action=ButtonAction.CANCEL, ok_action=ButtonAction.OK))
dialog = builder.get_object("input_dialog")
@@ -261,5 +259,11 @@ def get_message(message):
return locale.dgettext(TEXT_DOMAIN, message)
+@lru_cache(maxsize=5)
+def get_dialogs_string(path):
+ with open(path, "r") as f:
+ return "".join(f)
+
+
if __name__ == "__main__":
pass
diff --git a/app/ui/iptv.glade b/app/ui/iptv.glade
index f27c997f..ce75aa03 100644
--- a/app/ui/iptv.glade
+++ b/app/ui/iptv.glade
@@ -45,18 +45,9 @@ Author: Dmitriy Yefremov
dialog
True
True
+ False
center
-
-
-
@@ -65,6 +56,16 @@ Author: Dmitriy Yefremov
False
vertical
1
+
+
+
+ False
+ False
+ 0
+
+
@@ -201,7 +225,7 @@ Author: Dmitriy Yefremov
- 1
+ {use_header}
480
False
Stream data
@@ -612,7 +636,7 @@ Author: Dmitriy Yefremov
- 1
+ {use_header}
400
False
IPTV streams list configuration
diff --git a/app/ui/iptv.py b/app/ui/iptv.py
index b981ebd5..4e0c36f1 100644
--- a/app/ui/iptv.py
+++ b/app/ui/iptv.py
@@ -1,7 +1,6 @@
import re
import urllib
from urllib.error import HTTPError
-
from urllib.parse import urlparse
from urllib.request import Request, urlopen
@@ -9,13 +8,14 @@ from app.commons import run_idle, run_task
from app.eparser.ecommons import BqServiceType, Service
from app.eparser.iptv import NEUTRINO_FAV_ID_FORMAT, StreamType, ENIGMA2_FAV_ID_FORMAT
from app.properties import Profile
-from .uicommons import Gtk, Gdk, TEXT_DOMAIN, UI_RESOURCES_PATH, IPTV_ICON, Column
-from .dialogs import Action, show_dialog, DialogType
+from .dialogs import Action, show_dialog, DialogType, get_dialogs_string
from .main_helper import get_base_model, get_iptv_url
+from .uicommons import Gtk, Gdk, TEXT_DOMAIN, UI_RESOURCES_PATH, IPTV_ICON, Column, IS_GNOME_SESSION
_DIGIT_ENTRY_NAME = "digit-entry"
_ENIGMA2_REFERENCE = "{}:0:{}:{:X}:{:X}:{:X}:{:X}:0:0:0"
-_PATTERN = re.compile("(?:^[\s]*$|\D)")
+_PATTERN = re.compile("(?:^[\\s]*$|\\D)")
+_UI_PATH = UI_RESOURCES_PATH + "iptv.glade"
def is_data_correct(elems):
@@ -47,7 +47,8 @@ class IptvDialog:
builder = Gtk.Builder()
builder.set_translation_domain(TEXT_DOMAIN)
- builder.add_objects_from_file(UI_RESOURCES_PATH + "iptv.glade", ("iptv_dialog", "stream_type_liststore"))
+ builder.add_objects_from_string(get_dialogs_string(_UI_PATH).format(use_header=IS_GNOME_SESSION),
+ ("iptv_dialog", "stream_type_liststore"))
builder.connect_signals(handlers)
self._dialog = builder.get_object("iptv_dialog")
@@ -322,8 +323,8 @@ class IptvListConfigurationDialog:
builder = Gtk.Builder()
builder.set_translation_domain(TEXT_DOMAIN)
- builder.add_objects_from_file(UI_RESOURCES_PATH + "iptv.glade",
- ("iptv_list_configuration_dialog", "stream_type_liststore"))
+ builder.add_objects_from_string(get_dialogs_string(_UI_PATH).format(use_header=IS_GNOME_SESSION),
+ ("iptv_list_configuration_dialog", "stream_type_liststore"))
builder.connect_signals(handlers)
self._rows = iptv_rows
diff --git a/app/ui/uicommons.py b/app/ui/uicommons.py
index faac3f18..63c1f942 100644
--- a/app/ui/uicommons.py
+++ b/app/ui/uicommons.py
@@ -10,6 +10,8 @@ from gi.repository import Gtk, Gdk
# path to *.glade files
UI_RESOURCES_PATH = "app/ui/" if os.path.exists("app/ui/") else "/usr/share/demoneditor/app/ui/"
+IS_GNOME_SESSION = int(bool(os.environ.get("GNOME_DESKTOP_SESSION_ID")))
+
# translation
TEXT_DOMAIN = "demon-editor"
if UI_RESOURCES_PATH == "app/ui/":