Fallback to set_property when set_orientation does not exist

CellRendererProgress does not have set_orientation on GTK 2.0
And add same GTK 3.0 compatibility of ProgressBar fix to CellRendererProgress

issue6016
review25811002
This commit is contained in:
Cédric Krier committed 2016-11-08 18:45:25 +01:00
1 parent 25ed202165
commit ec9ebc4813
2 files changed
+12 -1

No files matched your search

+8
View File
@@ -63,6 +63,14 @@ if os.environ.get('GTK_VERSION', '2').startswith('3'):
self.set_inverted(inverted)
Gtk.ProgressBar.set_orientation = set_orientation
orig_set_orientation = Gtk.CellRendererProgress.set_orientation
def set_orientation(self, orientation):
orientation, inverted = orientation
orig_set_orientation(self, orientation)
self.set_property('inverted', inverted)
Gtk.CellRendererProgress.set_orientation = set_orientation
orig_popup = Gtk.Menu.popup
def popup(self, parent_menu_shell, parent_menu_item, func, button,
@@ -848,7 +848,10 @@ class ProgressBar(object):
self.renderer = gtk.CellRendererProgress()
orientation = self.orientations.get(self.attrs.get('orientation',
'left_to_right'), gtk.PROGRESS_LEFT_TO_RIGHT)
self.renderer.set_orientation(orientation)
if hasattr(self.renderer, 'set_orientation'):
self.renderer.set_orientation(orientation)
else:
self.renderer.set_property('orientation', orientation)
self.renderer.set_property('yalign', 0)
@realized