append output for sat update dialog

This commit is contained in:
DYefremov
2018-05-01 21:05:18 +03:00
parent 6ffd1d7926
commit d857c4b786
5 changed files with 52 additions and 32 deletions

View File

@@ -67,7 +67,7 @@ def upload_data(*, properties, download_type=DownloadDataType.ALL, remove_unused
tn = telnet(host=host, user=properties.get("telnet_user", "root"), password=properties.get("telnet_password", ""),
timeout=properties.get("telnet_timeout", 5))
next(tn)
# terminate enigma or enigma
# terminate enigma or neutrino
tn.send("init 4")
with FTP(host=host) as ftp:

View File

@@ -525,5 +525,13 @@ def get_base_model(model):
return model
def append_text_to_tview(char, view):
""" Appending text and scrolling to a given line in the text view. """
buf = view.get_buffer()
buf.insert_at_cursor(char)
insert = buf.get_insert()
view.scroll_to_mark(insert, 0.0, True, 0.0, 1.0)
if __name__ == "__main__":
pass

View File

@@ -9,9 +9,9 @@ from app.commons import run_idle, run_task
from app.ftp import upload_data, DownloadDataType
from app.tools.picons import PiconsParser, parse_providers, Provider, convert_to
from app.properties import Profile
from app.ui.uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TEXT_DOMAIN
from app.ui.dialogs import show_dialog, DialogType, get_message
from app.ui.main_helper import update_entry_data
from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TEXT_DOMAIN
from .dialogs import show_dialog, DialogType, get_message
from .main_helper import update_entry_data, append_text_to_tview
class PiconsDialog:
@@ -166,13 +166,7 @@ class PiconsDialog:
@run_idle
def append_output(self, char):
buf = self._text_view.get_buffer()
buf.insert_at_cursor(char)
self.scroll_to_end(buf)
def scroll_to_end(self, buf):
insert = buf.get_insert()
self._text_view.scroll_to_mark(insert, 0.0, True, 0.0, 1.0)
append_text_to_tview(char, self._text_view)
def resize(self, path):
if self._resize_no_radio_button.get_active():

View File

@@ -1575,6 +1575,7 @@
</child>
<child>
<object class="GtkScrolledWindow" id="sat_update_scrolled_window">
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
@@ -1672,21 +1673,6 @@
<object class="GtkToolbar" id="sat_update_toolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolButton" id="update_sat_list_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="is_important">True</property>
<property name="label" translatable="yes">Update</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-refresh</property>
<signal name="clicked" handler="on_update_satellites_list" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="cancel_tool_button">
<property name="visible">True</property>
@@ -1702,11 +1688,27 @@
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="update_sat_list_tool_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="is_important">True</property>
<property name="label" translatable="yes">Update</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-refresh</property>
<signal name="clicked" handler="on_update_satellites_list" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="receive_sat_list_tool_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="is_important">True</property>
<property name="label" translatable="yes">Receive</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-goto-bottom</property>
@@ -1732,18 +1734,25 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkTextView" id="text_view">
<property name="height_request">100</property>
<object class="GtkScrolledWindow" id="text_view_scrolled_window">
<property name="height_request">120</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="text_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="Extra:">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">expander</property>
<property name="label" translatable="yes">Extra:</property>
</object>
</child>
</object>

View File

@@ -6,7 +6,7 @@ from app.eparser import get_satellites, write_satellites, Satellite, Transponder
from app.tools.satellites import SatellitesParser
from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, TEXT_DOMAIN, MOVE_KEYS
from .dialogs import show_dialog, DialogType, WaitDialog
from .main_helper import move_items, scroll_to
from .main_helper import move_items, scroll_to, append_text_to_tview
def show_satellites_dialog(transient, options):
@@ -457,6 +457,8 @@ class SatellitesUpdateDialog:
self._main_model = main_model
# self._dialog.get_content_area().set_border_width(0)
self._sat_view = builder.get_object("sat_update_tree_view")
self._sat_update_expander = builder.get_object("sat_update_expander")
self._text_view = builder.get_object("text_view")
self._receive_sat_list_tool_button = builder.get_object("receive_sat_list_tool_button")
self._download_task = False
self._parser = None
@@ -502,10 +504,13 @@ class SatellitesUpdateDialog:
for sat in [r for r in model if r[4]]:
if not self._download_task:
return
print("Process:", sat[0])
self._sat_update_expander.set_expanded(True)
text = "Process: {}\n"
self.append_output(text.format(sat[0]))
sats.append(self._parser.get_satellite(sat[:-1]))
sats = {s[2]: s for s in sats} # key = position, v = satellite
for row in self._main_model:
pos = row[-1]
if pos in sats:
@@ -513,6 +518,10 @@ class SatellitesUpdateDialog:
print("The remaining satellites:", sats)
self._download_task = False
@run_idle
def append_output(self, text):
append_text_to_tview(text, self._text_view)
@run_idle
def on_cancel_receive(self, item=None):
self._download_task = False