[caribou/introspection: 2/10] More towards pygi
- From: Eitan Isaacson <eitani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [caribou/introspection: 2/10] More towards pygi
- Date: Thu, 6 Jan 2011 01:04:43 +0000 (UTC)
commit e172bd6f509616a121a83ab33b5fff0b4a14ba36
Author: Eitan Isaacson <eitan monotonous org>
Date: Wed Dec 29 15:49:03 2010 -0800
More towards pygi
bin/caribou.in | 4 ++--
caribou/ui/animation.py | 26 ++++++++++++++------------
caribou/ui/main.py | 12 ++++++------
caribou/ui/opacity.py | 2 +-
caribou/ui/scan.py | 27 ++++++++++++++-------------
caribou/ui/window.py | 41 +++++++++++++++++++++++++++--------------
6 files changed, 64 insertions(+), 48 deletions(-)
---
diff --git a/bin/caribou.in b/bin/caribou.in
index 9e8e0ae..8cfaeb1 100644
--- a/bin/caribou.in
+++ b/bin/caribou.in
@@ -27,7 +27,7 @@
from optparse import OptionParser
import gettext
import sys
-import gtk
+from gi.repository import Gtk
import os
# We can't rely on prefix if we're installed by relocated RPM. Instead, we
@@ -69,4 +69,4 @@ if __name__ == "__main__":
caribou = main.Caribou()
caribou.window.hide_all()
- gtk.main()
+ Gtk.main()
diff --git a/caribou/ui/animation.py b/caribou/ui/animation.py
index 44a9dfd..c382929 100644
--- a/caribou/ui/animation.py
+++ b/caribou/ui/animation.py
@@ -18,16 +18,16 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-import clutter
+from gi.repository import Clutter
class AnimatedWindowBase(object):
- def __init__(self, ease=clutter.EASE_IN_QUAD):
+ def __init__(self, ease=Clutter.AnimationMode.EASE_IN_QUAD):
if self.__class__ == AnimatedWindowBase:
raise TypeError, \
"AnimatedWindowBase is an abstract class, " \
- "must be subclassed with a gtk.Window"
+ "must be subclassed with a Gtk.Window"
- self._actor = clutter.Rectangle()
+ self._actor = Clutter.Rectangle()
self.ease = ease
def _on_new_frame(self, timeline, timing):
@@ -37,25 +37,27 @@ class AnimatedWindowBase(object):
def animated_move(self, x, y):
orig_x, orig_y = self.get_position()
self._actor.set_position(orig_x, orig_y)
- self._actor.set_size(self.allocation.width, self.allocation.height)
- animation = self._actor.animate(
- self.ease, 250, "x", x, "y", y)
+ #allocation = self.get_allocation()
+ #print allocation.width, allocation.height
+ #self._actor.set_size(self.allocation.width, self.allocation.height)
+ animation = self._actor.animatev(self.ease, 250, ["x", "y"])
timeline = animation.get_timeline()
timeline.connect('new-frame', self._on_new_frame)
return animation
if __name__ == "__main__":
- import gtk
- class AnimatedWindow(gtk.Window, AnimatedWindowBase):
+ import gobject
+ from gi.repository import Gtk
+ class AnimatedWindow(Gtk.Window, AnimatedWindowBase):
def __init__(self):
- gtk.Window.__init__(self)
+ gobject.GObject.__init__(self)
AnimatedWindowBase.__init__(self)
aw = AnimatedWindow()
aw.show_all()
aw.move(100, 100)
- aw.animated_move(200, 200)
- gtk.main()
+ #aw.animated_move(200, 200)
+ Gtk.main()
diff --git a/caribou/ui/main.py b/caribou/ui/main.py
index e5dcee2..adae398 100644
--- a/caribou/ui/main.py
+++ b/caribou/ui/main.py
@@ -1,7 +1,7 @@
-import gtk.gdk as gdk
+import Gtk.gdk as gdk
import pyatspi
-import gconf
-import gtk
+from gi.repository import GConf
+from gi.repository import Gtk
import signal
from window import CaribouWindowEntry
@@ -21,7 +21,7 @@ class Caribou:
self.window_factory = window_factory
self.kb_factory = kb_factory
self.window = window_factory(kb_factory())
- self.client = gconf.client_get_default()
+ self.client = GConf.Client.get_default()
self._register_event_listeners()
self.client.notify_add(const.CARIBOU_GCONF + "/layout",
self._on_layout_changed)
@@ -56,7 +56,7 @@ class Caribou:
def _get_a11y_enabled(self):
try:
- gconfc = gconf.client_get_default()
+ gconfc = GConf.Client.get_default()
atspi1 = gconfc.get_bool("/desktop/gnome/interface/accessibility")
atspi2 = gconfc.get_bool("/desktop/gnome/interface/accessibility2")
return atspi1 or atspi2
@@ -180,6 +180,6 @@ class Caribou:
result = pyatspi.Registry.deregisterKeystrokeListener(self.on_key_down, mask=None, kind=pyatspi.KEY_PRESSED_EVENT)
if debug == True:
print "deregisterKeystrokeListener"
- gtk.main_quit()
+ Gtk.main_quit()
diff --git a/caribou/ui/opacity.py b/caribou/ui/opacity.py
index bab14d5..575eb8d 100644
--- a/caribou/ui/opacity.py
+++ b/caribou/ui/opacity.py
@@ -26,7 +26,7 @@ class ProximityWindowBase(object):
if self.__class__ == ProximityWindowBase:
raise TypeError, \
"ProximityWindowBase is an abstract class, " \
- "must be subclassed with a gtk.Window"
+ "must be subclassed with a Gtk.Window"
self.connect('map-event', self.__onmapped)
self.max_distance = max_distance
if max_alpha < min_alpha:
diff --git a/caribou/ui/scan.py b/caribou/ui/scan.py
index 992f1d9..f845903 100644
--- a/caribou/ui/scan.py
+++ b/caribou/ui/scan.py
@@ -1,6 +1,7 @@
import gobject
import pyatspi
-import gtk
+from gi.repository import Gdk
+from gi.repository import Gtk
import caribou.common.const as const
from caribou.common.settings_manager import SettingsManager
@@ -203,23 +204,23 @@ class ScanService():
def _grab_mouse_events(self):
- gtk.gdk.event_handler_set(self._mouse_handler)
+ Gdk.event_handler_set(self._mouse_handler)
def _ungrab_mouse_events(self):
- gtk.gdk.event_handler_set(gtk.main_do_event)
+ Gdk.event_handler_set(Gtk.main_do_event)
def _mouse_handler(self, event):
if self.root_window.window.is_visible():
- if event.type == gtk.gdk.BUTTON_PRESS and \
+ if event.type == Gdk.EventType.BUTTON_PRESS and \
str(event.button) == self.switch_key.value:
self._handle_press()
- elif event.type == gtk.gdk.BUTTON_RELEASE and \
+ elif event.type == Gdk.BUTTON_RELEASE and \
str(event.button) == self.switch_key.value:
self._handle_release()
- elif not event.type == gtk.gdk.ENTER_NOTIFY:
- gtk.main_do_event(event)
+ elif not event.type == Gdk.ENTER_NOTIFY:
+ Gtk.main_do_event(event)
else:
- gtk.main_do_event(event)
+ Gtk.main_do_event(event)
def _scan_block(self):
if self.is_stop:
@@ -237,18 +238,18 @@ class ScanService():
self.index_i = 0
self.selected_block = []
- width = self.root_window.size_request()[0]
- height = self.root_window.size_request()[1]
+ #width = self.root_window.size_request()[0]
+ #height = self.root_window.size_request()[1]
root_x = self.root_window.get_position()[0]
root_y = self.root_window.get_position()[1]
offset_w = self.index_j*(width/3)
offset_h = self.index_i*(height/2)
- block_window = gtk.gdk.Rectangle(root_x + offset_w,
+ block_window = (root_x + offset_w,
root_y + offset_h,
width/3,
height/2)
- empty_r = gtk.gdk.Rectangle()
+ empty_r = ()
try:
for row in self.keyboard:
line = []
@@ -257,7 +258,7 @@ class ScanService():
button.window.get_position()[0]
abs_b_y = button.get_allocation()[1] + \
button.window.get_position()[1]
- abs_b_r = gtk.gdk.Rectangle(abs_b_x,
+ abs_b_r = (abs_b_x,
abs_b_y,
button.size_request()[0],
button.size_request()[1])
diff --git a/caribou/ui/window.py b/caribou/ui/window.py
index 0ed5c90..9b30a82 100644
--- a/caribou/ui/window.py
+++ b/caribou/ui/window.py
@@ -22,9 +22,9 @@
import animation
from caribou import data_path
-import gconf
-import gtk
-import gtk.gdk as gdk
+from gi.repository import GConf
+from gi.repository import Gtk
+from gi.repository import Gdk
import opacity
import os
import sys
@@ -32,21 +32,21 @@ import sys
CARIBOU_GCONF_LAYOUT_KEY = '/apps/caribou/osk/layout'
CARIBOU_LAYOUT_DIR = 'keyboards'
-class CaribouWindow(gtk.Window):
+class CaribouWindow(Gtk.Window):
__gtype_name__ = "CaribouWindow"
def __init__(self, text_entry_mech, default_placement=None,
min_alpha=1.0, max_alpha=1.0, max_distance=100):
- super(CaribouWindow, self).__init__(gtk.WINDOW_POPUP)
+ super(CaribouWindow, self).__init__(Gtk.WINDOW_POPUP)
self.set_name("CaribouWindow")
- self._vbox = gtk.VBox()
+ self._vbox = Gtk.VBox()
self.add(self._vbox)
self.keyboard = text_entry_mech
- self._vbox.pack_start(text_entry_mech)
+ self._vbox.pack_start(text_entry_mech, True, True, 0)
self.connect("size-allocate", lambda w, a: self._update_position())
- self._gconf_client = gconf.client_get_default()
+ self._gconf_client = GConf.Client.get_default()
self._cursor_location = gdk.Rectangle()
self._entry_location = gdk.Rectangle()
@@ -61,7 +61,7 @@ class CaribouWindow(gtk.Window):
def destroy(self):
self.keyboard.destroy()
- super(gtk.Window, self).destroy()
+ super(Gtk.Window, self).destroy()
def set_cursor_location(self, cursor_location):
@@ -82,7 +82,7 @@ class CaribouWindow(gtk.Window):
root_bbox = gdk.Rectangle(*args)
- current_screen = gtk.gdk.screen_get_default().get_number()
+ current_screen = Gdk.Screen.get_default().get_number()
for panel in self._gconf_client.all_dirs('/apps/panel/toplevels'):
orientation = self._gconf_client.get_string(panel+'/orientation')
size = self._gconf_client.get_int(panel+'/size')
@@ -163,12 +163,12 @@ class CaribouWindow(gtk.Window):
def show_all(self):
- gtk.Window.show_all(self)
+ Gtk.Window.show_all(self)
self.keyboard.show_all()
def hide_all(self):
self.keyboard.hide_all()
- gtk.Window.hide_all(self)
+ Gtk.Window.hide_all(self)
def _on_window_show(self, window):
child = self.get_child()
@@ -202,11 +202,11 @@ class CaribouWindowDocked(CaribouWindow,
def _roll_in(self):
x, y = self.get_position()
self.move(x + self.allocation.width, y)
- return self.animated_move(x, y)
+ #return self.animated_move(x, y)
def _roll_out(self):
x, y = self.get_position()
- return self.animated_move(x + self.allocation.width, y)
+ #return self.animated_move(x + self.allocation.width, y)
def hide_all(self):
animation = self._roll_out()
@@ -299,3 +299,16 @@ class CaribouWindowPlacement(object):
ystickto or self.CURSOR,
ygravitate or self.OUTSIDE)
+
+if __name__ == "__main__":
+ import keyboard
+ import signal
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+
+ w = CaribouWindowDocked(keyboard.CaribouKeyboard)
+ w.show_all()
+
+ try:
+ Gtk.main()
+ except KeyboardInterrupt:
+ Gtk.main_quit()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]