diff options
author | Gary Martin <gary@garycmartin.com> | 2012-11-24 18:11:04 (GMT) |
---|---|---|
committer | Gary Martin <gary@garycmartin.com> | 2012-11-24 18:11:04 (GMT) |
commit | 575a5d91bab90fc6dee435e3c8c9b98b1e1bed24 (patch) | |
tree | e04c50644d0de41e697e9ad3be4b6da8a0fc3c84 /toolbars.py | |
parent | fa0bf8ee2d79bd7ae73410a4de8d051221a02e52 (diff) |
Initial GTK3/gi.repository/sugar3 port
This commit launches but is not yet in a very usable state due to missing toolbar icons and the canvas going partly off the bottom of the screen.
Diffstat (limited to 'toolbars.py')
-rw-r--r-- | toolbars.py | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/toolbars.py b/toolbars.py index 9240395..bb9358f 100644 --- a/toolbars.py +++ b/toolbars.py @@ -1,15 +1,16 @@ # -*- coding: UTF-8 -*- # toolbars.py, see CalcActivity.py for info -import pygtk -pygtk.require('2.0') -import gtk +#import pygtk +#pygtk.require('2.0') +from gi.repository import Gtk + from mathlib import MathLib -from sugar.graphics.palette import Palette -from sugar.graphics.menuitem import MenuItem -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toggletoolbutton import ToggleToolButton +from sugar3.graphics.palette import Palette +from sugar3.graphics.menuitem import MenuItem +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.toggletoolbutton import ToggleToolButton import logging _logger = logging.getLogger('calc-activity') @@ -20,7 +21,7 @@ def _icon_exists(name): if name == '': return False - theme = gtk.icon_theme_get_default() + theme = Gtk.IconTheme.get_default() info = theme.lookup_icon(name, 0, 0) if info: return True @@ -32,12 +33,13 @@ class IconToolButton(ToolButton): ToolButton.__init__(self) if _icon_exists(icon_name): - self.set_icon(icon_name) + #self.set_icon(icon_name) + self.props.icon_name = icon_name else: if alt_html == '': alt_html = icon_name - label = gtk.Label() + label = Gtk.Label() label.set_markup(alt_html) label.show() self.set_label_widget(label) @@ -63,7 +65,8 @@ class IconToggleToolButton(ToggleToolButton): ToggleToolButton.__init__(self) self.items = items if 'icon' in items[0] and _icon_exists(items[0]['icon']): - self.set_named_icon(items[0]['icon']) + #self.set_named_icon(items[0]['icon']) + self.props.icon_name = items[0]['icon'] elif 'html' in items[0]: self.set_label(items[0]['html']) # self.set_tooltip(items[0][1]) @@ -87,9 +90,9 @@ class IconToggleToolButton(ToggleToolButton): else: self.callback(but) -class TextToggleToolButton(gtk.ToggleToolButton): +class TextToggleToolButton(Gtk.ToggleToolButton): def __init__(self, items, cb, desc, index=False): - gtk.ToggleToolButton.__init__(self) + Gtk.ToggleToolButton.__init__(self) self.items = items self.set_label(items[0]) self.selected = 0 @@ -108,14 +111,14 @@ class TextToggleToolButton(gtk.ToggleToolButton): else: self.callback(but) -class LineSeparator(gtk.SeparatorToolItem): +class LineSeparator(Gtk.SeparatorToolItem): def __init__(self): - gtk.SeparatorToolItem.__init__(self) + Gtk.SeparatorToolItem.__init__(self) self.set_draw(True) -class EditToolbar(gtk.Toolbar): +class EditToolbar(Gtk.Toolbar): def __init__(self, calc): - gtk.Toolbar.__init__(self) + Gtk.Toolbar.__init__(self) copy_tool = ToolButton('edit-copy') copy_tool.set_tooltip(_('Copy')) @@ -140,9 +143,9 @@ class EditToolbar(gtk.Toolbar): self.show_all() -class AlgebraToolbar(gtk.Toolbar): +class AlgebraToolbar(Gtk.Toolbar): def __init__(self, calc): - gtk.Toolbar.__init__(self) + Gtk.Toolbar.__init__(self) self.insert(IconToolButton('algebra-square', _('Square'), lambda x: calc.button_pressed(calc.TYPE_OP_POST, '**2'), @@ -183,9 +186,9 @@ class AlgebraToolbar(gtk.Toolbar): self.show_all() -class TrigonometryToolbar(gtk.Toolbar): +class TrigonometryToolbar(Gtk.Toolbar): def __init__(self, calc): - gtk.Toolbar.__init__(self) + Gtk.Toolbar.__init__(self) self.insert(IconToolButton('trigonometry-sin', _('Sine'), lambda x: calc.button_pressed(calc.TYPE_FUNCTION, 'sin'), @@ -229,9 +232,9 @@ class TrigonometryToolbar(gtk.Toolbar): self.show_all() -class BooleanToolbar(gtk.Toolbar): +class BooleanToolbar(Gtk.Toolbar): def __init__(self, calc): - gtk.Toolbar.__init__(self) + Gtk.Toolbar.__init__(self) self.insert(IconToolButton('boolean-and', _('Logical and'), lambda x: calc.button_pressed(calc.TYPE_OP_POST, '&'), @@ -255,9 +258,9 @@ class BooleanToolbar(gtk.Toolbar): self.show_all() -class MiscToolbar(gtk.Toolbar): +class MiscToolbar(Gtk.Toolbar): def __init__(self, calc, target_toolbar=None): - gtk.Toolbar.__init__(self) + Gtk.Toolbar.__init__(self) self.insert(IconToolButton('constants-pi', _('Pi'), lambda x: calc.button_pressed(calc.TYPE_TEXT, 'pi'), |