[wiican/gnome3porting: 1/3] [m] PyGTK2 to PyGI GTK 3 Step 1 The Great Renaming
- From: J. FÃlix OntaÃÃn <felixonta src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [wiican/gnome3porting: 1/3] [m] PyGTK2 to PyGI GTK 3 Step 1 The Great Renaming
- Date: Sun, 19 Aug 2012 23:24:34 +0000 (UTC)
commit 2bfbdc083ee2f528a072f42b8e8c175301aae75a
Author: J. FÃlix OntaÃÃn <fontanon emergya es>
Date: Wed Aug 15 18:01:49 2012 +0200
[m] PyGTK2 to PyGI GTK 3 Step 1 The Great Renaming
bin/wiican | 30 ++++++------
bin/wiican-service | 4 +-
tests/dbus-test.py | 4 +-
wiican/service/wiican_dbus.py | 4 +-
wiican/service/wiifinder.py | 18 ++++----
wiican/service/wminput.py | 20 ++++----
wiican/ui/editordlg.py | 52 +++++++++++-----------
wiican/ui/managerdlg.py | 96 +++++++++++++++++++-------------------
wiican/ui/notificator.py | 14 +++---
wiican/ui/pnganimation.py | 8 ++--
wiican/ui/validationerrordlg.py | 16 +++---
wiican/utils.py | 32 +++++++-------
12 files changed, 149 insertions(+), 149 deletions(-)
---
diff --git a/bin/wiican b/bin/wiican
index c399978..63c3f9a 100755
--- a/bin/wiican
+++ b/bin/wiican
@@ -24,8 +24,8 @@
import sys
import os
-import gtk
-import gobject
+from gi.repository import Gtk
+from gi.repository import GObject
import dbus, dbus.exceptions
import appindicator
@@ -64,7 +64,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
self.menu_mappings = []
# Load UI
- builder = gtk.Builder()
+ builder = Gtk.Builder()
if not builder.add_from_file(WIIMOTEMANAGER_UI):
raise 'Cant load %s' % WIIMOTEMANAGER_UI
builder.connect_signals(self)
@@ -151,7 +151,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
self.disconnect_menuitem.set_sensitive(True)
for mapping_menuitem in self.menu_mappings:
mapping_menuitem.set_sensitive(False)
- gobject.timeout_add(500, animate)
+ GObject.timeout_add(500, animate)
def __load_mappings_menu(self):
# Remove all mapping menuitems before adding the updated list
@@ -168,10 +168,10 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
if not mapping_manager.is_visible(mapping_id):
continue
- icon = gtk.gdk.pixbuf_new_from_file_at_size(mapping.get_icon(), 16, 16)
- menuitem = gtk.ImageMenuItem(mapping.get_name())
+ icon = GdkPixbuf.Pixbuf.new_from_file_at_size(mapping.get_icon(), 16, 16)
+ menuitem = Gtk.ImageMenuItem(mapping.get_name())
menuitem.set_tooltip_text(mapping.get_comment())
- menuitem.set_image(gtk.image_new_from_pixbuf(icon))
+ menuitem.set_image(Gtk.image_new_from_pixbuf(icon))
menuitem.connect('activate', self.__discover_cb, mapping)
if self.__cur_status & WC_WIIMOTE_DISCOVERING: menuitem.set_sensitive(False)
menuitem.show()
@@ -181,7 +181,7 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
cur_position += 1
if no_visible_mappings:
- menuitem = gtk.MenuItem(_('Set some visible mappings'))
+ menuitem = Gtk.MenuItem(_('Set some visible mappings'))
menuitem.connect('activate', self.preferences_cb)
menuitem.show()
self.main_menu.insert(menuitem, cur_position)
@@ -222,12 +222,12 @@ class WiicanIndicator(appindicator.Indicator, GConfStore):
location = self.get_geometry()[1]
valerr_dlg.move(location[0], location[1])
- if valerr_dlg.run() == gtk.RESPONSE_YES:
+ if valerr_dlg.run() == Gtk.ResponseType.YES:
mapping_editor_dlg = MappingEditorDialog(mapping)
mapping_editor_dlg.set_title(_('Editing ') + \
mapping.get_name())
- if mapping_editor_dlg.run() == gtk.RESPONSE_OK:
+ if mapping_editor_dlg.run() == Gtk.ResponseType.OK:
new_mapping = mapping_editor_dlg.get_mapping()
mapping_manager.write_mapping(new_mapping)
@@ -293,13 +293,13 @@ if __name__ == '__main__':
DBusGMainLoop(set_as_default=True)
wiican = WiicanIndicator()
- gobject.MainLoop().run()
+ GObject.MainLoop().run()
def display_error(message):
- error_loading_dlg = gtk.MessageDialog(
- flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
- type = gtk.MESSAGE_ERROR,
- buttons = gtk.BUTTONS_CLOSE,
+ error_loading_dlg = Gtk.MessageDialog(
+ flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ type = Gtk.MessageType.ERROR,
+ buttons = Gtk.ButtonsType.CLOSE,
message_format = message)
error_loading_dlg.set_title(_('Wiican Mapping Package load failed!'))
error_loading_dlg.run()
diff --git a/bin/wiican-service b/bin/wiican-service
index 966a925..3894259 100755
--- a/bin/wiican-service
+++ b/bin/wiican-service
@@ -22,7 +22,7 @@
###
import sys
-import gobject
+from gi.repository import GObject
import dbus
from dbus.mainloop.glib import DBusGMainLoop
@@ -30,7 +30,7 @@ from dbus.mainloop.glib import DBusGMainLoop
from wiican.service import WiicanDBus, WIICAN_URI
DBusGMainLoop(set_as_default=True)
-loop = gobject.MainLoop()
+loop = GObject.MainLoop()
if WIICAN_URI in dbus.SessionBus().list_names():
print "Found wiican already running, exiting"
diff --git a/tests/dbus-test.py b/tests/dbus-test.py
index 611acb8..7761491 100644
--- a/tests/dbus-test.py
+++ b/tests/dbus-test.py
@@ -21,7 +21,7 @@
#
###
-import gobject
+from gi.repository import GObject
import dbus
from dbus.mainloop.glib import DBusGMainLoop
@@ -58,4 +58,4 @@ if __name__ == '__main__':
wiican_iface.connect_to_signal('StatusChanged', status_cb,
dbus_interface='org.gnome.Wiican')
- gobject.MainLoop().run()
+ GObject.MainLoop().run()
diff --git a/wiican/service/wiican_dbus.py b/wiican/service/wiican_dbus.py
index 394e741..750ed11 100644
--- a/wiican/service/wiican_dbus.py
+++ b/wiican/service/wiican_dbus.py
@@ -238,14 +238,14 @@ class WiicanDBus(dbus.service.Object):
pass
if __name__ == '__main__':
- import gobject
+ from gi.repository import GObject
from dbus.mainloop.glib import DBusGMainLoop
def status_cb(status):
print 'Wiican status:', status
DBusGMainLoop(set_as_default=True)
- loop = gobject.MainLoop()
+ loop = GObject.MainLoop()
wiican = WiicanDBus(loop)
diff --git a/wiican/service/wiifinder.py b/wiican/service/wiifinder.py
index 45a3704..52a79a8 100644
--- a/wiican/service/wiifinder.py
+++ b/wiican/service/wiifinder.py
@@ -20,7 +20,7 @@
#
###
-import gobject
+from gi.repository import GObject
import gudev
WIIMOTE_DEVICE_NAME = '"Nintendo Wiimote"'
@@ -49,17 +49,17 @@ class WiimoteDevice(object):
"""
return self.device.get_sysfs_path()
-class WiimoteFinder(gobject.GObject):
+class WiimoteFinder(GObject.GObject):
"""
An object that will find and monitor Wiimote devices on your
machine and emit signals when are connected / disconnected
"""
__gsignals__ = {
- 'connected': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_PYOBJECT,)),
- 'disconnected': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_PYOBJECT,)),
+ 'connected': (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_PYOBJECT,)),
+ 'disconnected': (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_PYOBJECT,)),
}
def __init__(self):
@@ -103,10 +103,10 @@ class WiimoteFinder(gobject.GObject):
self.emit('disconnected', self.wiimotes[path])
del(self.wiimotes[path])
-gobject.type_register(WiimoteFinder)
+GObject.type_register(WiimoteFinder)
if __name__ == "__main__":
- import gobject
+ from gi.repository import GObject
def found(finder, device):
print device.path + ": " + device.nice_label
@@ -118,5 +118,5 @@ if __name__ == "__main__":
finder.connect('connected', found)
finder.connect('disconnected', lost)
- loop = gobject.MainLoop()
+ loop = GObject.MainLoop()
loop.run()
diff --git a/wiican/service/wminput.py b/wiican/service/wminput.py
index 1a7ec24..367c2a5 100644
--- a/wiican/service/wminput.py
+++ b/wiican/service/wminput.py
@@ -21,12 +21,12 @@
###
import os
-import gobject
+from gi.repository import GObject
import threading
import subprocess
import signal
-gobject.threads_init()
+GObject.threads_init()
def threaded(f):
def wrapper(*args):
@@ -35,12 +35,12 @@ def threaded(f):
t.start()
return wrapper
-class WMInputLauncher(gobject.GObject):
+class WMInputLauncher(GObject.GObject):
__gsignals__ = {
- 'wminput_launched' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_PYOBJECT,)),
- 'wminput_stopped' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_PYOBJECT,))
+ 'wminput_launched' : (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_PYOBJECT,)),
+ 'wminput_stopped' : (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_PYOBJECT,))
}
wminput_cmd = ['wminput']
@@ -69,7 +69,7 @@ class WMInputLauncher(gobject.GObject):
retcode = self._process.wait()
self.emit('wminput_stopped', retcode)
- @gobject.property
+ @GObject.property
def running(self):
return self._process is not None
@@ -95,5 +95,5 @@ if __name__ == '__main__':
x.connect('wminput_launched', loaded)
x.connect('wminput_stopped', stopped)
x.start()
- gobject.timeout_add(5000, stopit, x)
- gobject.MainLoop().run()
+ GObject.timeout_add(5000, stopit, x)
+ GObject.MainLoop().run()
diff --git a/wiican/ui/editordlg.py b/wiican/ui/editordlg.py
index ddfeedc..e824c0a 100644
--- a/wiican/ui/editordlg.py
+++ b/wiican/ui/editordlg.py
@@ -20,10 +20,10 @@
#
###
-import gtk
+from gi.repository import Gtk
import webbrowser
-import pango
-import gtksourceview2
+from gi.repository import Pango
+from gi.repository import GtkSource
import tempfile
import dbus, dbus.exceptions
@@ -38,7 +38,7 @@ from wiican.service import WC_DISABLED, WC_BLUEZ_PRESENT, WC_UINPUT_PRESENT, \
WC_WIIMOTE_DISCOVERING
# Load icons
-theme = gtk.icon_theme_get_default()
+theme = Gtk.IconTheme.get_default()
wiican_on_icon = theme.load_icon('wiican-on', 24, 0)
wiican_off_icon = theme.load_icon('wiican-off', 24, 0)
@@ -46,14 +46,14 @@ wiican_disc3_icon = theme.load_icon('wiican-discover3', 24, 0)
pref_store = UIPrefStore()
-class IconChooserDialog(gtk.FileChooserDialog):
+class IconChooserDialog(Gtk.FileChooserDialog):
def __init__(self, parent, title=_('Select image icon..'), icon_size=64):
# Do the icon preview
def update_preview_cb(file_chooser, preview, icon_size):
filename = file_chooser.get_preview_filename()
try:
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename,
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename,
icon_size, icon_size)
preview.set_from_pixbuf(pixbuf)
have_preview = True
@@ -62,13 +62,13 @@ class IconChooserDialog(gtk.FileChooserDialog):
file_chooser.set_preview_widget_active(have_preview)
return
- gtk.FileChooserDialog.__init__(self, title, parent,
- gtk.FILE_CHOOSER_ACTION_OPEN,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+ GObject.GObject.__init__(self, title, parent,
+ Gtk.FileChooserAction.OPEN,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
- self.set_default_response(gtk.RESPONSE_OK)
- self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ self.set_default_response(Gtk.ResponseType.OK)
+ self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
self.add_shortcut_folder('/usr/share/icons')
self.add_shortcut_folder('/usr/share/pixmaps')
@@ -76,7 +76,7 @@ class IconChooserDialog(gtk.FileChooserDialog):
self.set_current_folder(pref_store.options['icon_dir'])
#TODO: Maybe a better filter it's requiered
- filter = gtk.FileFilter()
+ filter = Gtk.FileFilter()
filter.set_name(_('Images'))
filter.add_mime_type('image/png')
filter.add_mime_type('image/jpeg')
@@ -89,7 +89,7 @@ class IconChooserDialog(gtk.FileChooserDialog):
self.add_filter(filter)
# Set a preview widget
- preview = gtk.Image()
+ preview = Gtk.Image()
self.set_preview_widget(preview)
self.connect('update-preview', update_preview_cb, preview, icon_size)
@@ -97,7 +97,7 @@ class MappingEditorDialog(object):
def __init__(self, mapping, system_mapping = False):
self.mapping = mapping
- self.builder = gtk.Builder()
+ self.builder = Gtk.Builder()
if not self.builder.add_objects_from_file(MAPPING_UI,
['mapping_editor_dlg']):#, 'mapping_buffer']):
raise 'Cant load %s' % MAPPING_UI
@@ -112,10 +112,10 @@ class MappingEditorDialog(object):
self.icon_image = self.builder.get_object('icon_image')
self.execute_btn = self.builder.get_object('execute_btn')
- lm = gtksourceview2.LanguageManager()
- self.mapping_buffer = gtksourceview2.Buffer()
+ lm = GtkSource.LanguageManager()
+ self.mapping_buffer = GtkSource.Buffer()
self.mapping_buffer.set_data('languages-manager', lm)
- view = gtksourceview2.View(self.mapping_buffer)
+ view = GtkSource.View(self.mapping_buffer)
view.set_show_line_numbers(True)
view.set_auto_indent(True)
@@ -125,18 +125,18 @@ class MappingEditorDialog(object):
if system_mapping:
self.warning_box = self.builder.get_object('warning_box')
self.warning_frame = self.builder.get_object('warning_frame')
- self.warning_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#F6FA9C'))
+ self.warning_box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#F6FA9C'))
self.warning_frame.show_all()
#FIXME: iconfilechooser with default dialog from glade 3.6.7 crashes
self.icon_dlg = IconChooserDialog(self.mapping_editor_dlg)
- self.iconfilechooser_btn = gtk.FileChooserButton(self.icon_dlg)
+ self.iconfilechooser_btn = Gtk.FileChooserButton(self.icon_dlg)
self.iconfilechooser_btn.show()
self.iconfilechooser_btn.connect('file-set', self.iconfilechooser_btn_file_set_cb)
self.builder.get_object('mapping_icon_hbox').add(self.iconfilechooser_btn)
# Populate dialog with mapping values
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.mapping.get_icon(),
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(self.mapping.get_icon(),
48, 48)
self.icon_image.set_from_pixbuf(pixbuf)
self.name_entry.set_text(self.mapping.get_name() or '')
@@ -148,7 +148,7 @@ class MappingEditorDialog(object):
self.mapping_editor_dlg.set_title(_('Editing ') + self.mapping.get_name())
# Initial error underlining and colorize comments
- self.mapping_buffer.create_tag('underline_error', underline=pango.UNDERLINE_ERROR)
+ self.mapping_buffer.create_tag('underline_error', underline=Pango.Underline.ERROR)
self.mapping_buffer.create_tag("comment", foreground="darkblue")
self.validator = MappingValidator()
self.changed_cb(None)
@@ -169,19 +169,19 @@ class MappingEditorDialog(object):
self.execute_btn.set_active(True)
self.execute_btn.handler_unblock(self.sig_id)
self.execute_btn.set_tooltip_text(_('A mapping is running'))
- self.execute_btn.set_image(gtk.image_new_from_pixbuf(wiican_disc3_icon))
+ self.execute_btn.set_image(Gtk.image_new_from_pixbuf(wiican_disc3_icon))
elif new_status == (WC_UINPUT_PRESENT | WC_BLUEZ_PRESENT):
self.execute_btn.set_sensitive(True)
self.execute_btn.set_tooltip_text(_('Execute this mapping'))
- self.execute_btn.set_image(gtk.image_new_from_pixbuf(wiican_on_icon))
+ self.execute_btn.set_image(Gtk.image_new_from_pixbuf(wiican_on_icon))
if self.execute_btn.get_active():
self.execute_btn.handler_block(self.sig_id)
self.execute_btn.set_active(False)
self.execute_btn.handler_unblock(self.sig_id)
else:
self.execute_btn.set_sensitive(False)
- self.execute_btn.set_image(gtk.image_new_from_pixbuf(wiican_off_icon))
+ self.execute_btn.set_image(Gtk.image_new_from_pixbuf(wiican_off_icon))
self.execute_btn.set_tooltip_text(_('Ensure a bluetooth ' \
+'adapter its available and uinput module its loaded'))
@@ -274,7 +274,7 @@ class MappingEditorDialog(object):
def iconfilechooser_btn_file_set_cb(self, widget):
filename = self.iconfilechooser_btn.get_filename()
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename, 48, 48)
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, 48, 48)
self.icon_image.set_from_pixbuf(pixbuf)
self.mapping.set_icon(filename)
pref_store.options['icon_dir'] = self.icon_dlg.get_current_folder()
diff --git a/wiican/ui/managerdlg.py b/wiican/ui/managerdlg.py
index 91a6338..1828159 100644
--- a/wiican/ui/managerdlg.py
+++ b/wiican/ui/managerdlg.py
@@ -21,7 +21,7 @@
###
import os.path
-import gtk
+from gi.repository import Gtk
from wiican.defs import *
from wiican.mapping import Mapping, MappingManager, MappingManagerError
@@ -35,17 +35,17 @@ mapping_manager = MappingManager()
pref_store = UIPrefStore()
# Load icons
-theme = gtk.icon_theme_get_default()
+theme = Gtk.IconTheme.get_default()
autostart_icon = theme.load_icon('emblem-favorite', 24, 0)
class MappingManagerDialog(object):
- mapping_filter = gtk.FileFilter()
+ mapping_filter = Gtk.FileFilter()
mapping_filter.set_name(_('Wiican Mapping Package'))
mapping_filter.add_mime_type('application/x-wii')
mapping_filter.add_pattern('*.wii')
def __init__(self):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
if not builder.add_objects_from_file(MAPPING_UI,
['mapping_manager_dlg', 'image3', 'image4', 'mapping_store',
'new_action', 'edit_action', 'delete_action',
@@ -59,18 +59,18 @@ class MappingManagerDialog(object):
self.autostart_ttb = builder.get_object('autostart_toggletoolbutton')
# Enable Drag&Drop
- target_entries = [('catalog', gtk.TARGET_SAME_WIDGET, 0)]
- self.mapping_list.enable_model_drag_source(gtk.gdk.BUTTON1_MASK,
- target_entries, gtk.gdk.ACTION_MOVE)
+ target_entries = [('catalog', Gtk.TargetFlags.SAME_WIDGET, 0)]
+ self.mapping_list.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
+ target_entries, Gdk.DragAction.MOVE)
self.mapping_list.enable_model_drag_dest(target_entries,
- gtk.gdk.ACTION_MOVE)
+ Gdk.DragAction.MOVE)
for mapping_id, mapping in mapping_manager.items():
# Prevent for loading a not found icon path
icon_path = mapping.get_icon()
if not os.path.exists(icon_path): icon_path = ICON_DEFAULT
- icon = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
+ icon = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_path, 24, 24)
visible = mapping_manager.is_visible(mapping_id)
autostart = None
@@ -110,11 +110,11 @@ class MappingManagerDialog(object):
mapping_editor_dlg = MappingEditorDialog(Mapping())
mapping_editor_dlg.set_title(_('Editing new mapping'))
- if mapping_editor_dlg.run() == gtk.RESPONSE_OK:
+ if mapping_editor_dlg.run() == Gtk.ResponseType.OK:
mapping = mapping_editor_dlg.get_mapping()
mapping_id = mapping_manager.add_new_mapping(mapping)
- icon = gtk.gdk.pixbuf_new_from_file_at_size(mapping.get_icon(), 24,
+ icon = GdkPixbuf.Pixbuf.new_from_file_at_size(mapping.get_icon(), 24,
24)
mapping_name = '<b>%s</b>\n<i>%s</i>' % (mapping.get_name(),
@@ -134,12 +134,12 @@ class MappingManagerDialog(object):
system_mapping = mapping_manager.is_system_mapping(mapping_id)
mapping_editor_dlg = MappingEditorDialog(mapping, system_mapping)
- if mapping_editor_dlg.run() == gtk.RESPONSE_OK:
+ if mapping_editor_dlg.run() == Gtk.ResponseType.OK:
new_mapping = mapping_editor_dlg.get_mapping()
new_mapping_id = mapping_manager.write_mapping(new_mapping)
if system_mapping:
- icon = gtk.gdk.pixbuf_new_from_file_at_size(new_mapping.get_icon(),
+ icon = GdkPixbuf.Pixbuf.new_from_file_at_size(new_mapping.get_icon(),
24, 24)
mapping_name = '<b>%s</b>\n<i>%s</i>' % (mapping.get_name(),
@@ -148,7 +148,7 @@ class MappingManagerDialog(object):
mapping.get_comment(), True, None, mapping_id])
else:
mapping_manager[mapping_id] = new_mapping
- model[selected][ICON_COL] = gtk.gdk.pixbuf_new_from_file_at_size(new_mapping.get_icon(),
+ model[selected][ICON_COL] = GdkPixbuf.Pixbuf.new_from_file_at_size(new_mapping.get_icon(),
24, 24)
model[selected][NAME_COL] = '<b>%s</b>\n<i>%s</i>' % (new_mapping.get_name(),
new_mapping.get_comment())
@@ -178,16 +178,16 @@ class MappingManagerDialog(object):
if selected is not None:
delete_message = _('Are you sure you want to completely remove this mapping?')
- delete_dlg = gtk.MessageDialog(parent = self.mapping_dlg,
- flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
- type = gtk.MESSAGE_QUESTION,
- buttons = gtk.BUTTONS_YES_NO,
+ delete_dlg = Gtk.MessageDialog(parent = self.mapping_dlg,
+ flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ type = Gtk.MessageType.QUESTION,
+ buttons = Gtk.ButtonsType.YES_NO,
message_format = delete_message)
- delete_dlg.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ delete_dlg.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
delete_dlg.set_title(_('Deleting mappings'))
- if delete_dlg.run() == gtk.RESPONSE_YES:
+ if delete_dlg.run() == Gtk.ResponseType.YES:
mapping_id = model[selected][MAPPING_ID_COL]
try:
del(mapping_manager[mapping_id])
@@ -195,12 +195,12 @@ class MappingManagerDialog(object):
mapping_manager.set_default_mapping(None)
except MappingManagerError, e:
delete_dlg.destroy()
- error_importing_dlg = gtk.MessageDialog(parent = self.mapping_dlg,
- flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
- type = gtk.MESSAGE_ERROR,
- buttons = gtk.BUTTONS_CLOSE,
+ error_importing_dlg = Gtk.MessageDialog(parent = self.mapping_dlg,
+ flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ type = Gtk.MessageType.ERROR,
+ buttons = Gtk.ButtonsType.CLOSE,
message_format = e.message)
- error_importing_dlg.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ error_importing_dlg.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
error_importing_dlg.run()
error_importing_dlg.destroy()
delete_dlg.destroy()
@@ -210,20 +210,20 @@ class MappingManagerDialog(object):
delete_dlg.destroy()
def mapping_list_key_release_event_cb(self, widget, event):
- if event.keyval == gtk.gdk.keyval_from_name("Delete"):
+ if event.keyval == Gdk.keyval_from_name("Delete"):
self.delete_action_activate_cb(None)
def import_action_activate_cb(self, widget):
- import_dlg = gtk.FileChooserDialog(_('Import mapping...'),
- self.mapping_dlg, gtk.FILE_CHOOSER_ACTION_OPEN,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
- gtk.RESPONSE_OK))
- import_dlg.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ import_dlg = Gtk.FileChooserDialog(_('Import mapping...'),
+ self.mapping_dlg, Gtk.FileChooserAction.OPEN,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN,
+ Gtk.ResponseType.OK))
+ import_dlg.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
import_dlg.add_filter(self.mapping_filter)
import_dlg.add_shortcut_folder(MAPPING_PACKAGES_BASE_DIR)
import_dlg.set_current_folder(pref_store.options['import_dir'])
- if not import_dlg.run() == gtk.RESPONSE_OK:
+ if not import_dlg.run() == Gtk.ResponseType.OK:
import_dlg.destroy()
return
@@ -233,19 +233,19 @@ class MappingManagerDialog(object):
mapping_id = mapping_manager.import_mapping(filename)
except MappingManagerError:
error_importing_message = _('Wiican Mapping Package import failed!')
- error_importing_dlg = gtk.MessageDialog(parent = self.mapping_dlg,
- flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
- type = gtk.MESSAGE_ERROR,
- buttons = gtk.BUTTONS_CLOSE,
+ error_importing_dlg = Gtk.MessageDialog(parent = self.mapping_dlg,
+ flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ type = Gtk.MessageType.ERROR,
+ buttons = Gtk.ButtonsType.CLOSE,
message_format = error_importing_message)
- error_importing_dlg.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ error_importing_dlg.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
error_importing_dlg.run()
error_importing_dlg.destroy()
import_dlg.destroy()
return
mapping = mapping_manager[mapping_id]
- icon = gtk.gdk.pixbuf_new_from_file_at_size(mapping.get_icon(), 24, 24)
+ icon = GdkPixbuf.Pixbuf.new_from_file_at_size(mapping.get_icon(), 24, 24)
mapping_name = '<b>%s</b>\n<i>%s</i>' % (mapping.get_name(),
mapping.get_comment())
@@ -262,18 +262,18 @@ class MappingManagerDialog(object):
mapping_id = model[selected][MAPPING_ID_COL]
mapping = mapping_manager[mapping_id]
- export_dlg = gtk.FileChooserDialog(_('Exporting mapping...'),
- self.mapping_dlg, gtk.FILE_CHOOSER_ACTION_SAVE,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE,
- gtk.RESPONSE_OK))
- export_dlg.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ export_dlg = Gtk.FileChooserDialog(_('Exporting mapping...'),
+ self.mapping_dlg, Gtk.FileChooserAction.SAVE,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE,
+ Gtk.ResponseType.OK))
+ export_dlg.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
export_dlg.set_do_overwrite_confirmation(True)
export_dlg.set_current_folder(pref_store.options['export_dir'])
export_dlg.set_current_name(mapping.get_name()+'.wii')
export_dlg.set_modal(True)
export_dlg.add_filter(self.mapping_filter)
- if export_dlg.run() == gtk.RESPONSE_OK:
+ if export_dlg.run() == Gtk.ResponseType.OK:
dest_file_path = export_dlg.get_filename()
if not dest_file_path.endswith('.wii'):
dest_file_path += '.wii'
@@ -309,7 +309,7 @@ class MappingManagerDialog(object):
def up_btn_clicked_cb(self, widget):
# From PyGTK FAQ Entry 13.51
- # http://faq.pygtk.org/index.py?req=show&file=faq13.051.htp
+ # http://faq.pyGtk.org/index.py?req=show&file=faq13.051.htp
def iter_prev(iter, model):
path = model.get_path(iter)
position = path[-1]
@@ -354,8 +354,8 @@ class MappingManagerDialog(object):
if drop_info:
path, position = drop_info
iter = model.get_iter(path)
- if position in (gtk.TREE_VIEW_DROP_BEFORE,
- gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
+ if position in (Gtk.TreeViewDropPosition.BEFORE,
+ Gtk.TreeViewDropPosition.INTO_OR_BEFORE):
model.insert_before(iter, data)
mapping_manager.swap_mapping_order(model[iter][MAPPING_ID_COL],
model[selected][MAPPING_ID_COL])
@@ -369,6 +369,6 @@ class MappingManagerDialog(object):
mapping_manager.options['mapping_sort'][-1],
model[selected][MAPPING_ID_COL], True)
- if context.action == gtk.gdk.ACTION_MOVE:
+ if context.action == Gdk.DragAction.MOVE:
context.finish(True, True, etime)
return
diff --git a/wiican/ui/notificator.py b/wiican/ui/notificator.py
index 2500a3e..7b49394 100644
--- a/wiican/ui/notificator.py
+++ b/wiican/ui/notificator.py
@@ -24,14 +24,14 @@
#
###
-import gtk
-import gobject
+from gi.repository import Gtk
+from gi.repository import GObject
NOTIF_IFACE = 'org.freedesktop.Notifications'
NOTIF_PATH = '/org/freedesktop/Notifications'
DEF_TIMEOUT = 10000
-DEF_ICON = gtk.STOCK_INFO
+DEF_ICON = Gtk.STOCK_INFO
DEF_URGENCY = 1
try:
@@ -41,16 +41,16 @@ try:
except: dbus_imported = False
else: dbus_imported=True
-class Notificator(gobject.GObject):
- SIGNAL = (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_PYOBJECT,))
+class Notificator(GObject.GObject):
+ SIGNAL = (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_PYOBJECT,))
__gsignals__ = {
'action_invoked' : SIGNAL,
}
def __init__(self, app_name, desktop_entry=None):
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.app_name = app_name
self.desktop_entry = desktop_entry
diff --git a/wiican/ui/pnganimation.py b/wiican/ui/pnganimation.py
index c8cc96e..c6abc51 100644
--- a/wiican/ui/pnganimation.py
+++ b/wiican/ui/pnganimation.py
@@ -20,9 +20,9 @@
#
###
-import gtk.gdk
+import Gtk.gdk
-#TODO: Replace this with gtk.gdk.PixbufAnimation
+#TODO: Replace this with GdkPixbuf.PixbufAnimation
class PngAnimation:
def __init__(self, frames=[]):
self.__frames = frames
@@ -35,9 +35,9 @@ class PngAnimation:
def __composite_thumb(self, source, dest):
dest = dest.add_alpha(True, chr(0xff), chr(0xff), chr(0xff))
- thumb = source.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR)
+ thumb = source.scale_simple(32, 32, GdkPixbuf.InterpType.BILINEAR)
thumb.composite(dest, 0, 0, dest.get_width(), dest.get_height(),
dest.get_width() - thumb.get_width(),
dest.get_height() - thumb.get_height(),
- 1, 1, gtk.gdk.INTERP_BILINEAR, 255)
+ 1, 1, GdkPixbuf.InterpType.BILINEAR, 255)
return dest
diff --git a/wiican/ui/validationerrordlg.py b/wiican/ui/validationerrordlg.py
index fb5c92b..d31cbd4 100644
--- a/wiican/ui/validationerrordlg.py
+++ b/wiican/ui/validationerrordlg.py
@@ -20,15 +20,15 @@
#
###
-import gtk
+from gi.repository import Gtk
from wiican.defs import WIIMOTEMANAGER_UI
class ValidationErrorDialog(object):
- error_icon = gtk.STOCK_DIALOG_ERROR
+ error_icon = Gtk.STOCK_DIALOG_ERROR
def __init__(self, icon_file, parent=None, open_editor=False):
- builder = gtk.Builder()
+ builder = Gtk.Builder()
if not builder.add_objects_from_file(WIIMOTEMANAGER_UI,
['ValidationErrorDialog', 'image1']):
raise 'Cant load %s' % WIIMOTEMANAGER_UI
@@ -39,13 +39,13 @@ class ValidationErrorDialog(object):
self.validation_error_dlg.connect('response', lambda d, r: d.hide())
- icon = gtk.gdk.pixbuf_new_from_file_at_size(icon_file, 64, 64)
+ icon = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_file, 64, 64)
self.icon_image.set_from_pixbuf(self.__composite_thumb(icon))
if parent:
self.validation_error_dlg.set_parent(parent)
self.validation_error_dlg.set_transient_for(parent)
- self.validation_error_dlg.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+ self.validation_error_dlg.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
if open_editor:
self.open_editor_btn.show()
@@ -61,11 +61,11 @@ class ValidationErrorDialog(object):
self.validation_error_dlg.move(x, y)
def __composite_thumb(self, icon):
- error = gtk.Invisible().render_icon(self.error_icon, gtk.ICON_SIZE_BUTTON)
- thumb = error.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR)
+ error = Gtk.Invisible().render_icon(self.error_icon, Gtk.IconSize.BUTTON)
+ thumb = error.scale_simple(32, 32, GdkPixbuf.InterpType.BILINEAR)
thumb.composite(icon, 0, 0, icon.get_width(), icon.get_height(),
icon.get_width() - thumb.get_width(),
icon.get_height() - thumb.get_height(),
- 1, 1, gtk.gdk.INTERP_BILINEAR, 255)
+ 1, 1, GdkPixbuf.InterpType.BILINEAR, 255)
return icon
diff --git a/wiican/utils.py b/wiican/utils.py
index 9234584..6a50f77 100644
--- a/wiican/utils.py
+++ b/wiican/utils.py
@@ -20,7 +20,7 @@
#
###
-import gconf
+from gi.repository import GConf
import types
import exceptions
@@ -56,17 +56,17 @@ class GConfStore(object):
return None
self.__app_key = key
- self.__client = gconf.client_get_default()
+ self.__client = GConf.Client.get_default()
self.options = GConfKeysDict()
self.options.update(self.defaults)
def loadconf(self, only_defaults=False):
- casts = {gconf.VALUE_BOOL: gconf.Value.get_bool,
- gconf.VALUE_INT: gconf.Value.get_int,
- gconf.VALUE_FLOAT: gconf.Value.get_float,
- gconf.VALUE_STRING: gconf.Value.get_string,
- gconf.VALUE_LIST: gconf.Value.get_list}
+ casts = {GConf.ValueType.BOOL: GConf.Value.get_bool,
+ GConf.ValueType.INT: GConf.Value.get_int,
+ GConf.ValueType.FLOAT: GConf.Value.get_float,
+ GConf.ValueType.STRING: GConf.Value.get_string,
+ GConf.ValueType.LIST: GConf.Value.get_list}
if only_defaults:
#FIXME: Why appears this message in stderr?
@@ -83,27 +83,27 @@ class GConfStore(object):
gval = self.__client.get(entry.key)
if gval == None: continue
- if gval.type == gconf.VALUE_LIST:
+ if gval.type == GConf.ValueType.LIST:
string_list = [item.get_string() for item in gval.get_list()]
self.options[entry.key.split('/')[-1]] = string_list
else:
self.options[entry.key.split('/')[-1]] = casts[gval.type](gval)
def saveconf(self):
- casts = {types.BooleanType: gconf.Client.set_bool,
- types.IntType: gconf.Client.set_int,
- types.FloatType: gconf.Client.set_float,
- types.StringType: gconf.Client.set_string,
- types.ListType: gconf.Client.set_list,
- types.TupleType: gconf.Client.set_list,
- set: gconf.Client.set_list}
+ casts = {types.BooleanType: GConf.Client.set_bool,
+ types.IntType: GConf.Client.set_int,
+ types.FloatType: GConf.Client.set_float,
+ types.StringType: GConf.Client.set_string,
+ types.ListType: GConf.Client.set_list,
+ types.TupleType: GConf.Client.set_list,
+ set: GConf.Client.set_list}
#TODO: To clear the gconf dir before save, is it convenient?
for name, value in self.options.items():
if type(value) in (list, tuple, set):
string_value = [str(item) for item in value]
casts[type(value)](self.__client, self.__app_key + '/' + name,
- gconf.VALUE_STRING, string_value)
+ GConf.ValueType.STRING, string_value)
else:
casts[type(value)](self.__client, self.__app_key + '/' + name,
value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]