Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2013-01-03 00:14:21 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2013-01-03 00:14:21 (GMT)
commit13886fdb54b1fc392110cac0e075e2a7411332c8 (patch)
tree1029648349b3f4320bbdc6cf018459786be0174f
parent9c5b89b28c94b7ec0a99f61c8b6e0df1b033fcb6 (diff)
Port to Gtk3
Signed-off-by: Daniel Francis <francis@sugarlabs.org>
-rw-r--r--alerts.py14
-rw-r--r--basic_options.py6
-rw-r--r--coloritem.py15
-rw-r--r--colors.py5
-rw-r--r--help.py35
-rw-r--r--icon.py4
-rw-r--r--item.py35
-rw-r--r--itembox.py12
-rw-r--r--itemgroup.py23
-rw-r--r--profile.py13
-rw-r--r--radioitem.py16
-rw-r--r--settingsitem.py13
-rw-r--r--settingsradioitem.py11
-rw-r--r--shortcontentitem.py15
-rw-r--r--stock.py53
-rw-r--r--toggleitem.py15
16 files changed, 133 insertions, 152 deletions
diff --git a/alerts.py b/alerts.py
index 9609a82..8d5ecd4 100644
--- a/alerts.py
+++ b/alerts.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,10 +16,10 @@
# MA 02110-1301, USA.
from gettext import gettext as _
-import gtk
-from sugar.graphics import style
-from sugar.graphics.alert import Alert as SugarAlert
-from sugar.graphics.alert import NotifyAlert as SugarNotify
+from gi.repository import Gtk
+from sugar3.graphics import style
+from sugar3.graphics.alert import Alert as SugarAlert
+from sugar3.graphics.alert import NotifyAlert as SugarNotify
from icon import Icon
@@ -28,7 +28,7 @@ class Alert(SugarAlert):
def __init__(self, parent, title, content, mtype):
SugarAlert.__init__(self)
self._parent = parent
- if mtype == gtk.MESSAGE_INFO:
+ if mtype == Gtk.MessageType.INFO:
icon = Icon(icon_name='emblem-notification')
icon.show()
self.props.icon = icon
@@ -36,7 +36,7 @@ class Alert(SugarAlert):
self.props.title = title
self.props.msg = content
ok_icon = Icon(icon_name='dialog-ok')
- self.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon)
+ self.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon)
ok_icon.show()
self.connect('response', self.remove_myself)
diff --git a/basic_options.py b/basic_options.py
index 52f4ebd..4ff9cbb 100644
--- a/basic_options.py
+++ b/basic_options.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,7 +17,7 @@
from gettext import gettext as _
-from sugar.activity.widgets import ActivityToolbarButton
+from sugar3.activity.widgets import ActivityToolbarButton
import stock
from item import Item
diff --git a/coloritem.py b/coloritem.py
index 227cbcb..6c0f10a 100644
--- a/coloritem.py
+++ b/coloritem.py
@@ -18,10 +18,11 @@
import logging
logger = logging.getLogger('option')
-import gobject
-import gtk
+from gi.repository import GObject
+from gi.repository import Gtk
+from gi.repository import Gdk
-from sugar.graphics.colorbutton import ColorToolButton
+from sugar3.graphics.colorbutton import ColorToolButton
from colors import color2string
from item import Item
@@ -29,17 +30,17 @@ import stock
class ColorItem(Item):
- __gsignals__ = {'updated': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_STRING,))}
+ __gsignals__ = {'updated': (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_STRING,))}
def __init__(self, parent=None, important=False):
- Item.__init__(self, gtk.STOCK_SELECT_COLOR)
+ Item.__init__(self, Gtk.STOCK_SELECT_COLOR)
self.color = '#FFFFFF'
def set_color(self, color):
self.color = color
if self.toolitem and self.color:
- self.toolitem.set_color(gtk.gdk.Color(self.color))
+ self.toolitem.set_color(Gdk.color_parse(self.color))
def get_tool_item(self):
self.toolitem = ColorToolButton()
diff --git a/colors.py b/colors.py
index 96d48ba..f44cb93 100644
--- a/colors.py
+++ b/colors.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Daniel Francis
+# Copyright (C) 2012-2013 Daniel Francis
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,7 +18,8 @@
import logging
logger = logging.getLogger('colors')
-from sugar.graphics.xocolor import XoColor
+from sugar3.graphics.xocolor import XoColor
+
def color2string(color):
color_string = ["#"]
diff --git a/help.py b/help.py
index 3325ed3..8fc5fc8 100644
--- a/help.py
+++ b/help.py
@@ -19,10 +19,11 @@
# MA 02110-1301, USA.
from gettext import gettext as _
-import gtk
+from gi.repository import Gtk
+from gi.repository import Gdk
-from sugar.graphics import style
-from sugar.graphics.icon import Icon
+from sugar3.graphics import style
+from sugar3.graphics.icon import Icon
import stock
from settingsitem import SettingsItem
@@ -33,26 +34,26 @@ import helpcontent
class Help(SettingsItem):
def __init__(self, box):
- title = stock.get_label(gtk.STOCK_HELP, False)
+ title = stock.get_label(Gtk.STOCK_HELP, False)
stock.register('sweetener-help-contents', title,
'<Ctrl>H', 'toolbar-help')
SettingsItem.__init__(self, None, 'sweetener-help-contents')
- sw = gtk.ScrolledWindow()
- sw.set_size_request(int(gtk.gdk.screen_width() / 2.8),
- gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3)
- sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
- self._max_text_width = int(gtk.gdk.screen_width() / 3) - 20
- self._vbox = gtk.VBox()
+ sw = Gtk.ScrolledWindow()
+ sw.set_size_request(int(Gdk.Screen.width() / 2.8),
+ Gdk.Screen.height() - style.GRID_CELL_SIZE * 3)
+ sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
+ self._max_text_width = int(Gdk.Screen.width() / 3) - 20
+ self._vbox = Gtk.VBox()
self._vbox.set_homogeneous(False)
- hbox = gtk.HBox()
+ hbox = Gtk.HBox()
hbox.pack_start(self._vbox, False, True, 0)
sw.add_with_viewport(hbox)
sw.show()
self.content = sw
item = self.get_tool_item()
item.show_all()
- separator = gtk.SeparatorToolItem()
+ separator = Gtk.SeparatorToolItem()
separator.show()
box.toolbar.insert(separator,
len(box.toolbar.get_children()[:-2]))
@@ -64,8 +65,8 @@ class Help(SettingsItem):
self.add_paragraph(text, icon)
def add_section(self, section_text):
- hbox = gtk.HBox()
- label = gtk.Label()
+ hbox = Gtk.HBox()
+ label = Gtk.Label()
label.set_use_markup(True)
label.set_markup('<b>%s</b>' % section_text)
label.set_line_wrap(True)
@@ -75,9 +76,9 @@ class Help(SettingsItem):
self._vbox.pack_start(hbox, False, False, padding=5)
def add_paragraph(self, text, icon=None):
- hbox = gtk.HBox()
- label = gtk.Label(text)
- label.set_justify(gtk.JUSTIFY_LEFT)
+ hbox = Gtk.HBox()
+ label = Gtk.Label(label=text)
+ label.set_justify(Gtk.Justification.LEFT)
label.set_line_wrap(True)
hbox.add(label)
if icon is not None:
diff --git a/icon.py b/icon.py
index 07c8c47..f50e77b 100644
--- a/icon.py
+++ b/icon.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Daniel Francis
+# Copyright (C) 2012-2013 Daniel Francis
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -15,4 +15,4 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-from sugar.graphics.icon import *
+from sugar3.graphics.icon import *
diff --git a/item.py b/item.py
index e20ab93..f743928 100644
--- a/item.py
+++ b/item.py
@@ -18,21 +18,21 @@
import logging
logger = logging.getLogger('option')
-import gobject
-import gtk
-from sugar.graphics.toolbutton import ToolButton
+from gi.repository import GObject
+from gi.repository import Gtk
+from sugar3.graphics.toolbutton import ToolButton
import stock
-class Item(gobject.GObject):
- __gsignals__ = {'activate': (gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_NONE,
+class Item(GObject.GObject):
+ __gsignals__ = {'activate': (GObject.SignalFlags.RUN_LAST,
+ None,
tuple())}
toolitem = None
- def __init__(self, stock_id=gtk.STOCK_CLEAR, important=False):
- gobject.GObject.__init__(self)
+ def __init__(self, stock_id=Gtk.STOCK_CLEAR, important=False):
+ GObject.GObject.__init__(self)
self._stock_id = stock_id
self.accel_group = None
self.important = important
@@ -55,13 +55,13 @@ class Item(gobject.GObject):
self.emit('activate')
def setup_accelerator(self):
- accelerator = stock.get_accelerator(self._stock_id)
+ accelerator = stock.stock_items[self._stock_id]['accelerator']
logger.debug(str(accelerator))
try:
- if accelerator[1] > 0:
- self.toolitem.props.accelerator = gtk.accelerator_name(
- accelerator[1], accelerator[0])
- except:
+ if accelerator:
+ self.toolitem.props.accelerator = accelerator
+ except Exception, err:
+ logger.error(err)
logger.error(
'Could not set up accelerator; if toogletoolbutton, update your sugar version')
@@ -79,10 +79,11 @@ class Item(gobject.GObject):
iconset = stock.stock_items[self.stock_id]['has_icon']
if iconset is not None:
try:
- pixbuf = iconset.render_icon(mstyle, gtk.TEXT_DIR_NONE,
- gtk.STATE_NORMAL,
- gtk.ICON_SIZE_LARGE_TOOLBAR)
- image = gtk.image_new_from_pixbuf(pixbuf)
+ pixbuf = iconset.render_icon(mstyle, Gtk.TextDirection.NONE,
+ Gtk.StateType.NORMAL,
+ Gtk.IconSize.LARGE_TOOLBAR,
+ self.toolitem, None)
+ image = Gtk.Image.new_from_pixbuf(pixbuf)
image.show()
self.toolitem.set_icon_widget(image)
except Exception, err:
diff --git a/itembox.py b/itembox.py
index d861c52..86fad19 100644
--- a/itembox.py
+++ b/itembox.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,16 +15,16 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
-import gtk
-from sugar.graphics.toolbarbox import ToolbarBox
-from sugar.activity.widgets import StopButton
+from gi.repository import Gtk
+from sugar3.graphics.toolbarbox import ToolbarBox
+from sugar3.activity.widgets import StopButton
class ItemBox(ToolbarBox):
def __init__(self, activity):
ToolbarBox.__init__(self)
self._parent = activity
- separator = gtk.SeparatorToolItem()
+ separator = Gtk.SeparatorToolItem()
separator.set_draw(False)
separator.set_expand(True)
separator.show()
diff --git a/itemgroup.py b/itemgroup.py
index 637eb4f..3fc9a3d 100644
--- a/itemgroup.py
+++ b/itemgroup.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,18 +15,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
-import gobject
-import gtk
-from sugar.activity.widgets import ToolbarButton
+from gi.repository import GObject
+from gi.repository import Gtk
+from sugar3.activity.widgets import ToolbarButton
-class ItemGroup(gobject.GObject):
+class ItemGroup(GObject.GObject):
def __init__(self, box, name=None, icon=None):
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.items = []
self.item = ToolbarButton(icon_name=icon)
box.toolbar.insert(self.item, len(box.toolbar) - 2)
- self.toolbar = gtk.Toolbar()
+ self.toolbar = Gtk.Toolbar()
self.item.props.page = self.toolbar
self.toolbar.show()
self.item.show()
@@ -43,7 +40,7 @@ class ItemGroup(gobject.GObject):
self.items.append(item)
def append_separator(self, important=False):
- toolitem = gtk.SeparatorToolItem()
+ toolitem = Gtk.SeparatorToolItem()
toolitem.show()
self.toolbar.insert(toolitem, len(self.items) - self.last_position)
self.items.append(self.toolbar)
@@ -52,7 +49,7 @@ class ItemGroup(gobject.GObject):
class GhostGroup(ItemGroup):
def __init__(self, box, name):
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.items = [i for i in box.toolbar.get_children()[:-2]]
self.toolbar = box.toolbar
self.activity = box._parent
@@ -61,7 +58,7 @@ class GhostGroup(ItemGroup):
class SubGroup(ItemGroup):
def __init__(self, group, name=None):
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.items = group.items
self.last_position = group.last_position
if len(self.items) > 0:
diff --git a/profile.py b/profile.py
index 39d1c97..1a122fa 100644
--- a/profile.py
+++ b/profile.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,11 +15,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
-import gtk
-from sugar import profile
+from gi.repository import Gdk
+from sugar3 import profile
+
profile_color = profile.get_color()
-fill_color = gtk.gdk.color_parse(profile_color.get_fill_color())
-stroke_color = gtk.gdk.color_parse(profile_color.get_stroke_color())
+fill_color = Gdk.color_parse(profile_color.get_fill_color())
+stroke_color = Gdk.color_parse(profile_color.get_stroke_color())
get_fill_color = lambda widget: fill_color
get_stroke_color = lambda widget: stroke_color
diff --git a/radioitem.py b/radioitem.py
index b47e28a..e162476 100644
--- a/radioitem.py
+++ b/radioitem.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,8 +17,8 @@
import logging
logger = logging.getLogger('toggleoption')
-import gtk
-from sugar.graphics.radiotoolbutton import RadioToolButton
+from gi.repository import Gtk
+from sugar3.graphics.radiotoolbutton import RadioToolButton
import stock
from toggleitem import ToggleItem
@@ -33,9 +30,10 @@ class RadioItem(ToggleItem):
self.group = group
def get_tool_item(self):
- self.toolitem = RadioToolButton()
- if self.group:
- self.toolitem.set_group(self.group.toolitem)
+ if self.group is not None:
+ self.toolitem = RadioToolButton(group=self.group.toolitem)
+ else:
+ self.toolitem = RadioToolButton()
self.setup_tool_icon()
self.toolitem.set_active(self.default_value)
self.toolitem.connect('toggled', self.toggled_cb)
diff --git a/settingsitem.py b/settingsitem.py
index 43ff987..2a94cc5 100644
--- a/settingsitem.py
+++ b/settingsitem.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,19 +18,19 @@
import logging
logger = logging.getLogger('option')
-import gobject
-import gtk
+from gi.repository import GObject
+from gi.repository import Gtk
from item import Item
class SettingsItem(Item):
- __gsignals__ = {'closed': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
+ __gsignals__ = {'closed': (GObject.SignalFlags.RUN_LAST, None,
tuple())}
def __init__(self, parent=None, stock_id=None, important=False):
Item.__init__(self, stock_id, important)
- self.content = gtk.EventBox()
+ self.content = Gtk.EventBox()
self.parent = parent
self.created = False
# For toggleoptions
diff --git a/settingsradioitem.py b/settingsradioitem.py
index cf1492d..6772ed2 100644
--- a/settingsradioitem.py
+++ b/settingsradioitem.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,14 +18,14 @@
import logging
logger = logging.getLogger('option')
-import gobject
+from gi.repository import GObject
from radioitem import RadioItem
from settingsitem import SettingsItem
class SettingsRadioItem(SettingsItem, RadioItem):
- __gsignals__ = {'toggled': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_BOOLEAN,))}
+ __gsignals__ = {'toggled': (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_BOOLEAN,))}
def __init__(self, group, default_value=True, parent=None,
stock_id=None, important=False):
diff --git a/shortcontentitem.py b/shortcontentitem.py
index 82fceba..defd11b 100644
--- a/shortcontentitem.py
+++ b/shortcontentitem.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,10 +16,10 @@
# MA 02110-1301, USA.
import logging
-logger = logging.getLogger('option')
+logger = logging.getLogger('shortcontentitem')
-import gobject
-import gtk
+from gi.repository import GObject
+from gi.repository import Gtk
from item import Item
@@ -31,11 +28,11 @@ class ShortContentItem(Item):
def __init__(self, parent=None, stock_id=None, important=False):
Item.__init__(self, stock_id, important)
- self.content = gtk.EventBox()
+ self.content = Gtk.EventBox()
self.parent = parent
self.separator = None
def get_tool_item(self):
- self.toolitem = gtk.ToolItem()
+ self.toolitem = Gtk.ToolItem()
self.toolitem.add(self.content)
return self.toolitem
diff --git a/stock.py b/stock.py
index 09f9724..7ee53c3 100644
--- a/stock.py
+++ b/stock.py
@@ -17,50 +17,48 @@
import logging
logger = logging.getLogger('stock')
-import gtk
+from gi.repository import Gtk
+from gi.repository import Gdk
-icon_factory = gtk.IconFactory()
-
-# Set the icon name for the stock items, this is used only in Sugar.
-# Associate here every default stock id with an icon name if you need it.
+icon_factory = Gtk.IconFactory()
stock_items = {}
def register(name, label, accelerator, icon_name):
if icon_name:
- icon_source = gtk.IconSource()
+ icon_source = Gtk.IconSource()
icon_source.set_icon_name(icon_name)
- icon = gtk.IconSet()
+ icon = Gtk.IconSet()
icon.add_source(icon_source)
icon_factory.add(name, icon)
icon_factory.add_default()
- iconset = gtk.icon_factory_lookup_default(name)
+ iconset = Gtk.IconFactory.lookup_default(name)
stock_items[name] = {'label': label,
'accelerator': accelerator,
'has_icon': iconset or None}
def overwrite_stock(stock_id, new_accelerator):
- info = list(gtk.stock_lookup(stock_id))
- keyval, mask = gtk.accelerator_parse(new_accelerator)
- info[2] = mask
- info[3] = keyval
+ info = Gtk.stock_lookup(stock_id)
+ keyval, mask = Gtk.accelerator_parse(new_accelerator)
+ info.modifier = mask
+ info.keyval = keyval
logger.debug(str(info))
- gtk.stock_add([(info[0], info[1], info[2], info[3], info[4])])
+ Gtk.stock_add([info])
# Here we overwrite the key accelerators for some stock ids.
# Feel free to add here any other stock id if you need it at your activity,
# and send us a patch.
-overwrite_stock(gtk.STOCK_ZOOM_IN, '<Ctrl>plus')
-overwrite_stock(gtk.STOCK_ZOOM_OUT, '<Ctrl>minus')
-overwrite_stock(gtk.STOCK_ZOOM_100, '<Ctrl>0')
+overwrite_stock(Gtk.STOCK_ZOOM_IN, '<Ctrl>plus')
+overwrite_stock(Gtk.STOCK_ZOOM_OUT, '<Ctrl>minus')
+overwrite_stock(Gtk.STOCK_ZOOM_100, '<Ctrl>0')
# Key accelerator will be F11 on desktops and <Alt>return on Sugar.
-overwrite_stock(gtk.STOCK_FULLSCREEN, '<Alt>Return')
-overwrite_stock(gtk.STOCK_ADD, '<Ctrl>A')
-overwrite_stock(gtk.STOCK_REMOVE, '<Ctrl>R')
-overwrite_stock(gtk.STOCK_SELECT_COLOR, '<Ctrl>L')
+overwrite_stock(Gtk.STOCK_FULLSCREEN, '<Alt>Return')
+overwrite_stock(Gtk.STOCK_ADD, '<Ctrl>A')
+overwrite_stock(Gtk.STOCK_REMOVE, '<Ctrl>R')
+overwrite_stock(Gtk.STOCK_SELECT_COLOR, '<Ctrl>L')
def get_label(stock, underline=True):
@@ -72,16 +70,17 @@ def get_label(stock, underline=True):
def get_accelerator(stock):
accelerator = stock_items[stock]['accelerator']
- return gtk.accelerator_parse(accelerator) if accelerator is not None \
- else (0, 0)
+ return Gtk.accelerator_parse(accelerator) if accelerator is not None \
+ else (0, Gdk.ModifierType(0))
-for i in gtk.stock_list_ids():
+for i in Gtk.stock_list_ids():
# I am very noisy
# logger.debug(i)
- info = gtk.stock_lookup(i)
- iconset = gtk.icon_factory_lookup_default(i)
+ info = Gtk.stock_lookup(i)
+ iconset = Gtk.IconFactory.lookup_default(i)
if info is not None:
- stock_items[i] = {'label': info[1],
- 'accelerator': gtk.accelerator_name(info[3], info[2]),
+ stock_items[i] = {'label': info.label,
+ 'accelerator': Gtk.accelerator_name(info.keyval,
+ info.modifier),
'has_icon': iconset or None}
diff --git a/toggleitem.py b/toggleitem.py
index 62eb653..f5ff5b6 100644
--- a/toggleitem.py
+++ b/toggleitem.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
+# Copyright (C) 2012-2013 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,16 +17,16 @@
import logging
logger = logging.getLogger('toggleoption')
-import gobject
-import gtk
-from sugar.graphics.toggletoolbutton import ToggleToolButton
+from gi.repository import GObject
+from gi.repository import Gtk
+from sugar3.graphics.toggletoolbutton import ToggleToolButton
import stock
from item import Item
class ToggleItem(Item):
- __gsignals__ = {'toggled': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_BOOLEAN,))}
+ __gsignals__ = {'toggled': (GObject.SignalFlags.RUN_LAST, None,
+ (GObject.TYPE_BOOLEAN,))}
def __init__(self, default_value=True, stock_id=None, important=False):
Item.__init__(self, stock_id, important)