Port gtk2-devel's gtk-builder-convert to Python 3
This commit is contained in:
parent
547c5c7682
commit
1449a8227d
17
gtk2.spec
17
gtk2.spec
@ -20,7 +20,7 @@
|
||||
Summary: GTK+ graphical user interface library
|
||||
Name: gtk2
|
||||
Version: 2.24.32
|
||||
Release: 5%{?dist}
|
||||
Release: 6%{?dist}
|
||||
License: LGPLv2+
|
||||
URL: http://www.gtk.org
|
||||
#VCS: git:git://git.gnome.org/gtk+#gtk-2-24
|
||||
@ -29,7 +29,9 @@ Source2: update-gtk-immodules
|
||||
Source3: im-cedilla.conf
|
||||
Source4: update-gtk-immodules.1
|
||||
|
||||
Patch1: system-python.patch
|
||||
# Use Python 3 in gtk-builder-convert
|
||||
# Accepted upstream: https://gitlab.gnome.org/GNOME/gtk/merge_requests/1080
|
||||
Patch1: python3.patch
|
||||
# https://bugzilla.gnome.org/show_bug.cgi?id=583273
|
||||
Patch2: icon-padding.patch
|
||||
# https://bugzilla.gnome.org/show_bug.cgi?id=599618
|
||||
@ -57,6 +59,8 @@ BuildRequires: pkgconfig(xcomposite)
|
||||
BuildRequires: pkgconfig(xdamage)
|
||||
BuildRequires: gettext
|
||||
BuildRequires: cups-devel
|
||||
# For setting shebang of gtk-builder-convert:
|
||||
BuildRequires: python3-devel
|
||||
# Bootstrap requirements
|
||||
BuildRequires: gtk-doc
|
||||
BuildRequires: automake
|
||||
@ -234,8 +238,8 @@ cp %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}/update-gtk-immodules
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/X11/xinit/xinput.d
|
||||
cp %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/X11/xinit/xinput.d
|
||||
|
||||
# Explicitly use python2 shebang instead of ambiguous python
|
||||
sed -i -e '/^#!\// s/python$/python2/' $RPM_BUILD_ROOT%{_bindir}/gtk-builder-convert
|
||||
# Use python3 shebang instead of ambiguous python
|
||||
pathfix.py -pn -i %{__python3} $RPM_BUILD_ROOT%{_bindir}/gtk-builder-convert
|
||||
|
||||
# Remove unpackaged files
|
||||
rm $RPM_BUILD_ROOT%{_libdir}/*.la
|
||||
@ -321,6 +325,11 @@ gtk-query-immodules-2.0-%{__isa_bits} --update-cache
|
||||
%doc tmpdocs/examples
|
||||
|
||||
%changelog
|
||||
* Tue Sep 03 2019 Petr Viktorin <pviktori@redhat.com> - 2.24.32-6
|
||||
- Port gtk2-devel's gtk-builder-convert to Python 3
|
||||
https://gitlab.gnome.org/GNOME/gtk/merge_requests/1080
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1737988
|
||||
|
||||
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.24.32-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
|
170
python3.patch
Normal file
170
python3.patch
Normal file
@ -0,0 +1,170 @@
|
||||
Uupstream pull request: https://gitlab.gnome.org/GNOME/gtk/merge_requests/1080
|
||||
|
||||
From 3ff8f70b9686205f0618d7a479fd42a457b90165 Mon Sep 17 00:00:00 2001
|
||||
From: Petr Viktorin <encukou@gmail.com>
|
||||
Date: Tue, 3 Sep 2019 13:54:49 +0200
|
||||
Subject: [PATCH 1/3] Make gtk-builder-convert compatible with Python 3
|
||||
|
||||
- Convert tabs to spaces
|
||||
- Use print as a function, even on Python 2
|
||||
- Output a binary file, or decode for stdout
|
||||
---
|
||||
gtk/gtk-builder-convert | 25 ++++++++++++++-----------
|
||||
1 file changed, 14 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/gtk/gtk-builder-convert b/gtk/gtk-builder-convert
|
||||
index ea737de195..41f7a8c941 100755
|
||||
--- a/gtk/gtk-builder-convert
|
||||
+++ b/gtk/gtk-builder-convert
|
||||
@@ -36,6 +36,7 @@ Examples:
|
||||
|
||||
Report bugs to http://bugzilla.gnome.org/."""
|
||||
|
||||
+from __future__ import print_function
|
||||
import getopt
|
||||
import os
|
||||
import sys
|
||||
@@ -259,7 +260,7 @@ class GtkBuilderConverter(object):
|
||||
for node in objects:
|
||||
self._convert(node.getAttribute("class"), node)
|
||||
if self._get_object(node.getAttribute('id')) is not None:
|
||||
- print "WARNING: duplicate id \"" + node.getAttribute('id') + "\""
|
||||
+ print("WARNING: duplicate id \"" + node.getAttribute('id') + "\"")
|
||||
self.objects[node.getAttribute('id')] = node
|
||||
|
||||
# Convert Gazpachos UI tag
|
||||
@@ -277,8 +278,7 @@ class GtkBuilderConverter(object):
|
||||
# reverse=True):
|
||||
# when we can depend on python 2.4 or higher
|
||||
root_objects = self.root_objects[:]
|
||||
- root_objects.sort(lambda a, b: cmp(b.getAttribute('id'),
|
||||
- a.getAttribute('id')))
|
||||
+ root_objects.sort(key=lambda a: a.getAttribute('id'), reverse=True)
|
||||
for obj in root_objects:
|
||||
self._interface.childNodes.insert(0, obj)
|
||||
|
||||
@@ -461,8 +461,8 @@ class GtkBuilderConverter(object):
|
||||
if signal_name in ['activate', 'toggled']:
|
||||
action.appendChild(signal)
|
||||
else:
|
||||
- print 'Unhandled signal %s::%s' % (node.getAttribute('class'),
|
||||
- signal_name)
|
||||
+ print('Unhandled signal %s::%s' % (node.getAttribute('class'),
|
||||
+ signal_name))
|
||||
|
||||
if not uimgr.childNodes:
|
||||
child = self._dom.createElement('child')
|
||||
@@ -481,8 +481,8 @@ class GtkBuilderConverter(object):
|
||||
for accelerator in get_accelerator_nodes(node):
|
||||
signal_name = accelerator.getAttribute('signal')
|
||||
if signal_name != 'activate':
|
||||
- print 'Unhandled accelerator signal for %s::%s' % (
|
||||
- node.getAttribute('class'), signal_name)
|
||||
+ print('Unhandled accelerator signal for %s::%s' % (
|
||||
+ node.getAttribute('class'), signal_name))
|
||||
continue
|
||||
accelerator.removeAttribute('signal')
|
||||
child.appendChild(accelerator)
|
||||
@@ -747,7 +747,7 @@ def _indent(output):
|
||||
return s.stdout.read()
|
||||
|
||||
def usage():
|
||||
- print __doc__
|
||||
+ print(__doc__)
|
||||
|
||||
def main(args):
|
||||
try:
|
||||
@@ -788,10 +788,13 @@ def main(args):
|
||||
|
||||
xml = _indent(conv.to_xml())
|
||||
if output_filename == "-":
|
||||
- print xml
|
||||
+ if isinstance(xml, str):
|
||||
+ print(xml)
|
||||
+ else:
|
||||
+ print(xml.decode(sys.stdout.encoding))
|
||||
else:
|
||||
- open(output_filename, 'w').write(xml)
|
||||
- print "Wrote", output_filename
|
||||
+ open(output_filename, 'wb').write(xml)
|
||||
+ print("Wrote", output_filename)
|
||||
|
||||
return 0
|
||||
|
||||
--
|
||||
2.22.0
|
||||
|
||||
|
||||
From 4f8efe3ae09ee69657b83399a118b5252f25d830 Mon Sep 17 00:00:00 2001
|
||||
From: Petr Viktorin <encukou@gmail.com>
|
||||
Date: Tue, 3 Sep 2019 14:53:05 +0200
|
||||
Subject: [PATCH 2/3] gtk-builder-convert: Remove compat code for Python 2.3
|
||||
and below
|
||||
|
||||
---
|
||||
gtk/gtk-builder-convert | 13 +------------
|
||||
1 file changed, 1 insertion(+), 12 deletions(-)
|
||||
|
||||
diff --git a/gtk/gtk-builder-convert b/gtk/gtk-builder-convert
|
||||
index 41f7a8c941..a16f83b217 100755
|
||||
--- a/gtk/gtk-builder-convert
|
||||
+++ b/gtk/gtk-builder-convert
|
||||
@@ -48,12 +48,7 @@ DIALOGS = ['GtkDialog',
|
||||
'GtkMessageDialog']
|
||||
WINDOWS = ['GtkWindow'] + DIALOGS
|
||||
|
||||
-# The subprocess is only available in Python 2.4+
|
||||
-try:
|
||||
- import subprocess
|
||||
- subprocess # pyflakes
|
||||
-except ImportError:
|
||||
- subprocess = None
|
||||
+import subprocess
|
||||
|
||||
def get_child_nodes(node):
|
||||
assert node.tagName == 'object'
|
||||
@@ -271,12 +266,6 @@ class GtkBuilderConverter(object):
|
||||
for node in self._dom.getElementsByTagName("accessibility"):
|
||||
self._convert_accessibility(node)
|
||||
|
||||
- # Output the newly created root objects and sort them
|
||||
- # by attribute id
|
||||
- # FIXME: Use sorted(self.root_objects,
|
||||
- # key=lambda n: n.getAttribute('id'),
|
||||
- # reverse=True):
|
||||
- # when we can depend on python 2.4 or higher
|
||||
root_objects = self.root_objects[:]
|
||||
root_objects.sort(key=lambda a: a.getAttribute('id'), reverse=True)
|
||||
for obj in root_objects:
|
||||
--
|
||||
2.22.0
|
||||
|
||||
|
||||
From b5ea5a0cf1f12be5072b9f06d1127a8977414916 Mon Sep 17 00:00:00 2001
|
||||
From: Petr Viktorin <encukou@gmail.com>
|
||||
Date: Tue, 3 Sep 2019 14:56:14 +0200
|
||||
Subject: [PATCH 3/3] gtk-builder-convert: Update bug report URL
|
||||
|
||||
Also, use a newline instead of period at the end to make the
|
||||
URL easy to copy
|
||||
---
|
||||
gtk/gtk-builder-convert | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gtk/gtk-builder-convert b/gtk/gtk-builder-convert
|
||||
index a16f83b217..b1faba822e 100755
|
||||
--- a/gtk/gtk-builder-convert
|
||||
+++ b/gtk/gtk-builder-convert
|
||||
@@ -34,7 +34,8 @@ When OUTPUT is -, write to standard output.
|
||||
Examples:
|
||||
gtk-builder-convert preference.glade preferences.ui
|
||||
|
||||
-Report bugs to http://bugzilla.gnome.org/."""
|
||||
+Report bugs to https://gitlab.gnome.org/GNOME/gtk/issues/new
|
||||
+"""
|
||||
|
||||
from __future__ import print_function
|
||||
import getopt
|
||||
--
|
||||
2.22.0
|
||||
|
@ -1,9 +0,0 @@
|
||||
diff -up gtk+-2.18.2/gtk/gtk-builder-convert.system-python gtk+-2.18.2/gtk/gtk-builder-convert
|
||||
--- gtk+-2.18.2/gtk/gtk-builder-convert.system-python 2009-10-13 15:59:50.423385098 -0400
|
||||
+++ gtk+-2.18.2/gtk/gtk-builder-convert 2009-10-13 16:00:31.876142050 -0400
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/env python
|
||||
+#!/usr/bin/python
|
||||
#
|
||||
# Copyright (C) 2006-2008 Async Open Source
|
||||
# Henrique Romano <henrique@async.com.br>
|
Loading…
Reference in New Issue
Block a user