Skip to content

Commit

Permalink
#3964 run configure sub-windows as dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 4, 2023
1 parent ddd9545 commit da23258
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 81 deletions.
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,7 @@ def add_service_exe(script, icon, base_name):
add_console_exe("fs/bin/xpra_launcher", "xpra.ico", "Xpra-Launcher-Debug")
add_gui_exe("xpra/gtk/dialogs/view_keyboard.py", "keyboard.ico", "GTK_Keyboard_Test")
add_gui_exe("xpra/gtk/dialogs/bug_report.py", "bugs.ico", "Bug_Report")
add_gui_exe("xpra/gtk/configure/main.py", "directory.ico", "Configure")
add_gui_exe("xpra/platform/win32/gdi_screen_capture.py", "screenshot.ico", "Screenshot")
if server_ENABLED:
add_gui_exe("fs/libexec/xpra/auth_dialog", "authentication.ico", "Auth_Dialog")
Expand Down Expand Up @@ -2101,7 +2102,7 @@ def bundle_tests():
add_packages("xpra.client.base")
add_packages("xpra.client.mixins", "xpra.client.auth")
add_modules("xpra.scripts.pinentry")
toggle_packages(gtk3_ENABLED, "xpra.gtk", "xpra.gtk.examples", "xpra.gtk.dialogs")
toggle_packages(gtk3_ENABLED, "xpra.gtk", "xpra.gtk.examples", "xpra.gtk.dialogs", "xpra.gtk.configure")
toggle_packages(client_ENABLED and gtk3_ENABLED, "xpra.client.gtk3", "xpra.client.gui")
toggle_packages((client_ENABLED and gtk3_ENABLED) or (audio_ENABLED and WIN32 and MINGW_PREFIX), "gi")
if client_ENABLED and WIN32 and MINGW_PREFIX:
Expand Down Expand Up @@ -2300,6 +2301,7 @@ def ax(base):
if gtk3_ENABLED:
ax("xpra.gtk")
ax("xpra.gtk.dialogs")
ax("xpra.gtk.configure")
if example_ENABLED:
ax("xpra.gtk.examples")
if keyboard_ENABLED:
Expand Down
4 changes: 4 additions & 0 deletions xpra/gstreamer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is part of Xpra.
# Copyright (C) 2023 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
4 changes: 4 additions & 0 deletions xpra/gtk/dialogs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is part of Xpra.
# Copyright (C) 2023 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
26 changes: 19 additions & 7 deletions xpra/gtk/dialogs/base_gui_window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of Xpra.
# Copyright (C) 2018-2021 Antoine Martin <[email protected]>
# Copyright (C) 2018-2023 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -21,7 +21,7 @@
gi.require_version('Gtk', '3.0') # @UndefinedVariable
from gi.repository import GLib, Gtk, Gdk, Gio # @UnresolvedImport

log = Logger("client", "util")
log = Logger("util")


def exec_command(cmd):
Expand Down Expand Up @@ -53,6 +53,7 @@ def __init__(self,
wm_class=("xpra-gui", "Xpra-GUI"),
default_size=(640, 300),
header_bar=(True, True),
parent:Gtk.Window|None=None,
):
self.exit_code = 0
super().__init__()
Expand All @@ -67,11 +68,16 @@ def __init__(self,
icon = get_icon_pixbuf(icon_name)
if icon:
self.set_icon(icon)
add_close_accel(self, self.quit)
if parent:
self.set_transient_for(parent)
self.set_modal(True)
close = self.hide
else:
close = self.quit
self.connect("delete_event", close)
add_close_accel(self, close)
add_window_accel(self, 'F1', self.show_about)
self.connect("delete_event", self.quit)
self.set_wmclass(*wm_class)

self.vbox = Gtk.VBox(homogeneous=False, spacing=10)
self.add(self.vbox)
self.populate()
Expand Down Expand Up @@ -129,6 +135,10 @@ def app_signal(self, signum : int | signal.Signals):
log("app_signal(%s) exit_code=%i", signum, self.exit_code)
self.quit()

def hide(self, *args):
log("hide%s", args)
super().hide()

def quit(self, *args):
log("quit%s", args)
self.do_quit()
Expand Down Expand Up @@ -156,11 +166,11 @@ def command_ended(self, proc):
self.reset_cursors()
log(f"command_ended({proc})")
if proc.returncode:

self.may_notify(NotificationID.FAILURE,
"Subcommand Failed",
"The subprocess terminated abnormally\nand returned %s" % exit_str(proc.returncode)
"The subprocess terminated abnormally\n\rand returned %s" % exit_str(proc.returncode)
)
pass

def busy_cursor(self, widget):
from xpra.gtk.cursors import cursor_types
Expand Down Expand Up @@ -194,6 +204,8 @@ def may_exit():
GLib.timeout_add(2000, may_exit)

def may_notify(self, nid:NotificationID, summary:str, body:str):
log.info(summary)
log.info(body)
from xpra.platform.gui import get_native_notifier_classes
nc = get_native_notifier_classes()
if not nc:
Expand Down
62 changes: 0 additions & 62 deletions xpra/gtk/dialogs/configure.py

This file was deleted.

4 changes: 2 additions & 2 deletions xpra/gtk/dialogs/gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of Xpra.
# Copyright (C) 2018-2021 Antoine Martin <[email protected]>
# Copyright (C) 2018-2023 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -13,7 +13,7 @@
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

log = Logger("client", "util")
log = Logger("util")


def has_client() -> bool:
Expand Down
17 changes: 8 additions & 9 deletions xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def configure_logging(options, mode) -> None:
"show-menu", "show-about", "show-session-info",
"webcam",
"showconfig",
):
):
to = sys.stdout
else:
to = sys.stderr
Expand All @@ -192,11 +192,11 @@ def configure_logging(options, mode) -> None:
"attach", "listen", "proxy",
"version", "info", "id",
"_audio_record", "_audio_play",
"stop", "print", "showconfig",
"stop", "print", "showconfig", "configure",
"_dialog", "_pass",
"pinentry",
"example",
) or mode.startswith("upgrade") or mode.startswith("request-"):
) or mode.startswith("upgrade") or mode.startswith("request-"):
if "help" in options.speaker_codec or "help" in options.microphone_codec:
server_mode = mode not in ("attach", "listen")
codec_help = show_audio_codec_help(server_mode, options.speaker_codec, options.microphone_codec)
Expand Down Expand Up @@ -3918,16 +3918,15 @@ def run_auth(_options, args) -> ExitValue:


def run_configure(args) -> ExitValue:
mod = "main"
if args:
valid = ("gstreamer", )
mod = args[0]
valid = ("gstreamer", "encodings", "features")
if mod not in valid:
raise ValueError(f"unsupported 'configure' argument {mod}, must be one of {csv(valid)}")
from importlib import import_module
mod = import_module(f"xpra.gtk.dialogs.configure_{mod}")
return mod.main()
from xpra.gtk.dialogs.configure import main
return main()
from importlib import import_module
mod = import_module(f"xpra.gtk.configure.{mod}")
return mod.main()


def run_showconfig(options, args) -> ExitValue:
Expand Down
1 change: 1 addition & 0 deletions xpra/scripts/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ def get_usage() -> list[str]:
"control DISPLAY command [arg1] [arg2]..",
"print DISPLAY filename",
"shell [DISPLAY]",
"configure",
"showconfig",
"list",
"list-sessions",
Expand Down

0 comments on commit da23258

Please sign in to comment.