From 9741582464d50c6a3367d9391068095236d3cad9 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Thu, 23 Aug 2012 10:47:43 +0000 Subject: Initial port to Gtk3 and Abiword introspection bindings. Signed-off-by: Carlos Garnacho Signed-off-by: Gonzalo Odiard --- diff --git a/AbiWordActivity.py b/AbiWordActivity.py index b272f04..abe065f 100644 --- a/AbiWordActivity.py +++ b/AbiWordActivity.py @@ -21,25 +21,25 @@ import logging import os # Abiword needs this to happen as soon as possible -import gobject -gobject.threads_init() +from gi.repository import GObject +GObject.threads_init() -import gtk +from gi.repository import Gtk +from gi.repository import Abi +from gi.repository import GdkPixbuf import telepathy import telepathy.client -from abiword import Canvas +from sugar3.activity import activity +from sugar3.activity.widgets import StopButton +from sugar3.activity.widgets import ActivityToolbarButton +from sugar3.activity.activity import get_bundle_path -from sugar.activity import activity -from sugar.activity.widgets import StopButton -from sugar.activity.widgets import ActivityToolbarButton -from sugar.activity.activity import get_bundle_path +from sugar3 import mime -from sugar import mime - -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toolbarbox import ToolbarButton, ToolbarBox -from sugar.graphics import style +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.toolbarbox import ToolbarButton, ToolbarBox +from sugar3.graphics import style from toolbar import EditToolbar from toolbar import ViewToolbar @@ -49,8 +49,9 @@ from toolbar import InsertToolbar from toolbar import ParagraphToolbar from widgets import ExportButtonFactory from port import chooser -import speech -from speechtoolbar import SpeechToolbar +# TODO Gtk3 +#import speech +#from speechtoolbar import SpeechToolbar logger = logging.getLogger('write-activity') @@ -64,14 +65,14 @@ class AbiWordActivity(activity.Activity): os.chdir(os.path.expanduser('~')) # create our main abiword canvas - self.abiword_canvas = Canvas() + self.abiword_canvas = Abi.Widget() toolbar_box = ToolbarBox() self.activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(self.activity_button, -1) - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() separator.show() self.activity_button.props.page.insert(separator, 2) ExportButtonFactory(self, self.abiword_canvas) @@ -89,7 +90,7 @@ class AbiWordActivity(activity.Activity): view_toolbar.props.label = _('View') toolbar_box.toolbar.insert(view_toolbar, -1) - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) text_toolbar = ToolbarButton() @@ -116,7 +117,7 @@ class AbiWordActivity(activity.Activity): insert_toolbar.props.label = _('Table') toolbar_box.toolbar.insert(insert_toolbar, -1) - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) image = ToolButton('insert-picture') @@ -125,23 +126,24 @@ class AbiWordActivity(activity.Activity): toolbar_box.toolbar.insert(image, -1) palette = image.get_palette() - content_box = gtk.VBox() + content_box = Gtk.VBox() palette.set_content(content_box) - image_floating_checkbutton = gtk.CheckButton(_('Floating')) + image_floating_checkbutton = Gtk.CheckButton(_('Floating')) image_floating_checkbutton.connect('toggled', self._image_floating_checkbutton_toggled_cb) - content_box.pack_start(image_floating_checkbutton) + content_box.pack_start(image_floating_checkbutton, True, True, 0) content_box.show_all() self.floating_image = False - if speech.supported: - self.speech_toolbar_button = ToolbarButton(icon_name='speak') - toolbar_box.toolbar.insert(self.speech_toolbar_button, -1) - self.speech_toolbar = SpeechToolbar(self) - self.speech_toolbar_button.set_page(self.speech_toolbar) - self.speech_toolbar_button.show() + # TODO Gtk3 +# if speech.supported: +# self.speech_toolbar_button = ToolbarButton(icon_name='speak') +# toolbar_box.toolbar.insert(self.speech_toolbar_button, -1) +# self.speech_toolbar = SpeechToolbar(self) +# self.speech_toolbar_button.set_page(self.speech_toolbar) +# self.speech_toolbar_button.show() - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) separator.show() @@ -161,13 +163,14 @@ class AbiWordActivity(activity.Activity): self.abiword_canvas.connect('size-allocate', self.size_allocate_cb) def size_allocate_cb(self, abi, alloc): - gobject.idle_add(abi.queue_draw) + logging.error('size allocate %s', alloc) + GObject.idle_add(abi.queue_draw) def __map_event_cb(self, event, activity): - logger.debug('__map_event_cb') + logger.debug('__map_event_cb abi') # no ugly borders please - self.abiword_canvas.set_property("shadow-type", gtk.SHADOW_NONE) + self.abiword_canvas.set_property("shadow-type", Gtk.ShadowType.NONE) # we only do per-word selections (when using the mouse) self.abiword_canvas.set_word_selections(True) @@ -200,13 +203,13 @@ class AbiWordActivity(activity.Activity): # we do it later because have problems if done before - OLPC #11049 logger.error('Loading keybindings') keybindings_file = os.path.join(get_bundle_path(), 'keybindings.xml') - self.abiword_canvas.invoke_cmd( + self.abiword_canvas.invoke_ex( 'com.abisource.abiword.loadbindings.fromURI', keybindings_file, 0, 0) # set default font self.abiword_canvas.select_all() # get_selection return content and length - if self.abiword_canvas.get_selection('text/plain')[1] == 0: + if self.abiword_canvas.get_selection('text/plain') is None: logging.error('Setting default font to Sans in new documents') self.abiword_canvas.set_font_name('Sans') self.abiword_canvas.moveto_bod() @@ -217,14 +220,15 @@ class AbiWordActivity(activity.Activity): pixbuf = self.abiword_canvas.render_page_to_image(1) pixbuf = pixbuf.scale_simple(style.zoom(300), style.zoom(225), - gtk.gdk.INTERP_BILINEAR) + GdkPixbuf.InterpType.BILINEAR) preview_data = [] - def save_func(buf, data): + def save_func(buf, lenght, data): data.append(buf) + return True - pixbuf.save_to_callback(save_func, 'png', user_data=preview_data) + pixbuf.save_to_callbackv(save_func, preview_data, 'png', [], []) preview_data = ''.join(preview_data) return preview_data @@ -313,18 +317,18 @@ class AbiWordActivity(activity.Activity): if self.joined: logger.error('Passing tube address to abicollab (join): %s', address) - self.abiword_canvas.invoke_cmd(cmd_prefix + 'joinTube', + self.abiword_canvas.invoke_ex(cmd_prefix + 'joinTube', address, 0, 0) # The intiator of the session has to be the first passed # to the Abicollab backend. logger.error('Adding the initiator to the session: %s', initiator_dbus_name) - self.abiword_canvas.invoke_cmd(cmd_prefix + 'buddyJoined', + self.abiword_canvas.invoke_ex(cmd_prefix + 'buddyJoined', initiator_dbus_name, 0, 0) else: logger.error('Passing tube address to abicollab (offer): %s', address) - self.abiword_canvas.invoke_cmd(cmd_prefix + 'offerTube', address, + self.abiword_canvas.invoke_ex(cmd_prefix + 'offerTube', address, 0, 0) self.tube_id = id @@ -345,7 +349,7 @@ class AbiWordActivity(activity.Activity): for handle, bus_name in added: logger.error('added handle: %s, with dbus_name: %s', handle, bus_name) - self.abiword_canvas.invoke_cmd(cmd_prefix + '.buddyJoined', + self.abiword_canvas.invoke_ex(cmd_prefix + '.buddyJoined', bus_name, 0, 0) self.participants[handle] = bus_name @@ -362,7 +366,7 @@ class AbiWordActivity(activity.Activity): cmd_prefix = 'com.abisource.abiword.abicollab.olpc' logger.error('removed handle: %d, with dbus name: %s', handle, bus_name) - self.abiword_canvas.invoke_cmd(cmd_prefix + '.buddyLeft', + self.abiword_canvas.invoke_ex(cmd_prefix + '.buddyLeft', bus_name, 0, 0) def _buddy_joined_cb(self, activity, buddy): @@ -400,9 +404,9 @@ class AbiWordActivity(activity.Activity): self.abiword_canvas.save('file://' + file_path, self.metadata['mime_type'], '') - - self.metadata['fulltext'] = self.abiword_canvas.get_content( - extension_or_mimetype=".txt")[:3000] + # TODO Gtk3 + #self.metadata['fulltext'] = self.abiword_canvas.get_content( + # extension_or_mimetype=".txt")[:3000] def _is_plain_text(self, mime_type): # These types have 'text/plain' in their mime_parents but we need diff --git a/fontcombobox.py b/fontcombobox.py index 58f9140..9de5e34 100644 --- a/fontcombobox.py +++ b/fontcombobox.py @@ -15,21 +15,22 @@ # 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 +from gi.repository import GObject 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) + GObject.GObject.__init__(self) + font_renderer = Gtk.CellRendererText() + self.pack_start(font_renderer, True) 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 @@ -39,15 +40,15 @@ class FontComboBox(gtk.ComboBox): name = family.get_name() if name not in FONT_BLACKLIST: font_model.append([name]) - font_faces = [] - for face in family.list_faces(): - face_name = face.get_face_name() - font_faces.append(face_name) - self.faces[name] = font_faces + # TODO gtk3 +# font_faces = [] +# for face in family.list_faces(): +# face_name = face.get_face_name() +# font_faces.append(face_name) +# self.faces[name] = font_faces - sorter = gtk.TreeModelSort(font_model) - sorter.set_sort_column_id(0, gtk.SORT_ASCENDING) - self.set_model(sorter) + font_model.set_sort_column_id(0, Gtk.SortType.ASCENDING) + self.set_model(font_model) self.show() def set_font_name(self, font_name): diff --git a/port/chooser.py b/port/chooser.py index c56d19f..d146133 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 @@ -46,7 +46,7 @@ def pick(cb=None, default=None, parent=None, what=None): out = None try: - if chooser.run() == gtk.RESPONSE_ACCEPT: + if chooser.run() == Gtk.ResponseType.ACCEPT: jobject = chooser.get_selected_object() logging.debug('ObjectChooser: %r' % jobject) 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/speech.py b/speech.py index 1e88a86..176b8b5 100644 --- a/speech.py +++ b/speech.py @@ -21,19 +21,19 @@ _logger = logging.getLogger('write-activity') supported = True -try: - import gst - gst.element_factory_make('espeak') - from speech_gst import * - _logger.info('use gst-plugins-espeak') -except Exception, e: - _logger.info('disable gst-plugins-espeak: %s' % e) - try: - from speech_dispatcher import * - _logger.info('use speech-dispatcher') - except Exception, e: - supported = False - _logger.info('disable speech: %s' % e) +#try: +# import gst +# gst.element_factory_make('espeak') +# from speech_gst import * +# _logger.info('use gst-plugins-espeak') +#except Exception, e: +# _logger.info('disable gst-plugins-espeak: %s' % e) +# try: +# from speech_dispatcher import * +# _logger.info('use speech-dispatcher') +# except Exception, e: +# supported = False +# _logger.info('disable speech: %s' % e) voice = 'default' pitch = 0 diff --git a/speech_dispatcher.py b/speech_dispatcher.py index 4fad27f..99d35d9 100644 --- a/speech_dispatcher.py +++ b/speech_dispatcher.py @@ -14,7 +14,7 @@ # 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 Gdk import time import threading import speechd @@ -105,12 +105,12 @@ class EspeakThread(threading.Thread): if type == speechd.CallbackType.INDEX_MARK: mark = kargs['index_mark'] word_count = int(mark) - gtk.gdk.threads_enter() + Gdk.threads_enter() speech.highlight_cb(word_count) - gtk.gdk.threads_leave() + Gdk.threads_leave() elif type == speechd.CallbackType.END: - gtk.gdk.threads_enter() + Gdk.threads_enter() speech.reset_cb() - gtk.gdk.threads_leave() + Gdk.threads_leave() global done done = True diff --git a/speechtoolbar.py b/speechtoolbar.py index 6d4d56d..ef73e81 100644 --- a/speechtoolbar.py +++ b/speechtoolbar.py @@ -19,26 +19,27 @@ import simplejson from gettext import gettext as _ import logging -import gtk -import gconf +from gi.repository import Gtk +from gi.repository import GObject +from gi.repository import GConf -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toggletoolbutton import ToggleToolButton -from sugar.graphics.combobox import ComboBox -from sugar.graphics.toolcombobox import ToolComboBox +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.toggletoolbutton import ToggleToolButton +from sugar3.graphics.combobox import ComboBox +from sugar3.graphics.toolcombobox import ToolComboBox import speech -class SpeechToolbar(gtk.Toolbar): +class SpeechToolbar(Gtk.Toolbar): def __init__(self, activity): - gtk.Toolbar.__init__(self) + GObject.GObject.__init__(self) self._activity = activity if not speech.supported: return self.is_paused = False - self._cnf_client = gconf.client_get_default() + self._cnf_client = GConf.Client.get_default() self.load_speech_parameters() self.sorted_voices = [i for i in speech.voices()] @@ -105,7 +106,7 @@ class SpeechToolbar(gtk.Toolbar): logging.error('Default voice %s', speech.voice) self._cnf_client.add_dir('/desktop/sugar/speech', - gconf.CLIENT_PRELOAD_NONE) + GConf.ClientPreloadType.PRELOAD_NONE) speech.pitch = self._cnf_client.get_int('/desktop/sugar/speech/pitch') speech.rate = self._cnf_client.get_int('/desktop/sugar/speech/rate') self._cnf_client.notify_add('/desktop/sugar/speech/pitch', \ diff --git a/toolbar.py b/toolbar.py index 49c15be..7f98f30 100644 --- a/toolbar.py +++ b/toolbar.py @@ -19,22 +19,26 @@ from gettext import gettext as _ import logging -import abiword -import gtk +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject +from gi.repository import GdkPixbuf +from gi.repository import Abi + import os import tempfile from urlparse import urlparse -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toolcombobox import ToolComboBox -from sugar.graphics.colorbutton import ColorToolButton -from sugar.graphics.toggletoolbutton import ToggleToolButton -from sugar.graphics import iconentry -from sugar.graphics import style -from sugar.activity.widgets import CopyButton -from sugar.activity.widgets import PasteButton -from sugar.activity.widgets import UndoButton -from sugar.activity.widgets import RedoButton +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.toolcombobox import ToolComboBox +from sugar3.graphics.colorbutton import ColorToolButton +from sugar3.graphics.toggletoolbutton import ToggleToolButton +from sugar3.graphics import iconentry +from sugar3.graphics import style +from sugar3.activity.widgets import CopyButton +from sugar3.activity.widgets import PasteButton +from sugar3.activity.widgets import UndoButton +from sugar3.activity.widgets import RedoButton from widgets import AbiButton from widgets import FontSizeCombo @@ -43,11 +47,11 @@ from fontcombobox import FontComboBox logger = logging.getLogger('write-activity') -class EditToolbar(gtk.Toolbar): +class EditToolbar(Gtk.Toolbar): def __init__(self, pc, toolbar_box): - gtk.Toolbar.__init__(self) + GObject.GObject.__init__(self) self._abiword_canvas = pc.abiword_canvas @@ -63,7 +67,7 @@ class EditToolbar(gtk.Toolbar): self.insert(paste, -1) paste.show() - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() self.insert(separator, -1) separator.show() @@ -88,13 +92,13 @@ class EditToolbar(gtk.Toolbar): pc.abiword_canvas.connect('selection-cleared', lambda abi, b: copy.set_sensitive(False)) - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() self.insert(separator, -1) separator.show() - search_label = gtk.Label(_("Search") + ": ") + search_label = Gtk.Label(label=_("Search") + ": ") search_label.show() - search_item_page_label = gtk.ToolItem() + search_item_page_label = Gtk.ToolItem() search_item_page_label.add(search_label) self.insert(search_item_page_label, -1) search_item_page_label.show() @@ -129,7 +133,7 @@ class EditToolbar(gtk.Toolbar): self._findnext.set_sensitive(False) def __paste_button_cb(self, button): - clipboard = gtk.Clipboard() + clipboard = Gtk.Clipboard() if clipboard.wait_is_image_available(): pixbuf_sel = clipboard.wait_for_image() @@ -197,7 +201,7 @@ class EditToolbar(gtk.Toolbar): # bad foddex! this function was copied from sugar's activity.py def _add_widget(self, widget, expand=False): - tool_item = gtk.ToolItem() + tool_item = Gtk.ToolItem() tool_item.set_expand(expand) tool_item.add(widget) @@ -207,21 +211,21 @@ class EditToolbar(gtk.Toolbar): tool_item.show() -class InsertToolbar(gtk.Toolbar): +class InsertToolbar(Gtk.Toolbar): def __init__(self, abiword_canvas): - gtk.Toolbar.__init__(self) + GObject.GObject.__init__(self) self._abiword_canvas = abiword_canvas - self._table = abiword.TableCreator() + self._table = Abi.Table() self._table.set_labels(_('Table'), _('Cancel')) self._table_id = self._table.connect('selected', self._table_cb) - image = gtk.Image() + image = Gtk.Image() image.set_from_icon_name('insert-table', -1) self._table.set_image(image) - self._table.set_relief(gtk.RELIEF_NONE) - tool_item = gtk.ToolItem() + self._table.set_relief(Gtk.ReliefStyle.NONE) + tool_item = Gtk.ToolItem() tool_item.add(self._table) self.insert(tool_item, -1) tool_item.show_all() @@ -260,16 +264,16 @@ class InsertToolbar(gtk.Toolbar): self._abiword_canvas.insert_table(rows, cols) def _table_rows_after_cb(self, button): - self._abiword_canvas.invoke_cmd('insertRowsAfter', '', 0, 0) + self._abiword_canvas.invoke_ex('insertRowsAfter', '', 0, 0) def _table_delete_rows_cb(self, button): - self._abiword_canvas.invoke_cmd('deleteRows', '', 0, 0) + self._abiword_canvas.invoke_ex('deleteRows', '', 0, 0) def _table_cols_after_cb(self, button): - self._abiword_canvas.invoke_cmd('insertColsAfter', '', 0, 0) + self._abiword_canvas.invoke_ex('insertColsAfter', '', 0, 0) def _table_delete_cols_cb(self, button): - self._abiword_canvas.invoke_cmd('deleteColumns', '', 0, 0) + self._abiword_canvas.invoke_ex('deleteColumns', '', 0, 0) def _isTable_cb(self, abi, b): self._table_rows_after.set_sensitive(b) @@ -278,10 +282,10 @@ class InsertToolbar(gtk.Toolbar): self._table_delete_cols.set_sensitive(b) -class ViewToolbar(gtk.Toolbar): +class ViewToolbar(Gtk.Toolbar): def __init__(self, abiword_canvas): - gtk.Toolbar.__init__(self) + GObject.GObject.__init__(self) self._abiword_canvas = abiword_canvas self._zoom_percentage = 0 @@ -306,50 +310,50 @@ class ViewToolbar(gtk.Toolbar): self._zoom_to_width.show() # TODO: fix the initial value - self._zoom_spin_adj = gtk.Adjustment(0, 25, 400, 25, 50, 0) - self._zoom_spin = gtk.SpinButton(self._zoom_spin_adj, 0, 0) + self._zoom_spin_adj = Gtk.Adjustment(0, 25, 400, 25, 50, 0) + self._zoom_spin = Gtk.SpinButton.new(self._zoom_spin_adj, 0, 0) self._zoom_spin_id = self._zoom_spin.connect('value-changed', self._zoom_spin_cb) self._zoom_spin.set_numeric(True) self._zoom_spin.show() - tool_item_zoom = gtk.ToolItem() + tool_item_zoom = Gtk.ToolItem() tool_item_zoom.add(self._zoom_spin) self.insert(tool_item_zoom, -1) tool_item_zoom.show() - zoom_perc_label = gtk.Label(_("%")) + zoom_perc_label = Gtk.Label(_("%")) zoom_perc_label.show() - tool_item_zoom_perc_label = gtk.ToolItem() + tool_item_zoom_perc_label = Gtk.ToolItem() tool_item_zoom_perc_label.add(zoom_perc_label) self.insert(tool_item_zoom_perc_label, -1) tool_item_zoom_perc_label.show() - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() separator.set_draw(True) separator.show() self.insert(separator, -1) - page_label = gtk.Label(_("Page: ")) + page_label = Gtk.Label(_("Page: ")) page_label.show() - tool_item_page_label = gtk.ToolItem() + tool_item_page_label = Gtk.ToolItem() tool_item_page_label.add(page_label) self.insert(tool_item_page_label, -1) tool_item_page_label.show() - self._page_spin_adj = gtk.Adjustment(0, 1, 0, -1, -1, 0) - self._page_spin = gtk.SpinButton(self._page_spin_adj, 0, 0) + self._page_spin_adj = Gtk.Adjustment(0, 1, 0, -1, -1, 0) + self._page_spin = Gtk.SpinButton.new(self._page_spin_adj, 0, 0) self._page_spin_id = self._page_spin.connect('value-changed', self._page_spin_cb) self._page_spin.set_numeric(True) self._page_spin.show() - tool_item_page = gtk.ToolItem() + tool_item_page = Gtk.ToolItem() tool_item_page.add(self._page_spin) self.insert(tool_item_page, -1) tool_item_page.show() - self._total_page_label = gtk.Label(" / 0") + self._total_page_label = Gtk.Label(label=" / 0") self._total_page_label.show() - tool_item = gtk.ToolItem() + tool_item = Gtk.ToolItem() tool_item.add(self._total_page_label) self.insert(tool_item, -1) tool_item.show() @@ -395,7 +399,7 @@ class ViewToolbar(gtk.Toolbar): def _page_count_cb(self, canvas, count): current_page = canvas.get_current_page_num() - self._page_spin_adj.set_all(current_page, 1, count, -1, -1, 0) + self._page_spin_adj.configure(current_page, 1, count, -1, -1, 0) self._total_page_label.props.label = \ ' / ' + str(count) @@ -407,10 +411,10 @@ class ViewToolbar(gtk.Toolbar): self._page_spin.handler_unblock(self._page_spin_id) -class TextToolbar(gtk.Toolbar): +class TextToolbar(Gtk.Toolbar): def __init__(self, abiword_canvas): - gtk.Toolbar.__init__(self) + GObject.GObject.__init__(self) self.font_name_combo = FontComboBox() self.font_name_combo.set_font_name('Sans') @@ -447,17 +451,17 @@ class TextToolbar(gtk.Toolbar): self._setToggleButtonState(underline, b, underline_id)) self.insert(underline, -1) - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() self.insert(separator, -1) color = ColorToolButton() color.connect('notify::color', self._text_color_cb, abiword_canvas) - tool_item = gtk.ToolItem() + tool_item = Gtk.ToolItem() tool_item.add(color) self.insert(tool_item, -1) abiword_canvas.connect('color', lambda abi, r, g, b: - color.set_color(gtk.gdk.Color(r * 256, g * 256, b * 256))) + color.set_color(Gdk.Color(r * 256, g * 256, b * 256))) # MAGIC NUMBER WARNING: Secondary toolbars are not a standard height? self.set_size_request(-1, style.GRID_CELL_SIZE) @@ -488,10 +492,10 @@ class TextToolbar(gtk.Toolbar): int(newcolor.blue / 256.0)) -class ParagraphToolbar(gtk.Toolbar): +class ParagraphToolbar(Gtk.Toolbar): def __init__(self, abi): - gtk.Toolbar.__init__(self) + GObject.GObject.__init__(self) def append_style(icon_name, tooltip, do_abi_cb, on_abi_cb): button = AbiButton(abi, 'style-name', do_abi_cb, on_abi_cb) @@ -538,7 +542,7 @@ class ParagraphToolbar(gtk.Toolbar): lambda: abi.set_style('Plain Text'), lambda abi, style: style == 'Plain Text') - self.insert(gtk.SeparatorToolItem(), -1) + self.insert(Gtk.SeparatorToolItem(), -1) def append_align(icon_name, tooltip, do_abi_cb, style_name): button = AbiButton(abi, style_name, do_abi_cb) @@ -565,10 +569,10 @@ class ParagraphToolbar(gtk.Toolbar): self.show_all() -class ListToolbar(gtk.Toolbar): +class ListToolbar(Gtk.Toolbar): def __init__(self, abi): - gtk.Toolbar.__init__(self) + GObject.GObject.__init__(self) def append(icon_name, tooltip, do_abi_cb, on_abi_cb): button = AbiButton(abi, 'style-name', do_abi_cb, on_abi_cb) diff --git a/widgets.py b/widgets.py index f12544a..a3b3709 100644 --- a/widgets.py +++ b/widgets.py @@ -18,14 +18,14 @@ import time from gettext import gettext as _ import logging -from sugar.graphics.radiotoolbutton import RadioToolButton -from sugar.graphics.combobox import ComboBox -from sugar.graphics.palette import Palette -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.menuitem import MenuItem -from sugar.datastore import datastore - -from sugar.activity.activity import SCOPE_PRIVATE +from sugar3.graphics.radiotoolbutton import RadioToolButton +from sugar3.graphics.combobox import ComboBox +from sugar3.graphics.palette import Palette +from sugar3.graphics.toolbutton import ToolButton +from sugar3.graphics.menuitem import MenuItem +from sugar3.datastore import datastore + +from sugar3.activity.activity import SCOPE_PRIVATE logger = logging.getLogger('write-activity') -- cgit v0.9.1