diff --git a/app/eparser/__init__.py b/app/eparser/__init__.py
index b5ecd60a..88add57e 100644
--- a/app/eparser/__init__.py
+++ b/app/eparser/__init__.py
@@ -1,5 +1,5 @@
from .lamedb import get_channels, write_channels, Channel
-from .bouquets import get_bouquets, write_bouquets, Bouquet, Bouquets
+from .bouquets import get_bouquets, write_bouquets, to_bouquet_id, Bouquet, Bouquets
from .satxml import get_satellites, write_satellites, Satellite, Transponder
from .blacklist import get_blacklist, write_blacklist
diff --git a/app/eparser/blacklist.py b/app/eparser/blacklist.py
index 3080f369..4102ab70 100644
--- a/app/eparser/blacklist.py
+++ b/app/eparser/blacklist.py
@@ -15,8 +15,8 @@ def get_blacklist(path):
def write_blacklist(path, channels):
- if channels:
- with open(path + __FILE_NAME, "w") as file:
+ with open(path + __FILE_NAME, "w") as file:
+ if channels:
file.writelines("\n".join(channels))
diff --git a/app/eparser/bouquets.py b/app/eparser/bouquets.py
index c4a6f0f4..8df17060 100644
--- a/app/eparser/bouquets.py
+++ b/app/eparser/bouquets.py
@@ -35,17 +35,24 @@ def write_bouquet(path, name, bq_type, channels):
for ch in channels:
if not ch: # if was duplicate
continue
- data_type = int(ch.data_id.split(":")[-2])
- if data_type == 22:
- data_type = 16
- elif data_type == 25:
- data_type = 19
- bouquet.append("#SERVICE {}:0:{}:{}:0:0:0:\n".format(1, data_type, ch.fav_id))
+ bouquet.append("#SERVICE {}\n".format(to_bouquet_id(ch)))
with open(path + "userbouquet.{}.{}".format(name, bq_type), "w") as file:
file.writelines(bouquet)
+def to_bouquet_id(ch):
+ """ Creates bouquet channel id """
+ data_type = int(ch.data_id.split(":")[-2])
+ if data_type == 22:
+ data_type = 16
+ elif data_type == 25:
+ data_type = 19
+ service = "{}:0:{}:{}:0:0:0:".format(1, data_type, ch.fav_id)
+
+ return service
+
+
def get_bouquet(path, name, bq_type):
""" Parsing services ids from bouquet file """
with open(path + "userbouquet.{}.{}".format(name, bq_type)) as file:
diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py
index e00d42a9..93e65d72 100644
--- a/app/ui/main_app_window.py
+++ b/app/ui/main_app_window.py
@@ -2,11 +2,11 @@ import os
from contextlib import suppress
from app.commons import run_idle
-from app.eparser import get_blacklist, write_blacklist
+from app.eparser import get_blacklist, write_blacklist, to_bouquet_id
from app.eparser import get_channels, get_bouquets, write_bouquets, write_channels, Bouquets, Bouquet, Channel
from app.eparser.__constants import CAS, FLAG
from app.properties import get_config, write_config
-from . import Gtk, Gdk
+from . import Gtk, Gdk, LOCKED_ICON
from .dialogs import show_dialog
from .download_dialog import show_download_dialog
from .satellites_dialog import show_satellites_dialog
@@ -24,12 +24,14 @@ class MainAppWindow:
"bouquets_remove_popup_item", "fav_remove_popoup_item")
_FAV_ELEMENTS = ("up_tool_button", "down_tool_button", "cut_tool_button", "paste_tool_button", "cut_menu_item",
"paste_menu_item", "fav_cut_popoup_item", "fav_paste_popup_item")
+ _LOCK_HIDE_ELEMENTS = ("locked_tool_button", "hide_tool_button")
__DYNAMIC_ELEMENTS = ("up_tool_button", "down_tool_button", "cut_tool_button", "copy_tool_button",
"paste_tool_button", "to_fav_tool_button", "new_tool_button", "remove_tool_button",
"cut_menu_item", "copy_menu_item", "paste_menu_item", "delete_menu_item", "edit_tool_button",
"services_to_fav_move_popup_item", "services_remove_popup_item", "fav_cut_popoup_item",
"fav_paste_popup_item", "bouquets_new_popup_item", "bouguets_edit_popup_item",
- "services_remove_popup_item", "bouquets_remove_popup_item", "fav_remove_popoup_item")
+ "services_remove_popup_item", "bouquets_remove_popup_item", "fav_remove_popoup_item",
+ "locked_tool_button", "hide_tool_button")
def __init__(self):
handlers = {"on_close_main_window": self.on_quit,
@@ -88,8 +90,6 @@ class MainAppWindow:
# dynamically active elements depending on the selected view
self.__tool_elements = {k: builder.get_object(k) for k in self.__DYNAMIC_ELEMENTS}
self.__cas_label = builder.get_object("cas_label")
- self.__hide_check_button = builder.get_object("hide_check_button")
- self.__lock_check_button = builder.get_object("lock_check_button")
builder.connect_signals(handlers)
self.init_drag_and_drop() # drag and drop
self.__main_window.show()
@@ -477,6 +477,7 @@ class MainAppWindow:
bqs.append(bq)
bqs = Bouquets(*model.get(itr, 0, 1), bqs)
bouquets.append(bqs)
+
# Getting bouquets
self.__bouquets_view.get_model().foreach(parse_bouquets)
write_bouquets(path, bouquets, self.__bouquets)
@@ -615,6 +616,8 @@ class MainAppWindow:
self.__tool_elements[elem].set_sensitive(not_empty and is_service)
for elem in self._BOUQUET_ELEMENTS:
self.__tool_elements[elem].set_sensitive(False)
+ for elem in self._LOCK_HIDE_ELEMENTS:
+ self.__tool_elements[elem].set_sensitive(not_empty)
for elem in self._REMOVE_ELEMENTS:
self.__tool_elements[elem].set_sensitive(not_empty)
@@ -633,8 +636,20 @@ class MainAppWindow:
if flag is FLAG.HIDE:
pass
elif flag is FLAG.LOCK:
- if self.__lock_check_button.get_active():
- pass
+ locked = self.has_locked(model, paths)
+ for path in paths:
+ itr = model.get_iter(path)
+ channel = self.__channels.get(model.get_value(itr, 16), None)
+ if channel:
+ bq_id = to_bouquet_id(channel)
+ self.__blacklist.discard(bq_id) if locked else self.__blacklist.add(bq_id)
+ model.set_value(itr, 4, None) if locked else model.set_value(itr, 4, LOCKED_ICON)
+
+ def has_locked(self, model, paths):
+ for path in paths:
+ if model.get_value(model.get_iter(path), 4):
+ return True
+ return False
def start_app():
diff --git a/app/ui/main_window.glade b/app/ui/main_window.glade
index c7e19451..1c365205 100644
--- a/app/ui/main_window.glade
+++ b/app/ui/main_window.glade
@@ -542,6 +542,46 @@
False
+
+
+
+ False
+ True
+
+
+
+
+
+ False
+ True
+
+
+
+
+
+ False
+ False
+
+