Remove support of GTK+ 2.0
issue6932 review35761002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Remove support of GTK+ 2.0
|
||||
* Add icons on Many2One in editable tree
|
||||
* Use translated values when exporting Reference and Selection fields
|
||||
|
||||
|
||||
+5
-3
@@ -17,12 +17,14 @@ if hasattr(sys, 'frozen'):
|
||||
prefix = os.path.dirname(sys.executable)
|
||||
os.environ['GTK_EXE_PREFIX'] = prefix
|
||||
os.environ['GTK_DATA_PREFIX'] = prefix
|
||||
os.environ['XDG_DATA_DIRS'] = os.path.join(prefix, 'share')
|
||||
etc = os.path.join(prefix, 'etc')
|
||||
os.environ['GTK2_RC_FILES'] = os.path.join(etc, 'gtk-2.0', 'gtkrc')
|
||||
os.environ['GDK_PIXBUF_MODULE_FILE'] = os.path.join(
|
||||
etc, 'gtk-2.0', 'gdk-pixbuf.loaders')
|
||||
etc, 'gtk-3.0', 'gdk-pixbuf.loaders')
|
||||
os.environ['GTK_IM_MODULE_FILE'] = os.path.join(
|
||||
etc, 'gtk-2.0', 'gtk.immodules')
|
||||
etc, 'gtk-3.0', 'gtk.immodules')
|
||||
os.environ['GI_TYPELIB_PATH'] = os.path.join(
|
||||
prefix, 'lib', 'girepository-1.0')
|
||||
if sys.platform == 'win32':
|
||||
# cx_freeze >= 5 put python modules under lib directory
|
||||
sys.path.append(os.path.join(prefix, 'lib'))
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# GTK+ Input Method Modules file
|
||||
# Automatically generated file, do not edit
|
||||
# Created by gtk-query-immodules-2.0 from gtk+-2.24.30
|
||||
#
|
||||
# ModulesPath = @executable_path/lib/gtk-2.0/immodules
|
||||
#
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-am-et.so"
|
||||
"am_et" "Amharic (EZ+)" "gtk20" "@executable_path/share/locale" "am"
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-cedilla.so"
|
||||
"cedilla" "Cedilla" "gtk20" "@executable_path/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa"
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-cyrillic-translit.so"
|
||||
"cyrillic_translit" "Cyrillic (Transliterated)" "gtk20" "@executable_path/share/locale" ""
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-inuktitut.so"
|
||||
"inuktitut" "Inuktitut (Transliterated)" "gtk20" "@executable_path/share/locale" "iu"
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-ipa.so"
|
||||
"ipa" "IPA" "gtk20" "@executable_path/share/locale" ""
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-multipress.so"
|
||||
"multipress" "Multipress" "gtk20" "" ""
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-quartz.so"
|
||||
"quartz" "Mac OS X Quartz" "gtk20" "@executable_path/share/locale" "ja:ko:zh:*"
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-thai.so"
|
||||
"thai" "Thai-Lao" "gtk20" "@executable_path/share/locale" "lo:th"
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-ti-er.so"
|
||||
"ti_er" "Tigrigna-Eritrean (EZ+)" "gtk20" "@executable_path/share/locale" "ti"
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-ti-et.so"
|
||||
"ti_et" "Tigrigna-Ethiopian (EZ+)" "gtk20" "@executable_path/share/locale" "ti"
|
||||
|
||||
"@executable_path/lib/gtk-2.0/2.10.0/immodules/im-viqr.so"
|
||||
"viqr" "Vietnamese (VIQR)" "gtk20" "@executable_path/share/locale" "vi"
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
include "../../share/themes/Clearlooks/gtk-2.0/gtkrc"
|
||||
include "../../share/themes/Mac/gtk-2.0-key/gtkrc"
|
||||
@@ -0,0 +1,40 @@
|
||||
# GTK+ Input Method Modules file
|
||||
# Automatically generated file, do not edit
|
||||
# Created by gtk-query-immodules-3.0 from gtk+-3.22.26
|
||||
#
|
||||
# ModulesPath = @executable_path/lib/gtk-3.0/3.0.0/x86_64-apple-darwin16.7.0/immodules:@executable_path/lib/gtk-3.0/3.0.0/immodules:@executable_path/lib/gtk-3.0/x86_64-apple-darwin16.7.0/immodules:@executable_path/lib/gtk-3.0/immodules
|
||||
#
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-am-et.so"
|
||||
"am_et" "Amharic (EZ+)" "gtk30" "@executable_path/share/locale" "am"
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-cedilla.so"
|
||||
"cedilla" "Cedilla" "gtk30" "@executable_path/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa"
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-cyrillic-translit.so"
|
||||
"cyrillic_translit" "Cyrillic (Transliterated)" "gtk30" "@executable_path/share/locale" ""
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-inuktitut.so"
|
||||
"inuktitut" "Inuktitut (Transliterated)" "gtk30" "@executable_path/share/locale" "iu"
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-ipa.so"
|
||||
"ipa" "IPA" "gtk30" "@executable_path/share/locale" ""
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-multipress.so"
|
||||
"multipress" "Multipress" "gtk30" "" ""
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-quartz.so"
|
||||
"quartz" "Mac OS X Quartz" "gtk30" "@executable_path/share/locale" "ja:ko:zh:*"
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-thai.so"
|
||||
"thai" "Thai-Lao" "gtk30" "@executable_path/share/locale" "lo:th"
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-ti-er.so"
|
||||
"ti_er" "Tigrigna-Eritrean (EZ+)" "gtk30" "@executable_path/share/locale" "ti"
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-ti-et.so"
|
||||
"ti_et" "Tigrigna-Ethiopian (EZ+)" "gtk30" "@executable_path/share/locale" "ti"
|
||||
|
||||
"@executable_path/lib/gtk-3.0/3.0.0/immodules/im-viqr.so"
|
||||
"viqr" "Vietnamese (VIQR)" "gtk30" "@executable_path/share/locale" "vi"
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ Prerequisites
|
||||
-------------
|
||||
|
||||
* Python 2.7.9 or later (http://www.python.org/)
|
||||
* gtk+ 2.6 or later and pygtk 2.22 or later (http://www.pygtk.org/)
|
||||
* gtk+ 3.20 or later and py-gobject3 (http://www.gtk.org/)
|
||||
* librsvg (http://librsvg.sourceforge.net/)
|
||||
* python-dateutil (http://labix.org/python-dateutil)
|
||||
|
||||
+78
-36
@@ -1,49 +1,91 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import user
|
||||
from subprocess import Popen, PIPE
|
||||
from subprocess import Popen, PIPE, check_call
|
||||
|
||||
from cx_Freeze import setup, Executable
|
||||
|
||||
include_files = [
|
||||
('tryton/data', 'data'),
|
||||
('tryton/plugins', 'plugins'),
|
||||
(os.path.join(sys.prefix, 'lib/gtk-2.0'), 'lib/gtk-2.0'),
|
||||
(os.path.join(sys.prefix, 'lib/gdk-pixbuf-2.0'), 'lib/gdk-pixbuf-2.0'),
|
||||
(os.path.join(sys.prefix, 'share/locale'), 'share/locale'),
|
||||
('%s/gtk-2.0/gtkrc' % sys.platform, 'etc/gtk-2.0/gtkrc'),
|
||||
('%s/gtk-2.0/gtk.immodules' % sys.platform, 'etc/gtk-2.0/gtk.immodules'),
|
||||
('%s/gtk-2.0/gdk-pixbuf.loaders' % sys.platform,
|
||||
'etc/gtk-2.0/gdk-pixbuf.loaders'),
|
||||
(os.path.join('tryton', 'data'), 'data'),
|
||||
(os.path.join('tryton', 'plugins'), 'plugins'),
|
||||
(os.path.join(sys.prefix, 'lib', 'gtk-3.0'),
|
||||
os.path.join('lib', 'gtk-3.0')),
|
||||
(os.path.join(sys.prefix, 'lib', 'gdk-pixbuf-2.0'),
|
||||
os.path.join('lib', 'gdk-pixbuf-2.0')),
|
||||
(os.path.join(sys.prefix, 'share', 'locale'),
|
||||
os.path.join('share', 'locale')),
|
||||
(os.path.join(sys.prefix, 'share', 'icons', 'Adwaita'),
|
||||
os.path.join('share', 'icons', 'Adwaita')),
|
||||
(os.path.join(sys.platform, 'gtk-3.0', 'gtk.immodules'),
|
||||
os.path.join('etc', 'gtk-3.0', 'gtk.immodules')),
|
||||
(os.path.join(sys.platform, 'gtk-3.0', 'gdk-pixbuf.loaders'),
|
||||
os.path.join('etc', 'gtk-3.0', 'gdk-pixbuf.loaders')),
|
||||
]
|
||||
|
||||
if sys.platform == 'win32':
|
||||
include_files.extend([
|
||||
(os.path.join(sys.prefix, 'share/themes/MS-Windows'),
|
||||
'share/themes/MS-Windows'),
|
||||
(os.path.join(sys.prefix, 'ssl'), 'etc/ssl'),
|
||||
])
|
||||
dll_paths = os.getenv('PATH', os.defpath).split(os.pathsep)
|
||||
required_dlls = [
|
||||
'librsvg-2-2.dll',
|
||||
'libcroco-0.6-3.dll',
|
||||
]
|
||||
for dll in required_dlls:
|
||||
for path in dll_paths:
|
||||
path = os.path.join(path, dll)
|
||||
if os.path.isfile(path):
|
||||
break
|
||||
else:
|
||||
raise Exception('%s not found' % dll)
|
||||
include_files.append((path, dll))
|
||||
required_gi_namespaces = [
|
||||
'Atk-1.0',
|
||||
'GLib-2.0',
|
||||
'GModule-2.0',
|
||||
'GObject-2.0',
|
||||
'Gdk-3.0',
|
||||
'GdkPixbuf-2.0',
|
||||
'Gio-2.0',
|
||||
'GooCanvas-2.0',
|
||||
'Gtk-3.0',
|
||||
'Pango-1.0',
|
||||
'PangoCairo-1.0',
|
||||
'PangoFT2-1.0',
|
||||
'Rsvg-2.0',
|
||||
'cairo-1.0',
|
||||
'fontconfig-2.0',
|
||||
'freetype2-2.0',
|
||||
]
|
||||
|
||||
elif sys.platform == 'darwin':
|
||||
include_files.extend([
|
||||
(os.path.join(sys.prefix, 'share/themes/Clearlooks'),
|
||||
'share/themes/Clearlooks'),
|
||||
(os.path.join(sys.prefix, 'share/themes/Mac'),
|
||||
'share/themes/Mac'),
|
||||
|
||||
def replace_path(match):
|
||||
libs = [os.path.basename(p) for p in match.group(1).split(',')]
|
||||
required_libs.update(libs)
|
||||
if sys.platform == 'darwin':
|
||||
libs = [os.path.join('@executable_path', l) for l in libs]
|
||||
return 'shared-library="%s"' % ','.join(libs)
|
||||
lib_re = re.compile(r'shared-library="([^\"]*)"')
|
||||
|
||||
required_libs = set()
|
||||
temp = tempfile.mkdtemp()
|
||||
for ns in required_gi_namespaces:
|
||||
gir_name = '%s.gir' % ns
|
||||
gir_file = os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name)
|
||||
gir_tmp = os.path.join(temp, gir_name)
|
||||
with open(gir_file, 'r') as src, open(gir_tmp, 'w') as dst:
|
||||
for line in src:
|
||||
dst.write(lib_re.sub(replace_path, line))
|
||||
typefile_name = '%s.typelib' % ns
|
||||
typefile_file = os.path.join('lib', 'girepository-1.0', typefile_name)
|
||||
typefile_tmp = os.path.join(temp, typefile_name)
|
||||
check_call(['g-ir-compiler', '--output=' + typefile_tmp, gir_tmp])
|
||||
|
||||
include_files.append((typefile_tmp, typefile_file))
|
||||
|
||||
if sys.platform == 'win32':
|
||||
required_libs.update([
|
||||
'libcroco-0.6-3.dll',
|
||||
'libepoxy-0.dll',
|
||||
])
|
||||
include_files.append(
|
||||
(os.path.join(sys.prefix, 'ssl'), os.path.join('etc', 'ssl')))
|
||||
lib_path = os.getenv('PATH', os.defpath).split(os.pathsep)
|
||||
else:
|
||||
lib_path = [os.path.join(sys.prefix, 'lib')]
|
||||
for lib in required_libs:
|
||||
for path in lib_path:
|
||||
path = os.path.join(path, lib)
|
||||
if os.path.isfile(path):
|
||||
break
|
||||
else:
|
||||
raise Exception('%s not found' % lib)
|
||||
include_files.append((path, lib))
|
||||
|
||||
version = Popen(
|
||||
'python setup.py --version', stdout=PIPE, shell=True).stdout.read()
|
||||
@@ -56,7 +98,7 @@ setup(name='tryton',
|
||||
'no_compress': True,
|
||||
'include_files': include_files,
|
||||
'silent': True,
|
||||
'packages': ['gtk'],
|
||||
'packages': ['gi'],
|
||||
'include_msvcr': True,
|
||||
},
|
||||
'bdist_mac': {
|
||||
|
||||
@@ -100,7 +100,7 @@ dist = setup(name=name,
|
||||
platforms='any',
|
||||
license='GPL-3',
|
||||
install_requires=[
|
||||
# "pygtk >= 2.6",
|
||||
# "py-gobject3",
|
||||
"python-dateutil",
|
||||
"chardet",
|
||||
],
|
||||
|
||||
+148
-145
@@ -14,161 +14,165 @@ except ImportError:
|
||||
sys.modules['cdecimal'] = decimal
|
||||
import os
|
||||
|
||||
Gdk = None
|
||||
Gtk = None
|
||||
if os.environ.get('GTK_VERSION', '2').startswith('3'):
|
||||
import pygtkcompat
|
||||
pygtkcompat.enable()
|
||||
pygtkcompat.enable_gtk(version='3.0')
|
||||
try:
|
||||
pygtkcompat.enable_goocanvas()
|
||||
except ValueError:
|
||||
pass
|
||||
import pygtkcompat
|
||||
|
||||
from gi.repository import GdkPixbuf
|
||||
_unset = object()
|
||||
pygtkcompat.enable()
|
||||
pygtkcompat.enable_gtk(version='3.0')
|
||||
try:
|
||||
pygtkcompat.enable_goocanvas()
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
Gdk = sys.modules['gtk.gdk']
|
||||
# XXX this prevents isinstance test
|
||||
Gdk.PixbufLoader = GdkPixbuf.PixbufLoader.new
|
||||
from gi.repository import GdkPixbuf
|
||||
_unset = object()
|
||||
|
||||
Gtk = sys.modules['gtk']
|
||||
Gtk.widget_set_default_direction = Gtk.Widget.set_default_direction
|
||||
Gtk.accel_map_add_entry = Gtk.AccelMap.add_entry
|
||||
Gtk.accel_map_load = Gtk.AccelMap.load
|
||||
Gtk.accel_map_save = Gtk.AccelMap.save
|
||||
Gdk = sys.modules['gtk.gdk']
|
||||
# XXX this prevents isinstance test
|
||||
Gdk.PixbufLoader = GdkPixbuf.PixbufLoader.new
|
||||
|
||||
Gtk.PROGRESS_LEFT_TO_RIGHT = (Gtk.Orientation.HORIZONTAL, False)
|
||||
Gtk.PROGRESS_RIGHT_TO_LEFT = (Gtk.Orientation.HORIZONTAL, True)
|
||||
Gtk.PROGRESS_BOTTOM_TO_TOP = (Gtk.Orientation.VERTICAL, True)
|
||||
Gtk.PROGRESS_TOP_TO_BOTTOM = (Gtk.Orientation.VERTICAL, False)
|
||||
Gtk = sys.modules['gtk']
|
||||
Gtk.widget_set_default_direction = Gtk.Widget.set_default_direction
|
||||
Gtk.accel_map_add_entry = Gtk.AccelMap.add_entry
|
||||
Gtk.accel_map_load = Gtk.AccelMap.load
|
||||
Gtk.accel_map_save = Gtk.AccelMap.save
|
||||
|
||||
Gtk.CLIPBOARD_PRIMARY = Gdk.Atom.intern('PRIMARY', True)
|
||||
Gtk.CLIPBOARD_CLIPBOARD = Gdk.Atom.intern('CLIPBOARD', True)
|
||||
Gtk.PROGRESS_LEFT_TO_RIGHT = (Gtk.Orientation.HORIZONTAL, False)
|
||||
Gtk.PROGRESS_RIGHT_TO_LEFT = (Gtk.Orientation.HORIZONTAL, True)
|
||||
Gtk.PROGRESS_BOTTOM_TO_TOP = (Gtk.Orientation.VERTICAL, True)
|
||||
Gtk.PROGRESS_TOP_TO_BOTTOM = (Gtk.Orientation.VERTICAL, False)
|
||||
|
||||
orig_tree_view_column_set_cell_data_func = (
|
||||
Gtk.TreeViewColumn.set_cell_data_func)
|
||||
Gtk.CLIPBOARD_PRIMARY = Gdk.Atom.intern('PRIMARY', True)
|
||||
Gtk.CLIPBOARD_CLIPBOARD = Gdk.Atom.intern('CLIPBOARD', True)
|
||||
|
||||
def set_cell_data_func(self, cell, func, user_data=_unset):
|
||||
def callback(*args):
|
||||
if args[-1] == _unset:
|
||||
args = args[:-1]
|
||||
return func(*args)
|
||||
orig_tree_view_column_set_cell_data_func(
|
||||
self, cell, callback, user_data)
|
||||
Gtk.TreeViewColumn.set_cell_data_func = set_cell_data_func
|
||||
orig_tree_view_column_set_cell_data_func = (
|
||||
Gtk.TreeViewColumn.set_cell_data_func)
|
||||
|
||||
Gtk.TreeViewColumn.get_cell_renderers = Gtk.TreeViewColumn.get_cells
|
||||
|
||||
orig_set_orientation = Gtk.ProgressBar.set_orientation
|
||||
def set_cell_data_func(self, cell, func, user_data=_unset):
|
||||
def callback(*args):
|
||||
if args[-1] == _unset:
|
||||
args = args[:-1]
|
||||
return func(*args)
|
||||
orig_tree_view_column_set_cell_data_func(
|
||||
self, cell, callback, user_data)
|
||||
Gtk.TreeViewColumn.set_cell_data_func = set_cell_data_func
|
||||
|
||||
def set_orientation(self, orientation):
|
||||
orientation, inverted = orientation
|
||||
orig_set_orientation(self, orientation)
|
||||
self.set_inverted(inverted)
|
||||
Gtk.ProgressBar.set_orientation = set_orientation
|
||||
Gtk.TreeViewColumn.get_cell_renderers = Gtk.TreeViewColumn.get_cells
|
||||
|
||||
orig_set_orientation = Gtk.CellRendererProgress.set_orientation
|
||||
orig_set_orientation = Gtk.ProgressBar.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 set_orientation(self, orientation):
|
||||
orientation, inverted = orientation
|
||||
orig_set_orientation(self, orientation)
|
||||
self.set_inverted(inverted)
|
||||
Gtk.ProgressBar.set_orientation = set_orientation
|
||||
|
||||
def popup(self, parent_menu_shell, parent_menu_item, func, button,
|
||||
activate_time, data=None):
|
||||
if func:
|
||||
def position_func(menu, x, y, user_data=None):
|
||||
return func(menu, user_data)
|
||||
else:
|
||||
position_func = None
|
||||
orig_popup(self, parent_menu_shell, parent_menu_item,
|
||||
position_func, data, button, activate_time)
|
||||
Gtk.Menu.popup = popup
|
||||
orig_set_orientation = Gtk.CellRendererProgress.set_orientation
|
||||
|
||||
def get_active_text(self):
|
||||
active = self.get_active()
|
||||
if active < 0:
|
||||
return None
|
||||
else:
|
||||
model = self.get_model()
|
||||
index = self.get_property('entry-text-column')
|
||||
return model[active][index]
|
||||
Gtk.ComboBox.get_active_text = get_active_text
|
||||
|
||||
Gtk.GenericCellRenderer.__gobject_init__ = Gtk.GenericCellRenderer.__init__
|
||||
def set_orientation(self, orientation):
|
||||
orientation, inverted = orientation
|
||||
orig_set_orientation(self, orientation)
|
||||
self.set_property('inverted', inverted)
|
||||
Gtk.CellRendererProgress.set_orientation = set_orientation
|
||||
|
||||
from gi.repository import Pango
|
||||
Pango.SCALE_XX_SMALL = 1 / (1.2 * 1.2 * 1.2)
|
||||
Pango.SCALE_X_SMALL = 1 / (1.2 * 1.2)
|
||||
Pango.SCALE_SMALL = 1 / 1.2
|
||||
Pango.SCALE_MEDIUM = 1
|
||||
Pango.SCALE_LARGE = 1.2
|
||||
Pango.SCALE_X_LARGE = 1.2 * 1.2
|
||||
Pango.SCALE_XX_LARGE = 1.2 * 1.2 * 1.2
|
||||
orig_popup = Gtk.Menu.popup
|
||||
|
||||
def make_attr_constructor(method):
|
||||
def constructor(value, start_index, end_index):
|
||||
attr = getattr(Pango, method)(value)
|
||||
attr.start_index = start_index
|
||||
if end_index >= 0:
|
||||
attr.end_index = end_index
|
||||
return attr
|
||||
return constructor
|
||||
|
||||
def make_attr_2_constructor(method):
|
||||
def constructor(one, two, start_index, end_index):
|
||||
attr = getattr(Pango, method)(one, two)
|
||||
attr.start_index = start_index
|
||||
if end_index >= 0:
|
||||
attr.end_index = end_index
|
||||
return attr
|
||||
return constructor
|
||||
def popup(self, parent_menu_shell, parent_menu_item, func, button,
|
||||
activate_time, data=None):
|
||||
if func:
|
||||
def position_func(menu, x, y, user_data=None):
|
||||
return func(menu, user_data)
|
||||
else:
|
||||
position_func = None
|
||||
orig_popup(self, parent_menu_shell, parent_menu_item,
|
||||
position_func, data, button, activate_time)
|
||||
Gtk.Menu.popup = popup
|
||||
|
||||
def make_attr_3_constructor(method):
|
||||
def constructor(one, two, three, start_index, end_index):
|
||||
attr = getattr(Pango, method)(one, two, three)
|
||||
attr.start_index = start_index
|
||||
if end_index >= 0:
|
||||
attr.end_index = end_index
|
||||
return attr
|
||||
return constructor
|
||||
|
||||
for method, name, constructor in [
|
||||
('attr_language_new', 'AttrLanguage', make_attr_constructor),
|
||||
('attr_family_new', 'AttrFamily', make_attr_constructor),
|
||||
('attr_foreground_new', 'AttrForeground', make_attr_3_constructor),
|
||||
('attr_background_new', 'AttrBackground', make_attr_3_constructor),
|
||||
('attr_size_new', 'AttrSize', make_attr_constructor),
|
||||
('attr_size_new_absolute', 'AttrSizeAbsolute',
|
||||
make_attr_constructor),
|
||||
('attr_style_new', 'AttrStyle', make_attr_constructor),
|
||||
('attr_weight_new', 'AttrWeight', make_attr_constructor),
|
||||
('attr_variant_new', 'AttrVariant', make_attr_constructor),
|
||||
('attr_stretch_new', 'AttrStretch', make_attr_constructor),
|
||||
('attr_font_desc_new', 'AttrFontDesc', make_attr_constructor),
|
||||
('attr_underline_new', 'AttrUnderline', make_attr_constructor),
|
||||
('attr_underline_color_new', 'AttrUnderlineColor',
|
||||
make_attr_3_constructor),
|
||||
('attr_strikethrough_new', 'AttrStrikethrough',
|
||||
make_attr_constructor),
|
||||
('attr_strikethrough_color_new', 'AttrStrikethroughColor',
|
||||
make_attr_3_constructor),
|
||||
('attr_rise_new', 'AttrRise', make_attr_constructor),
|
||||
('attr_scale_new', 'AttrScale', make_attr_constructor),
|
||||
('attr_fallback_new', 'AttrFallback', make_attr_constructor),
|
||||
('attr_letter_spacing_new', 'AttrLetterSpacing',
|
||||
make_attr_constructor),
|
||||
('attr_shape_new', 'AttrShape', make_attr_2_constructor),
|
||||
]:
|
||||
if hasattr(Pango, method):
|
||||
setattr(Pango, name, constructor(method))
|
||||
else:
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
def get_active_text(self):
|
||||
active = self.get_active()
|
||||
if active < 0:
|
||||
return None
|
||||
else:
|
||||
model = self.get_model()
|
||||
index = self.get_property('entry-text-column')
|
||||
return model[active][index]
|
||||
Gtk.ComboBox.get_active_text = get_active_text
|
||||
|
||||
Gtk.GenericCellRenderer.__gobject_init__ = Gtk.GenericCellRenderer.__init__
|
||||
|
||||
from gi.repository import Pango
|
||||
Pango.SCALE_XX_SMALL = 1 / (1.2 * 1.2 * 1.2)
|
||||
Pango.SCALE_X_SMALL = 1 / (1.2 * 1.2)
|
||||
Pango.SCALE_SMALL = 1 / 1.2
|
||||
Pango.SCALE_MEDIUM = 1
|
||||
Pango.SCALE_LARGE = 1.2
|
||||
Pango.SCALE_X_LARGE = 1.2 * 1.2
|
||||
Pango.SCALE_XX_LARGE = 1.2 * 1.2 * 1.2
|
||||
|
||||
|
||||
def make_attr_constructor(method):
|
||||
def constructor(value, start_index, end_index):
|
||||
attr = getattr(Pango, method)(value)
|
||||
attr.start_index = start_index
|
||||
if end_index >= 0:
|
||||
attr.end_index = end_index
|
||||
return attr
|
||||
return constructor
|
||||
|
||||
|
||||
def make_attr_2_constructor(method):
|
||||
def constructor(one, two, start_index, end_index):
|
||||
attr = getattr(Pango, method)(one, two)
|
||||
attr.start_index = start_index
|
||||
if end_index >= 0:
|
||||
attr.end_index = end_index
|
||||
return attr
|
||||
return constructor
|
||||
|
||||
|
||||
def make_attr_3_constructor(method):
|
||||
def constructor(one, two, three, start_index, end_index):
|
||||
attr = getattr(Pango, method)(one, two, three)
|
||||
attr.start_index = start_index
|
||||
if end_index >= 0:
|
||||
attr.end_index = end_index
|
||||
return attr
|
||||
return constructor
|
||||
|
||||
for method, name, constructor in [
|
||||
('attr_language_new', 'AttrLanguage', make_attr_constructor),
|
||||
('attr_family_new', 'AttrFamily', make_attr_constructor),
|
||||
('attr_foreground_new', 'AttrForeground', make_attr_3_constructor),
|
||||
('attr_background_new', 'AttrBackground', make_attr_3_constructor),
|
||||
('attr_size_new', 'AttrSize', make_attr_constructor),
|
||||
('attr_size_new_absolute', 'AttrSizeAbsolute',
|
||||
make_attr_constructor),
|
||||
('attr_style_new', 'AttrStyle', make_attr_constructor),
|
||||
('attr_weight_new', 'AttrWeight', make_attr_constructor),
|
||||
('attr_variant_new', 'AttrVariant', make_attr_constructor),
|
||||
('attr_stretch_new', 'AttrStretch', make_attr_constructor),
|
||||
('attr_font_desc_new', 'AttrFontDesc', make_attr_constructor),
|
||||
('attr_underline_new', 'AttrUnderline', make_attr_constructor),
|
||||
('attr_underline_color_new', 'AttrUnderlineColor',
|
||||
make_attr_3_constructor),
|
||||
('attr_strikethrough_new', 'AttrStrikethrough',
|
||||
make_attr_constructor),
|
||||
('attr_strikethrough_color_new', 'AttrStrikethroughColor',
|
||||
make_attr_3_constructor),
|
||||
('attr_rise_new', 'AttrRise', make_attr_constructor),
|
||||
('attr_scale_new', 'AttrScale', make_attr_constructor),
|
||||
('attr_fallback_new', 'AttrFallback', make_attr_constructor),
|
||||
('attr_letter_spacing_new', 'AttrLetterSpacing',
|
||||
make_attr_constructor),
|
||||
('attr_shape_new', 'AttrShape', make_attr_2_constructor),
|
||||
]:
|
||||
if hasattr(Pango, method):
|
||||
setattr(Pango, name, constructor(method))
|
||||
|
||||
import gtk
|
||||
|
||||
if not hasattr(gtk, 'TreePath'):
|
||||
@@ -227,19 +231,18 @@ CSS = """
|
||||
}
|
||||
"""
|
||||
|
||||
if Gdk and Gtk:
|
||||
screen = Gdk.Screen.get_default()
|
||||
style_context = Gtk.StyleContext()
|
||||
screen = Gdk.Screen.get_default()
|
||||
style_context = Gtk.StyleContext()
|
||||
provider = Gtk.CssProvider()
|
||||
provider.load_from_data(CSS)
|
||||
style_context.add_provider_for_screen(
|
||||
screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||
theme_path = os.path.join(get_config_dir(), 'theme.css')
|
||||
if os.path.exists(theme_path):
|
||||
provider = Gtk.CssProvider()
|
||||
provider.load_from_data(CSS)
|
||||
provider.load_from_path(theme_path)
|
||||
style_context.add_provider_for_screen(
|
||||
screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||
theme_path = os.path.join(get_config_dir(), 'theme.css')
|
||||
if os.path.exists(theme_path):
|
||||
provider = Gtk.CssProvider()
|
||||
provider.load_from_path(theme_path)
|
||||
style_context.add_provider_for_screen(
|
||||
screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
|
||||
class TrytonClient(object):
|
||||
|
||||
Reference in New Issue
Block a user