Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaul Gutierrez Segales <rgs@collabora.co.uk>2011-10-30 23:55:00 (GMT)
committer Raul Gutierrez Segales <rgs@collabora.co.uk>2011-10-30 23:55:00 (GMT)
commit130fae162dbb839f91033becc71be7a33bb7c1f0 (patch)
tree640648c7aa999ac58345f5dbdc45bcc4ad259f07
parentc387222564cac1a8367a44cd7bdfd007f216c7dc (diff)
More Gtk3 changes here and there
-rw-r--r--AbacusActivity.py62
-rwxr-xr-xabacus.py10
-rw-r--r--abacus_window.py3
-rw-r--r--sprites.py3
4 files changed, 37 insertions, 41 deletions
diff --git a/AbacusActivity.py b/AbacusActivity.py
index 41fe836..ef1bc8c 100644
--- a/AbacusActivity.py
+++ b/AbacusActivity.py
@@ -11,27 +11,26 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-import pygtk
-pygtk.require('2.0')
-import gtk
+from gi.repository import Gtk
+from gi.repository import Gdk
-from sugar.activity import activity
-from sugar import profile
+from sugar3.activity import activity
+from sugar3 import profile
try: # 0.86+ toolbar widgets
- from sugar.graphics.toolbarbox import ToolbarBox
+ from sugar3.graphics.toolbarbox import ToolbarBox
HAS_TOOLBARBOX = True
except ImportError:
HAS_TOOLBARBOX = False
if HAS_TOOLBARBOX:
- from sugar.bundle.activitybundle import ActivityBundle
- from sugar.activity.widgets import ActivityToolbarButton
- from sugar.activity.widgets import StopButton
- from sugar.graphics.toolbarbox import ToolbarButton
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.radiotoolbutton import RadioToolButton
-from sugar.graphics.menuitem import MenuItem
-from sugar.graphics.icon import Icon
-from sugar.datastore import datastore
+ from sugar3.bundle.activitybundle import ActivityBundle
+ from sugar3.activity.widgets import ActivityToolbarButton
+ from sugar3.activity.widgets import StopButton
+ from sugar3.graphics.toolbarbox import ToolbarButton
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.graphics.radiotoolbutton import RadioToolButton
+from sugar3.graphics.menuitem import MenuItem
+from sugar3.graphics.icon import Icon
+from sugar3.datastore import datastore
from gettext import gettext as _
import locale
@@ -39,9 +38,7 @@ import locale
import logging
_logger = logging.getLogger('abacus-activity')
-from abacus_window import Abacus, Custom, Suanpan, Soroban, Schety,\
- Nepohualtzintzin, Binary, Hex, Decimal, Fractions,\
- Caacupe, Cuisenaire
+from abacus_window import Abacus, Custom, Suanpan, Soroban, Schety, Nepohualtzintzin, Binary, Hex, Decimal, Fractions, Caacupe, Cuisenaire
def _button_factory(icon_name, toolbar, callback, cb_arg=None, tooltip=None,
@@ -86,10 +83,10 @@ def _radio_factory(icon_name, toolbar, callback, cb_arg=None,
def _label_factory(label_text, toolbar):
''' Factory for adding a label to a toolbar '''
- label = gtk.Label(label_text)
+ label = Gtk.Label(label=label_text)
label.set_line_wrap(True)
label.show()
- toolitem = gtk.ToolItem()
+ toolitem = Gtk.ToolItem()
toolitem.add(label)
toolbar.insert(toolitem, -1)
toolitem.show()
@@ -97,12 +94,13 @@ def _label_factory(label_text, toolbar):
def _spin_factory(default, min, max, callback, toolbar):
- spin_adj = gtk.Adjustment(default, min, max, 1, 32, 0)
- spin = gtk.SpinButton(spin_adj, 0, 0)
+ spin_adj = Gtk.Adjustment(default, min, max, 1, 32, 0)
+ spin = Gtk.SpinButton()
+ spin.set_adjustment(spin_adj)
spin_id = spin.connect('value-changed', callback)
spin.set_numeric(True)
spin.show()
- toolitem = gtk.ToolItem()
+ toolitem = Gtk.ToolItem()
toolitem.add(spin)
toolbar.insert(toolitem, -1)
toolitem.show()
@@ -111,7 +109,7 @@ def _spin_factory(default, min, max, callback, toolbar):
def _separator_factory(toolbar, expand=False, visible=True):
''' add a separator to a toolbar '''
- separator = gtk.SeparatorToolItem()
+ separator = Gtk.SeparatorToolItem()
separator.props.draw = visible
separator.set_expand(expand)
toolbar.insert(separator, -1)
@@ -129,9 +127,9 @@ class AbacusActivity(activity.Activity):
# no sharing
self.max_participants = 1
- abacus_toolbar = gtk.Toolbar()
- custom_toolbar = gtk.Toolbar()
- edit_toolbar = gtk.Toolbar()
+ abacus_toolbar = Gtk.Toolbar()
+ custom_toolbar = Gtk.Toolbar()
+ edit_toolbar = Gtk.Toolbar()
if HAS_TOOLBARBOX:
# Use 0.86 toolbar design
@@ -314,9 +312,9 @@ class AbacusActivity(activity.Activity):
self.chinese.set_active(True)
# Create a canvas
- canvas = gtk.DrawingArea()
- canvas.set_size_request(gtk.gdk.screen_width(),
- gtk.gdk.screen_height())
+ canvas = Gtk.DrawingArea()
+ canvas.set_size_request(Gdk.Screen.width(),
+ Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
@@ -420,7 +418,7 @@ class AbacusActivity(activity.Activity):
def _copy_cb(self, arg=None):
''' Copy a number to the clipboard from the active abacus. '''
- clipBoard = gtk.Clipboard()
+ clipBoard = Gtk.Clipboard()
text = self.abacus.generate_label(sum_only=True)
if text is not None:
clipBoard.set_text(text)
@@ -428,7 +426,7 @@ class AbacusActivity(activity.Activity):
def _paste_cb(self, arg=None):
''' Paste a number from the clipboard to the active abacus. '''
- clipBoard = gtk.Clipboard()
+ clipBoard = Gtk.Clipboard()
text = clipBoard.wait_for_text()
if text is not None:
try:
diff --git a/abacus.py b/abacus.py
index 7369e3a..707ff92 100755
--- a/abacus.py
+++ b/abacus.py
@@ -63,21 +63,21 @@ class AbacusMain:
menu = Gtk.Menu()
for k, v in ABACI.iteritems():
- menu_items = Gtk.MenuItem(v)
+ menu_items = Gtk.MenuItem.new_with_label(v)
menu.append(menu_items)
menu_items.connect('activate', self._switch_abacus_cb, k)
- menu_items = Gtk.MenuItem(_('Reset'))
+ menu_items = Gtk.MenuItem.new_with_label(_('Reset'))
menu.append(menu_items)
menu_items.connect('activate', self._reset)
- menu_items = Gtk.MenuItem(_('Quit'))
+ menu_items = Gtk.MenuItem.new_with_label(_('Quit'))
menu.append(menu_items)
menu_items.connect('activate', self.destroy)
menu_items.show()
- root_menu = Gtk.MenuItem('Tools')
+ root_menu = Gtk.MenuItem.new_with_label('Tools')
root_menu.show()
root_menu.set_submenu(menu)
- vbox = Gtk.VBox(False, 0)
+ vbox = Gtk.VBox()
self.win.add(vbox)
vbox.show()
diff --git a/abacus_window.py b/abacus_window.py
index b88a24e..83887b3 100644
--- a/abacus_window.py
+++ b/abacus_window.py
@@ -34,7 +34,6 @@ LABELS = ('#000000', '#FFFFFF', '#000000', '#FFFFFF', '#000000',
'#000000', '#FFFFFF', '#FFFFFF', '#000000', '#000000')
import gi
-gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GdkPixbuf
from math import floor, ceil
@@ -45,7 +44,7 @@ import logging
_logger = logging.getLogger('abacus-activity')
try:
- from sugar.graphics import style
+ from sugar3.graphics import style
GRID_CELL_SIZE = style.GRID_CELL_SIZE
except ImportError:
GRID_CELL_SIZE = 0
diff --git a/sprites.py b/sprites.py
index 23a631c..e35f67b 100644
--- a/sprites.py
+++ b/sprites.py
@@ -77,8 +77,7 @@ def svg_str_to_pixbuf(svg_string):
'''
import gi
-gi.require_version('Gtk', '3.0')
-from gi.repository import Gtk, GdkPixbuf
+from gi.repository import Gtk, GdkPixbuf, Gdk
from gi.repository import Pango, PangoCairo