Ticket #3742: 0001-Port-to-Gtk3-SL-3742.patch

File 0001-Port-to-Gtk3-SL-3742.patch, 70.4 KB (added by humitos, 12 years ago)

Some things are not ported yet

  • activity.py

    From 42d0ec59142b4e85b1bc5e9895c744bc12035d19 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Thu, 12 Jul 2012 15:51:46 -0300
    Subject: [PATCH InfoSlicer] Port to Gtk3 SL #3742
    
    The activity is almost ported but there are some issues that should be
    solved in the future. Some of them are bugs already reported into
    pygobject bug tracker.
    
     - Drag and Drop Images from the Edit View is not working
     - The arrow after drag-n-drop an image to the article is not added
     - On "Home View" we are not able to move the articles up or down
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     activity.py                            |  138 +++++++++++++------------------
     book.py                                |   20 ++---
     bookview.py                            |  140 ++++++++++++++++++--------------
     edit.py                                |   14 ++--
     infoslicer/processing/Article.py       |   22 ++---
     infoslicer/processing/Paragraph.py     |    4 +-
     infoslicer/processing/Section.py       |    4 +-
     infoslicer/processing/Sentence.py      |   12 +--
     infoslicer/widgets/Edit_Pane.py        |   38 +++++----
     infoslicer/widgets/Editable_Textbox.py |   40 +++++----
     infoslicer/widgets/Editing_View.py     |   26 +++---
     infoslicer/widgets/Format_Pane.py      |   14 ++--
     infoslicer/widgets/Gallery_View.py     |   84 ++++++++++---------
     infoslicer/widgets/Image_Pane.py       |   30 +++----
     infoslicer/widgets/Reading_View.py     |   17 ++--
     infoslicer/widgets/Readonly_Textbox.py |   33 +++++---
     infoslicer/widgets/Textbox.py          |   22 ++---
     library.py                             |  121 +++++++++++++--------------
     net.py                                 |    2 +-
     setup.py                               |    2 +-
     toolbar.py                             |   26 +++---
     xol.py                                 |   64 ++++++++-------
     22 files changed, 455 insertions(+), 418 deletions(-)
    
    diff --git a/activity.py b/activity.py
    index 46cf2ad..fa94eab 100644
    a b  
    1212# along with this program; if not, write to the Free Software
    1313# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1414
    15 import gtk
     15from gi.repository import Gtk
     16from gi.repository import GObject
    1617from gettext import gettext as _
    1718
    18 from sugar.graphics.toolbutton import ToolButton
    19 from sugar.graphics.toggletoolbutton import ToggleToolButton
    20 from sugar.activity.activity import ActivityToolbox
    21 from sugar.activity import activity
     19GObject.threads_init()
    2220
    23 OLD_TOOLBAR = False
    24 try:
    25     from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
    26     from sugar.activity.widgets import StopButton
    27     from sugar.graphics.radiotoolbutton import RadioToolButton
    28     from sugar.activity.widgets import ActivityToolbarButton
    29 except ImportError:
    30     OLD_TOOLBAR = True
     21from sugar3.graphics.toolbutton import ToolButton
     22from sugar3.graphics.toggletoolbutton import ToggleToolButton
     23from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
     24from sugar3.activity.widgets import StopButton
     25from sugar3.activity import activity
     26from sugar3.graphics.radiotoolbutton import RadioToolButton
     27from sugar3.activity.widgets import ActivityToolbarButton
    3128
    3229import library
    3330import edit
    3431import book
    3532
    36 gtk.gdk.threads_init()
    37 gtk.gdk.threads_enter()
    38 
    39 
    4033class InfoslicerActivity(activity.Activity):
    4134    def __init__(self, handle):
    42         self.notebook = gtk.Notebook()
     35        self.notebook = Gtk.Notebook()
    4336        self.notebook.show()
    4437        self.notebook.props.show_border = False
    4538        self.notebook.props.show_tabs = False
    class InfoslicerActivity(activity.Activity): 
    6053        self.edit = edit.View()
    6154        self.library = library.View(self)
    6255
    63         if OLD_TOOLBAR:
    64             self.edit_toolbar = gtk.Toolbar()
    65             self.edit_bar = edit.ToolbarBuilder(self.edit, self.edit_toolbar)
    66             self.edit_toolbar.show_all()
    67 
    68             self.library_toolbar = gtk.Toolbar()
    69             self.library_bar = library.ToolbarBuilder(self.library,
    70                     self.library_toolbar)
    71             self.library_toolbar.show_all()
    72 
    73             toolbox = ActivityToolbox(self)
    74             toolbox.connect('current-toolbar-changed',
    75                     self._toolbar_changed_cb)
    76             self.set_toolbox(toolbox)
    77             toolbox.add_toolbar(_('Library'), self.library_toolbar)
    78             toolbox.add_toolbar(_('Edit'), self.edit_toolbar)
    79             toolbox.set_current_toolbar(1)
    80         else:
    81             toolbar_box = ToolbarBox()
    82             activity_button = ActivityToolbarButton(self)
    83             toolbar_box.toolbar.insert(activity_button, 0)
    84             self.set_toolbar_box(toolbar_box)
    85             self._toolbar = toolbar_box.toolbar
    86 
    87             tool_group = None
    88             search_button = RadioToolButton()
    89             search_button.props.group = tool_group
    90             tool_group = search_button
    91             search_button.props.icon_name = 'white-search'
    92             search_button.set_tooltip(_('Library'))
    93             search_button.mode = 'search'
    94             search_button.connect('clicked', self.__mode_button_clicked)
    95             self._toolbar.insert(search_button, -1)
    96 
    97             edit_button = RadioToolButton()
    98             edit_button.props.group = tool_group
    99             edit_button.props.icon_name = 'toolbar-edit'
    100             edit_button.set_tooltip(_('Edit'))
    101             edit_button.mode = 'edit'
    102             edit_button.connect('clicked', self.__mode_button_clicked)
    103             self._toolbar.insert(edit_button, -1)
    104             self._toolbar.insert(gtk.SeparatorToolItem(), -1)
    105             self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar)
    106             self.library_bar = library.ToolbarBuilder(self.library,
    107                                                       activity_button)
    108             self.library_bar.publish.show()
    109 
    110         edit_fake = gtk.EventBox()
    111 
    112         self.notebook.append_page(self.library)
    113         self.notebook.append_page(self.edit)
    114         self.notebook.append_page(edit_fake)
     56        toolbar_box = ToolbarBox()
     57        activity_button = ActivityToolbarButton(self)
     58        toolbar_box.toolbar.insert(activity_button, 0)
     59        self.set_toolbar_box(toolbar_box)
     60        self._toolbar = toolbar_box.toolbar
     61
     62        tool_group = None
     63        search_button = RadioToolButton()
     64        search_button.props.group = tool_group
     65        tool_group = search_button
     66        search_button.props.icon_name = 'white-search'
     67        search_button.set_tooltip(_('Library'))
     68        search_button.mode = 'search'
     69        search_button.connect('clicked', self.__mode_button_clicked)
     70        self._toolbar.insert(search_button, -1)
     71
     72        edit_button = RadioToolButton()
     73        edit_button.props.group = tool_group
     74        edit_button.props.icon_name = 'toolbar-edit'
     75        edit_button.set_tooltip(_('Edit'))
     76        edit_button.mode = 'edit'
     77        edit_button.connect('clicked', self.__mode_button_clicked)
     78        self._toolbar.insert(edit_button, -1)
     79        self._toolbar.insert(Gtk.SeparatorToolItem(), -1)
     80        self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar)
     81        self.library_bar = library.ToolbarBuilder(self.library,
     82                                                  activity_button)
     83        self.library_bar.publish.show()
     84
     85        edit_fake = Gtk.EventBox()
     86
     87        self.notebook.append_page(self.library, None)
     88        self.notebook.append_page(self.edit, None)
     89        self.notebook.append_page(edit_fake, None)
    11590
    11691        self.show_all()
    11792
    118         if not OLD_TOOLBAR:
    119             self.__mode_button_clicked(search_button)
    120             separator = gtk.SeparatorToolItem()
    121             separator.props.draw = False
    122             separator.set_expand(True)
    123             separator.show()
    124             self._toolbar.insert(separator, -1)
    125             stop_button = StopButton(self)
    126             stop_button.show()
    127             self._toolbar.insert(stop_button, -1)
     93        self.__mode_button_clicked(search_button)
     94        separator = Gtk.SeparatorToolItem()
     95        separator.props.draw = False
     96        separator.set_expand(True)
     97        separator.show()
     98        self._toolbar.insert(separator, -1)
     99        stop_button = StopButton(self)
     100        stop_button.show()
     101        self._toolbar.insert(stop_button, -1)
    128102
    129103    def new_instance(self):
    130104        self.instance()
    class InfoslicerActivity(activity.Activity): 
    138112        book.custom.sync(filepath)
    139113
    140114    def set_edit_sensitive(self, enable):
    141         if OLD_TOOLBAR:
    142             #self.edit_toolbar.props.sensitive = enable
    143             self.edit_page = (enable and 1 or 2)
     115        pass
    144116
    145117    def _toolbar_changed_cb(self, widget, index):
    146118        if index > 0:
  • book.py

    diff --git a/book.py b/book.py
    index f28ff99..02b13a6 100644
    a b  
    1313# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1414
    1515import os
    16 import gtk
    1716import uuid
    1817import logging
    19 import gobject
     18from gi.repository import GObject
    2019import cjson
    2120import shutil
    2221import zipfile
    23 from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT
    2422from gettext import gettext as _
    2523
    26 from sugar.activity.activity import get_bundle_path, get_activity_root
     24from sugar3.activity.activity import get_bundle_path, get_activity_root
    2725
    2826import net
    2927from infoslicer.processing.Article import Article
    custom = None 
    3634
    3735image_root = os.path.join(get_activity_root(), 'data', 'book')
    3836
    39 class Book(gobject.GObject):
     37class Book(GObject.GObject):
    4038    __gsignals__ = {
    41         'article-selected' : (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]),
    42         'article-added'    : (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]),
    43         'article-deleted'  : (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]) }
     39        'article-selected' : (GObject.SignalFlags.RUN_FIRST, None, [object]),
     40        'article-added'    : (GObject.SignalFlags.RUN_FIRST, None, [object]),
     41        'article-deleted'  : (GObject.SignalFlags.RUN_FIRST, None, [object])}
    4442
    4543    def get_article(self):
    4644        return self._article
    class Book(gobject.GObject): 
    7169
    7270        self._article.uid = entry['uid']
    7371        self._article.article_title = title
    74         gobject.idle_add(self._emit_article_selected)
     72        GObject.idle_add(self._emit_article_selected)
    7573
    76     article = gobject.property(type=object,
     74    article = GObject.property(type=object,
    7775            getter=get_article, setter=set_article)
    7876
    7977    def _emit_article_selected(self):
    class Book(gobject.GObject): 
    132130        self.sync_index()
    133131
    134132    def __init__(self, preinstalled, root):
    135         gobject.GObject.__init__(self)
     133        GObject.GObject.__init__(self)
    136134        self.root = root
    137135        self.index = []
    138136        self.uid = None
  • bookview.py

    diff --git a/bookview.py b/bookview.py
    index e38662b..e165c19 100644
    a b  
    1313# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1414
    1515import os
    16 import gtk
     16from gi.repository import Gtk
    1717import logging
    18 import gobject
     18from gi.repository import GObject
    1919from gettext import gettext as _
    2020
    21 from sugar.graphics.toolbutton import ToolButton
    22 from sugar.activity.activity import get_bundle_path, get_activity_root
    23 from sugar.graphics.style import *
     21from sugar3.graphics.toolbutton import ToolButton
     22from sugar3.activity.activity import get_bundle_path, get_activity_root
     23from sugar3.graphics.style import *
    2424
    2525logger = logging.getLogger('infoslicer')
    2626
    2727PUBLISH  = 0
    2828TITLE    = 1
    2929
    30 class BookView(gtk.VBox):
     30class BookView(Gtk.VBox):
    3131    def sync(self):
    3232        if not self._changing:
    3333            return
    34         gobject.source_remove(self._changing)
     34        GObject.source_remove(self._changing)
    3535        index, column = self.tree.get_cursor()
    3636        self._cursor_changed(index)
    3737
    3838    def __init__(self, book, name, tooltip, custom):
    39         gtk.VBox.__init__(self)
     39        GObject.GObject.__init__(self)
    4040        self.book = book
    4141        self._changing = None
    4242        self._check = None
    4343
    44         title = gtk.Toolbar()
     44        title = Gtk.Toolbar()
    4545
    4646        # title checkbox
    4747
    4848        if custom:
    49             self._check = gtk.CheckButton()
     49            self._check = Gtk.CheckButton()
    5050            self._check.props.can_focus = False
    5151            self._check.props.tooltip_text = \
    5252                    _('Articles are ready to be published')
    5353            self._check.connect('toggled', self._check_toggled_cb)
    54             check_box = gtk.HBox()
     54            check_box = Gtk.HBox()
    5555            check_box.set_size_request(50, -1)
    56             check_box.pack_start(self._check, True, False)
    57             tool_item = gtk.ToolItem()
     56            check_box.pack_start(self._check, True, False, 0)
     57            tool_item = Gtk.ToolItem()
    5858            tool_item.add(check_box)
    5959            tool_item.show()
    6060            title.insert(tool_item, -1)
    6161        else:
    62             tool_item = gtk.ToolItem()
    63             tool_item.add(gtk.Label('  '))
     62            tool_item = Gtk.ToolItem()
     63            tool_item.add(Gtk.Label(label='  '))
    6464            tool_item.show()
    6565            title.insert(tool_item, -1)
    6666
    6767        # title caption
    6868
    69         caption_label = gtk.Label(name)
     69        caption_label = Gtk.Label(label=name)
    7070        caption_label.props.tooltip_text = tooltip
    71         caption_label.modify_fg(gtk.STATE_NORMAL, COLOR_WHITE.get_gdk_color())
    72         caption_box = gtk.HBox()
    73         caption_box.pack_start(caption_label, False)
    74         caption = gtk.EventBox()
     71        caption_label.modify_fg(Gtk.StateType.NORMAL, COLOR_WHITE.get_gdk_color())
     72        caption_box = Gtk.HBox()
     73        caption_box.pack_start(caption_label, False, False, 0)
     74        caption = Gtk.EventBox()
    7575        caption.add(caption_box)
    76         caption.modify_bg(gtk.STATE_NORMAL, COLOR_TOOLBAR_GREY.get_gdk_color())
     76        caption.modify_bg(Gtk.StateType.NORMAL, COLOR_TOOLBAR_GREY.get_gdk_color())
    7777
    78         tool_item = gtk.ToolItem()
     78        tool_item = Gtk.ToolItem()
    7979        tool_item.add(caption)
    8080        tool_item.show()
    81 
    8281        title.insert(tool_item, -1)
    8382
    84         separator = gtk.SeparatorToolItem()
     83        separator = Gtk.SeparatorToolItem()
    8584        separator.props.draw = False
    8685        separator.set_expand(True)
    8786        title.insert(separator, -1)
    class BookView(gtk.VBox): 
    118117
    119118        # tree
    120119
    121         self.store = gtk.ListStore(bool, str)
    122         self.tree = gtk.TreeView(self.store)
     120        self.store = Gtk.ListStore(bool, str)
     121        self.tree = Gtk.TreeView(self.store)
    123122        self.tree.props.headers_visible = False
    124123        self.tree.connect('cursor-changed', self._cursor_changed_cb)
    125124
    126         cell = gtk.CellRendererToggle()
     125        cell = Gtk.CellRendererToggle()
    127126        cell.connect('toggled', self._cell_toggled_cb)
    128127        cell.props.activatable = True
    129128
    130         column = self.tree.insert_column_with_attributes(0, '', cell, active=0)
    131         column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
     129        # FIXME: insert_column_with_attributes does not exist on pygobject
     130        # column = self.tree.insert_column_with_attributes(0, '', cell, active=0)
     131
     132        logging.debug('TODO: this is a workaround due '
     133                      'https://bugzilla.gnome.org/show_bug.cgi?id=679415')
     134
     135        column = Gtk.TreeViewColumn('Wiki', cell)
     136        column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
    132137        column.props.fixed_width = 50
    133138        column.props.visible = custom
    134139
    135         cell = gtk.CellRendererText()
     140        self.tree.insert_column(column, 0)
     141
     142        cell = Gtk.CellRendererText()
    136143        cell.connect('edited', self._cell_edited_cb)
    137144        cell.props.editable = True
    138         self.tree.insert_column_with_attributes(1, '', cell, text=1)
     145
     146        # FIXME: insert_column_with_attributes does not exist on pygobject
     147        # self.tree.insert_column_with_attributes(1, '', cell, text=1)
     148
     149        logging.debug('TODO: this is a workaround due '
     150                      'https://bugzilla.gnome.org/show_bug.cgi?id=679415')
     151
     152        column = Gtk.TreeViewColumn('Custom', cell, text=1)
     153        self.tree.insert_column(column, 1)
    139154
    140155        for i in self.book.index:
    141156            self.store.append((i['ready'], i['title']))
    142157
    143158        # scrolled tree
    144159
    145         tree_scroll = gtk.ScrolledWindow()
    146         tree_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     160        tree_scroll = Gtk.ScrolledWindow()
     161        tree_scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    147162        tree_scroll.add(self.tree)
    148163
    149         self.pack_start(title, False)
    150         self.pack_start(tree_scroll)
     164        self.pack_start(title, False, False, 0)
     165        self.pack_start(tree_scroll, True, True, 0)
    151166
    152167        if len(self.store):
    153168            self.tree.set_cursor(0, self.tree.get_column(1), False)
    class BookView(gtk.VBox): 
    170185            return find_name(list, prefix, uniq+1)
    171186
    172187        if self._changing:
    173             gobject.source_remove(self._changing)
     188            GObject.source_remove(self._changing)
    174189            self._changing = None
    175190
    176191        name = find_name(self.store, _('New article'), 0)
    class BookView(gtk.VBox): 
    183198        index, column = self.tree.get_cursor()
    184199        if not index:
    185200            return
    186         index = index[0]
    187201
    188         if self._changing:
    189             gobject.source_remove(self._changing)
    190             self._changing = None
     202        logging.debug('TODO: This is not working because of the port to Gtk3. '
     203                      'TreePath object does not support indexing')
    191204
    192         self.book.remove(self.store[index][TITLE])
    193         self.store.remove(self.tree.props.model.get_iter(index))
     205        # index = index[0]
    194206
    195         if len(self.store):
    196             if index >= len(self.store):
    197                 index -= 1
    198             self.tree.set_cursor(index, self.tree.get_column(1), False)
    199             self._update_check(self.store[index][PUBLISH])
     207        # if self._changing:
     208        #     GObject.source_remove(self._changing)
     209        #     self._changing = None
     210
     211        # self.book.remove(self.store[index][TITLE])
     212        # self.store.remove(self.tree.props.model.get_iter(index))
     213
     214        # if len(self.store):
     215        #     if index >= len(self.store):
     216        #         index -= 1
     217        #     self.tree.set_cursor(index, self.tree.get_column(1), False)
     218        #     self._update_check(self.store[index][PUBLISH])
    200219
    201220    def _swap_cb(self, widget, delta):
    202221        old_index, column = self.tree.get_cursor()
    203222        if not old_index:
    204223            return
    205224
    206         old_index = old_index[0]
    207         new_index = old_index + delta
     225        logging.debug('TODO: This is not working because of the port to Gtk3. '
     226                      'TreePath object does not support indexing')
     227
     228        # old_index = old_index[0]
     229        # new_index = old_index + delta
    208230
    209         if new_index < 0:
    210             new_index = len(self.store)-1
    211         elif new_index >= len(self.store):
    212             new_index = 0
     231        # if new_index < 0:
     232        #     new_index = len(self.store)-1
     233        # elif new_index >= len(self.store):
     234        #     new_index = 0
    213235
    214         self.book.index[old_index], self.book.index[new_index] = \
    215                 self.book.index[new_index], self.book.index[old_index]
    216         self.store.swap(self.tree.props.model.get_iter(old_index),
    217                 self.tree.props.model.get_iter(new_index))
     236        # self.book.index[old_index], self.book.index[new_index] = \
     237        #         self.book.index[new_index], self.book.index[old_index]
     238        # self.store.swap(self.tree.props.model.get_iter(old_index),
     239        #         self.tree.props.model.get_iter(new_index))
    218240
    219241    def _check_toggled_cb(self, widget):
    220242        for i, entry in enumerate(self.store):
    class BookView(gtk.VBox): 
    241263
    242264    def _cursor_changed_cb(self, widget):
    243265        if self._changing:
    244             gobject.source_remove(self._changing)
     266            GObject.source_remove(self._changing)
    245267
    246268        index, column = self.tree.get_cursor()
    247269
    248270        if index != None:
    249             self._changing = gobject.timeout_add(500, self._cursor_changed,
     271            self._changing = GObject.timeout_add(500, self._cursor_changed,
    250272                    index)
    251273
    252274    def _cursor_changed(self, index):
  • edit.py

    diff --git a/edit.py b/edit.py
    index d21a989..e48509e 100644
    a b  
    1212# along with this program; if not, write to the Free Software
    1313# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1414
    15 import gtk
     15from gi.repository import Gtk
     16from gi.repository import GObject
    1617from gettext import gettext as _
    1718
    18 from sugar.graphics.toolbutton import ToolButton
    19 from sugar.graphics.toggletoolbutton import ToggleToolButton
    20 from sugar.activity.activity import ActivityToolbox
     19from sugar3.graphics.toolbutton import ToolButton
     20from sugar3.graphics.toggletoolbutton import ToggleToolButton
    2121
    2222from infoslicer.widgets.Edit_Pane import Edit_Pane
    2323from infoslicer.widgets.Format_Pane import Format_Pane
    TABS = (Edit_Pane(), 
    2828        Image_Pane(),
    2929        Format_Pane())
    3030
    31 class View(gtk.Notebook):
     31class View(Gtk.Notebook):
    3232    def __init__(self):
    33         gtk.Notebook.__init__(self)
     33        GObject.GObject.__init__(self)
    3434        self.props.show_border = False
    3535        self.props.show_tabs = False
    3636
    3737        for i in TABS:
    38             self.append_page(i)
     38            self.append_page(i, None)
    3939            i.show()
    4040
    4141        self.connect('map', self._map_cb)
  • infoslicer/processing/Article.py

    diff --git a/infoslicer/processing/Article.py b/infoslicer/processing/Article.py
    index 157b3c8..b3311b0 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    22
    3 import pygtk
    4 pygtk.require('2.0')
    5 import gtk
     3from gi.repository import Gtk
     4from gi.repository import GdkPixbuf
     5
    66from random import Random
    77from Article_Data import *
    88from Section import *
    class Article: 
    3535    """
    3636    Created by Jonathan Mace
    3737
    38     The Article class maintains a concrete representation of the article, in the form of a gtk.TextBuffer
     38    The Article class maintains a concrete representation of the article, in the form of a Gtk.TextBuffer
    3939
    40     Positions within the text are represented by gtk.TextIter
     40    Positions within the text are represented by Gtk.TextIter
    4141
    4242    The class contains methods for inserting and deleting new sentences, paragraphs and sections.
    4343
    class Article: 
    5656        """
    5757        Create default text buffer and set to empty
    5858        """
    59         self.__buf = gtk.TextBuffer()
     59        self.__buf = Gtk.TextBuffer()
    6060        self.__buf.set_text("")
    6161        insertionpoint = self.__buf.get_end_iter()
    6262        insertionmark = self.__buf.create_mark(None, insertionpoint, False)       
    class Article: 
    149149            nextsection = self.__sections[i+1]
    150150           
    151151            if section.getStart().compare(nextsection.getStart()) == -1:
    152                 text = self.__buf.get_slice(section.getStart(), nextsection.getStart())
     152                text = self.__buf.get_slice(section.getStart(), nextsection.getStart(), True)
    153153                if len(text) > 2 and text[-2] != "\n":
    154154                    nextsection.paragraphs = section.paragraphs + nextsection.paragraphs
    155155                else:
    class Article: 
    468468       
    469469    def getBuffer(self):
    470470        """
    471         This method simply returns the gtk.TextBuffer being maintained by this instance of the Article class.
     471        This method simply returns the Gtk.TextBuffer being maintained by this instance of the Article class.
    472472        """
    473473        return self.__buf
    474474
    class Article: 
    638638        self.markmark = self.__buf.create_mark(None, lociter, True)
    639639        self.__buf.insert(lociter, " ")
    640640        lociter = self.__buf.get_iter_at_mark(self.markmark)       
    641         arrow = gtk.gdk.pixbuf_new_from_xpm_data(arrow_xpm)
    642         self.__buf.insert_pixbuf(lociter, arrow)
     641        # FIXME: I don't know what the arrow_xpm type should be
     642        # https://bugzilla.gnome.org/show_bug.cgi?id=651962
     643        # arrow = GdkPixbuf.Pixbuf.new_from_xpm_data(arrow_xpm)
     644        # self.__buf.insert_pixbuf(lociter, arrow)
    643645       
    644646       
    645647    def clearArrow(self):
  • infoslicer/processing/Paragraph.py

    diff --git a/infoslicer/processing/Paragraph.py b/infoslicer/processing/Paragraph.py
    index 7c743c7..563fd16 100644
    a b class RawParagraph: 
    152152    def mark(self):
    153153        markiter = self.getStart()
    154154        self.markmark = self.buf.create_mark(None, markiter, True)
    155         arrow = gtk.gdk.pixbuf_new_from_xpm_data(arrow_xpm)
     155        arrow = GdkPixbuf.Pixbuf.new_from_xpm_data(arrow_xpm)
    156156        self.buf.insert_pixbuf(markiter, arrow)
    157157       
    158158    def unmark(self):
    class RawParagraph: 
    165165        return self.sentences
    166166   
    167167    def getText(self):
    168         return self.buf.get_slice(self.getStart(), self.getEnd())
     168        return self.buf.get_slice(self.getStart(), self.getEnd(), True)
    169169   
    170170    def clean(self):
    171171        if len(self.sentences) > 1:
  • infoslicer/processing/Section.py

    diff --git a/infoslicer/processing/Section.py b/infoslicer/processing/Section.py
    index 30e3dad..bc5f847 100644
    a b class RawSection: 
    214214    def mark(self):
    215215        markiter = self.getStart()
    216216        self.markmark = self.buf.create_mark(None, markiter, True)
    217         arrow = gtk.gdk.pixbuf_new_from_xpm_data(arrow_xpm)
     217        arrow = GdkPixbuf.Pixbuf.new_from_xpm_data(arrow_xpm)
    218218        self.buf.insert_pixbuf(markiter, arrow)
    219219       
    220220    def unmark(self):
    class RawSection: 
    260260            nextparagraph = self.paragraphs[i+1]
    261261           
    262262            if paragraph.getStart().compare(nextparagraph.getStart()) == -1:
    263                 text = self.buf.get_slice(paragraph.getStart(), nextparagraph.getStart())
     263                text = self.buf.get_slice(paragraph.getStart(), nextparagraph.getStart(), True)
    264264                if len(text) > 0 and text[-1] != "\n":
    265265                    logger.debug("concatenating paragraphs")
    266266                    nextparagraph.sentences = paragraph.sentences + nextparagraph.sentences
  • infoslicer/processing/Sentence.py

    diff --git a/infoslicer/processing/Sentence.py b/infoslicer/processing/Sentence.py
    index 09c31f4..1903a9c 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    22
    3 import pygtk
    4 pygtk.require('2.0')
     3import gi
     4gi.require_version('Gtk', '3.0')
    55import os
    6 import gtk
     6from gi.repository import Gtk
    77import logging
    88
    99from Article_Data import *
    class RawSentence: 
    8383        return data
    8484   
    8585    def getText(self):
    86         return self.buf.get_slice(self.getStart(), self.getEnd())
     86        return self.buf.get_slice(self.getStart(), self.getEnd(), True)
    8787   
    8888    def checkIntegrity(self, nextiter):
    89         text = unicode(self.buf.get_slice(self.getStart(), nextiter))
     89        text = unicode(self.buf.get_slice(self.getStart(), nextiter, True))
    9090        lines = text.splitlines(True)
    9191        sentencestartoffset = self.getStart().get_offset()
    9292        sentences = []
    class Picture( RawSentence ): 
    159159        leftmark = buf.create_mark(None, insertioniter, False)
    160160       
    161161        if os.path.isfile(picture_data.text):
    162             pixbuf = gtk.gdk.pixbuf_new_from_file(picture_data.text)
     162            pixbuf = GdkPixbuf.Pixbuf.new_from_file(picture_data.text)
    163163            buf.insert_pixbuf(insertioniter, pixbuf)
    164164        else:
    165165            logger.warning('cannot open image %s' % picture_data.text)
  • infoslicer/widgets/Edit_Pane.py

    diff --git a/infoslicer/widgets/Edit_Pane.py b/infoslicer/widgets/Edit_Pane.py
    index 8da2ad9..d7ab056 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
     5from gi.repository import Gdk
     6from gi.repository import GObject
    57import logging
    68from gettext import gettext as _
    79
    8 from sugar.graphics.toolcombobox import ToolComboBox
     10from sugar3.graphics.toolcombobox import ToolComboBox
    911
    1012from Reading_View import Reading_View
    1113from Editing_View import Editing_View
    from infoslicer.processing.Article import Article 
    1315
    1416logger = logging.getLogger('infoslicer')
    1517
    16 class Edit_Pane(gtk.HBox):
     18class Edit_Pane(Gtk.HBox):
    1719    """
    1820    Created by Jonathan Mace
    1921   
    class Edit_Pane(gtk.HBox): 
    3032    """
    3133   
    3234    def __init__(self):
    33         gtk.HBox.__init__(self)
     35        GObject.GObject.__init__(self)
    3436        self.toolitems = []
    3537
    36         readarticle_box = gtk.VBox()
     38        readarticle_box = Gtk.VBox()
    3739        readarticle_box.show()
    3840
    39         labeleb = gtk.EventBox()
    40         labeleb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#EEEEEE"))
     41        labeleb = Gtk.EventBox()
     42        labeleb.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#EEEEEE"))
    4143        readarticle_box.pack_start(labeleb, False, False, 0)
    4244        labeleb.show()
    4345       
    44         self.articletitle = gtk.Label()
    45         self.articletitle.set_justify(gtk.JUSTIFY_CENTER)
     46        self.articletitle = Gtk.Label()
     47        self.articletitle.set_justify(Gtk.Justification.CENTER)
    4648        labeleb.add(self.articletitle)
    4749        self.articletitle.show()
    4850
    49         vbox = gtk.VBox()
     51        vbox = Gtk.VBox()
    5052
    5153        snap = ToolComboBox(label_text=_('Snap selection to:'))
    5254        snap.combo.append_item(0, _("Nothing"))
    class Edit_Pane(gtk.HBox): 
    5456        snap.combo.append_item(2, _("Paragraphs"))
    5557        snap.combo.append_item(3, _("Sections"))
    5658        snap.combo.set_active(1)
    57         vbox.pack_start(snap, False)
     59        vbox.pack_start(snap, False, False, 0)
    5860
    5961        """
    6062        Create reading and editing panels
    6163        """
    6264        self.readarticle = Reading_View() 
    63         self.readarticle.set_size_request(gtk.gdk.screen_width()/2, -1)
     65        self.readarticle.set_size_request(Gdk.Screen.width()/2, -1)
    6466        self.readarticle.show()
    65         readarticle_box.pack_start(self.readarticle)
    66         vbox.pack_start(readarticle_box)
     67        readarticle_box.pack_start(self.readarticle, True, True, 0)
     68        vbox.pack_start(readarticle_box, True, True, 0)
    6769
    68         self.pack_start(vbox, False)
     70        self.pack_start(vbox, False, False, 0)
    6971
    7072        self.editarticle = Editing_View()
    71         self.pack_start(self.editarticle)
     73        self.pack_start(self.editarticle, True, True, 0)
    7274        self.editarticle.show()
    7375
    7476        snap.combo.connect("changed", self.selection_mode_changed, None)
  • infoslicer/widgets/Editable_Textbox.py

    diff --git a/infoslicer/widgets/Editable_Textbox.py b/infoslicer/widgets/Editable_Textbox.py
    index fd8711f..b5efd68 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
     5from gi.repository import Gdk
     6from gi.repository import GObject
     7from gi.repository import Pango
    58import cPickle
    6 import pango
    79import copy
    810from Textbox import Textbox
    911
     12import logging
     13
    1014SNAP_SENTENCE, SNAP_PARAGRAPH, SNAP_SECTION, SNAP_NONE = range(4)
    1115
    1216class Editable_Textbox( Textbox ):
    class Editable_Textbox( Textbox ): 
    1822    """
    1923   
    2024    def __init__(self):
    21         gtk.TextView.__init__(self)
     25        GObject.GObject.__init__(self)
    2226        self.set_border_width(1)
    2327        self.set_cursor_visible(True)
    2428        self.set_editable(True) 
    25         self.set_wrap_mode(gtk.WRAP_WORD)
     29        self.set_wrap_mode(Gtk.WrapMode.WORD)
    2630        self.article = None
    2731        self.set_mode(SNAP_SENTENCE)
    2832        self.changed = False
    class Editable_Textbox( Textbox ): 
    3034       
    3135        self.selecting = False
    3236        self.handlers = []
    33         self.modify_font(pango.FontDescription('arial 9'))
     37        self.modify_font(Pango.FontDescription('arial 9'))
    3438        self.ignore_snap_self = True
    3539        self.drag_source = False
    3640        self.edited = False
    3741        self.set_property("left-margin", 5)
    3842
     43        logging.debug('########### Editable_Textbox.drag_dest_set')
     44        self.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY)
     45
    3946    def set_article(self, article):
    4047        self.article = article
    4148        self.set_buffer(article.getBuffer())
    class Editable_Textbox( Textbox ): 
    4754        self.article.delete()
    4855       
    4956    def get_mouse_iter(self, x, y):
    50         click_coords = self.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y)
     57        click_coords = self.window_to_buffer_coords(Gtk.TextWindowType.TEXT, x, y)
    5158        mouseClickPositionIter = self.get_iter_at_location(click_coords[0], click_coords[1])
    5259        return mouseClickPositionIter
    5360   
    class Editable_Textbox( Textbox ): 
    5966            self.disconnect(handler)
    6067       
    6168        buffer.connect("changed", self.text_changed, None)
    62         gtk.TextView.set_buffer(self, buffer)
     69        Gtk.TextView.set_buffer(self, buffer)
    6370       
    6471        self.handlers = []
    6572       
    class Editable_Textbox( Textbox ): 
    143150                self.block = True
    144151       
    145152    def clicked_event(self, widget, event, data):
    146         if event.type == gtk.gdk._2BUTTON_PRESS or event.type == gtk.gdk._3BUTTON_PRESS:
     153        if event.type == Gdk.EventType._2BUTTON_PRESS or event.type == Gdk.EventType._3BUTTON_PRESS:
    147154            self.stop_emission("button_press_event")
    148155            return
    149156        if event.button == 3:
    class Editable_Textbox( Textbox ): 
    202209            return False
    203210       
    204211    def drag_begin_event(self, widget, context, data):
     212        logging.debug('############ Editable_Textbox.drag_begin_event')
    205213        self.grab_focus()
    206214        if self.snapto != SNAP_NONE:
    207215            a = self.article
    class Editable_Textbox( Textbox ): 
    256264            self.changed = False
    257265       
    258266    def drag_data_received_event(self, widget, context, x, y, selection_data, info, time, data):
     267        logging.debug('################ Editable_Textbox.drag_data_received_event')
    259268        if self.snapto != SNAP_NONE and not self.ignore_snap_self or (not self.drag_source and self.ignore_snap_self):   
    260269            a = self.article
    261270            insert_loc = self.get_mouse_iter(x, y)
    262             data_received_type = str(selection_data.type)   
    263             data = cPickle.loads(str(selection_data.data))
     271            data_received_type = str(selection_data.get_data_type())   
     272            data = cPickle.loads(str(selection_data.get_data()))
    264273           
    265274            if data_received_type == "sentence":
    266275                bestpoint = insert_loc 
    class Editable_Textbox( Textbox ): 
    276285            self.grab_focus()
    277286       
    278287    def drag_data_get_event(self, widget, context, selection_data, info, time, data):
     288        logging.debug('############### Editable_Textbox.drag_data_get_event')
    279289        if not self.ignore_snap_self and self.snapto != SNAP_NONE:
    280290            a = self.article
    281291           
    282292            if self.snapto == SNAP_SENTENCE:
    283                 atom = gtk.gdk.atom_intern("sentence")
     293                atom = Gdk.atom_intern("sentence", only_if_exists=False)
    284294            if self.snapto == SNAP_PARAGRAPH:
    285                 atom = gtk.gdk.atom_intern("paragraph")
     295                atom = Gdk.atom_intern("paragraph", only_if_exists=False)
    286296            if self.snapto == SNAP_SECTION:
    287                 atom = gtk.gdk.atom_intern("section")
     297                atom = Gdk.atom_intern("section", only_if_exists=False)
    288298               
    289299            string = cPickle.dumps(a.getSelection())
    290300            selection_data.set(atom, 8, string)
  • infoslicer/widgets/Editing_View.py

    diff --git a/infoslicer/widgets/Editing_View.py b/infoslicer/widgets/Editing_View.py
    index 5506a7f..3f9ecdc 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
     5from gi.repository import Gdk
     6from gi.repository import GObject
    57from Editable_Textbox import Editable_Textbox
    68
    7 class Editing_View( gtk.VBox ):
     9class Editing_View( Gtk.VBox ):
    810    """
    911    Created by Jonathan Mace
    1012    This class wraps an editable textbox into a scrollable window and
    1113    gives it a title.
    1214    """
    1315    def __init__(self):
    14         gtk.VBox.__init__(self)
     16        GObject.GObject.__init__(self)
    1517        self.set_border_width(0)
    1618        self.set_spacing(2)
    1719       
    18         labeleb = gtk.EventBox()
    19         labeleb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#EEEEEE"))
     20        labeleb = Gtk.EventBox()
     21        labeleb.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#EEEEEE"))
    2022        self.pack_start(labeleb, False, False, 0)
    2123        labeleb.show()
    2224       
    23         self.articletitle = gtk.Label()
    24         self.articletitle.set_justify(gtk.JUSTIFY_CENTER)
     25        self.articletitle = Gtk.Label()
     26        self.articletitle.set_justify(Gtk.Justification.CENTER)
    2527        labeleb.add(self.articletitle)
    2628        self.articletitle.show()
    2729       
    28         self.textwindow = gtk.ScrolledWindow()
    29         self.textwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
    30         self.pack_start(self.textwindow)
     30        self.textwindow = Gtk.ScrolledWindow()
     31        self.textwindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
     32        self.pack_start(self.textwindow, True, True, 0)
    3133        self.textwindow.show()
    3234       
    3335        self.textbox = Editable_Textbox()
  • infoslicer/widgets/Format_Pane.py

    diff --git a/infoslicer/widgets/Format_Pane.py b/infoslicer/widgets/Format_Pane.py
    index ef8c2f5..1be64f2 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
    55from gettext import gettext as _
    66
    77from Editing_View import Editing_View
    class Format_Pane(Editing_View): 
    2222        self.toolitems = []
    2323       
    2424        """
    25         self.combocontainer = gtk.ToolItem()
     25        self.combocontainer = Gtk.ToolItem()
    2626        self.combocontainer.add(self.combobox)
    2727        self.toolbar.insert(self.combocontainer, -1)
    2828        self.combocontainer.show()
    2929       
    30         self.boldbutton = gtk.ToolButton(gtk.STOCK_BOLD)
     30        self.boldbutton = Gtk.ToolButton(Gtk.STOCK_BOLD)
    3131        self.boldbutton.set_expand(False)
    3232        self.toolbar.insert(self.boldbutton, -1)
    3333        self.boldbutton.show()
    3434       
    35         self.italicbutton = gtk.ToolButton(gtk.STOCK_ITALIC)
     35        self.italicbutton = Gtk.ToolButton(Gtk.STOCK_ITALIC)
    3636        self.italicbutton.set_expand(False)
    3737        self.toolbar.insert(self.italicbutton, -1)
    3838        self.italicbutton.show()
    3939       
    40         self.underlinebutton = gtk.ToolButton(gtk.STOCK_UNDERLINE)
     40        self.underlinebutton = Gtk.ToolButton(Gtk.STOCK_UNDERLINE)
    4141        self.underlinebutton.set_expand(False)
    4242        self.toolbar.insert(self.underlinebutton, -1)
    4343        self.underlinebutton.show()
  • infoslicer/widgets/Gallery_View.py

    diff --git a/infoslicer/widgets/Gallery_View.py b/infoslicer/widgets/Gallery_View.py
    index 4464088..7cc59b9 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2from gi.repository import Gtk
     3from gi.repository import Gdk
     4from gi.repository import GObject
     5from gi.repository import GdkPixbuf
    56import os
    67import cPickle
    78import logging
    import book 
    1314
    1415logger = logging.getLogger('infoslicer')
    1516
    16 class Gallery_View( gtk.HBox ):
     17class Gallery_View( Gtk.HBox ):
    1718    """
    1819    Created by Christopher Leonard
    1920    Drag-and-drop methods added by Jonathan Mace
    class Gallery_View( gtk.HBox ): 
    3334   
    3435    def __init__(self):
    3536        self.image_list = []
    36         gtk.HBox.__init__(self)
     37        GObject.GObject.__init__(self)
    3738       
    3839        self.current_index = -1
    3940       
    40         left_button = gtk.Button(label="\n\n << \n\n")
     41        left_button = Gtk.Button(label="\n\n << \n\n")
    4142       
    42         right_button = gtk.Button(label="\n\n >> \n\n")
     43        right_button = Gtk.Button(label="\n\n >> \n\n")
    4344       
    44         self.imagenumberlabel = gtk.Label()
     45        self.imagenumberlabel = Gtk.Label()
    4546       
    46         self.image = gtk.Image()
     47        self.image = Gtk.Image()
    4748       
    48         self.imagebox = gtk.EventBox()
     49        self.imagebox = Gtk.EventBox()
    4950        self.imagebox.add(self.image)
    5051       
    51         self.imagebox.drag_source_set(gtk.gdk.BUTTON1_MASK, [("text/plain", gtk.TARGET_SAME_APP, 80)], gtk.gdk.ACTION_COPY)
     52        self.imagebox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
     53                                      [],
     54                                      Gdk.DragAction.COPY)
     55        self.imagebox.drag_source_add_image_targets()
    5256        self.imagebox.connect("drag-begin", self.drag_begin_event, None)
    5357        self.imagebox.connect("drag-data-get", self.drag_data_get_event, None)
    5458       
    55         self.caption = gtk.Label("")
     59        self.caption = Gtk.Label(label="")
    5660        self.caption.set_line_wrap(True)
    5761       
    58         self.image_drag_container = gtk.VBox()
    59         self.image_drag_container.pack_start(self.imagenumberlabel, expand = False)
    60         self.image_drag_container.pack_start(self.imagebox, expand=False)
    61         self.image_drag_container.pack_start(self.caption, expand=False)
    62        
    63         image_container = gtk.VBox()
    64         image_container.pack_start(gtk.Label(" "))
    65         image_container.pack_start(self.image_drag_container, expand=False)
    66         image_container.pack_start(gtk.Label(" "))
    67        
    68         left_button_container = gtk.VBox()
    69         left_button_container.pack_start(gtk.Label(" "))
    70         left_button_container.pack_start(left_button, expand=False)
    71         left_button_container.pack_start(gtk.Label(" "))
    72        
    73         right_button_container = gtk.VBox()
    74         right_button_container.pack_start(gtk.Label(" "))
    75         right_button_container.pack_start(right_button, expand=False)
    76         right_button_container.pack_start(gtk.Label(" "))
     62        self.image_drag_container = Gtk.VBox()
     63        self.image_drag_container.pack_start(self.imagenumberlabel, expand=False,
     64                                             fill=False, padding=0)
     65        self.image_drag_container.pack_start(self.imagebox, False, True, 0)
     66        self.image_drag_container.pack_start(self.caption, False, True, 0)
     67       
     68        image_container = Gtk.VBox()
     69        image_container.pack_start(Gtk.Label(" "), True, True, 0)
     70        image_container.pack_start(self.image_drag_container, False, True, 0)
     71        image_container.pack_start(Gtk.Label(" "), True, True, 0)
     72       
     73        left_button_container = Gtk.VBox()
     74        left_button_container.pack_start(Gtk.Label(" "), True, True, 0)
     75        left_button_container.pack_start(left_button, False, True, 0)
     76        left_button_container.pack_start(Gtk.Label(" "), True, True, 0)
     77       
     78        right_button_container = Gtk.VBox()
     79        right_button_container.pack_start(Gtk.Label(" "), True, True, 0)
     80        right_button_container.pack_start(right_button, False, True, 0)
     81        right_button_container.pack_start(Gtk.Label(" "), True, True, 0)
    7782
    7883       
    79         self.pack_start(left_button_container, expand=False)
    80         self.pack_start(image_container)
    81         self.pack_start(right_button_container, expand=False)
     84        self.pack_start(left_button_container, False, True, 0)
     85        self.pack_start(image_container, True, True, 0)
     86        self.pack_start(right_button_container, False, True, 0)
    8287   
    8388        self._source_article = None
    8489        self.show_all()
    class Gallery_View( gtk.HBox ): 
    99104        self.current_index += 1
    100105        if self.current_index == len(self.image_list):
    101106            self.current_index = 0
    102         self.imagebuf = gtk.gdk.pixbuf_new_from_file(self.image_list[self.current_index][0])
     107        self.imagebuf = GdkPixbuf.Pixbuf.new_from_file(self.image_list[self.current_index][0])
    103108        self.image.set_from_pixbuf(self.imagebuf)
    104109        self.caption.set_text("\n" + self.image_list[self.current_index][1])
    105110        self.imagenumberlabel.set_text("(%d / %d)\n" % (self.current_index+1, len(self.image_list)))   
    class Gallery_View( gtk.HBox ): 
    115120        if self.current_index == 0:
    116121            self.current_index = len(self.image_list)
    117122        self.current_index -= 1
    118         self.imagebuf = gtk.gdk.pixbuf_new_from_file(self.image_list[self.current_index][0])
     123        self.imagebuf = GdkPixbuf.Pixbuf.new_from_file(self.image_list[self.current_index][0])
    119124        self.image.set_from_pixbuf(self.imagebuf)
    120125        self.caption.set_text("\n" + self.image_list[self.current_index][1])
    121126        self.imagenumberlabel.set_text("(%d / %d)\n" % (self.current_index+1, len(self.image_list)))   
    class Gallery_View( gtk.HBox ): 
    129134            self.image.clear()
    130135            return       
    131136        self.current_index = 0
    132         self.imagebuf = gtk.gdk.pixbuf_new_from_file(self.image_list[self.current_index][0])
     137        self.imagebuf = GdkPixbuf.Pixbuf.new_from_file(self.image_list[self.current_index][0])
    133138        self.image.set_from_pixbuf(self.imagebuf)
    134139        self.caption.set_text("\n" + self.image_list[self.current_index][1])   
    135140        logger.debug("setting text to:")
    class Gallery_View( gtk.HBox ): 
    143148        logger.debug(self.image_list)
    144149       
    145150    def drag_begin_event(self, widget, context, data):
     151        logging.debug('########### Gallery_View.drag_begin_event called')
    146152        self.imagebox.drag_source_set_icon_pixbuf(self.imagebuf)
    147153       
    148154    def drag_data_get_event(self, widget, context, selection_data, info, timestamp, data):
    149         logger.debug("getting data")
    150         atom = gtk.gdk.atom_intern("section")
     155        logger.debug('############# Gallery_View.drag_data_get_event')
     156        atom = Gdk.atom_intern("section", only_if_exists=False)
    151157        imagedata = Picture_Data(self.source_article_id,
    152158                self.image_list[self.current_index][0],
    153159                self.image_list[self.current_index][2])
  • infoslicer/widgets/Image_Pane.py

    diff --git a/infoslicer/widgets/Image_Pane.py b/infoslicer/widgets/Image_Pane.py
    index 99026f0..473253c 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
     5from gi.repository import Gdk
     6from gi.repository import GObject
    57import logging
    68from gettext import gettext as _
    79
    from infoslicer.processing.Article import Article 
    1113
    1214logger = logging.getLogger('infoslicer')
    1315
    14 class Image_Pane(gtk.HBox):
     16class Image_Pane(Gtk.HBox):
    1517    """
    1618    Created by Christopher Leonard
    1719   
    class Image_Pane(gtk.HBox): 
    2325    """
    2426   
    2527    def __init__(self):
    26         gtk.HBox.__init__(self)
     28        GObject.GObject.__init__(self)
    2729        self.toolitems = []
    2830       
    29         gallery_box = gtk.VBox()
     31        gallery_box = Gtk.VBox()
    3032        gallery_box.show()
    3133
    32         labeleb = gtk.EventBox()
    33         labeleb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#EEEEEE"))
     34        labeleb = Gtk.EventBox()
     35        labeleb.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#EEEEEE"))
    3436        gallery_box.pack_start(labeleb, False, False, 0)
    3537        labeleb.show()
    3638       
    37         self.articletitle = gtk.Label()
    38         self.articletitle.set_justify(gtk.JUSTIFY_CENTER)
     39        self.articletitle = Gtk.Label()
     40        self.articletitle.set_justify(Gtk.Justification.CENTER)
    3941        labeleb.add(self.articletitle)
    4042        self.articletitle.show()
    4143       
    4244        self.gallery = Gallery_View()
    43         self.gallery.set_size_request(gtk.gdk.screen_width()/2, -1)
    44         gallery_box.pack_start(self.gallery)
     45        self.gallery.set_size_request(Gdk.Screen.width()/2, -1)
     46        gallery_box.pack_start(self.gallery, True, True, 0)
    4547
    46         self.pack_start(gallery_box, False)
     48        self.pack_start(gallery_box, False, False, 0)
    4749        self.editarticle = Editing_View()
    48         self.pack_start(self.editarticle)
     50        self.pack_start(self.editarticle, True, True, 0)
    4951        self.editarticle.show_all()
    5052
    5153        self.gallery._source_article = None
  • infoslicer/widgets/Reading_View.py

    diff --git a/infoslicer/widgets/Reading_View.py b/infoslicer/widgets/Reading_View.py
    index 55609c9..3c40757 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
     5from gi.repository import GObject
    56from Readonly_Textbox import Readonly_Textbox
    67import logging
    78
    89logger = logging.getLogger('infoslicer')
    910elogger = logging.getLogger('infoslicer::except')
    1011
    11 class Reading_View( gtk.VBox ):
     12class Reading_View( Gtk.VBox ):
    1213    """
    1314    Created by Jonathan Mace
    1415   
    class Reading_View( gtk.VBox ): 
    2122    """
    2223     
    2324    def __init__(self):
    24         gtk.VBox.__init__(self)
     25        GObject.GObject.__init__(self)
    2526       
    26         self.articlewindow = gtk.ScrolledWindow()
    27         self.articlewindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
    28         self.pack_start(self.articlewindow)
     27        self.articlewindow = Gtk.ScrolledWindow()
     28        self.articlewindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
     29        self.pack_start(self.articlewindow, True, True, 0)
    2930        self.articlewindow.show()
    3031       
    3132        self.textbox = Readonly_Textbox()
  • infoslicer/widgets/Readonly_Textbox.py

    diff --git a/infoslicer/widgets/Readonly_Textbox.py b/infoslicer/widgets/Readonly_Textbox.py
    index 958cfcd..638cf77 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
    5 import pango
     2from gi.repository import Gtk
     3from gi.repository import Gdk
     4from gi.repository import Pango
    65import cPickle
     6import logging
    77from Textbox import Textbox
    88
    99SELECT_SENTENCE, SELECT_PARAGRAPH, SELECT_SECTION, FULL_EDIT = range(4)
    class Readonly_Textbox( Textbox ): 
    2424        self.use_as_drag_source = use_as_drag_source
    2525        self.set_mode(SELECT_SENTENCE)
    2626        self.block = True
    27         self.modify_font(pango.FontDescription('arial 9'))
     27        self.modify_font(Pango.FontDescription('arial 9'))
    2828       
    2929   
    3030    def set_mode(self, mode):
    class Readonly_Textbox( Textbox ): 
    4545        self.event_handlers.append(self.connect("drag-motion", self.drag_motion, None))
    4646       
    4747    def drag_motion(self, widget, context, x, y, timestamp, data):
    48         context.drag_status(gtk.gdk.ACTION_COPY, timestamp)
     48        logging.debug('############ Readonly_Textbox.drag_motion')
     49        Gdk.drag_status(context, Gdk.DragAction.COPY, timestamp)
    4950        return True
    5051       
    5152    def clicked_event(self, widget, event, data):
    52         if event.type == gtk.gdk._2BUTTON_PRESS or event.type == gtk.gdk._3BUTTON_PRESS:
     53        if event.type == Gdk.EventType._2BUTTON_PRESS or event.type == Gdk.EventType._3BUTTON_PRESS:
    5354            self.stop_emission("button_press_event")
    5455            return
    5556        if event.button == 3:
    class Readonly_Textbox( Textbox ): 
    114115            if self.block == True:
    115116                self.stop_emission("motion-notify-event")
    116117                self.block = False
    117                 self.emit("motion-notify-event", event)
     118                logging.debug('FIXME: this is a workaround due '
     119                              'https://bugzilla.gnome.org/show_bug.cgi?id=679795')
     120                # I was getting this error:
     121                #   TypeError: could not convert type EventMotion
     122                #   to GdkEvent required for parameter 0
     123                # self.emit("motion-notify-event", event)
     124                self.emit("motion-notify-event", Gdk.Event())
    118125               
    119126                buf = self.get_buffer()           
    120127                mouseiter = self.get_mouse_iter(int(event.x), int(event.y))
    class Readonly_Textbox( Textbox ): 
    139146                    if self.selectionmode == SELECT_SECTION:
    140147                        selectionstart = article.getSection(mouseiter).getStart()
    141148                        selectionend = article.getSection(self.selectionstart).getEnd()
    142                 self.scroll_to_iter(mouseiter, 0)
     149                self.scroll_to_iter(mouseiter, 0, False, 0.5, 0.5)
    143150                article.highlight(selectionstart, selectionend)               
    144151                   
    145152            else:
    class Readonly_Textbox( Textbox ): 
    152159        self.stop_emission("button-release-event")
    153160       
    154161    def drag_data_get_event(self, widget, context, selection_data, info, time, data):
    155        
     162        logging.debug('######## Readonly_Textbox.drag_data_get_event')
    156163        a = self.article
    157164       
    158165        if self.selectionmode == SELECT_SENTENCE:
    159             atom = gtk.gdk.atom_intern("sentence")
     166            atom = Gdk.atom_intern("sentence", only_if_exists=False)
    160167        if self.selectionmode == SELECT_PARAGRAPH:
    161             atom = gtk.gdk.atom_intern("paragraph")
     168            atom = Gdk.atom_intern("paragraph", only_if_exists=False)
    162169        if self.selectionmode == SELECT_SECTION:
    163             atom = gtk.gdk.atom_intern("section")
     170            atom = Gdk.atom_intern("section", only_if_exists=False)
    164171           
    165172        string = cPickle.dumps(a.getSelection())
    166173        selection_data.set(atom, 8, string)
  • infoslicer/widgets/Textbox.py

    diff --git a/infoslicer/widgets/Textbox.py b/infoslicer/widgets/Textbox.py
    index 95f0681..634f967 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
     5from gi.repository import GObject
     6from gi.repository import Pango
    57import cPickle
    68import pango
    79
    810SELECT_SENTENCE, SELECT_PARAGRAPH, SELECT_SECTION, FULL_EDIT = range(4)
    911
    10 class Textbox( gtk.TextView ):
     12class Textbox( Gtk.TextView ):
    1113    """
    1214    Created by Jonathan Mace
    1315    The Textbox class is the base class for our own custom textboxes which implement
    class Textbox( gtk.TextView ): 
    1921   
    2022   
    2123    def __init__(self):
    22         gtk.TextView.__init__(self)
     24        GObject.GObject.__init__(self)
    2325        self.set_border_width(1)
    2426        self.event_handlers = []
    25         self.set_wrap_mode(gtk.WRAP_WORD)
     27        self.set_wrap_mode(Gtk.WrapMode.WORD)
    2628        self.set_cursor_visible(False)
    2729        self.set_editable(False) 
    28         self.modify_font(pango.FontDescription('arial 9'))
     30        self.modify_font(Pango.FontDescription('arial 9'))
    2931        self.article = None
    3032        self.set_property("left-margin", 5)
    3133       
    class Textbox( gtk.TextView ): 
    3739        return self.article
    3840       
    3941    def show(self):
    40         gtk.TextView.show(self) 
     42        Gtk.TextView.show(self) 
    4143       
    4244    def clear(self):
    4345        self.article.delete()     
    class Textbox( gtk.TextView ): 
    5153       
    5254    def get_mouse_iter(self, x, y):
    5355        # Convenience method to get the iter in the buffer of x, y coords.
    54         click_coords = self.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y)
     56        click_coords = self.window_to_buffer_coords(Gtk.TextWindowType.TEXT, x, y)
    5557        mouseClickPositionIter = self.get_iter_at_location(click_coords[0], click_coords[1])
    56         return mouseClickPositionIter
    57  No newline at end of file
     58        return mouseClickPositionIter
  • library.py

    diff --git a/library.py b/library.py
    index 325ed49..3087072 100644
    a b  
    1212# along with this program; if not, write to the Free Software
    1313# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1414
    15 import gtk
     15from gi.repository import Gtk
     16from gi.repository import Gdk
     17from gi.repository import GObject
    1618import logging
    1719from threading import Timer
    1820from datetime import datetime
    1921from gettext import gettext as _
    2022import locale
    2123
    22 from sugar.graphics.toolbutton import ToolButton
    23 from sugar.graphics.toggletoolbutton import ToggleToolButton
    24 from sugar.activity.activity import ActivityToolbox
    25 from sugar.graphics.toolcombobox import ToolComboBox
    26 from sugar.graphics.icon import Icon
    27 from sugar.datastore import datastore
    28 import sugar.graphics.style as style
     24from sugar3.graphics.toolbutton import ToolButton
     25from sugar3.graphics.toggletoolbutton import ToggleToolButton
     26from sugar3.graphics.toolcombobox import ToolComboBox
     27from sugar3.graphics.icon import Icon
     28from sugar3.datastore import datastore
     29from sugar3.graphics.alert import Alert
     30import sugar3.graphics.style as style
    2931
    3032import xol
    3133import net
    from infoslicer.widgets.Reading_View import Reading_View 
    3537
    3638logger = logging.getLogger('infoslicer')
    3739
    38 class View(gtk.EventBox):
     40class View(Gtk.EventBox):
    3941    def sync(self):
    4042        self.wiki.sync()
    4143        self.custom.sync()
    4244
    4345    def __init__(self, activity):
    44         gtk.EventBox.__init__(self)
     46        GObject.GObject.__init__(self)
    4547        self.activity = activity
    4648
    4749        self.wiki = BookView(book.wiki,
    class View(gtk.EventBox): 
    5254        # stubs for empty articles
    5355
    5456        def create_stub(icon_name, head_text, tail_text):
    55             head_label = gtk.Label(head_text)
    56             head_label_a = gtk.Alignment(0.5, 1, 0, 0)
     57            head_label = Gtk.Label(label=head_text)
     58            head_label_a = Gtk.Alignment.new(0.5, 1, 0, 0)
    5759            head_label_a.add(head_label)
    5860            icon = Icon(icon_name=icon_name,
    59                     icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
    60             tail_label = gtk.Label(tail_text)
    61             tail_label_a = gtk.Alignment(0.5, 0, 0, 0)
     61                    icon_size=Gtk.IconSize.LARGE_TOOLBAR)
     62            tail_label = Gtk.Label(label=tail_text)
     63            tail_label_a = Gtk.Alignment.new(0.5, 0, 0, 0)
    6264            tail_label_a.add(tail_label)
    63             stub = gtk.VBox()
    64             stub.pack_start(head_label_a)
    65             stub.pack_start(icon, False)
    66             stub.pack_start(tail_label_a)
     65            stub = Gtk.VBox()
     66            stub.pack_start(head_label_a, True, True, 0)
     67            stub.pack_start(icon, False, False, 0)
     68            stub.pack_start(tail_label_a, True, True, 0)
    6769            return stub
    6870
    6971        wiki_stub = create_stub('white-search',
    class View(gtk.EventBox): 
    7880        wiki_prefix = lang_code[0:2] + '.'
    7981        language_order = 0
    8082        order = 0
    81         search_box = gtk.HBox()
     83        search_box = Gtk.HBox()
    8284        self.wikimenu = ToolComboBox(label_text=_('Get article from:'))
    8385        for i in sorted(WIKI.keys()):
    8486            self.wikimenu.combo.append_item(WIKI[i], i)
    class View(gtk.EventBox): 
    8688                language_order = order
    8789            order = order + 1
    8890        self.wikimenu.combo.set_active(language_order)
    89         search_box.pack_start(self.wikimenu, False)
     91        search_box.pack_start(self.wikimenu, False, False, 0)
    9092
    91         self.searchentry = gtk.Entry()
    92         self.searchentry.set_size_request(int(gtk.gdk.screen_width() / 4), -1)
     93        self.searchentry = Gtk.Entry()
     94        self.searchentry.set_size_request(int(Gdk.Screen.width() / 4), -1)
    9395        self.searchentry.set_text(_("Article name"))
    9496        self.searchentry.select_region(0, -1)
    9597        self.searchentry.connect('activate', self._search_activate_cb)
    96         search_box.pack_start(self.searchentry)
     98        search_box.pack_start(self.searchentry, True, True, 0)
    9799        search_box.show_all()
    98100
    99         self.searchbutton = gtk.Button(label=_('Search'))
     101        self.searchbutton = Gtk.Button(label=_('Search'))
    100102        self.searchbutton.connect('clicked', self._search_clicked_cb)
    101         search_box.pack_start(self.searchbutton, False)
     103        search_box.pack_start(self.searchbutton, False, False, 0)
    102104
    103105        wiki_widget = Reading_View()
    104         wiki = gtk.Notebook()
     106        wiki = Gtk.Notebook()
    105107        wiki.props.show_border = False
    106108        wiki.props.show_tabs = False
    107         wiki.append_page(wiki_stub)
    108         wiki.append_page(wiki_widget)
     109        wiki.append_page(wiki_stub, None)
     110        wiki.append_page(wiki_widget, None)
    109111
    110         self.progress = gtk.Label()
     112        self.progress = Gtk.Label()
    111113        #self.progress.set_size_request(-1, style.SMALL_ICON_SIZE+4)
    112         #progress_box = gtk.HBox()
    113         #progress_box.pack_start(gtk.HSeparator(), False)
     114        #progress_box = Gtk.HBox()
     115        #progress_box.pack_start(Gtk.HSeparator(, True, True, 0), False)
    114116        #progress_box.pack_start(self.progress, False)
    115117
    116         wiki_box = gtk.VBox()
    117         wiki_box.pack_start(search_box, False)
    118         wiki_box.pack_start(wiki)
    119         wiki_box.pack_start(self.progress, False)
    120         wiki_box.set_size_request(gtk.gdk.screen_width()/4*3,
    121                 gtk.gdk.screen_height()/2 - style.GRID_CELL_SIZE / 2)
     118        wiki_box = Gtk.VBox()
     119        wiki_box.pack_start(search_box, False, False, 0)
     120        wiki_box.pack_start(wiki, True, True, 0)
     121        wiki_box.pack_start(self.progress, False, False, 0)
     122        wiki_box.set_size_request(Gdk.Screen.width()/4*3,
     123                Gdk.Screen.height()/2 - style.GRID_CELL_SIZE / 2)
    122124
    123125        custom_widget = Reading_View()
    124         custom = gtk.Notebook()
     126        custom = Gtk.Notebook()
    125127        custom.props.show_border = False
    126128        custom.props.show_tabs = False
    127         custom.append_page(custom_stub)
    128         custom.append_page(custom_widget)
    129         # custom.set_size_request(gtk.gdk.screen_width()/4*3,
    130         #         gtk.gdk.screen_height()/2 - 55)
    131         custom.set_size_request(gtk.gdk.screen_width()/4*3,
    132                 gtk.gdk.screen_height()/2 - style.GRID_CELL_SIZE / 2)
     129        custom.append_page(custom_stub, None)
     130        custom.append_page(custom_widget, None)
     131        # custom.set_size_request(Gdk.Screen.width()/4*3,
     132        #         Gdk.Screen.height()/2 - 55)
     133        custom.set_size_request(Gdk.Screen.width()/4*3,
     134                Gdk.Screen.height()/2 - style.GRID_CELL_SIZE / 2)
    133135
    134136        # workspace
    135137
    136         articles_box = gtk.HBox()
    137         articles_box.pack_start(self.wiki)
    138         articles_box.pack_start(gtk.VSeparator(), False)
    139         articles_box.pack_start(wiki_box, False)
     138        articles_box = Gtk.HBox()
     139        articles_box.pack_start(self.wiki, True, True, 0)
     140        articles_box.pack_start(Gtk.VSeparator(), False, False, 0)
     141        articles_box.pack_start(wiki_box, False, False, 0)
    140142
    141         custom_box = gtk.HBox()
    142         custom_box.pack_start(self.custom)
    143         custom_box.pack_start(gtk.VSeparator(), False)
    144         custom_box.pack_start(custom, False)
     143        custom_box = Gtk.HBox()
     144        custom_box.pack_start(self.custom, True, True, 0)
     145        custom_box.pack_start(Gtk.VSeparator(), False, False, 0)
     146        custom_box.pack_start(custom, False, False, 0)
    145147
    146         workspace = gtk.VBox()
    147         workspace.pack_start(articles_box, False)
    148         workspace.pack_start(custom_box, False)
     148        workspace = Gtk.VBox()
     149        workspace.pack_start(articles_box, False, False, 0)
     150        workspace.pack_start(custom_box, False, False, 0)
    149151        workspace.show_all()
    150152
    151153        self.add(workspace)
    class View(gtk.EventBox): 
    199201            return
    200202
    201203        if book.wiki.find('%s (from %s)' % (title, wiki))[0]:
    202             self.activity.notify_alert(
    203                     _('Exists'),
    204                     _('"%s" article already exists') % title)
     204            alert = Alert()
     205            alert.props.title = _('Exists')
     206            alert.props.msg = _('"%s" article already exists' % title)
     207            alert.show()
    205208        else:
    206209            Timer(0, self._download, [title, wiki]).start()
    207210
  • net.py

    diff --git a/net.py b/net.py
    index e3a13cf..968f407 100644
    a b import urllib 
    1818import logging
    1919from gettext import gettext as _
    2020
    21 from sugar.activity.activity import get_bundle_path
     21from sugar3.activity.activity import get_bundle_path
    2222
    2323import book
    2424from infoslicer.processing.NewtifulSoup import NewtifulStoneSoup \
  • setup.py

    diff --git a/setup.py b/setup.py
    index bb74f5a..83abd2a 100755
    a b  
    1414# along with this program; if not, write to the Free Software
    1515# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1616
    17 from sugar.activity import bundlebuilder
     17from sugar3.activity import bundlebuilder
    1818if __name__ == "__main__":
    1919    bundlebuilder.start()
    2020
  • toolbar.py

    diff --git a/toolbar.py b/toolbar.py
    index 811f93a..dbb2101 100644
    a b  
    1212# along with this program; if not, write to the Free Software
    1313# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1414
    15 import gtk
    16 import gobject
     15from gi.repository import Gtk
     16from gi.repository import GObject
    1717
    18 from sugar.graphics.icon import Icon
    19 import sugar.graphics.style as style
     18from sugar3.graphics.icon import Icon
     19import sugar3.graphics.style as style
    2020
    21 class WidgetItem(gtk.ToolItem):
     21class WidgetItem(Gtk.ToolItem):
    2222    def __init__(self, widget):
    23         gtk.ToolItem.__init__(self)
     23        GObject.GObject.__init__(self)
    2424        self.add(widget)
    2525        widget.show()
    2626
    27 class ButtonItem(gtk.ToolButton):
    28     def __init__(self, icon_name, size=gtk.ICON_SIZE_SMALL_TOOLBAR, **kwargs):
    29         gobject.GObject.__init__(self, **kwargs)
     27class ButtonItem(Gtk.ToolButton):
     28    def __init__(self, icon_name, size=Gtk.IconSize.SMALL_TOOLBAR, **kwargs):
     29        GObject.GObject.__init__(self, **kwargs)
    3030
    3131        icon = Icon(icon_name=icon_name, icon_size=size)
    32         # The alignment is a hack to work around gtk.ToolButton code
    33         # that sets the icon_size when the icon_widget is a gtk.Image
    34         alignment = gtk.Alignment(0.5, 0.5)
     32        # The alignment is a hack to work around Gtk.ToolButton code
     33        # that sets the icon_size when the icon_widget is a Gtk.Image
     34        alignment = Gtk.Alignment.new(0.5, 0.5)
    3535        alignment.add(icon)
    3636        self.set_icon_widget(alignment)
    3737
    38         if size == gtk.ICON_SIZE_SMALL_TOOLBAR:
     38        if size == Gtk.IconSize.SMALL_TOOLBAR:
    3939            button_size = style.SMALL_ICON_SIZE + 8
    4040            self.set_size_request(button_size, button_size)
  • xol.py

    diff --git a/xol.py b/xol.py
    index f9eeb73..79763de 100644
    a b  
    1515# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1616
    1717import os
    18 import gtk
     18from gi.repository import Gtk
    1919import zipfile
    2020import uuid
    2121import logging
    import parse 
    2323from glob import glob
    2424from gettext import gettext as _
    2525
    26 from sugar.activity.activity import get_bundle_path, get_activity_root, get_bundle_name
    27 from sugar.datastore import datastore
    28 from sugar import activity
     26from sugar3.activity.activity import get_bundle_path, get_activity_root, get_bundle_name
     27from sugar3.datastore import datastore
     28from sugar3 import activity
     29from sugar3.graphics.alert import NotifyAlert, ConfirmationAlert
    2930
    3031from infoslicer.processing.NewtifulSoup import NewtifulStoneSoup \
    3132        as BeautifulStoneSoup
    import book 
    3334
    3435logger = logging.getLogger('infoslicer')
    3536
     37
     38def __alert_notify_response_cb(alert, response_id, activity):
     39    activity.remove_alert(alert)
     40
     41
     42def __alert_response_cb(alert, response_id, activity, force):
     43    activity.remove_alert(alert)
     44    publish(activity, force)
     45
     46
    3647def publish(activity, force=False):
    3748    if not [i for i in book.custom.index if i['ready']]:
    38         activity.notify_alert(
    39                 _('Nothing to publish'),
    40                 _('Mark arcticles from "Custom" panel and try again.'))
     49        alert = NotifyAlert(5)
     50        alert.props.title = _('Nothing to publish')
     51        alert.props.msg = _('Mark arcticles from "Custom" '
     52                            'panel and try again.')
     53        alert.connect('response', __alert_notify_response_cb, activity)
     54        activity.add_alert(alert)
     55        alert.show()
    4156        return
    4257
    4358    title = activity.metadata['title']
    def publish(activity, force=False): 
    5267        if force:
    5368            jobject = jobject[0]
    5469        else:
    55             try:
    56                 # check for 0.84 code
    57                 from jarabe import config
    58             except:
    59                 # 0.82 couldn't override .xol bundles
    60                 activity.notify_alert(
    61                         _('Bundle exists'),
    62                         _('A bundle by "%s" name already exists. Please ' \
    63                         'click "Erase" in the Journal. You can click ' \
    64                         '"Publish" again afterwards.') % \
    65                         jobject[0].metadata['title'])
    66                 return
    67 
    68             activity.confirmation_alert(
    69                     _('Overwrite existed bundle?'),
    70                     _('A bundle for current object was already created. ' \
    71                           'Click "OK" to overwrite it.'),
    72                     publish, activity, True)
     70            alert = ConfirmationAlert()
     71            alert.props.title = _('Overwrite existed bundle?')
     72            alert.props.msg = _('A bundle for current object was already created. '
     73                                'Click "OK" to overwrite it.')
     74            alert.connect('response', __alert_response_cb, activity, True)
     75            activity.add_alert(alert)
     76            alert.show()
    7377            jobject[0].destroy()
    7478            return
    7579    else:
    def publish(activity, force=False): 
    9195
    9296    book.custom.sync_index()
    9397
    94     activity.notify_alert(_('Book published to your Journal'),
    95                           _('You can read the book in Browse or ' \
    96                                 'access the .xol file from your Journal'))
     98    alert = NotifyAlert()
     99    alert.props.title = _('Book published to your Journal')
     100    alert.props.msg = _('You can read the book in Browse or '
     101                        'access the .xol file from your Journal')
     102    alert.connect('response', __alert_notify_response_cb, activity)
     103    activity.add_alert(alert)
     104    alert.show()
    97105
    98106"""
    99107@author: Matthew Bailey