Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

gtk3: formally drop support for PyGTK, update docs

Formally remove support for PyGTK, and update the docs to reflect this.
Future code should be written in the Python-GObject style only and not rely
on the compatibility layer.

* Drop enable_gtk3=no from the scons stuff.
  Was enabled by default; now we don't support disabling it.
* Remove support for MYPAINT_ENABLE_GTK3=no for the same reason.
  • Loading branch information...
commit 819eae44cd225424e931761ee3697fceeaa78fdb 1 parent 5ebf38a
@achadwick achadwick authored
Showing with 45 additions and 105 deletions.
  1. +3 −22 README.gtk3
  2. +0 −1  SConstruct
  3. +38 −76 gui/pygtkcompat.py
  4. +4 −6 lib/SConscript
View
25 README.gtk3
@@ -17,13 +17,13 @@ nice to see some of the input-related bugs go away. The rough plan is:
but it must be compatible with both PyGTK-GTK2 and pygtkcompat-PyGI+GTK3
in this state, using pygtk naming conventions and import blocks.
-3. [ONGOING] Flip over to GTK3 by default, still using our abstraction layer.
+3. [DONE] Flip over to GTK3 by default, still using our abstraction layer.
New code should be written for PyGI+GTK3.
-4. [TODO] As and when, rip out our pygtkcompat abstractions and/or pygtkcompat
+4. [ONGOING] As and when, rip out our pygtkcompat abstractions and/or pygtkcompat
itself and port individual modules to PyGI+GTK3.
-As of writing, we are at stage 3. The status of this work is tracked in
+As of writing, we are at stage 4. The status of this work is tracked in
https://gna.org/bugs/?19230
@@ -70,22 +70,3 @@ These can be installed on a Debian-based system by running::
libgtk-3-dev python-gi-dev gir1.2-gtk-3.0 python-gi-cairo \
swig scons gettext libpng12-dev liblcms2-dev
-
-Testing and porting to GTK3
----------------------------
-
-See https://live.gnome.org/PyGObject/IntrospectionPorting
-
-We now build in GI+GTK3 mode by default, so if you want to build the binary
-parts of MyPaint for GTK2 and PyGTK, you need to request it explicitly::
-
- $ cd path/to/mypaint-src
- $ scons enable_gtk3=no
-
-Right now, our wrapper modules need be told to run in PyGTK mode as well: set
-the environment variable "MYPAINT_ENABLE_GTK3" to "no" to do this.
-
- $ MYPAINT_ENABLE_GTK3=no ./mypaint
-
-However, note that support for running like this will be dropped shortly.
-
View
1  SConstruct
@@ -33,7 +33,6 @@ opts.Add(BoolVariable('enable_gegl', 'enable GEGL based code in build', False))
opts.Add(BoolVariable('enable_introspection', 'enable GObject introspection support', False))
opts.Add(BoolVariable('enable_docs', 'enable documentation build', False))
opts.Add(BoolVariable('enable_gperftools', 'enable gperftools in build, for profiling', False))
-opts.Add(BoolVariable('enable_gtk3', 'enable gtk3 in mypaintlib', True))
opts.Add(BoolVariable('enable_openmp', 'enable OpenMP for libmypaint', False))
opts.Add('python_binary', 'python executable to build for', default_python_binary)
opts.Add('python_config', 'python-config to used', default_python_config)
View
114 gui/pygtkcompat.py
@@ -1,121 +1,83 @@
+"""PyGTK compatibility layer.
-import os
-USE_GTK3 = True
-if os.environ.get('MYPAINT_ENABLE_GTK3', 1) in ("0", "NO", "no", "N", "n"):
- USE_GTK3 = False
-print USE_GTK3
+To be removed as we migrate to Python-GObject's normal syntax. Do not write new
+code in the PyGTK style now, and feel free to simplify "if pygtkcompat.USE_GTK3"
+clauses in code elsewhere.
-if USE_GTK3:
- import gi
- from gi.repository import Gdk, Gtk, GdkPixbuf
+"""
+
+import gi
+from gi.repository import GObject
+from gi.repository import Gdk
+from gi.repository import Gtk
+from gi.repository import GdkPixbuf
+
+USE_GTK3 = True
class GdkPixbufCompat(object):
@staticmethod
def save(pixbuf, path, type, **kwargs):
-
- if USE_GTK3:
- return pixbuf.savev(path, type, kwargs.keys(), kwargs.values())
- else:
- return pixbuf.save(path, type, kwargs)
+ return pixbuf.savev(path, type, kwargs.keys(), kwargs.values())
@staticmethod
def new(colorspace, has_alpha, bps, width, height):
+ return GdkPixbuf.Pixbuf.new(colorspace, has_alpha, bps, width, height)
- if USE_GTK3:
- return GdkPixbuf.Pixbuf.new(colorspace, has_alpha, bps, width, height)
- else:
- return orig_gtk.gdk.Pixbuf(colorspace, has_alpha, bps, width, height)
class GdkCompat(object):
@staticmethod
def display_get_default():
-
- if USE_GTK3:
- display_manager = Gdk.DisplayManager.get()
- return display_manager.get_default_display()
- else:
- return orig_gtk.gdk.display_get_default()
+ display_manager = Gdk.DisplayManager.get()
+ return display_manager.get_default_display()
@staticmethod
def keymap_get_default():
- if USE_GTK3:
- return Gdk.Keymap.get_default()
- else:
- return orig_gtk.gdk.keymap_get_default()
+ return Gdk.Keymap.get_default()
+
class GtkCompat(object):
@staticmethod
def recent_manager_get_default():
- if USE_GTK3:
- return Gtk.RecentManager.get_default()
- else:
- return orig_gtk.recent_manager_get_default()
+ return Gtk.RecentManager.get_default()
@staticmethod
def settings_get_default():
- if USE_GTK3:
- return Gtk.Settings.get_default()
- else:
- return orig_gtk.settings_get_default()
+ return Gtk.Settings.get_default()
def accel_map_load(self, file):
- if USE_GTK3:
- return Gtk.AccelMap.load(file)
- else:
- return orig_gtk.accel_map_load(file)
+ return Gtk.AccelMap.load(file)
def accel_map_save(self, file):
- if USE_GTK3:
- return Gtk.AccelMap.save(file)
- else:
- return orig_gtk.accel_map_save(file)
+ return Gtk.AccelMap.save(file)
def accel_map_get(self):
- if USE_GTK3:
- return Gtk.AccelMap.get()
- else:
- return orig_gtk.accel_map_get()
+ return Gtk.AccelMap.get()
def accel_map_lookup_entry(self, accel_path):
# Returns "a 2-tuple containing the keyval and modifier mask
# corresponding to accel_path or None if not valid", like the GTK2
# function.
- if USE_GTK3:
- found, accel_key = Gtk.AccelMap.lookup_entry(accel_path)
- if not found:
- return None
- keyval = accel_key.accel_key
- mods = accel_key.accel_mods
- return keyval, mods
- else:
- return orig_gtk.accel_map_lookup_entry(accel_path)
+ found, accel_key = Gtk.AccelMap.lookup_entry(accel_path)
+ if not found:
+ return None
+ keyval = accel_key.accel_key
+ mods = accel_key.accel_mods
+ return keyval, mods
-def get_gobject():
- if USE_GTK3:
- from gi.repository import GObject
- return GObject
- else:
- import gobject
- return gobject
-
-def original_gtk():
- if USE_GTK3:
- print "Using GTK3"
-
- import gi
- import gi.pygtkcompat
- gi.pygtkcompat.enable()
- gi.pygtkcompat.enable_gtk(version='3.0')
- else:
- print "Using GTK2"
+def get_gobject():
+ return GObject
- import pygtk
- pygtk.require('2.0')
+def original_gtk():
+ print "Using GTK3"
+ import gi
+ import gi.pygtkcompat
+ gi.pygtkcompat.enable()
+ gi.pygtkcompat.enable_gtk(version='3.0')
import gtk
return gtk
View
10 lib/SConscript
@@ -54,14 +54,12 @@ env.ParseConfig('pkg-config --cflags --libs lcms2')
pygobject = 'pygobject-2.0'
-if env['enable_gtk3']:
- env.ParseConfig('pkg-config --cflags --libs gtk+-3.0')
- env.Append(CPPDEFINES=['HAVE_GTK3']) # possibly useful while we're porting
- pygobject = 'pygobject-3.0' # keep in step?
-else:
- env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
+env.ParseConfig('pkg-config --cflags --libs gtk+-3.0')
+env.Append(CPPDEFINES=['HAVE_GTK3']) # possibly useful while we're porting
+pygobject = 'pygobject-3.0' # keep in step?
if env['enable_gegl']:
+ # FIXME: this is now lagging.
assert pygobject == 'pygobject-2.0'
env.ParseConfig('pkg-config --cflags --libs gegl-0.2')
env.Append(CPPDEFINES=['HAVE_GEGL'])
Please sign in to comment.
Something went wrong with that request. Please try again.