corrected screenshots creation

This commit is contained in:
DYefremov
2021-10-01 23:47:14 +03:00
parent 3c5144134c
commit 6cfb72b1d7
2 changed files with 34 additions and 25 deletions

View File

@@ -40,7 +40,7 @@ from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, Page, Column, KeyboardKey
from ..commons import run_task, run_with_delay, log, run_idle
from ..connections import HttpAPI, UtfFTP
from ..eparser.ecommons import BqServiceType
from ..settings import IS_DARWIN, PlayStreamsMode
from ..settings import IS_DARWIN, PlayStreamsMode, IS_LINUX, IS_WIN
class EpgTool(Gtk.Box):
@@ -927,18 +927,27 @@ class ControlTool(Gtk.Box):
img = data.get("img_data", None)
if img:
is_darwin = self._settings.is_darwin
GLib.idle_add(self._screenshot_button_box.set_sensitive, is_darwin)
path = os.path.expanduser("~/Desktop") if is_darwin else None
GLib.idle_add(self._screenshot_button_box.set_sensitive, not IS_LINUX)
path = os.path.expanduser("~/Desktop") if not IS_LINUX else None
try:
import tempfile
import subprocess
with tempfile.NamedTemporaryFile(mode="wb", suffix=".jpg", dir=path, delete=not is_darwin) as tf:
with tempfile.NamedTemporaryFile(mode="wb", suffix=".jpg", dir=path, delete=IS_LINUX) as tf:
tf.write(img)
cmd = ["open" if is_darwin else "xdg-open", tf.name]
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if IS_LINUX:
cmd = ["xdg-open", tf.name]
elif IS_DARWIN:
cmd = ["open", tf.name]
else:
cmd = [tf.name]
if not IS_WIN:
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
# File must be closed.
if IS_WIN:
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=IS_WIN).communicate()
finally:
GLib.idle_add(self._screenshot_button_box.set_sensitive, True)

View File

@@ -225,10 +225,10 @@ class Application(Gtk.Application):
self._links_transmitter = None
self._satellite_tool = None
self._picon_manager = None
self._epg_box = None
self._timers_box = None
self._recordings_box = None
self._control_box = None
self._epg_tool = None
self._timers_tool = None
self._recordings_tool = None
self._control_tool = None
self._ftp_client = None
# Record
self._recorder = None
@@ -761,26 +761,26 @@ class Application(Gtk.Application):
box.pack_start(self._picon_manager, True, True, 0)
def on_epg_realize(self, box):
self._epg_box = EpgTool(self, self._http_api)
box.pack_start(self._epg_box, True, True, 0)
self._epg_tool = EpgTool(self, self._http_api)
box.pack_start(self._epg_tool, True, True, 0)
def on_timers_realize(self, box):
self._epg_box = TimerTool(self, self._http_api)
box.pack_start(self._epg_box, True, True, 0)
self._timers_tool = TimerTool(self, self._http_api)
box.pack_start(self._timers_tool, True, True, 0)
def on_recordings_realize(self, box):
self._recordings_box = RecordingsTool(self, self._http_api, self._settings)
box.pack_start(self._recordings_box, True, True, 0)
self._player_box.connect("play", self._recordings_box.on_playback)
self._player_box.connect("playback-close", self._recordings_box.on_playback_close)
self._recordings_tool = RecordingsTool(self, self._http_api, self._settings)
box.pack_start(self._recordings_tool, True, True, 0)
self._player_box.connect("play", self._recordings_tool.on_playback)
self._player_box.connect("playback-close", self._recordings_tool.on_playback_close)
def on_ftp_realize(self, box):
self._ftp_client = FtpClientBox(self, self._settings)
box.pack_start(self._ftp_client, True, True, 0)
def on_control_realize(self, box: Gtk.HBox):
self._control_box = ControlTool(self, self._http_api, self._settings)
box.pack_start(self._control_box, True, True, 0)
self._control_tool = ControlTool(self, self._http_api, self._settings)
box.pack_start(self._control_tool, True, True, 0)
def on_visible_page(self, stack, param):
self._page = Page(stack.get_visible_child_name())
@@ -2891,8 +2891,8 @@ class Application(Gtk.Application):
self._http_api.send(HttpAPI.Request.CURRENT, None, self.update_status)
def update_signal(self, sig):
if self._control_box:
self._control_box.update_signal(sig)
if self._page is Page.CONTROL:
self._control_tool.update_signal(sig)
self.set_signal(sig.get("e2snr", "0 %") if sig else "0 %")
@@ -3439,11 +3439,11 @@ class Application(Gtk.Application):
return True
def on_alt_selection(self, model, path, column):
if self._control_box and self._control_box.update_epg:
if self._control_tool and self._control_tool.update_epg:
row = model[path][:]
srv = self._services.get(row[Column.ALT_FAV_ID], None)
if srv and srv.transponder or row[Column.ALT_TYPE] == BqServiceType.IPTV.name:
self._control_box.on_service_changed(srv.picon_id.rstrip(".png").replace("_", ":"))
self._control_tool.on_service_changed(srv.picon_id.rstrip(".png").replace("_", ":"))
# ***************** Profile label ********************* #