Skip to content

Commit

Permalink
work towards eliminating gtk/util module
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 12, 2023
1 parent 0ed71eb commit 7883acc
Show file tree
Hide file tree
Showing 85 changed files with 734 additions and 696 deletions.
2 changes: 1 addition & 1 deletion tests/perf/test_measure_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from subprocess import Popen, PIPE, STDOUT

from xpra.exit_codes import exit_str
from xpra.gtk.gtk_util import get_root_size
from xpra.gtk.util import get_root_size
from xpra.log import Logger

log = Logger("util")
Expand Down
2 changes: 1 addition & 1 deletion tests/xpra/clients/fake_gtk_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import gi
gi.require_version('Gtk', '3.0') # @UndefinedVariable
from gi.repository import Gtk, GLib #pylint: disable=wrong-import-position @UnresolvedImport
from xpra.gtk.gtk_util import get_default_root_window
from xpra.gtk.util import get_default_root_window
from tests.xpra.clients.fake_client import FakeClient


Expand Down
2 changes: 1 addition & 1 deletion tests/xpra/test_apps/test_window_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

gi.require_version("Gtk", "3.0") # @UndefinedVariable
from gi.repository import Gtk #pylint: disable=wrong-import-position @UnresolvedImport
from xpra.gtk.gtk_util import get_root_size
from xpra.gtk.util import get_root_size

width = 400
height = 200
Expand Down
2 changes: 1 addition & 1 deletion tests/xpra/test_apps/test_window_moveresize.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def moveresize_X11(self, *_args):
def get_new_geometry(self):
x, y = self.get_position()
width, height = self.get_size()
from xpra.gtk.gtk_util import get_default_root_window
from xpra.gtk.util import get_default_root_window
maxx, maxy = get_default_root_window().get_geometry()[2:4]
new_x = (x+100) % (maxx-width)
new_y = (y+100) % (maxy-height)
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gl/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def main() -> int:
# pylint: disable=import-outside-toplevel
from xpra.platform import program_context
from xpra.platform.gui import init as gui_init
from xpra.gtk.gtk_util import init_display_source
from xpra.gtk.util import init_display_source
from xpra.log import enable_color
with program_context("OpenGL-Check"):
gui_init()
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gl/gtk3/client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from collections import namedtuple

from xpra.client.gtk3.window import ClientWindow
from xpra.gtk.gtk_util import set_visual
from xpra.gtk.window import set_visual
from xpra.util.types import typedict
from xpra.util.env import envbool
from xpra.log import Logger
Expand Down
12 changes: 6 additions & 6 deletions xpra/client/gtk3/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
from xpra.common import FULL_INFO, VIDEO_MAX_SIZE, NotificationID, DEFAULT_METADATA_SUPPORTED, noerr
from xpra.util.stats import std_unit
from xpra.scripts.config import TRUE_OPTIONS, FALSE_OPTIONS, InitExit
from xpra.gtk.cursors import cursor_types
from xpra.gtk.gtk_util import (
get_default_cursor, color_parse, get_default_root_window, get_root_size,
get_screen_sizes, get_monitors_info,
GDKWindow,
from xpra.gtk.cursors import cursor_types, get_default_cursor
from xpra.gtk.util import (
get_default_root_window, get_root_size,
GRAB_STATUS_STRING,
init_display_source,
)
from xpra.gtk.widget import scaled_image, label, ignorewarnings, IgnoreWarningsContext
from xpra.gtk.window import GDKWindow
from xpra.gtk.info import get_monitors_info, get_screen_sizes
from xpra.gtk.widget import scaled_image, label, ignorewarnings, IgnoreWarningsContext, color_parse
from xpra.gtk.pixbuf import get_icon_pixbuf, get_pixbuf_from_data
from xpra.gtk.versions import get_gtk_version_info
from xpra.exit_codes import ExitCode, ExitValue
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gtk3/keyboard_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def cleanup(self):
def main():
#use gtk as display source:
# pylint: disable=import-outside-toplevel
from xpra.gtk.gtk_util import init_display_source
from xpra.gtk.util import init_display_source
from xpra.util.str_fn import print_nested_dict
from xpra.platform import program_context
with program_context("GTK-Keyboard", "GTK Keyboard"):
Expand Down
6 changes: 3 additions & 3 deletions xpra/client/gtk3/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

from xpra.gtk.signals import register_os_signals
from xpra.scripts.config import read_config, make_defaults_struct, validate_config, save_config
from xpra.gtk.gtk_util import add_close_accel, color_parse
from xpra.gtk.widget import scaled_image, imagebutton, label, choose_file, modify_fg
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import scaled_image, imagebutton, label, choose_file, modify_fg, color_parse
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.util.str_fn import csv, repr_ellipsized
from xpra.os_util import WIN32, OSX
Expand Down Expand Up @@ -1113,7 +1113,7 @@ def do_main(argv):
from xpra.os_util import SIGNAMES
from xpra.scripts.main import InitExit, InitInfo
from xpra.platform.gui import init as gui_init, ready as gui_ready
from xpra.gtk.gtk_util import init_display_source
from xpra.gtk.util import init_display_source

init_display_source()

Expand Down
4 changes: 1 addition & 3 deletions xpra/client/gtk3/statusicon_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
from xpra.os_util import WIN32, OSX, POSIX
from xpra.util.env import envbool
from xpra.client.gui.tray_base import TrayBase, log
from xpra.gtk.gtk_util import (
get_default_root_window,
)
from xpra.gtk.util import get_default_root_window
from xpra.gtk.pixbuf import get_icon_from_file, get_pixbuf_from_data

ORIENTATION = {
Expand Down
10 changes: 3 additions & 7 deletions xpra/client/gtk3/window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@
from xpra.util.str_fn import csv
from xpra.util.env import envint, envbool
from xpra.gtk.gobject import no_arg_signal, one_arg_signal
from xpra.gtk.gtk_util import (
ds_inited,
get_default_root_window,
set_visual,
GRAB_STATUS_STRING,
)
from xpra.gtk.util import ds_inited, get_default_root_window, GRAB_STATUS_STRING
from xpra.gtk.window import set_visual
from xpra.gtk.widget import ignorewarnings
from xpra.gtk.pixbuf import get_pixbuf_from_data
from xpra.gtk.keymap import KEY_TRANSLATIONS
Expand Down Expand Up @@ -72,7 +68,7 @@
from xpra.x11.bindings.send_wm import send_wm_workspace
except ImportError as x11e:
log("x11 bindings", exc_info=True)
#gtk_util should have already logged a detailed warning
#gtk util should have already logged a detailed warning
log("cannot import the X11 bindings:")
log(" %s", x11e)
else:
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gtk3/window_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from xpra.util.str_fn import csv
from xpra.os_util import bytestostr
from xpra.common import GravityStr, WORKSPACE_UNSET
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import label, IgnoreWarningsContext
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.log import Logger
Expand Down
2 changes: 1 addition & 1 deletion xpra/codecs/gstreamer/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def get_type(self) -> str:
def selftest(_full=False) -> None:
log("gstreamer encoder selftest: %s", get_info())
from gi.repository import GLib # @UnresolvedImport
from xpra.gtk.gtk_util import get_root_size
from xpra.gtk.util import get_root_size
w, h = get_root_size()
c = Capture(width=w, height=h)
loop = GLib.MainLoop()
Expand Down
31 changes: 20 additions & 11 deletions xpra/gtk/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@
cursor_names = {}
cursor_types = {}

for x in dir(Gdk.CursorType):
if not x.isupper():
#probably a method
continue
try:
v = int(getattr(Gdk.CursorType, x))
cursor_names[v] = x
cursor_types[x] = v
except (TypeError, ValueError):
pass
def _init_map():
for x in dir(Gdk.CursorType):
if not x.isupper():
#probably a method
continue
try:
v = int(getattr(Gdk.CursorType, x))
cursor_names[v] = x
cursor_types[x] = v
except (TypeError, ValueError):
pass


_init_map()


def get_default_cursor() -> Gdk.Cursor:
display = Gdk.Display.get_default()
return Gdk.Cursor.new_from_name(display, "default")


def main():
Expand All @@ -31,4 +40,4 @@ def main():


if __name__ == "__main__":
main()
main()
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from xpra.util.version import XPRA_VERSION
from xpra.scripts.config import get_build_info
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.log import Logger

log = Logger("info")
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/auth_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# pylint: disable=wrong-import-position
from gi.repository import GLib, Gtk # @UnresolvedImport

from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import label
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.gtk.signals import register_os_signals
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/base_gui_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import gi
from collections.abc import Callable

from xpra.gtk.gtk_util import add_close_accel, add_window_accel
from xpra.gtk.window import add_close_accel, add_window_accel
from xpra.gtk.widget import imagebutton, IgnoreWarningsContext
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.exit_codes import exit_str
Expand Down
6 changes: 4 additions & 2 deletions xpra/gtk/dialogs/bug_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
from gi.repository import Gtk, Gdk # @UnresolvedImport

from xpra.common import ScreenshotData, noop
from xpra.gtk.gtk_util import add_close_accel, get_display_info, get_default_root_window
from xpra.gtk.util import get_default_root_window
from xpra.gtk.window import add_close_accel
from xpra.gtk.info import get_display_info
from xpra.gtk.widget import scaled_image, label, choose_file
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.gtk.versions import get_gtk_version_info
Expand Down Expand Up @@ -395,7 +397,7 @@ def main(argv=()):
# pylint: disable=import-outside-toplevel
from xpra.platform import program_context
from xpra.platform.gui import init, set_default_icon
from xpra.gtk.gtk_util import init_display_source
from xpra.gtk.util import init_display_source
with program_context("Xpra-Bug-Report", "Xpra Bug Report"):
from xpra.log import enable_color
enable_color()
Expand Down
4 changes: 2 additions & 2 deletions xpra/gtk/dialogs/confirm_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from gi.repository import Gtk # @UnresolvedImport

from xpra.gtk.signals import register_os_signals
from xpra.gtk.gtk_util import add_close_accel, color_parse
from xpra.gtk.widget import label, modify_fg
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import label, modify_fg, color_parse
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.platform.gui import force_focus
from xpra.os_util import get_util_logger
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/desktop_greeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from xpra.os_util import POSIX, OSX, which
from xpra.gtk.signals import register_os_signals
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import imagebutton, label, setfont
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.util.thread import start_thread
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/open_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from xpra.util.child_reaper import getChildReaper
from xpra.net.file_transfer import ACCEPT, OPEN, DENY
from xpra.util.stats import std_unit, std_unit_dec
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import scaled_image, label
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.platform.gui import set_window_progress
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/pass_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from xpra.os_util import get_util_logger
from xpra.gtk.signals import register_os_signals
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import label
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.platform.gui import force_focus
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from gi.repository import Gtk, GLib, GdkPixbuf # @UnresolvedImport

from xpra.net.qrcode import qrencode
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.log import Logger

log = Logger("menu")
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/qrcode_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from xpra.util.env import envbool
from xpra.os_util import SIGNAMES, bytestostr
from xpra.exit_codes import ExitCode
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import label
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.gtk.signals import install_signal_handlers
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/server_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from xpra.gtk.signals import register_os_signals
from xpra.util.types import typedict, AdHocStruct
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import scaled_image, label
from xpra.gtk.pixbuf import get_icon_pixbuf, get_pixbuf_from_data
from xpra.log import Logger, enable_debug_for
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/session_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from xpra.util.stats import values_to_scaled_values, values_to_diff_scaled_values, to_std_unit, std_unit_dec, std_unit
from xpra.client.gui import features
from xpra.client.base.gobject_client import InfoTimerClient
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.graph import make_graph_imagesurface
from xpra.gtk.widget import imagebutton, title_box, slabel
from xpra.gtk.pixbuf import get_icon_pixbuf
Expand Down
4 changes: 2 additions & 2 deletions xpra/gtk/dialogs/sessions_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from xpra.exit_codes import exit_str
from xpra.scripts.config import OPTION_TYPES
from xpra.scripts.main import get_command_args
from xpra.gtk.gtk_util import add_close_accel, color_parse
from xpra.gtk.widget import scaled_image, imagebutton, label, modify_fg, IgnoreWarningsContext
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import scaled_image, imagebutton, label, modify_fg, IgnoreWarningsContext, color_parse
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.gtk.signals import register_os_signals
from xpra.net.common import DEFAULT_PORTS
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/show_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from gi.repository import Gtk, GLib # @UnresolvedImport

from xpra.os_util import SIGNAMES
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import label
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.gtk.signals import install_signal_handlers
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/splash.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from xpra.os_util import SIGNAMES, OSX, WIN32
from xpra.exit_codes import ExitCode, ExitValue
from xpra.common import SPLASH_EXIT_DELAY
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import label, ignorewarnings
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.gtk.signals import install_signal_handlers
Expand Down
4 changes: 2 additions & 2 deletions xpra/gtk/dialogs/start_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from gi.repository import Gtk, Gdk, GLib # @UnresolvedImport

from xpra.gtk.signals import register_os_signals
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import imagebutton, label, setfont
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.util.str_fn import repr_ellipsized
Expand Down Expand Up @@ -1193,7 +1193,7 @@ def main(options=None) -> int: # pragma: no cover
from xpra.platform import program_context
from xpra.log import enable_color
from xpra.platform.gui import init, ready
from xpra.gtk.gtk_util import init_display_source
from xpra.gtk.util import init_display_source
with program_context("xpra-start-gui", "Xpra Start GUI"):
enable_color()
init_display_source()
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/start_new_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
gi.require_version("Gtk", "3.0") # @UndefinedVariable
from gi.repository import Gtk # @UnresolvedImport

from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import scaled_image, label
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.gtk.signals import register_os_signals
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from xpra.util.child_reaper import getChildReaper
from xpra.gtk.signals import register_os_signals
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import imagebutton, label, IgnoreWarningsContext
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.platform.paths import get_python_execfile_command, get_python_exec_command
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/dialogs/update_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from gi.repository import GLib, Gtk # @UnresolvedImport

from xpra.platform.gui import init as gui_init, force_focus
from xpra.gtk.gtk_util import add_close_accel
from xpra.gtk.window import add_close_accel
from xpra.gtk.widget import scaled_image, label
from xpra.gtk.pixbuf import get_icon_pixbuf
from xpra.log import Logger, enable_debug_for
Expand Down
Loading

0 comments on commit 7883acc

Please sign in to comment.