diff options
author | Simon Schampijer <simon@laptop.org> | 2013-01-23 12:26:39 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@laptop.org> | 2013-01-31 20:18:11 (GMT) |
commit | cb71d268f900270bcbc28b7dddf02a37f3f21883 (patch) | |
tree | 1cd3a006a6484106abc4c7860be107e3ed1491d4 | |
parent | ccf711ae1acaea90e37ab61ff0213927c21afc0e (diff) |
Fixup of the leftovers from the convert script
- add missing Gdk imports
- do not use GObject.GObject.__init__(self) when we
have a Gtk object
- correct Gdk, GObject, Rsvg and GdkPixbuf imports
- add missing Gtk.Alignment arguments
-rw-r--r-- | activity.py | 10 | ||||
-rw-r--r-- | cardlist.py | 21 | ||||
-rw-r--r-- | cardtable.py | 17 | ||||
-rw-r--r-- | createcardpanel.py | 15 | ||||
-rw-r--r-- | createtoolbar.py | 6 | ||||
-rw-r--r-- | face.py | 3 | ||||
-rw-r--r-- | fontcombobox.py | 4 | ||||
-rw-r--r-- | playerscoreboard.py | 2 | ||||
-rw-r--r-- | port/roundbox.py | 4 | ||||
-rw-r--r-- | score.py | 4 | ||||
-rw-r--r-- | scoreboard.py | 7 | ||||
-rw-r--r-- | speak/eye.py | 12 | ||||
-rw-r--r-- | speak/face.py | 6 | ||||
-rw-r--r-- | speak/mouth.py | 8 | ||||
-rw-r--r-- | svgcard.py | 9 | ||||
-rw-r--r-- | svglabel.py | 6 | ||||
-rw-r--r-- | theme.py | 2 |
17 files changed, 84 insertions, 52 deletions
diff --git a/activity.py b/activity.py index 843b820..fceef10 100644 --- a/activity.py +++ b/activity.py @@ -16,10 +16,6 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# activate threads for gst needs -from gi.repository import GObject -GObject.threads_init() - import locale locale.setlocale(locale.LC_NUMERIC, 'C') @@ -32,6 +28,12 @@ import os import zipfile from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject + +# activate threads for gst needs +GObject.threads_init() + import telepathy import telepathy.client diff --git a/cardlist.py b/cardlist.py index a4f6b74..4f22c46 100644 --- a/cardlist.py +++ b/cardlist.py @@ -16,6 +16,9 @@ # from gi.repository import Gtk +from gi.repository import GObject +from gi.repository import GdkPixbuf + import svgcard import logging from os.path import join, basename @@ -23,8 +26,6 @@ import shutil from model import Pair -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT - from sugar.graphics import style from sugar.graphics.icon import Icon @@ -36,12 +37,14 @@ _logger = logging.getLogger('memorize-activity') class CardList(Gtk.EventBox): __gsignals__ = { - 'pair-selected': (SIGNAL_RUN_FIRST, None, 9 * [TYPE_PYOBJECT]), - 'update-create-toolbar': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), + 'pair-selected': (GObject.SignalFlags.RUN_FIRST, + None, 9 * [object]), + 'update-create-toolbar': (GObject.SignalFlags.RUN_FIRST, + None, 3 * [object]), } def __init__(self): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.pairs = [] self.current_pair = None self.current_game_key = None @@ -245,14 +248,14 @@ class CardList(Gtk.EventBox): class CardPair(Gtk.EventBox): __gsignals__ = { - 'pair-selected': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), - 'pair-closed': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), + 'pair-selected': (GObject.SignalFlags.RUN_FIRST, None, [object]), + 'pair-closed': (GObject.SignalFlags.RUN_FIRST, None, [object]), } def __init__(self, text1, text2=None, aimg=None, bimg=None, asnd=None, bsnd=None, aspeak=None, bspeak=None, font_name1=None, font_name2=None): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.bg_color = '#000000' self.asnd = asnd @@ -295,7 +298,7 @@ class CardPair(Gtk.EventBox): close_image = Icon( icon_name='remove', icon_size=Gtk.IconSize.LARGE_TOOLBAR) - align = Gtk.Alignment.new(.5, .5) + align = Gtk.Alignment.new(.5, .5, 0, 0) align.add(close_image) close_button = Gtk.ToolButton() close_button.set_icon_widget(align) diff --git a/cardtable.py b/cardtable.py index 939007f..2c4a712 100644 --- a/cardtable.py +++ b/cardtable.py @@ -16,11 +16,14 @@ # from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject from gi.repository import Pango + import svgcard import os import math -from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT + import logging _logger = logging.getLogger('memorize-activity') @@ -31,13 +34,13 @@ import theme class CardTable(Gtk.EventBox): __gsignals__ = { - 'card-flipped': (SIGNAL_RUN_FIRST, None, [int, TYPE_PYOBJECT]), - 'card-overflipped': (SIGNAL_RUN_FIRST, None, [int]), - 'card-highlighted': (SIGNAL_RUN_FIRST, None, [int, TYPE_PYOBJECT]), + 'card-flipped': (GObject.SignalFlags.RUN_FIRST, None, [int, object]), + 'card-overflipped': (GObject.SignalFlags.RUN_FIRST, None, [int]), + 'card-highlighted': (GObject.SignalFlags.RUN_FIRST, None, [int, object]), } def __init__(self): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.data = None self.cards_data = None self._workspace_size = 0 @@ -50,12 +53,12 @@ class CardTable(Gtk.EventBox): self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#000000')) self.table = Gtk.Table() self.table.grab_focus() - self.table.set_flags(Gtk.CAN_FOCUS) + self.table.set_focus(True) self.table.set_can_default(True) 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.ResizeMode.IMMEDIATE) self.set_property('child', self.table) self.load_message = Gtk.Label(label='Loading Game') self.load_message.modify_fg(Gtk.StateType.NORMAL, diff --git a/createcardpanel.py b/createcardpanel.py index ba625ba..e75ae83 100644 --- a/createcardpanel.py +++ b/createcardpanel.py @@ -18,13 +18,16 @@ # from gi.repository import Gtk +from gi.repository import GObject +from gi.repository import GdkPixbuf + 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 @@ -46,9 +49,9 @@ _logger = logging.getLogger('memorize-activity') class CreateCardPanel(Gtk.EventBox): __gsignals__ = { - 'add-pair': (SIGNAL_RUN_FIRST, None, 10 * [TYPE_PYOBJECT]), - 'update-pair': (SIGNAL_RUN_FIRST, None, 8 * [TYPE_PYOBJECT]), - 'change-font': (SIGNAL_RUN_FIRST, None, 2 * [TYPE_PYOBJECT]), + 'add-pair': (GObject.SignalFlags.RUN_FIRST, None, 10 * [object]), + 'update-pair': (GObject.SignalFlags.RUN_FIRST, None, 8 * [object]), + 'change-font': (GObject.SignalFlags.RUN_FIRST, None, 2 * [object]), } def __init__(self): @@ -65,7 +68,7 @@ class CreateCardPanel(Gtk.EventBox): label_box.show_all() return label_box - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.equal_pairs = False self._updatebutton_sensitive = False @@ -278,7 +281,7 @@ class CardEditor(Gtk.EventBox): } def __init__(self, editor_index): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.snd = None self.editor_index = editor_index diff --git a/createtoolbar.py b/createtoolbar.py index 4459447..b372cee 100644 --- a/createtoolbar.py +++ b/createtoolbar.py @@ -19,7 +19,7 @@ from gettext import gettext as _ 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 @@ -33,8 +33,8 @@ class CreateToolbarBuilder(GObject.GObject): __gtype_name__ = 'CreateToolbar' __gsignals__ = { - 'create_new_game': (SIGNAL_RUN_FIRST, None, []), - 'create_equal_pairs': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), + 'create_new_game': (GObject.SignalFlags.RUN_FIRST, None, []), + 'create_equal_pairs': (GObject.SignalFlags.RUN_FIRST, None, [object]), } def __init__(self, activity): @@ -13,6 +13,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gi.repository import Gtk +from gi.repository import Gdk import logging _logger = logging.getLogger('memorize-activity') @@ -26,7 +27,7 @@ import theme class Face(Gtk.EventBox): def __init__(self): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_BLACK.get_gdk_color()) diff --git a/fontcombobox.py b/fontcombobox.py index 2b3a8f2..1dd5236 100644 --- a/fontcombobox.py +++ b/fontcombobox.py @@ -15,6 +15,7 @@ # 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 + from gi.repository import Gtk FONT_BLACKLIST = ['cmex10', 'cmmi10', 'cmr10', 'cmsy10', 'esint10', 'eufm10', @@ -24,7 +25,8 @@ FONT_BLACKLIST = ['cmex10', 'cmmi10', 'cmr10', 'cmsy10', 'esint10', 'eufm10', class FontComboBox(Gtk.ComboBox): def __init__(self): - GObject.GObject.__init__(self) + Gtk.ComboBox.__init__(self) + font_renderer = Gtk.CellRendererText() self.pack_start(font_renderer, True, True, 0) self.add_attribute(font_renderer, 'text', 0) diff --git a/playerscoreboard.py b/playerscoreboard.py index 4eb7a25..e26c2bb 100644 --- a/playerscoreboard.py +++ b/playerscoreboard.py @@ -31,7 +31,7 @@ _logger = logging.getLogger('memorize-activity') class PlayerScoreboard(Gtk.EventBox): def __init__(self, nick, fill_color, stroke_color, score=0): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.default_color = '#4c4d4f' self.selected_color = '#818286' diff --git a/port/roundbox.py b/port/roundbox.py index 8a2d188..02cc1a3 100644 --- a/port/roundbox.py +++ b/port/roundbox.py @@ -1,5 +1,7 @@ import math + from gi.repository import Gtk + from sugar.graphics import style @@ -9,7 +11,7 @@ class RoundBox(Gtk.HBox): _BORDER_DEFAULT = style.LINE_WIDTH def __init__(self, **kwargs): - GObject.GObject.__init__(self, **kwargs) + Gtk.HBox.__init__(self, **kwargs) self._radius = style.zoom(10) self.border = self._BORDER_DEFAULT @@ -16,9 +16,11 @@ # import svglabel -from gi.repository import Gtk import os +from gi.repository import Gtk +from gi.repository import Gdk + import theme diff --git a/scoreboard.py b/scoreboard.py index 00f7a1c..e01ede4 100644 --- a/scoreboard.py +++ b/scoreboard.py @@ -15,8 +15,11 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -from gi.repository import Gtk import logging + +from gi.repository import Gtk +from gi.repository import Gdk + from playerscoreboard import PlayerScoreboard _logger = logging.getLogger('memorize-activity') @@ -24,7 +27,7 @@ _logger = logging.getLogger('memorize-activity') class Scoreboard(Gtk.EventBox): def __init__(self): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.players = {} self.current_buddy = None diff --git a/speak/eye.py b/speak/eye.py index e03556f..dc2349f 100644 --- a/speak/eye.py +++ b/speak/eye.py @@ -21,16 +21,18 @@ # You should have received a copy of the GNU General Public License # along with Speak.activity. If not, see <http://www.gnu.org/licenses/>. -import gi +import math + +import cairo from gi.repository import Gtk -import Gtk.gdk +from gi.repository import Gdk from gi.repository import GObject -import cairo -import math + class Eye(Gtk.DrawingArea): def __init__(self, fill_color): - GObject.GObject.__init__(self) + Gtk.DrawingArea.__init__(self) + self.connect("expose_event", self.expose) self.frame = 0 self.blink = False diff --git a/speak/face.py b/speak/face.py index 77821ce..c78677e 100644 --- a/speak/face.py +++ b/speak/face.py @@ -23,10 +23,12 @@ import logging -from gi.repository import Gtk + import json from gettext import gettext as _ +from gi.repository import Gtk + import sugar.graphics.style as style import espeak @@ -92,7 +94,7 @@ class Status: class View(Gtk.EventBox): def __init__(self, fill_color=style.COLOR_BUTTON_GREY): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.status = Status() self.fill_color = fill_color diff --git a/speak/mouth.py b/speak/mouth.py index 999c2c7..796d6e6 100644 --- a/speak/mouth.py +++ b/speak/mouth.py @@ -23,15 +23,17 @@ # This code is a super-stripped down version of the waveform view from Measure -from gi.repository import Gtk -import cairo from struct import unpack import numpy.core +from gi.repository import Gtk +import cairo + class Mouth(Gtk.DrawingArea): def __init__(self, audioSource, fill_color): - GObject.GObject.__init__(self) + Gtk.DrawingArea.__init__(self) + self.connect("expose_event",self.expose) self.buffers = [] self.buffer_size = 256 @@ -17,12 +17,15 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # +import logging from os.path import join, dirname -import rsvg import re + +from gi.repository import Rsvg from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GdkPixbuf from gi.repository import Pango -import logging from sugar.util import LRU @@ -59,7 +62,7 @@ class SvgCard(Gtk.EventBox): def __init__(self, identifier, pprops, jpeg, size, align, bg_color='#000000', font_name=model.DEFAULT_FONT): - GObject.GObject.__init__(self) + Gtk.EventBox.__init__(self) self.bg_color = bg_color self.flipped = False diff --git a/svglabel.py b/svglabel.py index 66e4a12..9f14987 100644 --- a/svglabel.py +++ b/svglabel.py @@ -16,7 +16,8 @@ # from gi.repository import Gtk -import rsvg +from gi.repository import Gdk +from gi.repository import Rsvg import re @@ -29,7 +30,8 @@ class SvgLabel(Gtk.DrawingArea): def __init__(self, filename, fill_color, stroke_color, pixbuf=False, background_color='', request_x=45, request_y=45): - GObject.GObject.__init__(self) + Gtk.DrawingArea.__init__(self) + self.set_size_request(request_x, request_y) self.filename = filename self.background_color = background_color @@ -15,7 +15,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -from gi.repository import Gtk +from gi.repository import Gdk PAIR_SIZE = Gdk.Screen.width() / 5 PAD = 10 |