From e54795f8862d65e64724833ebb7b63ba003dd4fc Mon Sep 17 00:00:00 2001 From: Kshitij Kumar Date: Mon, 14 Jan 2013 18:01:35 +0000 Subject: gtk3 changes --- diff --git a/activity.py b/activity.py index 8bfd758..76874d7 100644 --- a/activity.py +++ b/activity.py @@ -17,8 +17,8 @@ # # activate threads for gst needs -import gobject -gobject.threads_init() +from gi.repository import GObject +GObject.threads_init() import locale locale.setlocale(locale.LC_NUMERIC, 'C') @@ -31,19 +31,19 @@ import os import zipfile -import gtk +from gi.repository import Gtk import telepathy import telepathy.client -from sugar.activity.widgets import ActivityToolbarButton -from sugar.activity.widgets import StopButton -from sugar.graphics.toolbarbox import ToolbarBox -from sugar.graphics.toggletoolbutton import ToggleToolButton -from sugar.activity.activity import Activity -from sugar.presence import presenceservice -from sugar.presence.tubeconn import TubeConnection +from sugar3.activity.widgets import ActivityToolbarButton +from sugar3.activity.widgets import StopButton +from sugar3.graphics.toolbarbox import ToolbarBox +from sugar3.graphics.toggletoolbutton import ToggleToolButton +from sugar3.activity.activity import Activity +from sugar3.presence import presenceservice +from sugar3.presence.tubeconn import TubeConnection -from sugar import profile +from sugar3 import profile import cardtable import scoreboard import game @@ -86,7 +86,7 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder = \ memorizetoolbar.MemorizeToolbarBuilder(self) - toolbar_box.toolbar.insert(gtk.SeparatorToolItem(), -1) + toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1) self._edit_button = ToggleToolButton('view-source') self._edit_button.set_tooltip(_('Edit game')) @@ -96,7 +96,7 @@ class MemorizeActivity(Activity): self._createToolbarBuilder = \ createtoolbar.CreateToolbarBuilder(self) - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() separator.set_expand(True) separator.set_draw(False) separator.set_size_request(0, -1) @@ -166,7 +166,7 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder.connect('game_changed', self.change_game) - self.hbox = gtk.HBox(False) + self.hbox = Gtk.HBox(False) self.set_canvas(self.hbox) # connect to the in/out events of the memorize activity @@ -174,7 +174,7 @@ class MemorizeActivity(Activity): self.connect('focus_out_event', self._focus_out) self.connect('destroy', self._cleanup_cb) - self.add_events(gtk.gdk.POINTER_MOTION_MASK) + self.add_events(Gdk.POINTER_MOTION_MASK) self.connect('motion_notify_event', lambda widget, event: face.look_at()) @@ -304,7 +304,7 @@ class MemorizeActivity(Activity): self.hbox.remove(self.scoreboard) self.hbox.remove(self.table) self.hbox.pack_start(self.createcardpanel, False) - self.hbox.pack_start(self.cardlist) + self.hbox.pack_start(self.cardlist, True, True, 0) self.cardlist.load_game(self.game) self.game.model.create_temp_directories() self.createcardpanel.set_temp_folder( @@ -323,7 +323,7 @@ class MemorizeActivity(Activity): self.hbox.remove(self.createcardpanel) self.hbox.remove(self.cardlist) if self.play_mode in (False, None): - self.hbox.pack_start(self.scoreboard) + self.hbox.pack_start(self.scoreboard, True, True, 0) self.hbox.pack_start(self.table, False) self.play_mode = True self._memorizeToolbarBuilder.update_controls(mode == _MODE_PLAY) diff --git a/audio.py b/audio.py index ddee412..0224321 100644 --- a/audio.py +++ b/audio.py @@ -15,7 +15,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gst +import Gst import logging _logger = logging.getLogger('memorize-activity') @@ -23,41 +23,41 @@ _logger = logging.getLogger('memorize-activity') class Audio(object): def __init__(self): - self._player = gst.element_factory_make('playbin', 'player') - fakesink = gst.element_factory_make('fakesink', 'my-fakesink') + self._player = Gst.ElementFactory.make('playbin', 'player') + fakesink = Gst.ElementFactory.make('fakesink', 'my-fakesink') self._player.set_property('video-sink', fakesink) self._playing = None bus = self._player.get_bus() bus.add_signal_watch() - bus.connect('message', self._gstmessage_cb) + bus.connect('message', self._Gstmessage_cb) def play(self, filename=None): if filename: _logger.debug('play audio %s' % filename) self._player.set_property('uri', 'file://' + filename) - self._player.set_state(gst.STATE_NULL) + self._player.set_state(Gst.STATE_NULL) elif self._playing == None: return else: _logger.debug('continue audio') - self._player.set_state(gst.STATE_PLAYING) + self._player.set_state(Gst.STATE_PLAYING) self._playing = True def pause(self): if self._playing != None: _logger.debug('pause audio') - self._player.set_state(gst.STATE_PAUSED) + self._player.set_state(Gst.STATE_PAUSED) self._playing = False def stop(self): - self._player.set_state(gst.STATE_NULL) + self._player.set_state(Gst.STATE_NULL) - def _gstmessage_cb(self, bus, message): + def _Gstmessage_cb(self, bus, message): message_type = message.type - if message_type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR): - self._player.set_state(gst.STATE_NULL) + if message_type in (Gst.MESSAGE_EOS, Gst.MESSAGE_ERROR): + self._player.set_state(Gst.STATE_NULL) self._playing = None _logger.debug('audio stoped with type %d' % message_type) diff --git a/cardlist.py b/cardlist.py index 6bc781c..a739600 100644 --- a/cardlist.py +++ b/cardlist.py @@ -15,7 +15,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gtk +from gi.repository import Gtk import svgcard import logging from os.path import join, basename @@ -23,17 +23,17 @@ import shutil from model import Pair -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT +from GObject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT -from sugar.graphics import style -from sugar.graphics.icon import Icon +from sugar3.graphics import style +from sugar3.graphics.icon import Icon import theme _logger = logging.getLogger('memorize-activity') -class CardList(gtk.EventBox): +class CardList(Gtk.EventBox): __gsignals__ = { 'pair-selected': (SIGNAL_RUN_FIRST, None, 9 * [TYPE_PYOBJECT]), @@ -41,7 +41,7 @@ class CardList(gtk.EventBox): } def __init__(self): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.pairs = [] self.current_pair = None self.current_game_key = None @@ -49,19 +49,19 @@ class CardList(gtk.EventBox): self.pair_list_modified = False self.game_loaded = False - self.vbox = gtk.VBox(False) + self.vbox = Gtk.VBox(False) - fill_box = gtk.Label() - fill_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#000000')) + fill_box = Gtk.Label() + fill_box.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse('#000000')) fill_box.show() self.vbox.pack_end(fill_box, True, True) - scroll = gtk.ScrolledWindow() - scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scroll = Gtk.ScrolledWindow() + scroll.set_policy(Gtk.POLICY_AUTOMATIC, Gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(self.vbox) scroll.set_border_width(0) - scroll.get_child().modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse('#000000')) + scroll.get_child().modify_bg(Gtk.STATE_NORMAL, + Gdk.color_parse('#000000')) self.add(scroll) self.show_all() @@ -78,14 +78,14 @@ class CardList(gtk.EventBox): self.clean_list(load=True) for key in game_pairs: if game_pairs[key].props.aimg != None: - aimg = gtk.gdk.pixbuf_new_from_file( \ + aimg = Gdk.pixbuf_new_from_file( \ join(self.model.data['pathimg'], game_pairs[key].props.aimg)) else: aimg = None if game_pairs[key].props.bimg != None: - bimg = gtk.gdk.pixbuf_new_from_file( \ + bimg = Gdk.pixbuf_new_from_file( \ join(self.model.data['pathimg'], game_pairs[key].props.bimg)) else: @@ -242,7 +242,7 @@ class CardList(gtk.EventBox): self.pair_list_modified = False -class CardPair(gtk.EventBox): +class CardPair(Gtk.EventBox): __gsignals__ = { 'pair-selected': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), @@ -252,7 +252,7 @@ class CardPair(gtk.EventBox): def __init__(self, text1, text2=None, aimg=None, bimg=None, asnd=None, bsnd=None, aspeak=None, bspeak=None, font_name1=None, font_name2=None): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.bg_color = '#000000' self.asnd = asnd @@ -260,7 +260,7 @@ class CardPair(gtk.EventBox): self.current_game_key = None - row = gtk.HBox() + row = Gtk.HBox() row.props.border_width = 10 row.props.spacing = 10 @@ -274,9 +274,9 @@ class CardPair(gtk.EventBox): None, theme.PAIR_SIZE, 1, self.bg_color, font_name1) self.bcard1.flip() self.bcard1.set_pixbuf(aimg) - align = gtk.Alignment(.5, .5, 0, 0) + align = Gtk.Alignment(.5, .5, 0, 0) align.add(self.bcard1) - row.pack_start(align) + row.pack_start(align, True, True, 0) self.bcard2 = svgcard.SvgCard(-1, {'front_text': {'card_text': text2, @@ -288,26 +288,26 @@ class CardPair(gtk.EventBox): None, theme.PAIR_SIZE, 1, self.bg_color, font_name2) self.bcard2.flip() self.bcard2.set_pixbuf(bimg) - align = gtk.Alignment(.5, .5, 0, 0) + align = Gtk.Alignment(.5, .5, 0, 0) align.add(self.bcard2) - row.pack_start(align) + row.pack_start(align, True, True, 0) close_image = Icon( icon_name='remove', - icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) - align = gtk.Alignment(.5, .5) + icon_size=Gtk.ICON_SIZE_LARGE_TOOLBAR) + align = Gtk.Alignment(.5, .5) align.add(close_image) - close_button = gtk.ToolButton() + close_button = Gtk.ToolButton() close_button.set_icon_widget(align) close_button.connect('clicked', self.emit_close) close_button.set_size_request(style.STANDARD_ICON_SIZE, style.STANDARD_ICON_SIZE) - align = gtk.Alignment(.5, 0, 0, 0) + align = Gtk.Alignment(.5, 0, 0, 0) align.add(close_button) row.pack_start(align, False) self.connect('button-press-event', self.emit_selected) - self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.bg_color)) + self.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse(self.bg_color)) self.add(row) self.show_all() @@ -323,7 +323,7 @@ class CardPair(gtk.EventBox): else: self.bg_color = '#b2b3b7' - self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.bg_color)) + self.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse(self.bg_color)) self.bcard1.set_background(self.bg_color) self.bcard2.set_background(self.bg_color) diff --git a/cardtable.py b/cardtable.py index 97428cc..da246df 100644 --- a/cardtable.py +++ b/cardtable.py @@ -15,12 +15,12 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gtk -import pango +from gi.repository import Gtk +from gi.repository import Pango import svgcard import os import math -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT +from GObject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT import logging _logger = logging.getLogger('memorize-activity') @@ -28,7 +28,7 @@ _logger = logging.getLogger('memorize-activity') import theme -class CardTable(gtk.EventBox): +class CardTable(Gtk.EventBox): __gsignals__ = { 'card-flipped': (SIGNAL_RUN_FIRST, None, [int, TYPE_PYOBJECT]), @@ -37,7 +37,7 @@ class CardTable(gtk.EventBox): } def __init__(self): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.data = None self.cards_data = None self._workspace_size = 0 @@ -47,20 +47,20 @@ class CardTable(gtk.EventBox): self.connect('size-allocate', self._allocate_cb) # Set table settings - self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#000000')) - self.table = gtk.Table() + self.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse('#000000')) + self.table = Gtk.Table() self.table.grab_focus() - self.table.set_flags(gtk.CAN_FOCUS) - self.table.set_flags(gtk.CAN_DEFAULT) + self.table.set_flags(Gtk.CAN_FOCUS) + self.table.set_flags(Gtk.CAN_DEFAULT) self.table.set_row_spacings(theme.CARD_PAD) self.table.set_col_spacings(theme.CARD_PAD) self.table.set_border_width(theme.CARD_PAD) - self.table.set_resize_mode(gtk.RESIZE_IMMEDIATE) + self.table.set_resize_mode(Gtk.RESIZE_IMMEDIATE) self.set_property('child', self.table) - self.load_message = gtk.Label('Loading Game') - self.load_message.modify_fg(gtk.STATE_NORMAL, - gtk.gdk.color_parse('#ffffff')) - self.load_message.modify_font(pango.FontDescription('10')) + self.load_message = Gtk.Label('Loading Game') + self.load_message.modify_fg(Gtk.STATE_NORMAL, + Gdk.color_parse('#ffffff')) + self.load_message.modify_font(Pango.FontDescription('10')) self.load_message.show() self.first_load = True self.load_mode = False @@ -146,7 +146,7 @@ class CardTable(gtk.EventBox): self.id2cd[identifier] = card self.cards[(x, y)] = card self.dict[identifier] = (x, y) - self.table.attach(card, x, x + 1, y, y + 1, gtk.SHRINK, gtk.SHRINK) + self.table.attach(card, x, x + 1, y, y + 1, Gtk.SHRINK, Gtk.SHRINK) x += 1 if x == self.size: @@ -184,31 +184,31 @@ class CardTable(gtk.EventBox): x = self.selected_card[0] y = self.selected_card[1] - if event.keyval in (gtk.keysyms.Left, gtk.keysyms.KP_Left): + if event.keyval in (Gtk.keysyms.Left, Gtk.keysyms.KP_Left): if (x - 1, y) in self.table_positions: card = self.cards[x - 1, y] identifier = self.cd2id.get(card) self.emit('card-highlighted', identifier, False) - elif event.keyval in (gtk.keysyms.Right, gtk.keysyms.KP_Right): + elif event.keyval in (Gtk.keysyms.Right, Gtk.keysyms.KP_Right): if (x + 1, y) in self.table_positions: card = self.cards[x + 1, y] identifier = self.cd2id.get(card) self.emit('card-highlighted', identifier, False) - elif event.keyval in (gtk.keysyms.Up, gtk.keysyms.KP_Up): + elif event.keyval in (Gtk.keysyms.Up, Gtk.keysyms.KP_Up): if (x, y - 1) in self.table_positions: card = self.cards[x, y - 1] identifier = self.cd2id.get(card) self.emit('card-highlighted', identifier, False) - elif event.keyval in (gtk.keysyms.Down, gtk.keysyms.KP_Down): + elif event.keyval in (Gtk.keysyms.Down, Gtk.keysyms.KP_Down): if (x, y + 1) in self.table_positions: card = self.cards[x, y + 1] identifier = self.cd2id.get(card) self.emit('card-highlighted', identifier, False) - elif event.keyval in (gtk.keysyms.space, gtk.keysyms.KP_Page_Down): + elif event.keyval in (Gtk.keysyms.space, Gtk.keysyms.KP_Page_Down): card = self.cards[x, y] self.card_flipped(card) @@ -254,8 +254,8 @@ class CardTable(gtk.EventBox): self.set_property('child', self.table) self.load_mode = mode self.queue_draw() - while gtk.events_pending(): - gtk.main_iteration() + while Gtk.events_pending(): + Gtk.main_iteration() def load_msg(self, widget, msg): if not self.load_mode: diff --git a/createcardpanel.py b/createcardpanel.py index e490f64..078f80b 100644 --- a/createcardpanel.py +++ b/createcardpanel.py @@ -17,20 +17,20 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gtk +from gi.repository import Gtk from os.path import join, basename import shutil from gettext import gettext as _ import svgcard import logging -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT -from sugar.graphics import style -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.icon import Icon -from sugar.graphics.palette import Palette -from sugar.graphics.toggletoolbutton import ToggleToolButton -from sugar.graphics.toolcombobox import ToolComboBox +from GObject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT +from sugar3.graphics import style +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.icon import Icon +from sugar3.graphics.palette import Palette +from sugar3.graphics.toggletoolbutton import ToggleToolButton +from sugar3.graphics.toolcombobox import ToolComboBox from fontcombobox import FontComboBox from port import chooser @@ -44,7 +44,7 @@ import model _logger = logging.getLogger('memorize-activity') -class CreateCardPanel(gtk.EventBox): +class CreateCardPanel(Gtk.EventBox): __gsignals__ = { 'add-pair': (SIGNAL_RUN_FIRST, None, 10 * [TYPE_PYOBJECT]), 'update-pair': (SIGNAL_RUN_FIRST, None, 8 * [TYPE_PYOBJECT]), @@ -53,19 +53,19 @@ class CreateCardPanel(gtk.EventBox): def __init__(self): def make_label(icon_name, label): - label_box = gtk.HBox() + label_box = Gtk.HBox() icon = Icon( icon_name=icon_name, - icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) + icon_size=Gtk.ICON_SIZE_LARGE_TOOLBAR) label_box.pack_start(icon, False) - label = gtk.Label(label) - label.modify_fg(gtk.STATE_NORMAL, - style.COLOR_TOOLBAR_GREY.get_gdk_color()) - label_box.pack_start(label) + label = Gtk.Label(label) + label.modify_fg(Gtk.STATE_NORMAL, + style.COLOR_TOOLBAR_GREY.get_Gdk_color()) + label_box.pack_start(label, True, True, 0) label_box.show_all() return label_box - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.equal_pairs = False self._updatebutton_sensitive = False @@ -74,7 +74,7 @@ class CreateCardPanel(gtk.EventBox): # save buttons - buttons_bar = gtk.HBox() + buttons_bar = Gtk.HBox() buttons_bar.props.border_width = 10 self._addbutton = ToolButton( @@ -109,11 +109,11 @@ class CreateCardPanel(gtk.EventBox): # edit panel - self.card_box = gtk.HBox() - self.card_box.pack_start(self.cardeditor1) - self.card_box.pack_start(self.cardeditor2) + self.card_box = Gtk.HBox() + self.card_box.pack_start(self.cardeditor1, True, True, 0) + self.card_box.pack_start(self.cardeditor2, True, True, 0) - box = gtk.VBox() + box = Gtk.VBox() box.pack_start(self.card_box, False) box.pack_start(buttons_bar, False) self.add(box) @@ -201,7 +201,7 @@ class CreateCardPanel(gtk.EventBox): self.card_box.remove(self.cardeditor2) else: if not self.cardeditor2.parent: - self.card_box.pack_start(self.cardeditor2) + self.card_box.pack_start(self.cardeditor2, True, True, 0) def clean(self, widget): self.cardeditor1.clean() @@ -268,7 +268,7 @@ class CreateCardPanel(gtk.EventBox): self.cardeditor2.temp_folder = temp_folder -class CardEditor(gtk.EventBox): +class CardEditor(Gtk.EventBox): __gsignals__ = { 'has-text': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), @@ -278,17 +278,17 @@ class CardEditor(gtk.EventBox): } def __init__(self, editor_index): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.snd = None self.editor_index = editor_index self.temp_folder = None - box = gtk.VBox() + box = Gtk.VBox() box.props.spacing = theme.PAD box.props.border_width = theme.PAD - self.previewlabel = gtk.Label(_('Preview:')) + self.previewlabel = Gtk.Label(_('Preview:')) self.previewlabel.set_alignment(0, 1) box.pack_start(self.previewlabel, False) @@ -300,15 +300,15 @@ class CardEditor(gtk.EventBox): 'opacity': '1'}}, None, theme.PAIR_SIZE, 1, '#c0c0c0') self.card.flip() - card_align = gtk.Alignment(.5, .5, 0, 0) + card_align = Gtk.Alignment(.5, .5, 0, 0) card_align.add(self.card) box.pack_start(card_align, False) - textlabel = gtk.Label(_('Text:')) + textlabel = Gtk.Label(_('Text:')) textlabel.set_alignment(0, 1) box.pack_start(textlabel, False) - self.textentry = gtk.Entry() + self.textentry = Gtk.Entry() self.textentry.connect('changed', self.update_text) box.pack_start(self.textentry, False) @@ -404,15 +404,15 @@ class CardEditor(gtk.EventBox): self.set_speak(None) - pixbuf_t = gtk.gdk.pixbuf_new_from_file_at_size( + pixbuf_t = Gdk.pixbuf_new_from_file_at_size( index, theme.PAIR_SIZE - theme.PAD * 2, theme.PAIR_SIZE - theme.PAD * 2) size = max(pixbuf_t.get_width(), pixbuf_t.get_height()) - pixbuf_z = gtk.gdk.pixbuf_new_from_file_at_size( + pixbuf_z = Gdk.pixbuf_new_from_file_at_size( 'images/white.png', size, size) pixbuf_t.composite(pixbuf_z, 0, 0, pixbuf_t.get_width(), pixbuf_t.get_height(), 0, 0, 1, 1, - gtk.gdk.INTERP_BILINEAR, 255) + Gdk.INTERP_BILINEAR, 255) self.card.set_pixbuf(pixbuf_z) _logger.debug('Picture Loaded: ' + index) self.emit('has-picture', True) @@ -432,7 +432,7 @@ class CardEditor(gtk.EventBox): dst = join(self.temp_folder, 'sounds', basename(index)) shutil.copy(index, dst) self.set_snd(dst) - icon_theme = gtk.icon_theme_get_default() + icon_theme = Gtk.icon_theme_get_default() pixbuf_t = icon_theme.load_icon("audio-x-generic", style.XLARGE_ICON_SIZE, 0) self.card.set_pixbuf(pixbuf_t) @@ -484,8 +484,8 @@ class SpeakPalette(Palette): self.face = speak.face.View() - toolbar = gtk.HBox() - toolbar.modify_bg(gtk.STATE_NORMAL, style.COLOR_BLACK.get_gdk_color()) + toolbar = Gtk.HBox() + toolbar.modify_bg(Gtk.STATE_NORMAL, style.COLOR_BLACK.get_Gdk_color()) usespeak_play = ToolButton(icon_name='media-playback-start') usespeak_play.connect('clicked', lambda button: @@ -493,7 +493,7 @@ class SpeakPalette(Palette): toolbar.pack_start(usespeak_play, False) self.voices = speak.widgets.Voices(self.face) - toolbar.pack_start(ToolComboBox(self.voices)) + toolbar.pack_start(ToolComboBox(self.voices, True, True, 0)) toolbar.show_all() self.set_content(toolbar) diff --git a/createtoolbar.py b/createtoolbar.py index 49feaf7..9b9c22e 100644 --- a/createtoolbar.py +++ b/createtoolbar.py @@ -17,18 +17,18 @@ from gettext import gettext as _ -import gtk -import gobject -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT +from gi.repository import Gtk +from gi.repository import GObject +from GObject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT import logging -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toggletoolbutton import ToggleToolButton -from sugar.graphics.alert import Alert -from sugar.graphics.icon import Icon +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.toggletoolbutton import ToggleToolButton +from sugar3.graphics.alert import Alert +from sugar3.graphics.icon import Icon -class CreateToolbarBuilder(gobject.GObject): +class CreateToolbarBuilder(GObject.GObject): __gtype_name__ = 'CreateToolbar' @@ -38,7 +38,7 @@ class CreateToolbarBuilder(gobject.GObject): } def __init__(self, activity): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self.activity = activity self.toolbar = self.activity.get_toolbar_box().toolbar @@ -60,7 +60,7 @@ class CreateToolbarBuilder(gobject.GObject): self.toolbar.show_all() def _add_widget(self, widget, expand=False): - tool_item = gtk.ToolItem() + tool_item = Gtk.ToolItem() tool_item.set_expand(expand) tool_item.add(widget) widget.show() diff --git a/face.py b/face.py index dd4bf90..7032455 100644 --- a/face.py +++ b/face.py @@ -12,23 +12,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import gtk +from gi.repository import Gtk import logging _logger = logging.getLogger('memorize-activity') -from sugar.graphics import style +from sugar3.graphics import style import speak.espeak import speak.face import theme -class Face(gtk.EventBox): +class Face(Gtk.EventBox): def __init__(self): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) - self.modify_bg(gtk.STATE_NORMAL, style.COLOR_BLACK.get_gdk_color()) + self.modify_bg(Gtk.STATE_NORMAL, style.COLOR_BLACK.get_Gdk_color()) self.face = speak.face.View(style.Color('#4b4c4e')) self.face.set_border_width(theme.SVG_PAD) @@ -52,7 +52,7 @@ def look_at(): if not speak.espeak.supported: return - display = gtk.gdk.display_get_default() + display = Gdk.display_get_default() screen_, x, y, modifiers_ = display.get_pointer() for i in _cache: diff --git a/fontcombobox.py b/fontcombobox.py index 58f9140..5d76a7e 100644 --- a/fontcombobox.py +++ b/fontcombobox.py @@ -15,21 +15,21 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import gtk +from gi.repository import Gtk FONT_BLACKLIST = ['cmex10', 'cmmi10', 'cmr10', 'cmsy10', 'esint10', 'eufm10', 'msam10', 'msbm10', 'rsfs10', 'wasy10'] -class FontComboBox(gtk.ComboBox): +class FontComboBox(Gtk.ComboBox): def __init__(self): - gtk.ComboBox.__init__(self) - font_renderer = gtk.CellRendererText() - self.pack_start(font_renderer) + Gtk.ComboBox.__init__(self) + font_renderer = Gtk.CellRendererText() + self.pack_start(font_renderer, True, True, 0) self.add_attribute(font_renderer, 'text', 0) self.add_attribute(font_renderer, 'font', 0) - font_model = gtk.ListStore(str) + font_model = Gtk.ListStore(str) context = self.get_pango_context() font_index = 0 @@ -45,8 +45,8 @@ class FontComboBox(gtk.ComboBox): font_faces.append(face_name) self.faces[name] = font_faces - sorter = gtk.TreeModelSort(font_model) - sorter.set_sort_column_id(0, gtk.SORT_ASCENDING) + sorter = Gtk.TreeModelSort(font_model) + sorter.set_sort_column_id(0, Gtk.SORT_ASCENDING) self.set_model(sorter) self.show() diff --git a/game.py b/game.py index c5e54d1..9ed439c 100644 --- a/game.py +++ b/game.py @@ -16,12 +16,12 @@ # import logging -import gobject +from gi.repository import GObject from os.path import join from gettext import gettext as _ -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT, GObject, timeout_add -from gobject import source_remove +from GObject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT, GObject, timeout_add +from GObject import source_remove from model import Model from audio import Audio @@ -58,7 +58,7 @@ class MemorizeGame(GObject): } def __init__(self): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self.myself = None self.players_score = {} self.players = [] diff --git a/memorizetoolbar.py b/memorizetoolbar.py index 1a06da7..78f4d38 100644 --- a/memorizetoolbar.py +++ b/memorizetoolbar.py @@ -15,24 +15,24 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gobject +from gi.repository import GObject from os.path import join, dirname from gettext import gettext as _ -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toolcombobox import ToolComboBox -from sugar.graphics.alert import Alert -from sugar.graphics.icon import Icon -from sugar.activity.widgets import RadioMenuButton -from sugar.graphics.menuitem import MenuItem +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.toolcombobox import ToolComboBox +from sugar3.graphics.alert import Alert +from sugar3.graphics.icon import Icon +from sugar3.activity.widgets import RadioMenuButton +from sugar3.graphics.menuitem import MenuItem import logging -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT +from GObject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT _logger = logging.getLogger('memorize-activity') -class MemorizeToolbarBuilder(gobject.GObject): +class MemorizeToolbarBuilder(GObject.GObject): __gtype_name__ = 'MemoryToolbarBuilder' @@ -50,7 +50,7 @@ class MemorizeToolbarBuilder(gobject.GObject): } def __init__(self, activity): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self.activity = activity self.toolbar = self.activity.get_toolbar_box().toolbar self.jobject = None diff --git a/messenger.py b/messenger.py index 3cbd7e7..02c8578 100644 --- a/messenger.py +++ b/messenger.py @@ -22,8 +22,8 @@ import tempfile from os import environ, chmod from os.path import join, getsize, dirname, basename from dbus.service import method, signal -from dbus.gobject_service import ExportedGObject -from sugar.datastore import datastore +from dbus.GObject_service import ExportedGObject +from sugar3.datastore import datastore from gettext import gettext as _ SERVICE = 'org.laptop.Memorize' diff --git a/model.py b/model.py index 2567ed2..b8afacd 100644 --- a/model.py +++ b/model.py @@ -20,33 +20,33 @@ from os import environ, makedirs, chmod from os.path import join, basename, isdir, split, normpath, exists import logging import random -import gobject +from gi.repository import GObject import zipfile import tempfile -from sugar.activity.activity import get_bundle_path, get_activity_root +from sugar3.activity.activity import get_bundle_path, get_activity_root _logger = logging.getLogger('model') DEFAULT_FONT = 'Sans' -class Pair(gobject.GObject): +class Pair(GObject.GObject): __gproperties__ = { - 'aimg': (str, None, None, None, gobject.PARAM_READWRITE), - 'asnd': (str, None, None, None, gobject.PARAM_READWRITE), - 'achar': (str, None, None, None, gobject.PARAM_READWRITE), - 'bimg': (str, None, None, None, gobject.PARAM_READWRITE), - 'bsnd': (str, None, None, None, gobject.PARAM_READWRITE), - 'bchar': (str, None, None, None, gobject.PARAM_READWRITE), - 'aspeak': (str, None, None, None, gobject.PARAM_READWRITE), - 'bspeak': (str, None, None, None, gobject.PARAM_READWRITE), - 'color': (gobject.TYPE_INT, 'Base', 'Base', 0, 10, 0, \ - gobject.PARAM_READWRITE) + 'aimg': (str, None, None, None, GObject.PARAM_READWRITE), + 'asnd': (str, None, None, None, GObject.PARAM_READWRITE), + 'achar': (str, None, None, None, GObject.PARAM_READWRITE), + 'bimg': (str, None, None, None, GObject.PARAM_READWRITE), + 'bsnd': (str, None, None, None, GObject.PARAM_READWRITE), + 'bchar': (str, None, None, None, GObject.PARAM_READWRITE), + 'aspeak': (str, None, None, None, GObject.PARAM_READWRITE), + 'bspeak': (str, None, None, None, GObject.PARAM_READWRITE), + 'color': (GObject.TYPE_INT, 'Base', 'Base', 0, 10, 0, \ + GObject.PARAM_READWRITE) } def __init__(self): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self._properties = {'aimg': None, 'asnd': None, 'achar': None, 'bimg': None, 'bsnd': None, 'bchar': None, 'color': 100, 'aspeak': None, 'bspeak': None} diff --git a/playerscoreboard.py b/playerscoreboard.py index 5c8db14..73df73c 100644 --- a/playerscoreboard.py +++ b/playerscoreboard.py @@ -15,7 +15,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gtk +from gi.repository import Gtk import svglabel import logging @@ -28,10 +28,10 @@ import theme _logger = logging.getLogger('memorize-activity') -class PlayerScoreboard(gtk.EventBox): +class PlayerScoreboard(Gtk.EventBox): def __init__(self, nick, fill_color, stroke_color, score=0): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.default_color = '#4c4d4f' self.selected_color = '#818286' @@ -46,15 +46,15 @@ class PlayerScoreboard(gtk.EventBox): self.connect('size-allocate', self._allocate_cb) # Set table - self.table = gtk.Table(2, 2, False) - self.modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(self.current_color)) + self.table = Gtk.Table(2, 2, False) + self.modify_bg(Gtk.STATE_NORMAL, + Gdk.color_parse(self.current_color)) self.table.set_row_spacings(theme.PAD / 2) self.table.set_col_spacings(theme.PAD / 2) self.table.set_border_width(theme.PAD) # Score table - self.score_table = gtk.Table() + self.score_table = Gtk.Table() self.score_table.set_row_spacings(theme.PAD / 2) self.score_table.set_col_spacings(theme.PAD / 2) @@ -73,17 +73,17 @@ class PlayerScoreboard(gtk.EventBox): theme.BODY_WIDTH, theme.BODY_HEIGHT) # Set nick label - self.nick = gtk.Label(nick) - self.nick.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff')) + self.nick = Gtk.Label(nick) + self.nick.modify_fg(Gtk.STATE_NORMAL, Gdk.color_parse('#ffffff')) self.nick.set_alignment(0, 0.5) # Set message label - self.msg = gtk.Label('Waiting for next game...') - self.msg.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff')) + self.msg = Gtk.Label('Waiting for next game...') + self.msg.modify_fg(Gtk.STATE_NORMAL, Gdk.color_parse('#ffffff')) self.msg.set_alignment(0, 0.5) self.add(self.table) - self.table.attach(self.icon, 0, 1, 0, 3, gtk.SHRINK, gtk.SHRINK) + self.table.attach(self.icon, 0, 1, 0, 3, Gtk.SHRINK, Gtk.SHRINK) self.table.attach(self.nick, 1, 2, 0, 1) self.table.attach(self.score_table, 1, 2, 1, 2) @@ -123,7 +123,7 @@ class PlayerScoreboard(gtk.EventBox): self.scores.append(new_score) new_score.show() self.score_table.attach(new_score, self.current_x, self.current_x + 1, - self.current_y, self.current_y + 1, gtk.SHRINK, gtk.SHRINK) + self.current_y, self.current_y + 1, Gtk.SHRINK, Gtk.SHRINK) self.current_x += 1 if self.current_x == self._score_cols: self.current_x = 0 @@ -136,8 +136,8 @@ class PlayerScoreboard(gtk.EventBox): self.current_color = self.selected_color else: self.current_color = self.default_color - self.modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(self.current_color)) + self.modify_bg(Gtk.STATE_NORMAL, + Gdk.color_parse(self.current_color)) self.icon.set_background(self.current_color) for score in self.scores: score.set_selected(sel) diff --git a/port/chooser.py b/port/chooser.py index 1ee4023..9e1b3ff 100644 --- a/port/chooser.py +++ b/port/chooser.py @@ -14,11 +14,11 @@ """Object chooser method""" -import gtk +from gi.repository import Gtk import logging -from sugar import mime -from sugar.graphics.objectchooser import ObjectChooser +from sugar3 import mime +from sugar3.graphics.objectchooser import ObjectChooser TEXT = hasattr(mime, 'GENERIC_TYPE_TEXT') and mime.GENERIC_TYPE_TEXT or None IMAGE = hasattr(mime, 'GENERIC_TYPE_IMAGE') and mime.GENERIC_TYPE_IMAGE or None @@ -47,7 +47,7 @@ def pick(cb=None, default=None, parent=None, what=None): out = None try: - if chooser.run() == gtk.RESPONSE_ACCEPT: + if chooser.run() == Gtk.RESPONSE_ACCEPT: jobject = chooser.get_selected_object() logging.debug('ObjectChooser: %r' % jobject) diff --git a/port/roundbox.py b/port/roundbox.py index 54ae1a9..ab0f81e 100644 --- a/port/roundbox.py +++ b/port/roundbox.py @@ -1,15 +1,15 @@ import math -import gtk -from sugar.graphics import style +from gi.repository import Gtk +from sugar3.graphics import style -class RoundBox(gtk.HBox): +class RoundBox(Gtk.HBox): __gtype_name__ = 'RoundBox' _BORDER_DEFAULT = style.LINE_WIDTH def __init__(self, **kwargs): - gtk.HBox.__init__(self, **kwargs) + Gtk.HBox.__init__(self, **kwargs) self._radius = style.zoom(10) self.border = self._BORDER_DEFAULT @@ -61,20 +61,20 @@ class RoundBox(gtk.HBox): if __name__ == '__main__': - win = gtk.Window() - win.connect('destroy', gtk.main_quit) + win = Gtk.Window() + win.connect('destroy', Gtk.main_quit) win.set_default_size(450, 550) - vbox = gtk.VBox() + vbox = Gtk.VBox() box1 = RoundBox() vbox.add(box1) - label1 = gtk.Label("Test 1") + label1 = Gtk.Label("Test 1") box1.add(label1) rbox = RoundBox() rbox.background_color = style.Color('#FF0000') vbox.add(rbox) - label2 = gtk.Label("Test 2") + label2 = Gtk.Label("Test 2") rbox.add(label2) bbox = RoundBox() @@ -84,4 +84,4 @@ if __name__ == '__main__': win.add(vbox) win.show_all() - gtk.main() + Gtk.main() diff --git a/score.py b/score.py index ef84d87..2217d91 100644 --- a/score.py +++ b/score.py @@ -16,7 +16,7 @@ # import svglabel -import gtk +from gi.repository import Gtk import os import theme @@ -57,12 +57,12 @@ class Score(svglabel.SvgLabel): self.status = status if status: self.pixbuf = self.pixbuf_sel - self.modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(self.selected_color)) + self.modify_bg(Gtk.STATE_NORMAL, + Gdk.color_parse(self.selected_color)) else: self.pixbuf = self.pixbuf_un - self.modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(self.default_color)) + self.modify_bg(Gtk.STATE_NORMAL, + Gdk.color_parse(self.default_color)) self.queue_draw() def get_pixbuf_un(self): diff --git a/scoreboard.py b/scoreboard.py index 4aa6997..75cdef0 100644 --- a/scoreboard.py +++ b/scoreboard.py @@ -15,33 +15,33 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gtk +from gi.repository import Gtk import logging from playerscoreboard import PlayerScoreboard _logger = logging.getLogger('memorize-activity') -class Scoreboard(gtk.EventBox): +class Scoreboard(Gtk.EventBox): def __init__(self): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.players = {} self.current_buddy = None - self.vbox = gtk.VBox(False) + self.vbox = Gtk.VBox(False) - fill_box = gtk.EventBox() - fill_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#4c4d4f')) + fill_box = Gtk.EventBox() + fill_box.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse('#4c4d4f')) fill_box.show() self.vbox.pack_end(fill_box, True, True) - scroll = gtk.ScrolledWindow() - scroll.props.shadow_type = gtk.SHADOW_NONE - scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + scroll = Gtk.ScrolledWindow() + scroll.props.shadow_type = Gtk.SHADOW_NONE + scroll.set_policy(Gtk.POLICY_NEVER, Gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(self.vbox) scroll.set_border_width(0) - scroll.get_child().set_property('shadow-type', gtk.SHADOW_NONE) + scroll.get_child().set_property('shadow-type', Gtk.SHADOW_NONE) self.add(scroll) self.show_all() diff --git a/setup.py b/setup.py index 530f97c..c60f4d0 100755 --- a/setup.py +++ b/setup.py @@ -16,6 +16,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from sugar.activity import bundlebuilder +from sugar3.activity import bundlebuilder bundlebuilder.start() diff --git a/speak/espeak.py b/speak/espeak.py index 389045d..70610c8 100644 --- a/speak/espeak.py +++ b/speak/espeak.py @@ -12,8 +12,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import gst -import gobject +import gi.repository import Gst +from gi.repository import GObject import subprocess import logging @@ -21,27 +21,27 @@ logger = logging.getLogger('speak') supported = True -class BaseAudioGrab(gobject.GObject): +class BaseAudioGrab(GObject.GObject): __gsignals__ = { - 'new-buffer': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT]) + 'new-buffer': (GObject.SIGNAL_RUN_FIRST, None, [GObject.TYPE_PYOBJECT]) } def __init__(self): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self.pipeline = None self.quiet = True def restart_sound_device(self): self.quiet = False - self.pipeline.set_state(gst.STATE_NULL) - self.pipeline.set_state(gst.STATE_PLAYING) + self.pipeline.set_state(Gst.STATE_NULL) + self.pipeline.set_state(Gst.STATE_PLAYING) def stop_sound_device(self): if self.pipeline is None: return - self.pipeline.set_state(gst.STATE_NULL) + self.pipeline.set_state(Gst.STATE_NULL) # Shut theirs mouths down self._new_buffer('') @@ -55,7 +55,7 @@ class BaseAudioGrab(gobject.GObject): # build a pipeline that reads the given file # and sends it to both the real audio output # and a fake one that we use to draw from - self.pipeline = gst.parse_launch( + self.pipeline = Gst.parse_launch( cmd + ' ' \ '! decodebin ' \ '! tee name=tee ' \ @@ -66,17 +66,17 @@ class BaseAudioGrab(gobject.GObject): def on_buffer(element, buffer, pad): # we got a new buffer of data, ask for another - gobject.timeout_add(100, self._new_buffer, str(buffer)) + GObject.timeout_add(100, self._new_buffer, str(buffer)) return True sink = self.pipeline.get_by_name('sink') sink.props.signal_handoffs = True sink.connect('handoff', on_buffer) - def gstmessage_cb(bus, message): + def Gstmessage_cb(bus, message): self._was_message = True - if message.type == gst.MESSAGE_WARNING: + if message.type == Gst.MESSAGE_WARNING: def check_after_warnings(): if not self._was_message: self.stop_sound_device() @@ -84,16 +84,16 @@ class BaseAudioGrab(gobject.GObject): logger.debug(message.type) self._was_message = False - gobject.timeout_add(500, self._new_buffer, str(buffer)) + GObject.timeout_add(500, self._new_buffer, str(buffer)) - elif message.type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR): + elif message.type in (Gst.MESSAGE_EOS, Gst.MESSAGE_ERROR): logger.debug(message.type) self.stop_sound_device() self._was_message = False bus = self.pipeline.get_bus() bus.add_signal_watch() - bus.connect('message', gstmessage_cb) + bus.connect('message', Gstmessage_cb) def _new_buffer(self, buf): if not self.quiet: @@ -103,13 +103,13 @@ class BaseAudioGrab(gobject.GObject): # load proper espeak plugin try: - import gst - gst.element_factory_make('espeak') - from espeak_gst import AudioGrabGst as AudioGrab - from espeak_gst import * - logger.info('use gst-plugins-espeak') + import Gst + Gst.ElementFactory.make('espeak', None) + from espeak_Gst import AudioGrabGst as AudioGrab + from espeak_Gst import * + logger.info('use Gst-plugins-espeak') except Exception, e: - logger.info('disable gst-plugins-espeak: %s' % e) + logger.info('disable Gst-plugins-espeak: %s' % e) if subprocess.call('which espeak', shell=True) == 0: from espeak_cmd import AudioGrabCmd as AudioGrab from espeak_cmd import * diff --git a/speak/espeak_gst.py b/speak/espeak_gst.py index 85cfa26..85cd48b 100644 --- a/speak/espeak_gst.py +++ b/speak/espeak_gst.py @@ -15,7 +15,7 @@ import logging logger = logging.getLogger('speak') -import gst +from gi.repository import Gst import espeak PITCH_MAX = 200 @@ -44,7 +44,7 @@ class AudioGrabGst(espeak.BaseAudioGrab): def voices(): out = [] - for i in gst.element_factory_make('espeak').props.voices: + for i in Gst.ElementFactory.make('espeak', None).props.voices: name, language, dialect = i if name in ('en-rhotic','english_rp','english_wmids'): # these voices don't produce sound diff --git a/speak/eye.py b/speak/eye.py index 1fe23f5..0073a80 100644 --- a/speak/eye.py +++ b/speak/eye.py @@ -21,16 +21,16 @@ # You should have received a copy of the GNU General Public License # along with Speak.activity. If not, see . -import pygtk -import gtk -import gtk.gdk -import gobject +import gi +from gi.repository import Gtk +import Gdk +from gi.repository import GObject import cairo import math -class Eye(gtk.DrawingArea): +class Eye(Gtk.DrawingArea): def __init__(self, fill_color): - gtk.DrawingArea.__init__(self) + Gtk.DrawingArea.__init__(self) self.connect("expose_event", self.expose) self.frame = 0 self.blink = False @@ -38,8 +38,8 @@ class Eye(gtk.DrawingArea): self.fill_color = fill_color # listen for clicks - self.add_events(gtk.gdk.BUTTON_PRESS_MASK) - self.add_events(gtk.gdk.BUTTON_RELEASE_MASK) + self.add_events(Gdk.BUTTON_PRESS_MASK) + self.add_events(Gdk.BUTTON_RELEASE_MASK) self.connect("button_press_event", self._mouse_pressed_cb) self.connect("button_release_event", self._mouse_released_cb) @@ -48,7 +48,7 @@ class Eye(gtk.DrawingArea): # Unfortunately that would cause a lot of CPU usage. So instead we rely on our parent to # tell us to redraw when the mouse has moved. We still need to call add_events so that # our parent will get mouse motion events, but we don't connect the callback for them ourselves. - self.add_events(gtk.gdk.POINTER_MOTION_MASK) + self.add_events(Gdk.POINTER_MOTION_MASK) # self.connect("motion_notify_event", self._mouse_moved_cb) def _mouse_moved_cb(self, widget, event): diff --git a/speak/face.py b/speak/face.py index f11a74c..9b57af3 100644 --- a/speak/face.py +++ b/speak/face.py @@ -23,11 +23,11 @@ import logging -import gtk +from gi.repository import Gtk import json from gettext import gettext as _ -import sugar.graphics.style as style +import sugar3.graphics.style as style import espeak import eye @@ -90,9 +90,9 @@ class Status: new.mouth = self.mouth return new -class View(gtk.EventBox): +class View(Gtk.EventBox): def __init__(self, fill_color=style.COLOR_BUTTON_GREY): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.status = Status() self.fill_color = fill_color @@ -103,20 +103,20 @@ class View(gtk.EventBox): # make an empty box for some eyes self._eyes = None - self._eyebox = gtk.HBox() + self._eyebox = Gtk.HBox() self._eyebox.show() # make an empty box to put the mouth in self._mouth = None - self._mouthbox = gtk.HBox() + self._mouthbox = Gtk.HBox() self._mouthbox.show() # layout the screen - box = gtk.VBox(homogeneous=False) - box.pack_start(self._eyebox) + box = Gtk.VBox(homogeneous=False) + box.pack_start(self._eyebox, True, True, 0) box.pack_start(self._mouthbox, False) box.set_border_width(FACE_PAD) - self.modify_bg(gtk.STATE_NORMAL, self.fill_color.get_gdk_color()) + self.modify_bg(Gtk.STATE_NORMAL, self.fill_color.get_Gdk_color()) self.add(box) self._mapped = False @@ -159,7 +159,7 @@ class View(gtk.EventBox): for i in status.eyes: eye = i(self.fill_color) self._eyes.append(eye) - self._eyebox.pack_start(eye, padding=FACE_PAD) + self._eyebox.pack_start(eye, True, True, FACE_PAD) eye.show() self._mouth = status.mouth(self._audio, self.fill_color) @@ -167,7 +167,7 @@ class View(gtk.EventBox): self._mouthbox.add(self._mouth) # enable mouse move events so we can track the eyes while the mouse is over the mouth - #self._mouth.add_events(gtk.gdk.POINTER_MOTION_MASK) + #self._mouth.add_events(Gdk.POINTER_MOTION_MASK) def say(self, something): self._audio.speak(self._peding or self.status, something) diff --git a/speak/mouth.py b/speak/mouth.py index b01155a..3966d2f 100644 --- a/speak/mouth.py +++ b/speak/mouth.py @@ -23,15 +23,15 @@ # This code is a super-stripped down version of the waveform view from Measure -import gtk +from gi.repository import Gtk import cairo from struct import unpack import numpy.core -class Mouth(gtk.DrawingArea): +class Mouth(Gtk.DrawingArea): def __init__(self, audioSource, fill_color): - gtk.DrawingArea.__init__(self) + Gtk.DrawingArea.__init__(self) self.connect("expose_event",self.expose) self.buffers = [] self.buffer_size = 256 diff --git a/speak/widgets.py b/speak/widgets.py index e3fffde..6005b8c 100644 --- a/speak/widgets.py +++ b/speak/widgets.py @@ -14,7 +14,7 @@ import logging -from sugar.graphics.combobox import ComboBox +from sugar3.graphics.combobox import ComboBox import voice diff --git a/svgcard.py b/svgcard.py index 631640e..528dc25 100644 --- a/svgcard.py +++ b/svgcard.py @@ -20,11 +20,11 @@ from os.path import join, dirname import rsvg import re -import gtk -import pango +from gi.repository import Gtk +from gi.repository import Pango import logging -from sugar.util import LRU +from sugar3.util import LRU import theme import face @@ -34,7 +34,7 @@ import model _logger = logging.getLogger('memorize-activity') -class SvgCard(gtk.EventBox): +class SvgCard(Gtk.EventBox): border_svg = join(dirname(__file__), 'images', 'card.svg') @@ -59,7 +59,7 @@ class SvgCard(gtk.EventBox): def __init__(self, identifier, pprops, jpeg, size, align, bg_color='#000000', font_name=model.DEFAULT_FONT): - gtk.EventBox.__init__(self) + Gtk.EventBox.__init__(self) self.bg_color = bg_color self.flipped = False @@ -73,7 +73,7 @@ class SvgCard(gtk.EventBox): self.text_layouts = [None, None] self.font_name = font_name - self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bg_color)) + self.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse(bg_color)) self.set_size_request(size, size) # Views properties @@ -90,14 +90,14 @@ class SvgCard(gtk.EventBox): self.show_text = True self.current_face = 'back' - self.draw = gtk.DrawingArea() - self.draw.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bg_color)) - self.draw.set_events(gtk.gdk.ALL_EVENTS_MASK) + self.draw = Gtk.DrawingArea() + self.draw.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse(bg_color)) + self.draw.set_events(Gdk.ALL_EVENTS_MASK) self.draw.connect('expose-event', self._expose_cb) self.draw.connect('realize', self._realize_cb) self.draw.show_all() - self.workspace = gtk.VBox() + self.workspace = Gtk.VBox() self.workspace.add(self.draw) self.add(self.workspace) self.show_all() @@ -133,7 +133,7 @@ class SvgCard(gtk.EventBox): widget.window.draw_layout(self.gc, layout=layout, x=(self.size - width) / 2, y=y, - foreground=gtk.gdk.color_parse(props['text_color'])) + foreground=Gdk.color_parse(props['text_color'])) return False @@ -162,7 +162,7 @@ class SvgCard(gtk.EventBox): data = re.sub('size_card1', str(self.size), data) data = re.sub('size_card2', str(self.size - 6), data) data = re.sub('size_card3', str(self.size - 17), data) - pixbuf = rsvg.Handle(data=data).get_pixbuf() + pixbuf = Rsvg.Handle.new_from_data(data).get_pixbuf() self.cache[key] = pixbuf return pixbuf @@ -170,8 +170,8 @@ class SvgCard(gtk.EventBox): self.props['front'].update({'fill_color': fill_color, 'stroke_color': stroke_color}) self.queue_draw() - while gtk.events_pending(): - gtk.main_iteration() + while Gtk.events_pending(): + Gtk.main_iteration() def set_pixbuf(self, pixbuf): if pixbuf == None: @@ -186,8 +186,8 @@ class SvgCard(gtk.EventBox): self.show_jpeg = True self.queue_draw() - while gtk.events_pending(): - gtk.main_iteration() + while Gtk.events_pending(): + Gtk.main_iteration() def get_pixbuf(self): return self.jpeg @@ -213,12 +213,12 @@ class SvgCard(gtk.EventBox): if not self.flipped_once: if self.jpeg is not None: - pixbuf_t = gtk.gdk.pixbuf_new_from_file(self.jpeg) + pixbuf_t = Gdk.pixbuf_new_from_file(self.jpeg) if pixbuf_t.get_width() != self.size - 22 \ or pixbuf_t.get_height() != self.size - 22: self.jpeg = pixbuf_t.scale_simple(self.size - 22, self.size - 22, - gtk.gdk.INTERP_BILINEAR) + Gdk.INTERP_BILINEAR) del pixbuf_t else: self.jpeg = pixbuf_t @@ -245,8 +245,8 @@ class SvgCard(gtk.EventBox): self.flipped = True self.queue_draw() - while gtk.events_pending(): - gtk.main_iteration() + while Gtk.events_pending(): + Gtk.main_iteration() def cement(self): if not self.get_speak(): @@ -301,8 +301,8 @@ class SvgCard(gtk.EventBox): card_size = self.size - theme.SVG_PAD * 2 layout = self.create_pango_layout(text) layout.set_width(PIXELS_PANGO(card_size)) - layout.set_wrap(pango.WRAP_WORD) - desc = pango.FontDescription(self.font_name + " " + str(size)) + layout.set_wrap(Pango.WrapMode.WORD) + desc = Pango.FontDescription(self.font_name + " " + str(size)) layout.set_font_description(desc) if layout.get_line_count() <= max_lines_count and \ @@ -313,7 +313,7 @@ class SvgCard(gtk.EventBox): if layout.get_line_count() > 1: # XXX for single line ALIGN_CENTER wrongly affects on text position # and also in some cases for multilined text - layout.set_alignment(pango.ALIGN_CENTER) + layout.set_alignment(Pango.Alignment.CENTER) _text_layout_cache[key] = layout @@ -332,8 +332,8 @@ class SvgCard(gtk.EventBox): def set_background(self, color): self.bg_color = color - self.draw.modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(self.bg_color)) + self.draw.modify_bg(Gtk.STATE_NORMAL, + Gdk.color_parse(self.bg_color)) def change_text(self, newtext): self.text_layouts[self.flipped] = None diff --git a/svglabel.py b/svglabel.py index 9991765..7491804 100644 --- a/svglabel.py +++ b/svglabel.py @@ -15,12 +15,12 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gtk +from gi.repository import Gtk import rsvg import re -class SvgLabel(gtk.DrawingArea): +class SvgLabel(Gtk.DrawingArea): filename = '' fill_color = '' @@ -29,13 +29,13 @@ class SvgLabel(gtk.DrawingArea): def __init__(self, filename, fill_color, stroke_color, pixbuf=False, background_color='', request_x=45, request_y=45): - gtk.DrawingArea.__init__(self) + Gtk.DrawingArea.__init__(self) self.set_size_request(request_x, request_y) self.filename = filename self.background_color = background_color self.fill_color = fill_color self.stroke_color = stroke_color - self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(background_color)) + self.modify_bg(Gtk.STATE_NORMAL, Gdk.color_parse(background_color)) if pixbuf: self.pixbuf = pixbuf else: @@ -62,7 +62,7 @@ class SvgLabel(gtk.DrawingArea): data = re.sub('', entity, data) self.data_size = len(data) - return rsvg.Handle(data=data).get_pixbuf() + return Rsvg.Handle.new_from_data(data).get_pixbuf() def set_color(self, fill_color, stroke_color): self.fill_color = fill_color @@ -98,6 +98,6 @@ class SvgLabel(gtk.DrawingArea): def set_background(self, background_color): self.background_color = background_color - self.modify_bg(gtk.STATE_NORMAL, - gtk.gdk.color_parse(self.background_color)) + self.modify_bg(Gtk.STATE_NORMAL, + Gdk.color_parse(self.background_color)) self.queue_draw() diff --git a/theme.py b/theme.py index 4250629..8cc24f4 100644 --- a/theme.py +++ b/theme.py @@ -15,9 +15,9 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import gtk +from gi.repository import Gtk -PAIR_SIZE = gtk.gdk.screen_width() / 5 +PAIR_SIZE = Gdk.screen_width() / 5 PAD = 10 SVG_PAD = 10 CARD_PAD = 4 -- cgit v0.9.1