[pygobject/ebassi/gtk4-overrides: 1/4] Simplify the version check for GTK2, GTK3, and GTK4
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/ebassi/gtk4-overrides: 1/4] Simplify the version check for GTK2, GTK3, and GTK4
- Date: Fri, 11 Sep 2020 17:06:11 +0000 (UTC)
commit db7b81812de1ac561cbc7b9408ccf97c2595563b
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Sep 11 17:44:03 2020 +0100
Simplify the version check for GTK2, GTK3, and GTK4
Similar to what the Gdk.py overrides do.
gi/overrides/Gtk.py | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 64a5088e..2bcb6aa1 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -32,6 +32,9 @@ from gi import PyGIDeprecationWarning
Gtk = get_introspection_module('Gtk')
+GTK2 = Gtk._version == '2.0'
+GTK3 = Gtk._version == '3.0'
+GTK4 = Gtk._version == '4.0'
__all__ = []
@@ -39,7 +42,7 @@ __all__ = []
Template = Template
__all__.append('Template')
-if Gtk._version == '2.0':
+if GTK2:
warn_msg = "You have imported the Gtk 2.0 module. Because Gtk 2.0 \
was not designed for use with introspection some of the \
interfaces and API will fail. As such this is not supported \
@@ -224,7 +227,7 @@ Editable = override(Editable)
__all__.append("Editable")
-if Gtk._version in ("2.0", "3.0"):
+if GTK2 or GTK3:
class Action(Gtk.Action):
__init__ = deprecated_init(Gtk.Action.__init__,
arg_names=('name', 'label', 'tooltip', 'stock_id'),
@@ -447,7 +450,7 @@ SizeGroup = override(SizeGroup)
__all__.append('SizeGroup')
-if Gtk._version in ("2.0", "3.0"):
+if GTK2 or GTK3:
class MenuItem(Gtk.MenuItem):
__init__ = deprecated_init(Gtk.MenuItem.__init__,
arg_names=('label',),
@@ -1522,7 +1525,7 @@ Adjustment = override(Adjustment)
__all__.append('Adjustment')
-if Gtk._version in ("2.0", "3.0"):
+if GTK2 or GTK3:
class Table(Gtk.Table, Container):
__init__ = deprecated_init(Gtk.Table.__init__,
arg_names=('n_rows', 'n_columns', 'homogeneous'),
@@ -1576,7 +1579,7 @@ Paned = override(Paned)
__all__.append('Paned')
-if Gtk._version in ("2.0", "3.0"):
+if GTK2 or GTK3:
class Arrow(Gtk.Arrow):
__init__ = deprecated_init(Gtk.Arrow.__init__,
arg_names=('arrow_type', 'shadow_type'),
@@ -1626,14 +1629,14 @@ class TreeModelFilter(Gtk.TreeModelFilter):
TreeModelFilter = override(TreeModelFilter)
__all__.append('TreeModelFilter')
-if Gtk._version == '3.0':
+if GTK3:
class Menu(Gtk.Menu):
def popup(self, parent_menu_shell, parent_menu_item, func, data, button, activate_time):
self.popup_for_device(None, parent_menu_shell, parent_menu_item, func, data, button,
activate_time)
Menu = override(Menu)
__all__.append('Menu')
-if Gtk._version in ("2.0", "3.0"):
+if GTK2 or GTK3:
_Gtk_main_quit = Gtk.main_quit
@override(Gtk.main_quit)
@@ -1649,11 +1652,11 @@ if Gtk._version in ("2.0", "3.0"):
return _Gtk_main(*args, **kwargs)
-if Gtk._version in ("2.0", "3.0"):
+if GTK2 or GTK3:
stock_lookup = strip_boolean_result(Gtk.stock_lookup)
__all__.append('stock_lookup')
-if Gtk._version == "4.0":
+if GTK4:
initialized = Gtk.init_check()
else:
initialized, argv = Gtk.init_check(sys.argv)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]