summaryrefslogtreecommitdiffstats
path: root/caribou/import_from_gi.repository.patch
blob: c9f04f6af874049f4c7cb25e7b301c5c141bb3b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
From 1857bd953dc02ac781991f0b97b488b4f300b01f Mon Sep 17 00:00:00 2001
From: Alexandre Rostovtsev <tetromino@gmail.com>
Date: Tue, 30 Aug 2011 03:05:11 +0000
Subject: Use GLib, GObject from gi.repository instead of glib, gobject

Use GLib and GObject from gi.repository instead of glib and gobject
modules for compatibility with pygobject-3.0. Otherwise, when running on
a system with pygobject-2.0 and pygobject-3.0 installed, caribou-preferences
fails with

ImportError: could not import gobject (error was: ImportError('When
using gi.repository you must not import static modules like "gobject".
Please change all occurrences of "import gobject" to "from gi.repository
import GObject".',))

https://bugzilla.gnome.org/show_bug.cgi?id=657666
---
diff --git a/bin/antler-keyboard.in b/bin/antler-keyboard.in
index 1b0c450..ce64128 100755
--- a/bin/antler-keyboard.in
+++ b/bin/antler-keyboard.in
@@ -25,7 +25,7 @@ exec_prefix=@exec_prefix@
 
 if [ $script_dir == "@libexecdir@" ]
 then
-  datadir="$(@PYTHON@ -c "import glib; print ':'.join(glib.get_system_data_dirs())")"
+  datadir="$(@PYTHON@ -c "from gi.repository import GLib; print ':'.join(GLib.get_system_data_dirs())")"
   export PYTHONPATH="${prefix}/lib/python@PYTHON_VERSION@/site-packages${PYTHONPATH:+:$PYTHONPATH}"
   export GI_TYPELIB_PATH="@libdir@/girepository-1.0${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}"
   export LD_LIBRARY_PATH="@libdir@${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
diff --git a/bin/caribou-preferences.in b/bin/caribou-preferences.in
index 6aae29e..57772e7 100755
--- a/bin/caribou-preferences.in
+++ b/bin/caribou-preferences.in
@@ -25,7 +25,7 @@ exec_prefix=@exec_prefix@
 
 if [ $script_dir == "@bindir@" ]
 then
-  datadir="$(@PYTHON@ -c "import glib; print ':'.join(glib.get_system_data_dirs())")"
+  datadir="$(@PYTHON@ -c "from gi.repository import GLib; print ':'.join(GLib.get_system_data_dirs())")"
   export PYTHONPATH="@prefix@/lib/python@PYTHON_VERSION@/site-packages${PYTHONPATH:+:$PYTHONPATH}"
   export GI_TYPELIB_PATH="@libdir@/girepository-1.0${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}"
   export LD_LIBRARY_PATH="@libdir@${LD_LIBRARY_PATH:+:LD_LIBRARY_PATH}"
diff --git a/caribou/antler/keyboard_view.py b/caribou/antler/keyboard_view.py
index 3e09d94..350be91 100644
--- a/caribou/antler/keyboard_view.py
+++ b/caribou/antler/keyboard_view.py
@@ -3,9 +3,9 @@ from caribou.settings import CaribouSettings
 from antler_settings import AntlerSettings
 from gi.repository import Gtk
 from gi.repository import Gdk
+from gi.repository import GObject
+from gi.repository import GLib
 from gi.repository import Caribou
-import gobject
-import glib
 import os
 from math import ceil
 
@@ -30,7 +30,7 @@ PRETTY_LABELS = {
 
 class AntlerKey(Gtk.Button):
     def __init__(self, key, spacing=0):
-        gobject.GObject.__init__(self)
+        GObject.GObject.__init__(self)
         self.caribou_key = key.weak_ref()
         self.set_label(self._get_key_label())
         self._spacing = spacing
@@ -71,7 +71,7 @@ class AntlerKey(Gtk.Button):
             if not unichar.isspace() and unichar != u'\x00':
                 label = unichar
 
-        return "<b>%s</b>" % glib.markup_escape_text(label.encode('utf-8'))
+        return "<b>%s</b>" % GLib.markup_escape_text(label.encode('utf-8'))
 
     def _caribou_key_pressed (self, key, _key):
         self.set_state_flags(Gtk.StateFlags.ACTIVE, False)
@@ -106,7 +106,7 @@ class AntlerKey(Gtk.Button):
 
 class AntlerSubLevel(Gtk.Window):
     def __init__(self, key):
-        gobject.GObject.__init__(self, type=Gtk.WindowType.POPUP)
+        GObject.GObject.__init__(self, type=Gtk.WindowType.POPUP)
 
         self.set_decorated(False)
         self.set_resizable(False)
@@ -138,7 +138,7 @@ class AntlerLayout(Gtk.Box):
     KEY_SPAN = 4
 
     def __init__(self, level=None, spacing=6):
-        gobject.GObject.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
+        GObject.GObject.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
         self.set_spacing(12)
         self._columns = []
         self._keys_map = {}
@@ -243,7 +243,7 @@ class AntlerLayout(Gtk.Box):
 
 class AntlerKeyboardView(Gtk.Notebook):
     def __init__(self, keyboard_type):
-        gobject.GObject.__init__(self)
+        GObject.GObject.__init__(self)
         settings = AntlerSettings()
         self.set_show_tabs(False)
 
@@ -253,7 +253,7 @@ class AntlerKeyboardView(Gtk.Notebook):
         self._app_css_provider = Gtk.CssProvider()
         self._load_style(
             self._app_css_provider, "style.css",
-            [glib.get_user_data_dir()] + list(glib.get_system_data_dirs()))
+            [GLib.get_user_data_dir()] + list(GLib.get_system_data_dirs()))
 
         if not use_system.value:
             Gtk.StyleContext.add_provider_for_screen(
@@ -262,7 +262,7 @@ class AntlerKeyboardView(Gtk.Notebook):
 
         self._user_css_provider = Gtk.CssProvider()
         self._load_style(self._user_css_provider, "user-style.css",
-                         [glib.get_user_data_dir()])
+                         [GLib.get_user_data_dir()])
         Gtk.StyleContext.add_provider_for_screen(
                 Gdk.Screen.get_default(), self._user_css_provider,
                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 1)
diff --git a/caribou/antler/main.py b/caribou/antler/main.py
index 6bd3932..fab1c60 100644
--- a/caribou/antler/main.py
+++ b/caribou/antler/main.py
@@ -1,17 +1,16 @@
-from gi.repository import Caribou
+from gi.repository import Caribou, GObject
 from window import AntlerWindowEntry
 from keyboard_view import AntlerKeyboardView
-import gobject
 import sys
 
 class AntlerKeyboardService(Caribou.KeyboardService):
     def __init__(self):
-        gobject.GObject.__init__(self)
+        GObject.GObject.__init__(self)
         self.register_keyboard("Antler")
         self.window = AntlerWindowEntry(AntlerKeyboardView)
 
     def run(self):
-        loop = gobject.MainLoop()
+        loop = GObject.MainLoop()
         loop.run()
 
     def do_show(self, timestamp):
diff --git a/caribou/antler/window.py b/caribou/antler/window.py
index a72203e..f7c5fa5 100644
--- a/caribou/antler/window.py
+++ b/caribou/antler/window.py
@@ -22,24 +22,24 @@
 
 from gi.repository import Gtk
 from gi.repository import Gdk
+from gi.repository import GObject
 from gi.repository import Clutter
 from antler_settings import AntlerSettings
 from math import sqrt
 import os
 import sys
-import gobject
 
 Clutter.init("antler")
 
 
 class AnimatedWindowBase(Gtk.Window, Clutter.Animatable):
     __gproperties__ = {
-        'antler-window-position' : (gobject.TYPE_PYOBJECT, 'Window position',
+        'antler-window-position' : (GObject.TYPE_PYOBJECT, 'Window position',
                                       'Window position in X, Y coordinates',
-                                      gobject.PARAM_READWRITE)
+                                      GObject.PARAM_READWRITE)
         }
     def __init__(self):
-        gobject.GObject.__init__(self, type=Gtk.WindowType.POPUP)
+        GObject.GObject.__init__(self, type=Gtk.WindowType.POPUP)
         # animation
         self._stage = Clutter.Stage.get_default()
         self._move_animation = None
@@ -71,7 +71,7 @@ class AnimatedWindowBase(Gtk.Window, Clutter.Animatable):
             return True
         if prop_name == "opacity":
             opacity = initial_value + ((final_value - initial_value) * progress)
-            gobject.idle_add(lambda: self.set_opacity(opacity))
+            GObject.idle_add(lambda: self.set_opacity(opacity))
 
             return True
         else:
@@ -132,9 +132,9 @@ class ProximityWindowBase(AnimatedWindowBase):
         self.min_alpha = min_alpha
         if self.max_alpha != self.min_alpha:
             if self._poll_tid == 0:
-                self._poll_tid = gobject.timeout_add(100, self._proximity_check)
+                self._poll_tid = GObject.timeout_add(100, self._proximity_check)
         elif self._poll_tid != 0:
-            gobject.source_remove(self._poll_tid)
+            GObject.source_remove(self._poll_tid)
 
     def _onmapped(self, obj, event, settings):
         if self.is_composited():
diff --git a/caribou/settings/preferences_window.py b/caribou/settings/preferences_window.py
index 55f9fca..541ecb5 100644
--- a/caribou/settings/preferences_window.py
+++ b/caribou/settings/preferences_window.py
@@ -20,7 +20,7 @@
 
 from caribou.settings.setting_types import *
 
-import gobject
+from gi.repository import GObject
 from gi.repository import Gdk
 from gi.repository import Gtk
 
@@ -230,7 +230,7 @@ class PreferencesDialog(Gtk.Dialog, AbstractPreferencesUI):
     __gtype_name__ = "PreferencesDialog"
 
     def __init__(self, settings_manager):
-        gobject.GObject.__init__(self)
+        GObject.GObject.__init__(self)
         self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)
         self.set_border_width(6)
         self.set_title(settings_manager.groups.label)
@@ -243,7 +243,7 @@ class PreferencesWindow(Gtk.Window, AbstractPreferencesUI):
     __gtype_name__ = "PreferencesWindow"
 
     def __init__(self, settings_manager):
-        gobject.GObject.__init__(self)
+        GObject.GObject.__init__(self)
         self.set_border_width(6)
         self.set_title(settings_manager.groups.label)
 
diff --git a/caribou/settings/setting_types.py b/caribou/settings/setting_types.py
index 66fb0f0..c4af2a6 100644
--- a/caribou/settings/setting_types.py
+++ b/caribou/settings/setting_types.py
@@ -1,5 +1,4 @@
-import gobject
-from gi.repository import GLib
+from gi.repository import GLib, GObject
 
 ENTRY_DEFAULT=0
 ENTRY_COMBO=1
@@ -10,17 +9,17 @@ ENTRY_SLIDER=5
 ENTRY_CHECKBOX=6
 ENTRY_RADIO=7
 
-class Setting(gobject.GObject):
+class Setting(GObject.GObject):
     __gsignals__ = {'value-changed' :
-                    (gobject.SIGNAL_RUN_FIRST,
-                     gobject.TYPE_NONE, 
-                     (gobject.TYPE_PYOBJECT,)),
+                    (GObject.SIGNAL_RUN_FIRST,
+                     GObject.TYPE_NONE, 
+                     (GObject.TYPE_PYOBJECT,)),
                     'sensitivity-changed' :
-                    (gobject.SIGNAL_RUN_FIRST,
-                     gobject.TYPE_NONE, 
-                     (gobject.TYPE_BOOLEAN,))}
+                    (GObject.SIGNAL_RUN_FIRST,
+                     GObject.TYPE_NONE, 
+                     (GObject.TYPE_BOOLEAN,))}
     def __init__(self, name, label, children=[]):
-        gobject.GObject.__init__(self)
+        GObject.GObject.__init__(self)
         self.name = name
         self.label = label
         self.children = children
@@ -129,8 +128,8 @@ class IntegerSetting(ValueSetting):
     variant_type = 'i'
     entry_type = ENTRY_SPIN
     def __init__(self, *args, **kwargs):
-        self.min = kwargs.pop('min', gobject.G_MININT)
-        self.max = kwargs.pop('max', gobject.G_MAXINT)
+        self.min = kwargs.pop('min', GObject.G_MININT)
+        self.max = kwargs.pop('max', GObject.G_MAXINT)
         ValueSetting.__init__(self, *args, **kwargs)
 
     def convert_value(self, val):
@@ -140,8 +139,8 @@ class FloatSetting(ValueSetting):
     variant_type = 'd'
     entry_type = ENTRY_SPIN
     def __init__(self, *args, **kwargs):
-        self.min = kwargs.pop('min', gobject.G_MINFLOAT)
-        self.max = kwargs.pop('max', gobject.G_MAXFLOAT)
+        self.min = kwargs.pop('min', GObject.G_MINFLOAT)
+        self.max = kwargs.pop('max', GObject.G_MAXFLOAT)
         ValueSetting.__init__(self, *args, **kwargs)
 
     def convert_value(self, val):
--
cgit v0.9.0.2