diff --git a/xpra/gtk/configure/gstreamer.py b/xpra/gtk/configure/gstreamer.py index dd358cc013..070b1954f2 100644 --- a/xpra/gtk/configure/gstreamer.py +++ b/xpra/gtk/configure/gstreamer.py @@ -4,9 +4,11 @@ # later version. See the file COPYING for details. import gi +from textwrap import wrap from xpra.gtk.dialogs.base_gui_window import BaseGUIWindow from xpra.gtk.widget import label +from xpra.platform.paths import get_icon from xpra.log import Logger gi.require_version('Gtk', '3.0') @@ -14,21 +16,73 @@ log = Logger("gstreamer", "util") +DISCLAIMER = """ +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""".replace("\n", "") class ConfigureGUI(BaseGUIWindow): def __init__(self, parent:Gtk.Window|None=None): + self.warning_shown = False + self.warning_pixbuf = get_icon("warning.png") + size = (800, 554) + if self.warning_pixbuf: + size = self.warning_pixbuf.get_width(), self.warning_pixbuf.get_height() super().__init__( "Configure Xpra's GStreamer Codecs", "gstreamer.png", wm_class=("xpra-configure-gstreamer-gui", "Xpra Configure GStreamer GUI"), - default_size=(640, 300), + default_size=size, header_bar=(True, False), parent=parent, ) + self.set_resizable(False) def populate(self): - self.add_widget(label("Configure Xpra GStreamer Codecs", font="sans 20")) + for x in self.vbox.get_children(): + self.vbox.remove(x) + if not self.warning_shown: + self.populate_with_warning() + else: + self.add_widget(label("Configure Xpra GStreamer Codecs", font="sans 20")) + self.vbox.show_all() + + def populate_with_warning(self): + layout = Gtk.Layout() + self.vbox.add(layout) + pixbuf = get_icon("warning.png") + image = Gtk.Image.new_from_pixbuf(pixbuf) + layout.put(image, 0, 0) + for i, text in enumerate(( + "This tool can cause your system to crash,", + "it may even damage hardware in rare cases.", + " Use with caution.", + )): + lbl = label(text, font="Sans 22") + layout.put(lbl, 86, 70+i*40) + for i, line in enumerate(wrap(DISCLAIMER, width=70)): + lbl = label(line, font="Sans 12") + layout.put(lbl, 72, 220+i*24) + button = Gtk.Button.new_with_label("Understood") + button.connect("clicked", self.understood) + layout.put(button, 200, 450) + button = Gtk.Button.new_with_label("Get me out of here") + button.connect("clicked", self.dismiss) + layout.put(button, 400, 450) + self.warning_shown = True + + def understood(self, *args): + self.warning_shown = True + self.populate() + + def show(self): + super().show() def main() -> int: diff --git a/xpra/gtk/dialogs/base_gui_window.py b/xpra/gtk/dialogs/base_gui_window.py index 4e50cdca8c..754f5e84e1 100644 --- a/xpra/gtk/dialogs/base_gui_window.py +++ b/xpra/gtk/dialogs/base_gui_window.py @@ -71,11 +71,11 @@ def __init__(self, if parent: self.set_transient_for(parent) self.set_modal(True) - close = self.hide + self.do_dismiss = self.hide else: - close = self.quit - self.connect("delete_event", close) - add_close_accel(self, close) + self.do_dismiss = self.quit + self.connect("delete_event", self.dismiss) + add_close_accel(self, self.dismiss) add_window_accel(self, 'F1', self.show_about) with IgnoreWarningsContext(): self.set_wmclass(*wm_class) @@ -87,6 +87,11 @@ def __init__(self, self.connect("focus-in-event", self.focus_in) self.connect("focus-out-event", self.focus_out) + def dismiss(self, *args): + log(f"dismiss{args} calling {self.do_dismiss}") + self.do_dismiss() + + def add_headerbar(self, about=True, toolbox=True): hb = Gtk.HeaderBar() hb.set_show_close_button(True)