gui decoupling

This commit is contained in:
Dmitriy Yefremov
2017-10-14 12:24:59 +03:00
parent 005934e3dd
commit c9f4eee7d6
7 changed files with 564 additions and 470 deletions

View File

@@ -1,5 +1,4 @@
from main.ui import start_app as start
from main.ui.main import start_app as start
if __name__ == "__main__":
start()

44
main/ftp.py Normal file
View File

@@ -0,0 +1,44 @@
from ftplib import FTP
import os
__DATA_FILES_LIST = ("tv", "radio", "lamedb")
def download_data(*, properties):
with FTP(properties["host"]) as ftp:
ftp.login(user=properties["user"], passwd=properties["password"])
save_path = properties["data_dir_path"]
# bouquets section
ftp.cwd(properties["services_path"])
files = []
ftp.dir(files.append)
for file in files:
name = str(file).strip()
if name.endswith(__DATA_FILES_LIST):
name = name.split()[-1]
with open(save_path + name, 'wb') as f:
ftp.retrbinary('RETR ' + name, f.write)
# satellites.xml section
ftp.cwd(properties["satellites_xml_path"])
files.clear()
ftp.dir(files.append)
for file in files:
name = str(file).strip()
xml_file = "satellites.xml"
if name.endswith(xml_file):
with open(save_path + xml_file, 'wb') as f:
ftp.retrbinary('RETR ' + xml_file, f.write)
for name in os.listdir(save_path):
print(name)
return ftp.voidcmd("NOOP")
def upload_data(*, properties):
load_path = properties["data_dir_path"]
for file_name in os.listdir(load_path):
print(file_name)
# Open the file for transfer in binary mode
# f = open(file_name, "rb")
# transfer the file into receiver
# send = ftp.storbinary("STOR " + file_name, f)

0
main/ui/__init__.py Normal file
View File

View File

@@ -40,30 +40,6 @@
<property name="sizing">autosize</property>
<property name="title" translatable="yes">Package</property>
</object>
<object class="GtkTreeStore" id="satellites_tree_store">
<columns>
<!-- column-name satelitte -->
<column type="gchararray"/>
<!-- column-name freq -->
<column type="gchararray"/>
<!-- column-name rate -->
<column type="gchararray"/>
<!-- column-name pol -->
<column type="gchararray"/>
<!-- column-name fec -->
<column type="gchararray"/>
<!-- column-name system -->
<column type="gchararray"/>
<!-- column-name mod -->
<column type="gchararray"/>
<!-- column-name pls_mode -->
<column type="gchararray"/>
<!-- column-name pls_code -->
<column type="gchararray"/>
<!-- column-name is_id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkTreeViewColumn" id="service_column">
<property name="resizable">True</property>
<property name="sizing">autosize</property>
@@ -508,7 +484,7 @@
<property name="label" translatable="yes">Tools</property>
<property name="use_underline">True</property>
<property name="icon_name">applications-utilities</property>
<signal name="clicked" handler="on_satellite_editor_show" object="satellites_tree_store" swapped="no"/>
<signal name="clicked" handler="on_satellite_editor_show" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1052,384 +1028,6 @@
<action-widget response="-12">button1</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="satellites_editor_dialog">
<property name="width_request">640</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Satellites</property>
<property name="icon_name">applications-utilities</property>
<property name="type_hint">dialog</property>
<property name="transient_for">main_window</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox2">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area2">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="sat_ed_cancel_button">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="height_request">320</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="menuitem6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Файл</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem1">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem3">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem4">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem3">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem10">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Правка</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem13">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem14">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="satellites_editor_toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="load_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Load</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-goto-bottom</property>
<signal name="clicked" handler="on_satellites_list_load" object="satellites_tree_store" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="separatortoolitem2">
<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="save_tool_button1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Save</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-floppy</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="separatortoolitem3">
<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="del_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Delete</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-remove</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="satellites_editor_tree_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">satellites_tree_store</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection3">
<property name="mode">multiple</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="satellite_column">
<property name="title" translatable="yes">Satellite</property>
<child>
<object class="GtkCellRendererText" id="satellite_cellrenderertext"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="freq_column1">
<property name="title" translatable="yes">Freq.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="frequency_cellrenderertext"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="rate_column1">
<property name="title" translatable="yes">Rate</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="sat_rate_cellrenderertext"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="pol_column1">
<property name="title" translatable="yes">Pol.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="sat_pol_cellrenderertext"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="fec_column1">
<property name="title" translatable="yes">Fec.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="set_fec_cellrenderertext"/>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="sys_column">
<property name="title" translatable="yes">System</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="sys_cellrenderertext"/>
<attributes>
<attribute name="text">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="mod_column">
<property name="title" translatable="yes">Mod.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="mod_cellrenderertext"/>
<attributes>
<attribute name="text">6</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="pls_mode_column">
<property name="title" translatable="yes">Pls mode</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="pls_mode_cellrenderertext"/>
<attributes>
<attribute name="text">7</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="pls_code_column">
<property name="title" translatable="yes">Pls code</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="pls_code_cellrenderertext"/>
<attributes>
<attribute name="text">8</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="is_id_column">
<property name="title" translatable="yes">Is ID</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="is_id_cellrenderertext"/>
<attributes>
<attribute name="text">9</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">sat_ed_cancel_button</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="settings_dialog">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Options</property>

View File

@@ -1,16 +1,15 @@
import os
from ftplib import FTP
from threading import Thread
import gi
from main.eparser import get_channels, get_satellites, get_bouquets, get_bouquet
from threading import Thread
from main.eparser import get_channels, get_bouquets, get_bouquet
from main.eparser.__constants import SERVICE_TYPE
from main.properties import get_config, write_config
from main.ftp import download_data, upload_data
from .satellites_dialog import SatellitesDialog
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
__main_window = None
__status_bar = None
__options = get_config()
__services_model = None
@@ -19,13 +18,12 @@ __fav_model = None
__services_view = None
__fav_view = None
__bouquets_view = None
__DATA_FILES_LIST = ("tv", "radio", "lamedb")
__channels = {}
def on_about_app(item):
builder = Gtk.Builder()
builder.add_from_file("editor_ui.glade")
builder.add_from_file("ui/main.glade")
dialog = builder.get_object("about_dialog")
dialog.run()
dialog.destroy()
@@ -43,7 +41,6 @@ def get_handlers():
"on_tree_view_key_release": on_tree_view_key_release,
"on_bouquets_selection": on_bouquets_selection,
"on_satellite_editor_show": on_satellite_editor_show,
"on_satellites_list_load": on_satellites_list_load,
"on_services_selection": on_services_selection,
"on_fav_selection": on_fav_selection,
"on_up": on_up,
@@ -89,22 +86,7 @@ def on_delete(item):
def on_satellite_editor_show(model):
""" Shows satellites editor dialog """
builder = Gtk.Builder()
builder.add_from_file("editor_ui.glade")
builder.connect_signals(get_handlers())
dialog = builder.get_object("satellites_editor_dialog")
dialog.run()
dialog.destroy()
def on_satellites_list_load(model):
""" Load satellites data into model """
satellites = get_satellites(__options["data_dir_path"])
model.clear()
for name, flags, pos, transponders in satellites:
parent = model.append(None, [name, *[None for x in range(9)]])
for transponder in transponders:
model.append(parent, ["Transponder:", *transponder])
SatellitesDialog(__main_window, __options["data_dir_path"]).show()
def data_open(model):
@@ -163,7 +145,7 @@ def delete_selection(view, *args):
def on_path_open(*args):
builder = Gtk.Builder()
builder.add_from_file("editor_ui.glade")
builder.add_from_file("ui/main.glade")
dialog = builder.get_object("path_chooser_dialog")
response = dialog.run()
if response == -12: # for fix assertion 'gtk_widget_get_can_default (widget)' failed
@@ -173,7 +155,7 @@ def on_path_open(*args):
def on_preferences(item):
builder = Gtk.Builder()
builder.add_from_file("editor_ui.glade")
builder.add_from_file("main.glade")
builder.connect_signals(get_handlers())
dialog = builder.get_object("settings_dialog")
host_field = builder.get_object("host_field")
@@ -232,42 +214,9 @@ def on_reload(item):
def connect(properties, download=True):
assert isinstance(properties, dict)
try:
with FTP(properties["host"]) as ftp:
ftp.login(user=properties["user"], passwd=properties["password"])
save_path = properties["data_dir_path"]
if download:
# bouquets section
ftp.cwd(properties["services_path"])
files = []
ftp.dir(files.append)
for file in files:
name = str(file).strip()
if name.endswith(__DATA_FILES_LIST):
name = name.split()[-1]
with open(save_path + name, 'wb') as f:
ftp.retrbinary('RETR ' + name, f.write)
# satellites.xml section
ftp.cwd(properties["satellites_xml_path"])
files.clear()
ftp.dir(files.append)
for file in files:
name = str(file).strip()
xml_file = "satellites.xml"
if name.endswith(xml_file):
with open(save_path + xml_file, 'wb') as f:
ftp.retrbinary('RETR ' + xml_file, f.write)
__status_bar.push(1, ftp.voidcmd("NOOP"))
for name in os.listdir(save_path):
print(name)
else:
for file_name in os.listdir(save_path):
print(file_name)
# Open the file for transfer in binary mode
# f = open(file_name, "rb")
# transfer the file into receiver
# send = ftp.storbinary("STOR " + file_name, f)
res = download_data(properties=properties) if download else upload_data(properties=properties)
__status_bar.push(1, res)
except Exception as e:
__status_bar.remove_all(1)
__status_bar.push(1, getattr(e, "message", repr(e))) # Or maybe so: getattr(e, 'message', str(e))
@@ -275,8 +224,9 @@ def connect(properties, download=True):
def init_ui():
builder = Gtk.Builder()
builder.add_from_file("editor_ui.glade")
main_window = builder.get_object("main_window")
builder.add_from_file("ui/main.glade")
global __main_window
__main_window = builder.get_object("main_window")
global __services_view
__services_view = builder.get_object("services_tree_view")
global __fav_view
@@ -292,7 +242,7 @@ def init_ui():
global __status_bar
__status_bar = builder.get_object("status_bar")
builder.connect_signals(get_handlers())
main_window.show_all()
__main_window.show_all()
def start_app():

View File

@@ -0,0 +1,466 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkTreeStore" id="satellites_tree_store">
<columns>
<!-- column-name satelitte -->
<column type="gchararray"/>
<!-- column-name freq -->
<column type="gchararray"/>
<!-- column-name rate -->
<column type="gchararray"/>
<!-- column-name pol -->
<column type="gchararray"/>
<!-- column-name fec -->
<column type="gchararray"/>
<!-- column-name system -->
<column type="gchararray"/>
<!-- column-name mod -->
<column type="gchararray"/>
<!-- column-name pls_mode -->
<column type="gchararray"/>
<!-- column-name pls_code -->
<column type="gchararray"/>
<!-- column-name is_id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="satellites_editor_dialog">
<property name="width_request">640</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Satellites</property>
<property name="icon_name">applications-utilities</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox7">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog_action_area">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="sat_ed_cancel_button">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="height_request">320</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Файл</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="new_menu_item">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="open_menu_item">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="save_menui_tem">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="save_as_menui_tem">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="quit_menu_item">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Правка</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="add_menu_item">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="edit_menu_item">
<property name="label">gtk-edit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="delete_menu_item">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="satellites_editor_toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="load_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Load</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-goto-bottom</property>
<signal name="clicked" handler="on_satellites_list_load" object="satellites_tree_store" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="separatortoolitem2">
<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="save_tool_button1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Save</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-floppy</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="separatortoolitem3">
<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="add_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Add</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-add</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="edit_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Edit</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-edit</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="remove_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Remove</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-remove</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="satellites_editor_tree_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">satellites_tree_store</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection8">
<property name="mode">multiple</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="satellite_column">
<property name="title" translatable="yes">Satellite</property>
<child>
<object class="GtkCellRendererText" id="satellite_cellrenderertext"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="freq_column1">
<property name="title" translatable="yes">Freq.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="frequency_cellrenderertext"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="rate_column1">
<property name="title" translatable="yes">Rate</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="sat_rate_cellrenderertext"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="pol_column1">
<property name="title" translatable="yes">Pol.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="sat_pol_cellrenderertext"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="fec_column1">
<property name="title" translatable="yes">Fec.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="set_fec_cellrenderertext"/>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="sys_column">
<property name="title" translatable="yes">System</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="sys_cellrenderertext"/>
<attributes>
<attribute name="text">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="mod_column">
<property name="title" translatable="yes">Mod.</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="mod_cellrenderertext"/>
<attributes>
<attribute name="text">6</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="pls_mode_column">
<property name="title" translatable="yes">Pls mode</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="pls_mode_cellrenderertext"/>
<attributes>
<attribute name="text">7</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="pls_code_column">
<property name="title" translatable="yes">Pls code</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="pls_code_cellrenderertext"/>
<attributes>
<attribute name="text">8</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="is_id_column">
<property name="title" translatable="yes">Is ID</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="is_id_cellrenderertext"/>
<attributes>
<attribute name="text">9</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">sat_ed_cancel_button</action-widget>
</action-widgets>
</object>
<object class="GtkTreeStore" id="satellites_tree_store1">
<columns>
<!-- column-name satelitte -->
<column type="gchararray"/>
<!-- column-name freq -->
<column type="gchararray"/>
<!-- column-name rate -->
<column type="gchararray"/>
<!-- column-name pol -->
<column type="gchararray"/>
<!-- column-name fec -->
<column type="gchararray"/>
<!-- column-name system -->
<column type="gchararray"/>
<!-- column-name mod -->
<column type="gchararray"/>
<!-- column-name pls_mode -->
<column type="gchararray"/>
<!-- column-name pls_code -->
<column type="gchararray"/>
<!-- column-name is_id -->
<column type="gchararray"/>
</columns>
</object>
</interface>

View File

@@ -0,0 +1,37 @@
import gi
from main.eparser import get_satellites
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
class SatellitesDialog:
def __init__(self, transient, data_path):
handlers = {
"on_satellites_list_load": self.on_satellites_list_load
}
builder = Gtk.Builder()
builder.add_from_file("./ui/satellites_dialog.glade")
builder.connect_signals(handlers)
self._dialog = builder.get_object("satellites_editor_dialog")
self._data_path = data_path
self._dialog.set_transient_for(transient)
def show(self):
self._dialog.run()
self._dialog.destroy()
def on_satellites_list_load(self, model):
""" Load satellites data into model """
satellites = get_satellites(self._data_path)
model.clear()
aggr = [None for x in range(9)]
for name, flags, pos, transponders in satellites:
parent = model.append(None, [name, *aggr])
for transponder in transponders:
model.append(parent, ["Transponder:", *transponder])
if __name__ == "__main__":
pass