[pygobject/wip/jfelder/gtk4-toolbutton: 2/3] gtk overrides: Drop Gtk.main for Gtk4
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/wip/jfelder/gtk4-toolbutton: 2/3] gtk overrides: Drop Gtk.main for Gtk4
- Date: Mon, 16 Mar 2020 20:40:11 +0000 (UTC)
commit 1f8f3617cb7135fd399797f939f94e1279e1a1c0
Author: Jean Felder <jean felder gmail com>
Date: Mon Mar 16 20:46:17 2020 +0100
gtk overrides: Drop Gtk.main for Gtk4
It has been removed (gtk commit
4dd780a96b1d37903ab88a4ae4536329cd9e164e)
The associated test is skipped for Gtk 4.
gi/overrides/Gtk.py | 24 +++++++++++-------------
tests/test_ossig.py | 3 +++
tests/test_overrides_gtk.py | 1 +
3 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 74555d16..b4213642 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -1614,22 +1614,20 @@ if Gtk._version == '3.0':
Menu = override(Menu)
__all__.append('Menu')
-_Gtk_main_quit = Gtk.main_quit
-
-
-@override(Gtk.main_quit)
-def main_quit(*args):
- _Gtk_main_quit()
-
+if Gtk._version in ("2.0", "3.0"):
+ _Gtk_main_quit = Gtk.main_quit
-_Gtk_main = Gtk.main
+ @override(Gtk.main_quit)
+ def main_quit(*args):
+ _Gtk_main_quit()
+ _Gtk_main = Gtk.main
-@override(Gtk.main)
-def main(*args, **kwargs):
- with register_sigint_fallback(Gtk.main_quit):
- with wakeup_on_signal():
- return _Gtk_main(*args, **kwargs)
+ @override(Gtk.main)
+ def main(*args, **kwargs):
+ with register_sigint_fallback(Gtk.main_quit):
+ with wakeup_on_signal():
+ return _Gtk_main(*args, **kwargs)
if Gtk._version in ("2.0", "3.0"):
diff --git a/tests/test_ossig.py b/tests/test_ossig.py
index b59f2f5a..9340c02b 100644
--- a/tests/test_ossig.py
+++ b/tests/test_ossig.py
@@ -24,8 +24,10 @@ from contextlib import contextmanager
try:
from gi.repository import Gtk
+ Gtk_version = Gtk._version
except ImportError:
Gtk = None
+ Gtk_version = None
from gi.repository import Gio, GLib
from gi._ossighelper import wakeup_on_signal, register_sigint_fallback
@@ -90,6 +92,7 @@ class TestOverridesWakeupOnAlarm(unittest.TestCase):
app.run()
@unittest.skipIf(Gtk is None or os.name == "nt", "not on Windows")
+ @unittest.skipIf(Gtk is None or Gtk_version == "4.0", "not in gtk4")
def test_gtk_main(self):
signal.signal(signal.SIGALRM, lambda *args: Gtk.main_quit())
GLib.idle_add(signal.setitimer, signal.ITIMER_REAL, 0.001)
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 0b4eae60..6bf9350f 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -806,6 +806,7 @@ class TestGtk(unittest.TestCase):
self.assertEqual(stock_item.stock_id, 'gtk-ok')
self.assertEqual(Gtk.stock_lookup('nosuchthing'), None)
+ @unittest.skipIf(Gtk_version == "4.0", "not in gtk4")
def test_gtk_main(self):
# with no arguments
GLib.idle_add(Gtk.main_quit)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]