[accerciser/macaroon-pygi] Starting the port of macaroon into pygobject
- From: Javier HernÃndez AntÃnez <jhernandez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [accerciser/macaroon-pygi] Starting the port of macaroon into pygobject
- Date: Wed, 5 Oct 2011 14:58:22 +0000 (UTC)
commit 5387e64be8e8c22e725ccd200e478eb51e230856
Author: Javier HernÃndez <jhernandez emergya es>
Date: Wed Oct 5 16:57:42 2011 +0200
Starting the port of macaroon into pygobject
macaroon/bin/macaroon.in | 15 +--
macaroon/configure.in | 13 ---
macaroon/macaroon/playback/keypress_actions.py | 29 +++---
macaroon/macaroon/playback/sequence.py | 19 ++--
macaroon/macaroon/playback/sequence_step.py | 12 ++-
macaroon/macaroon/playback/utils.py | 7 +-
macaroon/macaroon/playback/wait_actions.py | 9 ++-
macaroon/macaroon/record/about.py | 32 +++---
macaroon/macaroon/record/main.py | 121 ++++++++++++------------
macaroon/macaroon/record/script_factory.py | 40 ++++----
macaroon/pyreqs.py | 2 +-
11 files changed, 151 insertions(+), 148 deletions(-)
---
diff --git a/macaroon/bin/macaroon.in b/macaroon/bin/macaroon.in
index 62600b6..0a5050f 100644
--- a/macaroon/bin/macaroon.in
+++ b/macaroon/bin/macaroon.in
@@ -24,15 +24,12 @@ sys.path.insert(1, libs)
from macaroon.record.main import Main
-if not '@PYGTK_DIR@' in sys.path:
- sys.path.insert(0, '@PYGTK_DIR@')
+#if not '@PYGTK_DIR@' in sys.path:
+# sys.path.insert(0, '@PYGTK_DIR@')
-import pygtk
-pygtk.require('2.0')
-
-import gnome
-# make this program accessible
-props = { gnome.PARAM_APP_DATADIR : os.path.join(sys.prefix, 'share')}
-gnome.program_init('macaroon', '@VERSION@', properties=props)
+#import gnome
+## make this program accessible
+#props = { gnome.PARAM_APP_DATADIR : os.path.join(sys.prefix, 'share')}
+#gnome.program_init('macaroon', '@VERSION@', properties=props)
Main()
diff --git a/macaroon/configure.in b/macaroon/configure.in
index 1578659..01395bb 100644
--- a/macaroon/configure.in
+++ b/macaroon/configure.in
@@ -6,19 +6,6 @@ AM_MAINTAINER_MODE([enable])
dnl == check for python ==
AM_PATH_PYTHON(2.4)
-dnl == avoid running pyreqs during package building ==
-AC_MSG_CHECKING([whether to run pyreqs.py])
-AC_ARG_WITH(pyreqs,
- [ --with-pyreqs Build with Python module checks.],
- with_pyreqs=$withval,
- with_pyreqs=yes)
-AC_MSG_RESULT($with_pyreqs)
-if test "$with_pyreqs" = "yes"; then
- dnl == check for required modules ==
- AM_CHECK_PYSCRIPT($srcdir/pyreqs.py, ,
- [AC_MSG_ERROR(Could not find required Python module)])
-fi
-
dnl == i18n ==
GETTEXT_PACKAGE=macaroon
AC_SUBST(GETTEXT_PACKAGE)
diff --git a/macaroon/macaroon/playback/keypress_actions.py b/macaroon/macaroon/playback/keypress_actions.py
index 8b265ba..a964c9a 100644
--- a/macaroon/macaroon/playback/keypress_actions.py
+++ b/macaroon/macaroon/playback/keypress_actions.py
@@ -15,11 +15,14 @@ See "COPYING" in the source distribution for more information.
Headers in this file shall remain intact.
'''
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
import pyatspi
-import gtk
+
from sequence_step import AtomicAction
-import gobject
import utils
+
_ = lambda x: x
# Highest granularity, define timing for every single press and release
@@ -30,7 +33,7 @@ min_delta = 50
# Maximum time before a key release
release_max = 400
-keymap = gtk.gdk.keymap_get_default()
+keymap = Gdk.Keymap.get_default()
class KeyPressAction(AtomicAction):
'''
@@ -53,7 +56,7 @@ class KeyPressAction(AtomicAction):
if delta_time > release_max: delta_time = release_max
self._key_name = key_name
if key_code is None:
- key_code = utils.getKeyCodeFromVal(gtk.gdk.keyval_from_name(key_name))
+ key_code = utils.getKeyCodeFromVal(Gdk.keyval_from_name(key_name))
AtomicAction.__init__(self, delta_time, self._keyPress, key_code)
def _keyPress(self, key_code):
@@ -95,7 +98,7 @@ class KeyReleaseAction(AtomicAction):
if delta_time > release_max: delta_time = release_max
self._key_name = key_name
if key_code is None:
- key_code = utils.getKeyCodeFromVal(gtk.gdk.keyval_from_name(key_name))
+ key_code = utils.getKeyCodeFromVal(Gdk.keyval_from_name(key_name))
AtomicAction.__init__(self, delta_time, self._keyRelease, key_code)
def _keyRelease(self, key_code):
@@ -143,7 +146,7 @@ class KeyComboAction(AtomicAction):
@param delta_time: Time to wait before performing step.
@type delta_time: integer
'''
- keyval, modifiers = gtk.accelerator_parse(key_combo)
+ keyval, modifiers = Gtk.accelerator_parse(key_combo)
key_code = utils.getKeyCodeFromVal(keyval)
self._key_combo = key_combo
if delta_time < min_delta: delta_time = min_delta
@@ -167,15 +170,15 @@ class KeyComboAction(AtomicAction):
interval = 0
mod_hw_codes = map(mod_key_code_mappings.get, modifiers.value_names)
for mod_hw_code in mod_hw_codes:
- gobject.timeout_add(interval, self._keyPress, mod_hw_code)
+ GObject.timeout_add(interval, self._keyPress, mod_hw_code)
interval += keystroke_interval
- gobject.timeout_add(interval, self._keyPressRelease, key_code)
+ GObject.timeout_add(interval, self._keyPressRelease, key_code)
interval += keystroke_interval
mod_hw_codes.reverse()
for mod_hw_code in mod_hw_codes:
- gobject.timeout_add(interval, self._keyRelease, mod_hw_code)
+ GObject.timeout_add(interval, self._keyRelease, mod_hw_code)
interval += keystroke_interval
- gobject.timeout_add(interval, self.stepDone)
+ GObject.timeout_add(interval, self.stepDone)
def _keyPress(self, hw_code):
'''
@@ -255,10 +258,10 @@ class TypeAction(AtomicAction):
'''
interval = 0
for char in string_to_type:
- gobject.timeout_add(interval, self._charType,
- gtk.gdk.unicode_to_keyval(ord(char)))
+ GObject.timeout_add(interval, self._charType,
+ Gdk.unicode_to_keyval(ord(char)))
interval += self.interval
- gobject.timeout_add(interval, self.stepDone)
+ GObject.timeout_add(interval, self.stepDone)
def _charType(self, keyval):
'''
diff --git a/macaroon/macaroon/playback/sequence.py b/macaroon/macaroon/playback/sequence.py
index 70bfee8..bacb1b1 100644
--- a/macaroon/macaroon/playback/sequence.py
+++ b/macaroon/macaroon/playback/sequence.py
@@ -15,12 +15,15 @@ See "COPYING" in the source distribution for more information.
Headers in this file shall remain intact.
'''
-import gobject, pyatspi, sys
+from gi.repository import GObject
+from gi.repository import GLib
+import pyatspi
+import sys
from wait_actions import WaitAction
from os import environ
_ = lambda x: x
-class MacroSequence(gobject.GObject):
+class MacroSequence(GObject.GObject):
'''
Sequence class. Holds a list of steps and performs them in order.
Waits for each step to emit a "done" signal. And performs the next step
@@ -28,7 +31,7 @@ class MacroSequence(gobject.GObject):
is completed.
@ivar _loop: Loop instance if the main loop should be embedded.
- @type _loop: gobject.MainLoop
+ @type _loop: GLib.MainLoop
@ivar _verbose: Print to standard output the current step the sequence is in.
@type _verbose: boolean
@ivar _current_step: The index of the currently performed step.
@@ -44,13 +47,13 @@ class MacroSequence(gobject.GObject):
came through.
@type _anticipated_events: list of Accessibility.Accessible
'''
- __gsignals__ = {'step-done' : (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, (gobject.TYPE_INT,))}
+ __gsignals__ = {'step-done' : (GObject.SignalFlags.RUN_FIRST,
+ None, (GObject.TYPE_INT,))}
def __init__(self):
'''
Initialize L{MacroSequence}.
'''
- self.__gobject_init__()
+ super(MacroSequence, self).__init__()
self._loop = None
self._verbose = False
self._current_step = 0
@@ -79,7 +82,7 @@ class MacroSequence(gobject.GObject):
self._verbose = bool(verbose or environ.get('MACAROON_VERBOSE', 0))
self._iterAction()
if embedded_loop:
- self._loop = gobject.MainLoop()
+ self._loop = GLib.MainLoop()
self._loop.run()
def _iterAction(self):
@@ -109,7 +112,7 @@ class MacroSequence(gobject.GObject):
*self._anticipated_event_types)
self._current_handler = action.connect('done', self._onStepDone)
- gobject.timeout_add(action.delta_time, self._doAction, action)
+ GObject.timeout_add(action.delta_time, self._doAction, action)
def _onAnticipatedEvent(self, event):
'''
diff --git a/macaroon/macaroon/playback/sequence_step.py b/macaroon/macaroon/playback/sequence_step.py
index 3c6bb04..cef4d12 100644
--- a/macaroon/macaroon/playback/sequence_step.py
+++ b/macaroon/macaroon/playback/sequence_step.py
@@ -15,9 +15,11 @@ See "COPYING" in the source distribution for more information.
Headers in this file shall remain intact.
'''
-import gobject, pyatspi, sys
+from gi.repository import GObject
+import pyatspi
+import sys
-class SequenceStep(gobject.GObject):
+class SequenceStep(GObject.GObject):
'''
Base class for all sequence steps in a Macaroon sequence. Emits a "done"
signal when the step is done.
@@ -28,14 +30,14 @@ class SequenceStep(gobject.GObject):
@ivar done: True if step is done.
@type done: boolean
'''
- __gsignals__ = {'done' : (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, ())}
+ __gsignals__ = {'done' : (GObject.SignalFlags.RUN_FIRST,
+ None, ())}
delta_time = 0
def __init__(self):
'''
Initialize L{SequenceStep}.
'''
- self.__gobject_init__()
+ super(SequenceStep, self).__init__()
self.done = False
def stepDone(self):
diff --git a/macaroon/macaroon/playback/utils.py b/macaroon/macaroon/playback/utils.py
index 677f64d..dbbb9e2 100644
--- a/macaroon/macaroon/playback/utils.py
+++ b/macaroon/macaroon/playback/utils.py
@@ -11,13 +11,14 @@
# Headers in this file shall remain intact.
-import pyatspi, gtk
+from gi.repository import Gdk
+import pyatspi
-keymap = gtk.gdk.keymap_get_default()
+keymap = Gdk.Keymap.get_default()
def getKeyCodeFromVal(keyval):
global keymap
- entry = keymap.get_entries_for_keyval(keyval)
+ success, entry = keymap.get_entries_for_keyval(keyval)
if not entry:
raise TypeError("Invalid key name")
else:
diff --git a/macaroon/macaroon/playback/wait_actions.py b/macaroon/macaroon/playback/wait_actions.py
index 1c8200b..437878b 100644
--- a/macaroon/macaroon/playback/wait_actions.py
+++ b/macaroon/macaroon/playback/wait_actions.py
@@ -15,10 +15,15 @@ See "COPYING" in the source distribution for more information.
Headers in this file shall remain intact.
'''
+from gi.repository import GObject
+import pyatspi
+
import re
from sequence_step import SequenceStep
-import utils, pyatspi, gobject, sys
+import utils
+import sys
+
_ = lambda x: x
class WaitAction(SequenceStep):
@@ -73,7 +78,7 @@ class WaitAction(SequenceStep):
self._cached_events = cached_events
if self.checkExistingState(): return
pyatspi.Registry.registerEventListener(self.onEvent, *self.wait_for)
- gobject.timeout_add(self._timeout, self._onTimeout)
+ GObject.timeout_add(self._timeout, self._onTimeout)
def checkExistingState(self):
'''
diff --git a/macaroon/macaroon/record/about.py b/macaroon/macaroon/record/about.py
index f99fb4a..d66830f 100644
--- a/macaroon/macaroon/record/about.py
+++ b/macaroon/macaroon/record/about.py
@@ -11,14 +11,14 @@
# Headers in this file shall remain intact.
-import gtk
-from gnome import program_get, url_show
+from gi.repository import Gtk
+#from gnome import program_get, url_show
_ = lambda x: x
-gtk.about_dialog_set_url_hook(lambda dialog, url, data: url_show(url), None)
+#Gtk.about_dialog_set_url_hook(lambda dialog, url, data: url_show(url), None)
-class MacaroonAboutDialog(gtk.AboutDialog):
+class MacaroonAboutDialog(Gtk.AboutDialog):
'''
Creates a dialog with info about the program.
@@ -54,19 +54,19 @@ class MacaroonAboutDialog(gtk.AboutDialog):
'''
Initialize dialog.
'''
- program = program_get()
- gtk.AboutDialog.__init__(self)
+# program = program_get()
+ GObject.GObject.__init__(self)
self.connect('response', self._onResponse)
- gtk.AboutDialog.set_authors(self, self.AUTHORS)
- gtk.AboutDialog.set_artists(self, self.ARTISTS)
- gtk.AboutDialog.set_documenters(self, self.DOCUMENTERS)
- gtk.AboutDialog.set_comments(self, self.COMMENTS)
- gtk.AboutDialog.set_copyright(self, self.COPYRIGHT)
- gtk.AboutDialog.set_license(self, self.LICENSE)
- gtk.AboutDialog.set_logo_icon_name(self, 'macaroon')
- gtk.AboutDialog.set_version(self, program.get_app_version())
- gtk.AboutDialog.set_website(self, self.WEB_URL)
- gtk.AboutDialog.set_website_label(self, self.WEB_LABEL)
+ Gtk.AboutDialog.set_authors(self, self.AUTHORS)
+ Gtk.AboutDialog.set_artists(self, self.ARTISTS)
+ Gtk.AboutDialog.set_documenters(self, self.DOCUMENTERS)
+ Gtk.AboutDialog.set_comments(self, self.COMMENTS)
+ Gtk.AboutDialog.set_copyright(self, self.COPYRIGHT)
+ Gtk.AboutDialog.set_license(self, self.LICENSE)
+ Gtk.AboutDialog.set_logo_icon_name(self, 'macaroon')
+# Gtk.AboutDialog.set_version(self, program.get_app_version())
+ Gtk.AboutDialog.set_website(self, self.WEB_URL)
+ Gtk.AboutDialog.set_website_label(self, self.WEB_LABEL)
def _onResponse(self, dialog, response_id):
'''
diff --git a/macaroon/macaroon/record/main.py b/macaroon/macaroon/record/main.py
index 17c5297..6d83bca 100644
--- a/macaroon/macaroon/record/main.py
+++ b/macaroon/macaroon/record/main.py
@@ -11,9 +11,12 @@
# Headers in this file shall remain intact.
+from gi.repository import Gtk
+from gi.repository import GObject
+from gi.repository import Pango
+from gi.repository import GtkSource
+
import script_factory
-import gtk, gobject
-import gtksourceview, pango
from Queue import Queue
from macaroon.playback import MacroSequence
@@ -33,7 +36,7 @@ class Main:
start_tooltip = _('Record new keyboard macro')
stop_tooltip = _('Stop recording macro')
def __init__(self):
- status_icon = gtk.status_icon_new_from_stock(gtk.STOCK_MEDIA_RECORD)
+ status_icon = Gtk.StatusIcon.new_from_stock(Gtk.STOCK_MEDIA_RECORD)
status_icon.connect('activate', self._onActivate)
status_icon.connect('popup-menu', self._onPopup)
status_icon.set_tooltip(self.start_tooltip)
@@ -45,20 +48,20 @@ class Main:
self.macro_preview = None
# Get program ID
global APP_ID
- from gnome import program_get
- _prog = program_get()
- if _prog is not None:
- APP_ID = _prog.get_app_id()
+# from gnome import program_get
+# _prog = program_get()
+# if _prog is not None:
+# APP_ID = _prog.get_app_id()
pyatspi.Registry.start()
def _onRecordChange(self, gobject, pspec, status_icon):
is_recording = self.script_buffer.get_property('recording')
if is_recording:
- status_icon.set_from_stock(gtk.STOCK_MEDIA_STOP)
+ status_icon.set_from_stock(Gtk.STOCK_MEDIA_STOP)
status_icon.set_tooltip(self.stop_tooltip)
else:
- status_icon.set_from_stock(gtk.STOCK_MEDIA_RECORD)
+ status_icon.set_from_stock(Gtk.STOCK_MEDIA_RECORD)
status_icon.set_tooltip(self.start_tooltip)
def _onActivate(self, status_icon):
@@ -83,19 +86,19 @@ class Main:
<menuitem action="Quit" />
</popup>
</ui>'''
- main_action_group = gtk.ActionGroup('MenuActions')
+ main_action_group = Gtk.ActionGroup('MenuActions')
main_action_group.add_actions([
('ScriptType', None, 'Script type'),
- ('Quit', gtk.STOCK_QUIT, _('_Quit'), None, None, self._onQuit),
- ('About', gtk.STOCK_ABOUT, _('_About'), None, None, self._onAbout)])
- ui_manager = gtk.UIManager()
+ ('Quit', Gtk.STOCK_QUIT, _('_Quit'), None, None, self._onQuit),
+ ('About', Gtk.STOCK_ABOUT, _('_About'), None, None, self._onAbout)])
+ ui_manager = Gtk.UIManager()
ui_manager.add_ui_from_string(popup_ui)
ui_manager.insert_action_group(main_action_group, 0)
return ui_manager
def _onPopup(self, status_icon, button, activate_time):
menu = self.ui_manager.get_widget('/popup')
- menu.popup(None, None, gtk.status_icon_position_menu,
+ menu.popup(None, None, Gtk.status_icon_position_menu,
button, activate_time, status_icon)
def _onQuit(self, action):
@@ -106,46 +109,46 @@ class Main:
Shows the about dialog.
@param widget: The widget that emitted the signal that callback caught.
- @type widget: L{gtk.Widget}
+ @type widget: L{Gtk.Widget}
'''
about = MacaroonAboutDialog()
about.show_all()
-class MacroPreview(gtk.Window):
+class MacroPreview(Gtk.Window):
def __init__(self, script_buffer):
- gtk.Window.__init__(self)
+ GObject.GObject.__init__(self)
self.set_title(_('Macro preview'))
self.set_default_size(480, 720)
self.set_border_width(6)
self.connect('delete-event', self._onDelete)
self.script_buffer = script_buffer
- text_view = gtksourceview.SourceView(self.script_buffer)
+ text_view = GtkSource.View(self.script_buffer)
text_view.set_editable(True)
text_view.set_cursor_visible(True)
- text_view.modify_font(pango.FontDescription('Mono'))
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- sw.set_shadow_type(gtk.SHADOW_IN)
+ text_view.modify_font(Pango.FontDescription('Mono'))
+ sw = Gtk.ScrolledWindow()
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ sw.set_shadow_type(Gtk.ShadowType.IN)
sw.add(text_view)
- vbox = gtk.VBox()
+ vbox = Gtk.VBox()
vbox.set_spacing(3)
- vbox.pack_start(sw)
- bbox = gtk.HButtonBox()
- bbox.set_layout(gtk.BUTTONBOX_START)
- for label, callback in [(gtk.STOCK_SAVE_AS, self._onSave),
- (gtk.STOCK_CLEAR, self._onClear),
- (gtk.STOCK_MEDIA_RECORD, self._onRecord),
- (gtk.STOCK_MEDIA_PLAY, self._onPlay)]:
- button = gtk.Button(label)
+ vbox.pack_start(sw, True, True, 0)
+ bbox = Gtk.HButtonBox()
+ bbox.set_layout(Gtk.ButtonBoxStyle.START)
+ for label, callback in [(Gtk.STOCK_SAVE_AS, self._onSave),
+ (Gtk.STOCK_CLEAR, self._onClear),
+ (Gtk.STOCK_MEDIA_RECORD, self._onRecord),
+ (Gtk.STOCK_MEDIA_PLAY, self._onPlay)]:
+ button = Gtk.Button(label)
button.set_use_stock(True)
button.connect('clicked', callback)
- bbox.pack_start(button)
- if label == gtk.STOCK_MEDIA_RECORD:
+ bbox.pack_start(button, True, True, 0)
+ if label == Gtk.STOCK_MEDIA_RECORD:
self.script_buffer.connect('notify::recording',
self._onRecordChange, button)
vbox.pack_start(bbox, False)
- self.progress_bar = gtk.ProgressBar()
+ self.progress_bar = Gtk.ProgressBar()
vbox.pack_start(self.progress_bar, False)
self.add(vbox)
@@ -176,9 +179,9 @@ class MacroPreview(gtk.Window):
def _onRecordChange(self, gobject, pspec, button):
is_recording = self.script_buffer.get_property('recording')
if is_recording:
- button.set_label(gtk.STOCK_MEDIA_STOP)
+ button.set_label(Gtk.STOCK_MEDIA_STOP)
else:
- button.set_label(gtk.STOCK_MEDIA_RECORD)
+ button.set_label(Gtk.STOCK_MEDIA_RECORD)
def _onDelete(self, window, event):
if self._askLoseChanges():
@@ -192,18 +195,18 @@ class MacroPreview(gtk.Window):
contents of script buffer.
@param button: Button that was clicked.
- @type button: gtk.Button
+ @type button: Gtk.Button
'''
- save_dialog = gtk.FileChooserDialog(
+ save_dialog = Gtk.FileChooserDialog(
'Save recorded script',
- action=gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK))
+ action=Gtk.FileChooserAction.SAVE,
+ buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OK, Gtk.ResponseType.OK))
save_dialog.set_do_overwrite_confirmation(True)
- save_dialog.set_default_response(gtk.RESPONSE_OK)
+ save_dialog.set_default_response(Gtk.ResponseType.OK)
save_dialog.show_all()
response = save_dialog.run()
- if response == gtk.RESPONSE_OK:
+ if response == Gtk.ResponseType.OK:
save_to = open(save_dialog.get_filename(), 'w')
save_to.write(self.script_buffer.get_text(
self.script_buffer.get_start_iter(),
@@ -217,7 +220,7 @@ class MacroPreview(gtk.Window):
Callback for 'clear' button press.
@param button: Button that was clicked.
- @type button: gtk.Button
+ @type button: Gtk.Button
'''
if self._askLoseChanges():
self.script_buffer.clearBuffer()
@@ -239,28 +242,28 @@ class MacroPreview(gtk.Window):
'''
if not self.script_buffer.get_modified():
return True
- dialog = gtk.MessageDialog(self.get_toplevel(), 0, gtk.MESSAGE_WARNING,
- gtk.BUTTONS_OK_CANCEL,
+ dialog = Gtk.MessageDialog(self.get_toplevel(), 0, Gtk.MessageType.WARNING,
+ Gtk.ButtonsType.OK_CANCEL,
_('The current script will be lost.'))
dialog.set_title(_('Confirm clear'))
response_id = dialog.run()
dialog.destroy()
- if response_id == gtk.RESPONSE_OK:
+ if response_id == Gtk.ResponseType.OK:
return True
else:
return False
-class ScriptBuffer(gtksourceview.SourceBuffer):
+class ScriptBuffer(GtkSource.Buffer):
__gproperties__ = {
- 'recording': (gobject.TYPE_BOOLEAN,
+ 'recording': (GObject.TYPE_BOOLEAN,
'Is recording',
'True if script buffer is recording',
- False, gobject.PARAM_READWRITE)}
+ False, GObject.PARAM_READWRITE)}
factory_mapping = {'Level1' : script_factory.Level1SequenceFactory,
'Level2' : script_factory.Level2SequenceFactory}
def __init__(self, uimanager):
- gtksourceview.SourceBuffer.__init__(self)
- lm = gtksourceview.SourceLanguagesManager()
+ GtkSource.Buffer.__init__(self)
+ lm = GtkSource.LanguagesManager()
lang = lm.get_language_from_mime_type('text/x-python')
self.set_language(lang)
self.set_highlight(True)
@@ -270,12 +273,12 @@ class ScriptBuffer(gtksourceview.SourceBuffer):
self._addToUIManager()
def _addToUIManager(self):
- self.script_type_actions = gtk.ActionGroup('ScriptTypes')
+ self.script_type_actions = Gtk.ActionGroup('ScriptTypes')
self.script_type_actions.add_radio_actions(
(('Level1', None, 'Level 1', None, None, 1),
('Level2', None, 'Level 2', None, None, 2)),
2, self._onChange)
- self._wait_for_focus_toggle = gtk.ToggleAction('WaitForFocus',
+ self._wait_for_focus_toggle = Gtk.ToggleAction('WaitForFocus',
'Record focus events',
None, None)
self._wait_for_focus_toggle.set_active(True)
@@ -442,17 +445,17 @@ class ScriptBuffer(gtksourceview.SourceBuffer):
class _FakeDeviceEvent(object):
def __init__(self, key_combo, type):
- id = gtk.gdk.keyval_from_name(key_combo)
- if gtk.gdk.keyval_from_name(key_combo):
+ id = Gdk.keyval_from_name(key_combo)
+ if Gdk.keyval_from_name(key_combo):
modifiers = 0
else:
- id, modifiers = gtk.accelerator_parse(key_combo)
- keymap = gtk.gdk.keymap_get_default()
+ id, modifiers = Gtk.accelerator_parse(key_combo)
+ keymap = Gdk.keymap_get_default()
map_entry = keymap.get_entries_for_keyval(65471)
self.type = type
self.id = id
self.hw_code = map_entry[0][0]
self.modifiers = int(modifiers)
self.timestamp = 0
- self.event_string = gtk.gdk.keyval_name(id)
+ self.event_string = Gdk.keyval_name(id)
self.is_text = True
diff --git a/macaroon/macaroon/record/script_factory.py b/macaroon/macaroon/record/script_factory.py
index 6309206..9e2ad1a 100644
--- a/macaroon/macaroon/record/script_factory.py
+++ b/macaroon/macaroon/record/script_factory.py
@@ -11,11 +11,13 @@
# Headers in this file shall remain intact.
-from gtk import keysyms
-import gtk
+from gi.repository import Gtk
+from gi.repository import Gdk
+
+import pyatspi
+
from Queue import Queue
from time import time
-import pyatspi
class _CommandsQueue(Queue):
def __init__(self):
@@ -46,10 +48,10 @@ class ScriptFactory(object):
'''
intepreter_line = '#!/usr/bin/python'
import_line = ''
- MODIFIERS = [keysyms.Control_L, keysyms.Control_R,
- keysyms.Alt_L, keysyms.Alt_R,
- keysyms.Super_L, keysyms.Super_R,
- keysyms.Shift_L, keysyms.Shift_R]
+ MODIFIERS = [Gdk.KEY_Control_L, Gdk.KEY_Control_R,
+ Gdk.KEY_Alt_L, Gdk.KEY_Alt_R,
+ Gdk.KEY_Super_L, Gdk.KEY_Super_R,
+ Gdk.KEY_Shift_L, Gdk.KEY_Shift_R]
def __init__(self):
'''
@@ -137,9 +139,9 @@ class Level2SequenceFactory(SequenceFactory):
if isinstance(event, pyatspi.event.DeviceEvent):
# If it's a fake one, then it is a global WM hotkey, no need for context.
self._prependContext()
- if event.modifiers in (0, gtk.gdk.SHIFT_MASK) and \
- gtk.gdk.keyval_to_unicode(event.id):
- self.typed_text += unichr(gtk.gdk.keyval_to_unicode(event.id))
+ if event.modifiers in (0, Gdk.EventMask.SHIFT_MASK) and \
+ Gdk.keyval_to_unicode(event.id):
+ self.typed_text += unichr(Gdk.keyval_to_unicode(event.id))
else:
if self.frame_name:
if isinstance(event, pyatspi.event.DeviceEvent):
@@ -160,7 +162,7 @@ class Level2SequenceFactory(SequenceFactory):
self.typed_text = ''
self.commands_queue.put_nowait(
'sequence.append(KeyComboAction("%s"))\n' % \
- gtk.accelerator_name(event.id, event.modifiers))
+ Gtk.accelerator_name(event.id, event.modifiers))
def focusCommand(self, event):
self.last_focused = (event.source.name,
@@ -262,9 +264,9 @@ class DogtailFactory(ScriptFactory):
if event.id in self.MODIFIERS or \
event.event_string.startswith('ISO'):
return
- if event.modifiers in (0, gtk.gdk.SHIFT_MASK) and \
- gtk.gdk.keyval_to_unicode(event.id):
- self.typed_text += unichr(gtk.gdk.keyval_to_unicode(event.id))
+ if event.modifiers in (0, Gdk.EventMask.SHIFT_MASK) and \
+ Gdk.keyval_to_unicode(event.id):
+ self.typed_text += unichr(Gdk.keyval_to_unicode(event.id))
else:
if self.app_name:
self.commands_queue.put_nowait('focus.application("%s")\n' % \
@@ -279,7 +281,7 @@ class DogtailFactory(ScriptFactory):
self.typed_text)
self.typed_text = ''
self.commands_queue.put_nowait('keyCombo("%s")\n' % \
- gtk.accelerator_name(event.id,
+ Gtk.accelerator_name(event.id,
event.modifiers))
@@ -315,9 +317,9 @@ class LDTPFactory(DogtailFactory):
if event.id in self.MODIFIERS or \
event.event_string.startswith('ISO'):
return
- if event.modifiers in (0, gtk.gdk.SHIFT_MASK) and \
- gtk.gdk.keyval_to_unicode(event.id):
- self.typed_text += unichr(gtk.gdk.keyval_to_unicode(event.id))
+ if event.modifiers in (0, Gdk.EventMask.SHIFT_MASK) and \
+ Gdk.keyval_to_unicode(event.id):
+ self.typed_text += unichr(Gdk.keyval_to_unicode(event.id))
else:
if self.frame_name:
self.commands_queue.put_nowait('waittillguiexist("%s")\n' % \
@@ -328,5 +330,5 @@ class LDTPFactory(DogtailFactory):
self.typed_text)
self.typed_text = ''
self.commands_queue.put_nowait('generatekeyevent("%s")\n' % \
- gtk.accelerator_name(event.id,
+ Gtk.accelerator_name(event.id,
event.modifiers))
diff --git a/macaroon/pyreqs.py b/macaroon/pyreqs.py
index 238d4e2..234b41d 100644
--- a/macaroon/pyreqs.py
+++ b/macaroon/pyreqs.py
@@ -24,7 +24,7 @@ except KeyError:
pass
# test for python modules
-modules = ['pygtk', 'gtk', 'gtk.gdk', 'wnck']
+modules = ['pygtk', 'gtk', 'Gtk.gdk', 'wnck']
for name in modules:
try:
m = __import__(name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]