mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-03-11 07:01:12 +01:00
added icons to services view
This commit is contained in:
@@ -7,13 +7,16 @@ from collections import namedtuple
|
||||
|
||||
from app.commons import log
|
||||
from app.eparser.__constants import POLARIZATION, SYSTEM, FEC, SERVICE_TYPE
|
||||
from app.ui import CODED_ICON, LOCKED_ICON, HIDE_ICON
|
||||
from .blacklist import get_blacklist
|
||||
|
||||
_HEADER = "eDVB services /4/"
|
||||
_FILE_PATH = "../data/lamedb"
|
||||
_SEP = ":" # separator
|
||||
_FILE_NAME = "lamedb"
|
||||
|
||||
Channel = namedtuple("Channel", ["flags_cas", "transponder_type", "service", "package", "service_type",
|
||||
"ssid", "freq", "rate", "pol", "fec",
|
||||
Channel = namedtuple("Channel", ["flags_cas", "transponder_type", "coded", "service", "locked", "hide",
|
||||
"package", "service_type", "ssid", "freq", "rate", "pol", "fec",
|
||||
"system", "pos", "data_id", "fav_id", "transponder"])
|
||||
|
||||
|
||||
@@ -42,13 +45,13 @@ def write_channels(path, channels):
|
||||
lines.extend(services_lines)
|
||||
lines.append("end\nFile was created in DemonEditor.\n....Enjoy watching!....\n")
|
||||
|
||||
with open(path + "lamedb", "w") as file:
|
||||
with open(path + _FILE_NAME, "w") as file:
|
||||
file.writelines(lines)
|
||||
|
||||
|
||||
def parse(path):
|
||||
""" Parsing lamedb """
|
||||
with open(path, "r") as file:
|
||||
with open(path + _FILE_NAME, "r") as file:
|
||||
try:
|
||||
data = str(file.read())
|
||||
except UnicodeDecodeError as e:
|
||||
@@ -58,7 +61,7 @@ def parse(path):
|
||||
transponders, sep, services = services.partition("services") # 2 step
|
||||
services, sep, _ = services.partition("end") # 3 step
|
||||
|
||||
return parse_channels(services.split("\n"), transponders.split("/"))
|
||||
return parse_channels(services.split("\n"), transponders.split("/"), path)
|
||||
|
||||
|
||||
def parse_transponders(arg):
|
||||
@@ -72,12 +75,13 @@ def parse_transponders(arg):
|
||||
return transponders
|
||||
|
||||
|
||||
def parse_channels(*args):
|
||||
def parse_channels(services, transponders, path):
|
||||
""" Parsing channels """
|
||||
channels = []
|
||||
transponders = parse_transponders(args[1])
|
||||
transponders = parse_transponders(transponders)
|
||||
blacklist = get_blacklist(path)
|
||||
|
||||
srv = split(args[0], 3)
|
||||
srv = split(services, 3)
|
||||
if srv[0][0] == "": # remove first empty element
|
||||
srv.remove(srv[0])
|
||||
|
||||
@@ -86,8 +90,14 @@ def parse_channels(*args):
|
||||
sp = "0"
|
||||
# For comparison in bouquets. Needed in upper case!!!
|
||||
fav_id = "{}:{}:{}:{}".format(str(data[0]).lstrip(sp), str(data[2]).lstrip(sp),
|
||||
str(data[3]).lstrip(sp), str(data[1]).lstrip(sp))
|
||||
package = list(filter(lambda x: x.startswith("p:"), ch[2].split(",")))
|
||||
str(data[3]).lstrip(sp), str(data[1]).lstrip(sp)).upper()
|
||||
all_flags = ch[2].split(",")
|
||||
coded = CODED_ICON if list(filter(lambda x: x.startswith("C:"), all_flags)) else None
|
||||
flags = list(filter(lambda x: x.startswith("f:"), all_flags))
|
||||
hide = HIDE_ICON if flags and int(flags[0][2:]) == 2 else None
|
||||
locked = LOCKED_ICON if blacklist and fav_id in blacklist else None
|
||||
|
||||
package = list(filter(lambda x: x.startswith("p:"), all_flags))
|
||||
package = package[0][2:] if package else None
|
||||
|
||||
transponder_id = "{}:{}:{}".format(data[1], data[2], data[3])
|
||||
@@ -99,7 +109,10 @@ def parse_channels(*args):
|
||||
service_type = SERVICE_TYPE.get(data[4], SERVICE_TYPE["-2"])
|
||||
channels.append(Channel(flags_cas=ch[2],
|
||||
transponder_type=tr_type,
|
||||
coded=coded,
|
||||
service=ch[1],
|
||||
locked=locked,
|
||||
hide=hide,
|
||||
package=package,
|
||||
service_type=service_type,
|
||||
ssid=data[0],
|
||||
@@ -110,7 +123,7 @@ def parse_channels(*args):
|
||||
system=SYSTEM[tr[6]],
|
||||
pos="{}{}.{}".format(*list(tr[4])),
|
||||
data_id=ch[0],
|
||||
fav_id=fav_id.upper(),
|
||||
fav_id=fav_id,
|
||||
transponder=transponder))
|
||||
return channels
|
||||
|
||||
|
||||
@@ -3,5 +3,10 @@ import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
CODED_ICON = Gtk.IconTheme.get_default().load_icon("emblem-readonly", 16, 0)
|
||||
LOCKED_ICON = Gtk.IconTheme.get_default().load_icon("system-lock-screen", 16, 0)
|
||||
HIDE_ICON = Gtk.IconTheme.get_default().load_icon("go-jump", 16, 0)
|
||||
TV_ICON = Gtk.IconTheme.get_default().load_icon("tv-symbolic", 16, 0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
@@ -2,8 +2,8 @@ import os
|
||||
from contextlib import suppress
|
||||
|
||||
from app.commons import run_idle
|
||||
from app.eparser import get_channels, get_bouquets, write_bouquets, write_channels, Bouquets, Bouquet, Channel, \
|
||||
get_blacklist
|
||||
from app.eparser import get_blacklist, write_blacklist
|
||||
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
|
||||
@@ -442,7 +442,7 @@ class MainAppWindow:
|
||||
self.__bouquets["{}:{}".format(name, bt_type)] = bt.services
|
||||
|
||||
def append_services(self, data_path):
|
||||
channels = get_channels(data_path + "lamedb")
|
||||
channels = get_channels(data_path)
|
||||
if channels:
|
||||
for ch in channels:
|
||||
# adding channels to dict with fav_id as keys
|
||||
@@ -483,6 +483,8 @@ class MainAppWindow:
|
||||
# Getting services
|
||||
services = [Channel(*row[:]) for row in services_model]
|
||||
write_channels(path, services)
|
||||
# blacklist
|
||||
write_blacklist(path, self.__blacklist)
|
||||
|
||||
def on_services_selection(self, model, path, column):
|
||||
self.delete_selection(self.__fav_view)
|
||||
@@ -631,7 +633,8 @@ class MainAppWindow:
|
||||
if flag is FLAG.HIDE:
|
||||
pass
|
||||
elif flag is FLAG.LOCK:
|
||||
pass
|
||||
if self.__lock_check_button.get_active():
|
||||
pass
|
||||
|
||||
|
||||
def start_app():
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="image2">
|
||||
<object class="GtkImage" id="send_recive_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">mail-send-receive</property>
|
||||
@@ -115,8 +115,14 @@
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name type -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name coded -->
|
||||
<column type="GdkPixbuf"/>
|
||||
<!-- column-name service -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name locked -->
|
||||
<column type="GdkPixbuf"/>
|
||||
<!-- column-name hide -->
|
||||
<column type="GdkPixbuf"/>
|
||||
<!-- column-name package -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name service_type -->
|
||||
@@ -186,7 +192,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Download data from receiver</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="image">image2</property>
|
||||
<property name="image">send_recive_image</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_download" swapped="no"/>
|
||||
</object>
|
||||
@@ -471,6 +477,16 @@
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorToolItem" id="separatortoolitem5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="cut_tool_button">
|
||||
<property name="visible">True</property>
|
||||
@@ -742,14 +758,33 @@
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="service_column">
|
||||
<property name="resizable">True</property>
|
||||
<property name="spacing">2</property>
|
||||
<property name="title" translatable="yes">Service</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">2</property>
|
||||
<property name="sort_column_id">3</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="coded_cellrendererpixbuf"/>
|
||||
<attributes>
|
||||
<attribute name="pixbuf">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="service_cellrenderertext"/>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
<attribute name="text">3</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="locked_cellrendererpixbuf"/>
|
||||
<attributes>
|
||||
<attribute name="pixbuf">4</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="hide_cellrendererpixbuf"/>
|
||||
<attributes>
|
||||
<attribute name="pixbuf">5</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -757,14 +792,15 @@
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="package_column">
|
||||
<property name="resizable">True</property>
|
||||
<property name="sizing">autosize</property>
|
||||
<property name="title" translatable="yes">Package</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">3</property>
|
||||
<property name="sort_column_id">6</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="package_cellrenderertext"/>
|
||||
<attributes>
|
||||
<attribute name="text">3</attribute>
|
||||
<attribute name="text">6</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -775,13 +811,13 @@
|
||||
<property name="title" translatable="yes">Type</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">4</property>
|
||||
<property name="sort_column_id">7</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="service_type_cellrenderertex">
|
||||
<property name="xalign">0.51999998092651367</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">4</attribute>
|
||||
<attribute name="text">7</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -792,13 +828,13 @@
|
||||
<property name="title" translatable="yes">Ssid</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">5</property>
|
||||
<property name="sort_column_id">8</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="ssid_cellrenderertext">
|
||||
<property name="xalign">0.50999999046325684</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">5</attribute>
|
||||
<attribute name="text">8</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -809,13 +845,13 @@
|
||||
<property name="title" translatable="yes">Freq</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">6</property>
|
||||
<property name="sort_column_id">9</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="freq_cellrenderertext">
|
||||
<property name="xalign">0.50999999046325684</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">6</attribute>
|
||||
<attribute name="text">9</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -826,13 +862,13 @@
|
||||
<property name="title" translatable="yes">Rate</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">7</property>
|
||||
<property name="sort_column_id">10</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="rate_cellrenderertext">
|
||||
<property name="xalign">0.50999999046325684</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">7</attribute>
|
||||
<attribute name="text">10</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -843,13 +879,13 @@
|
||||
<property name="title" translatable="yes">Pol</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">8</property>
|
||||
<property name="sort_column_id">11</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="pol_cellrenderertext">
|
||||
<property name="xalign">0.50999999046325684</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">8</attribute>
|
||||
<attribute name="text">11</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -860,13 +896,13 @@
|
||||
<property name="title" translatable="yes">FEC</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">9</property>
|
||||
<property name="sort_column_id">12</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="fec_cellrenderertext">
|
||||
<property name="xalign">0.50999999046325684</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">9</attribute>
|
||||
<attribute name="text">12</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -877,13 +913,13 @@
|
||||
<property name="title" translatable="yes">System</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">10</property>
|
||||
<property name="sort_column_id">13</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="system_cellrenderertex">
|
||||
<property name="xalign">0.50999999046325684</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">10</attribute>
|
||||
<attribute name="text">13</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -893,13 +929,13 @@
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Pos</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="sort_column_id">11</property>
|
||||
<property name="sort_column_id">14</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="pos_cellrenderertext1">
|
||||
<property name="xalign">0.50999999046325684</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">11</attribute>
|
||||
<attribute name="text">14</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -911,7 +947,7 @@
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="data_id_cellrenderertext"/>
|
||||
<attributes>
|
||||
<attribute name="text">12</attribute>
|
||||
<attribute name="text">15</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -923,7 +959,7 @@
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="fav_id_cellrenderertext"/>
|
||||
<attributes>
|
||||
<attribute name="text">13</attribute>
|
||||
<attribute name="text">16</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
@@ -933,9 +969,9 @@
|
||||
<property name="visible">False</property>
|
||||
<property name="title" translatable="yes">transponder</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="transponder_cellrenderertext3"/>
|
||||
<object class="GtkCellRendererText" id="transponder_cellrenderertext"/>
|
||||
<attributes>
|
||||
<attribute name="text">14</attribute>
|
||||
<attribute name="text">17</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user