Ticket #3742: Initial-Port.diff

File Initial-Port.diff, 61.3 KB (added by humitos, 12 years ago)
  • activity.py

    diff --git a/activity.py b/activity.py
    index 126d4c7..ac6a7b0 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
    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 OLD_TOOLBAR = False
    22 try:
    23     from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
    24     from sugar.activity.widgets import StopButton
    25     from sugar.graphics.radiotoolbutton import RadioToolButton
    26     from sugar.activity.widgets import ActivityToolbarButton
    27 except ImportError:
    28     OLD_TOOLBAR = True
     19from sugar3.graphics.toolbutton import ToolButton
     20from sugar3.graphics.toggletoolbutton import ToggleToolButton
     21from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
     22from sugar3.activity.widgets import StopButton
     23from sugar3.graphics.radiotoolbutton import RadioToolButton
     24from sugar3.activity.widgets import ActivityToolbarButton
    2925from port.activity import SharedActivity
    3026
    3127import library
    3228import edit
    3329import book
    3430
    35 gtk.gdk.threads_init()
    36 gtk.gdk.threads_enter()
     31Gdk.threads_init()
     32Gdk.threads_enter()
    3733
    3834class InfoslicerActivity(SharedActivity):
    3935    def __init__(self, handle):
    40         self.notebook = gtk.Notebook()
     36        self.notebook = Gtk.Notebook()
    4137        self.notebook.show()
    4238        self.notebook.props.show_border = False
    4339        self.notebook.props.show_tabs = False
    class InfoslicerActivity(SharedActivity): 
    5349        self.edit = edit.View()
    5450        self.library = library.View(self)
    5551
    56         if OLD_TOOLBAR:
    57             self.edit_toolbar = gtk.Toolbar()
    58             self.edit_bar = edit.ToolbarBuilder(self.edit, self.edit_toolbar)
    59             self.edit_toolbar.show_all()
    60 
    61             self.library_toolbar = gtk.Toolbar()
    62             self.library_bar = library.ToolbarBuilder(self.library,
    63                     self.library_toolbar)
    64             self.library_toolbar.show_all()
    65 
    66             toolbox = ActivityToolbox(self)
    67             toolbox.connect('current-toolbar-changed',
    68                     self._toolbar_changed_cb)
    69             self.set_toolbox(toolbox)
    70             toolbox.add_toolbar(_('Library'), self.library_toolbar)
    71             toolbox.add_toolbar(_('Edit'), self.edit_toolbar)
    72             toolbox.set_current_toolbar(1)
    73         else:
    74             toolbar_box = ToolbarBox()
    75             activity_button = ActivityToolbarButton(self)
    76             toolbar_box.toolbar.insert(activity_button, 0)
    77             self.set_toolbar_box(toolbar_box)
    78             self._toolbar = toolbar_box.toolbar
    79 
    80             tool_group = None
    81             search_button = RadioToolButton()
    82             search_button.props.group = tool_group
    83             tool_group = search_button
    84             search_button.props.icon_name = 'white-search'
    85             search_button.set_tooltip(_('Library'))
    86             search_button.mode = 'search'
    87             search_button.connect('clicked', self.__mode_button_clicked)
    88             self._toolbar.insert(search_button, -1)
    89 
    90             edit_button = RadioToolButton()
    91             edit_button.props.group = tool_group
    92             edit_button.props.icon_name = 'toolbar-edit'
    93             edit_button.set_tooltip(_('Edit'))
    94             edit_button.mode = 'edit'
    95             edit_button.connect('clicked', self.__mode_button_clicked)
    96             self._toolbar.insert(edit_button, -1)
    97             self._toolbar.insert(gtk.SeparatorToolItem(), -1)
    98             self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar)
    99             self.library_bar = library.ToolbarBuilder(self.library,
    100                                                       activity_button)
    101             self.library_bar.publish.show()
    102 
    103         edit_fake = gtk.EventBox()
     52        toolbar_box = ToolbarBox()
     53        activity_button = ActivityToolbarButton(self)
     54        toolbar_box.toolbar.insert(activity_button, 0)
     55        self.set_toolbar_box(toolbar_box)
     56        self._toolbar = toolbar_box.toolbar
     57
     58        tool_group = None
     59        search_button = RadioToolButton()
     60        search_button.props.group = tool_group
     61        tool_group = search_button
     62        search_button.props.icon_name = 'white-search'
     63        search_button.set_tooltip(_('Library'))
     64        search_button.mode = 'search'
     65        search_button.connect('clicked', self.__mode_button_clicked)
     66        self._toolbar.insert(search_button, -1)
     67
     68        edit_button = RadioToolButton()
     69        edit_button.props.group = tool_group
     70        edit_button.props.icon_name = 'toolbar-edit'
     71        edit_button.set_tooltip(_('Edit'))
     72        edit_button.mode = 'edit'
     73        edit_button.connect('clicked', self.__mode_button_clicked)
     74        self._toolbar.insert(edit_button, -1)
     75        self._toolbar.insert(Gtk.SeparatorToolItem(), -1)
     76        self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar)
     77        self.library_bar = library.ToolbarBuilder(self.library,
     78                                                  activity_button)
     79        self.library_bar.publish.show()
     80
     81        edit_fake = Gtk.EventBox()
    10482
    10583        self.notebook.append_page(self.library)
    10684        self.notebook.append_page(self.edit)
    class InfoslicerActivity(SharedActivity): 
    10886
    10987        self.show_all()
    11088
    111         if not OLD_TOOLBAR:
    112             self.__mode_button_clicked(search_button)
    113             separator = gtk.SeparatorToolItem()
    114             separator.props.draw = False
    115             separator.set_expand(True)
    116             separator.show()
    117             self._toolbar.insert(separator, -1)
    118             stop_button = StopButton(self)
    119             stop_button.show()
    120             self._toolbar.insert(stop_button, -1)
     89        self.__mode_button_clicked(search_button)
     90        separator = Gtk.SeparatorToolItem()
     91        separator.props.draw = False
     92        separator.set_expand(True)
     93        separator.show()
     94        self._toolbar.insert(separator, -1)
     95        stop_button = StopButton(self)
     96        stop_button.show()
     97        self._toolbar.insert(stop_button, -1)
    12198
    12299    def new_instance(self):
    123100        self.instance()
    class InfoslicerActivity(SharedActivity): 
    131108        book.custom.sync(filepath)
    132109
    133110    def set_edit_sensitive(self, enable):
    134         if OLD_TOOLBAR:
    135             #self.edit_toolbar.props.sensitive = enable
    136             self.edit_page = (enable and 1 or 2)
     111        pass
    137112
    138113    def _toolbar_changed_cb(self, widget, index):
    139114        if index > 0:
  • book.py

    diff --git a/book.py b/book.py
    index f28ff99..ea40951 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 8b049d6..f90ce8a 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 *
    2424from port.widgets import ToolWidget, ToolButton
    2525
    2626logger = logging.getLogger('infoslicer')
    logger = logging.getLogger('infoslicer') 
    2828PUBLISH  = 0
    2929TITLE    = 1
    3030
    31 class BookView(gtk.VBox):
     31class BookView(Gtk.VBox):
    3232    def sync(self):
    3333        if not self._changing:
    3434            return
    35         gobject.source_remove(self._changing)
     35        GObject.source_remove(self._changing)
    3636        index, column = self.tree.get_cursor()
    3737        self._cursor_changed(index)
    3838
    3939    def __init__(self, book, name, tooltip, custom):
    40         gtk.VBox.__init__(self)
     40        GObject.GObject.__init__(self)
    4141        self.book = book
    4242        self._changing = None
    4343        self._check = None
    4444
    45         title = gtk.Toolbar()
     45        title = Gtk.Toolbar()
    4646
    4747        # title checkbox
    4848
    4949        if custom:
    50             self._check = gtk.CheckButton()
     50            self._check = Gtk.CheckButton()
    5151            self._check.props.can_focus = False
    5252            self._check.props.tooltip_text = \
    5353                    _('Articles are ready to be published')
    5454            self._check.connect('toggled', self._check_toggled_cb)
    55             check_box = gtk.HBox()
     55            check_box = Gtk.HBox()
    5656            check_box.set_size_request(50, -1)
    57             check_box.pack_start(self._check, True, False)
     57            check_box.pack_start(self._check, True, False, 0)
    5858            title.insert(ToolWidget(check_box), -1)
    5959        else:
    60             title.insert(ToolWidget(gtk.Label('  ')), -1)
     60            title.insert(ToolWidget(Gtk.Label(label='  ')), -1)
    6161
    6262        # title caption
    6363
    64         caption_label = gtk.Label(name)
     64        caption_label = Gtk.Label(label=name)
    6565        caption_label.props.tooltip_text = tooltip
    66         caption_label.modify_fg(gtk.STATE_NORMAL, COLOR_WHITE.get_gdk_color())
    67         caption_box = gtk.HBox()
    68         caption_box.pack_start(caption_label, False)
    69         caption = gtk.EventBox()
     66        caption_label.modify_fg(Gtk.StateType.NORMAL, COLOR_WHITE.get_gdk_color())
     67        caption_box = Gtk.HBox()
     68        caption_box.pack_start(caption_label, False, False, 0)
     69        caption = Gtk.EventBox()
    7070        caption.add(caption_box)
    71         caption.modify_bg(gtk.STATE_NORMAL, COLOR_TOOLBAR_GREY.get_gdk_color())
     71        caption.modify_bg(Gtk.StateType.NORMAL, COLOR_TOOLBAR_GREY.get_gdk_color())
    7272        title.insert(ToolWidget(caption), -1)
    7373
    74         separator = gtk.SeparatorToolItem()
     74        separator = Gtk.SeparatorToolItem()
    7575        separator.props.draw = False
    7676        separator.set_expand(True)
    7777        title.insert(separator, -1)
    class BookView(gtk.VBox): 
    111111
    112112        # tree
    113113
    114         self.store = gtk.ListStore(bool, str)
    115         self.tree = gtk.TreeView(self.store)
     114        self.store = Gtk.ListStore(bool, str)
     115        self.tree = Gtk.TreeView(self.store)
    116116        self.tree.props.headers_visible = False
    117117        self.tree.connect('cursor-changed', self._cursor_changed_cb)
    118118
    119         cell = gtk.CellRendererToggle()
     119        cell = Gtk.CellRendererToggle()
    120120        cell.connect('toggled', self._cell_toggled_cb)
    121121        cell.props.activatable = True
    122122
    123         column = self.tree.insert_column_with_attributes(0, '', cell, active=0)
    124         column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
    125         column.props.fixed_width = 50
    126         column.props.visible = custom
     123        # FIXME: insert_column_with_attributes does not exist
     124        # column = self.tree.insert_column_with_attributes(0, '', cell, active=0)
     125        # column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
     126        # column.props.fixed_width = 50
     127        # column.props.visible = custom
    127128
    128         cell = gtk.CellRendererText()
     129        cell = Gtk.CellRendererText()
    129130        cell.connect('edited', self._cell_edited_cb)
    130131        cell.props.editable = True
    131         self.tree.insert_column_with_attributes(1, '', cell, text=1)
     132        # self.tree.insert_column_with_attributes(1, '', cell, text=1)
    132133
    133134        for i in self.book.index:
    134135            self.store.append((i['ready'], i['title']))
    135136
    136137        # scrolled tree
    137138
    138         tree_scroll = gtk.ScrolledWindow()
    139         tree_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     139        tree_scroll = Gtk.ScrolledWindow()
     140        tree_scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    140141        tree_scroll.add(self.tree)
    141142
    142         self.pack_start(title, False)
    143         self.pack_start(tree_scroll)
     143        self.pack_start(title, False, False, 0)
     144        self.pack_start(tree_scroll, True, True, 0)
    144145
    145146        if len(self.store):
    146147            self.tree.set_cursor(0, self.tree.get_column(1), False)
    class BookView(gtk.VBox): 
    163164            return find_name(list, prefix, uniq+1)
    164165
    165166        if self._changing:
    166             gobject.source_remove(self._changing)
     167            GObject.source_remove(self._changing)
    167168            self._changing = None
    168169
    169170        name = find_name(self.store, _('New article'), 0)
    class BookView(gtk.VBox): 
    179180        index = index[0]
    180181
    181182        if self._changing:
    182             gobject.source_remove(self._changing)
     183            GObject.source_remove(self._changing)
    183184            self._changing = None
    184185
    185186        self.book.remove(self.store[index][TITLE])
    class BookView(gtk.VBox): 
    234235
    235236    def _cursor_changed_cb(self, widget):
    236237        if self._changing:
    237             gobject.source_remove(self._changing)
     238            GObject.source_remove(self._changing)
    238239
    239240        index, column = self.tree.get_cursor()
    240241
    241242        if index != None:
    242             self._changing = gobject.timeout_add(500, self._cursor_changed,
     243            self._changing = GObject.timeout_add(500, self._cursor_changed,
    243244                    index)
    244245
    245246    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..08dc5fe 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    22
    3 import pygtk
    4 pygtk.require('2.0')
    5 import gtk
     3import gi
     4gi.require_version('Gtk', '3.0')
     5from gi.repository import Gtk
     6
    67from random import Random
    78from Article_Data import *
    89from Section import *
    class Article: 
    3536    """
    3637    Created by Jonathan Mace
    3738
    38     The Article class maintains a concrete representation of the article, in the form of a gtk.TextBuffer
     39    The Article class maintains a concrete representation of the article, in the form of a Gtk.TextBuffer
    3940
    40     Positions within the text are represented by gtk.TextIter
     41    Positions within the text are represented by Gtk.TextIter
    4142
    4243    The class contains methods for inserting and deleting new sentences, paragraphs and sections.
    4344
    class Article: 
    5657        """
    5758        Create default text buffer and set to empty
    5859        """
    59         self.__buf = gtk.TextBuffer()
     60        self.__buf = Gtk.TextBuffer()
    6061        self.__buf.set_text("")
    6162        insertionpoint = self.__buf.get_end_iter()
    6263        insertionmark = self.__buf.create_mark(None, insertionpoint, False)       
    class Article: 
    468469       
    469470    def getBuffer(self):
    470471        """
    471         This method simply returns the gtk.TextBuffer being maintained by this instance of the Article class.
     472        This method simply returns the Gtk.TextBuffer being maintained by this instance of the Article class.
    472473        """
    473474        return self.__buf
    474475
    class Article: 
    638639        self.markmark = self.__buf.create_mark(None, lociter, True)
    639640        self.__buf.insert(lociter, " ")
    640641        lociter = self.__buf.get_iter_at_mark(self.markmark)       
    641         arrow = gtk.gdk.pixbuf_new_from_xpm_data(arrow_xpm)
     642        arrow = GdkPixbuf.Pixbuf.new_from_xpm_data(arrow_xpm)
    642643        self.__buf.insert_pixbuf(lociter, arrow)
    643644       
    644645       
  • infoslicer/processing/Paragraph.py

    diff --git a/infoslicer/processing/Paragraph.py b/infoslicer/processing/Paragraph.py
    index 7c743c7..038011b 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):
  • infoslicer/processing/Section.py

    diff --git a/infoslicer/processing/Section.py b/infoslicer/processing/Section.py
    index 30e3dad..cdd049d 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):
  • infoslicer/processing/Sentence.py

    diff --git a/infoslicer/processing/Sentence.py b/infoslicer/processing/Sentence.py
    index 09c31f4..6f82495 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 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..02a805b 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
    class Editable_Textbox( Textbox ): 
    1820    """
    1921   
    2022    def __init__(self):
    21         gtk.TextView.__init__(self)
     23        GObject.GObject.__init__(self)
    2224        self.set_border_width(1)
    2325        self.set_cursor_visible(True)
    2426        self.set_editable(True) 
    25         self.set_wrap_mode(gtk.WRAP_WORD)
     27        self.set_wrap_mode(Gtk.WrapMode.WORD)
    2628        self.article = None
    2729        self.set_mode(SNAP_SENTENCE)
    2830        self.changed = False
    class Editable_Textbox( Textbox ): 
    3032       
    3133        self.selecting = False
    3234        self.handlers = []
    33         self.modify_font(pango.FontDescription('arial 9'))
     35        self.modify_font(Pango.FontDescription('arial 9'))
    3436        self.ignore_snap_self = True
    3537        self.drag_source = False
    3638        self.edited = False
    class Editable_Textbox( Textbox ): 
    4749        self.article.delete()
    4850       
    4951    def get_mouse_iter(self, x, y):
    50         click_coords = self.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y)
     52        click_coords = self.window_to_buffer_coords(Gtk.TextWindowType.TEXT, x, y)
    5153        mouseClickPositionIter = self.get_iter_at_location(click_coords[0], click_coords[1])
    5254        return mouseClickPositionIter
    5355   
    class Editable_Textbox( Textbox ): 
    5961            self.disconnect(handler)
    6062       
    6163        buffer.connect("changed", self.text_changed, None)
    62         gtk.TextView.set_buffer(self, buffer)
     64        Gtk.TextView.set_buffer(self, buffer)
    6365       
    6466        self.handlers = []
    6567       
    class Editable_Textbox( Textbox ): 
    143145                self.block = True
    144146       
    145147    def clicked_event(self, widget, event, data):
    146         if event.type == gtk.gdk._2BUTTON_PRESS or event.type == gtk.gdk._3BUTTON_PRESS:
     148        if event.type == Gdk._2BUTTON_PRESS or event.type == Gdk._3BUTTON_PRESS:
    147149            self.stop_emission("button_press_event")
    148150            return
    149151        if event.button == 3:
    class Editable_Textbox( Textbox ): 
    280282            a = self.article
    281283           
    282284            if self.snapto == SNAP_SENTENCE:
    283                 atom = gtk.gdk.atom_intern("sentence")
     285                atom = Gdk.atom_intern("sentence")
    284286            if self.snapto == SNAP_PARAGRAPH:
    285                 atom = gtk.gdk.atom_intern("paragraph")
     287                atom = Gdk.atom_intern("paragraph")
    286288            if self.snapto == SNAP_SECTION:
    287                 atom = gtk.gdk.atom_intern("section")
     289                atom = Gdk.atom_intern("section")
    288290               
    289291            string = cPickle.dumps(a.getSelection())
    290292            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..be5a750 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 os
    68import cPickle
    79import logging
    import book 
    1315
    1416logger = logging.getLogger('infoslicer')
    1517
    16 class Gallery_View( gtk.HBox ):
     18class Gallery_View( Gtk.HBox ):
    1719    """
    1820    Created by Christopher Leonard
    1921    Drag-and-drop methods added by Jonathan Mace
    class Gallery_View( gtk.HBox ): 
    3335   
    3436    def __init__(self):
    3537        self.image_list = []
    36         gtk.HBox.__init__(self)
     38        GObject.GObject.__init__(self)
    3739       
    3840        self.current_index = -1
    3941       
    40         left_button = gtk.Button(label="\n\n << \n\n")
     42        left_button = Gtk.Button(label="\n\n << \n\n")
    4143       
    42         right_button = gtk.Button(label="\n\n >> \n\n")
     44        right_button = Gtk.Button(label="\n\n >> \n\n")
    4345       
    44         self.imagenumberlabel = gtk.Label()
     46        self.imagenumberlabel = Gtk.Label()
    4547       
    46         self.image = gtk.Image()
     48        self.image = Gtk.Image()
    4749       
    48         self.imagebox = gtk.EventBox()
     50        self.imagebox = Gtk.EventBox()
    4951        self.imagebox.add(self.image)
    5052       
    51         self.imagebox.drag_source_set(gtk.gdk.BUTTON1_MASK, [("text/plain", gtk.TARGET_SAME_APP, 80)], gtk.gdk.ACTION_COPY)
     53        # FIXME
     54        # http://developer.gnome.org/gtk3/3.5/gtk3-Drag-and-Drop.html#gtk-drag-source-set
     55        # self.imagebox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, ("text/plain", Gtk.TargetFlags.SAME_APP, 80), Gdk.DragAction.COPY)
    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 ): 
    147152       
    148153    def drag_data_get_event(self, widget, context, selection_data, info, timestamp, data):
    149154        logger.debug("getting data")
    150         atom = gtk.gdk.atom_intern("section")
     155        atom = Gdk.atom_intern("section")
    151156        imagedata = Picture_Data(self.source_article_id,
    152157                self.image_list[self.current_index][0],
    153158                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..eca893d 100644
    a b  
    11# Copyright (C) IBM Corporation 2008
    2 import pygtk
    3 pygtk.require('2.0')
    4 import gtk
    5 import pango
     2import gi
     3gi.require_version('Gtk', '3.0')
     4from gi.repository import Gtk
     5from gi.repository import Pango
    66import cPickle
    77from Textbox import Textbox
    88
    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        context.drag_status(Gdk.DragAction.COPY, timestamp)
    4949        return True
    5050       
    5151    def clicked_event(self, widget, event, data):
    52         if event.type == gtk.gdk._2BUTTON_PRESS or event.type == gtk.gdk._3BUTTON_PRESS:
     52        if event.type == Gdk._2BUTTON_PRESS or event.type == Gdk._3BUTTON_PRESS:
    5353            self.stop_emission("button_press_event")
    5454            return
    5555        if event.button == 3:
    class Readonly_Textbox( Textbox ): 
    156156        a = self.article
    157157       
    158158        if self.selectionmode == SELECT_SENTENCE:
    159             atom = gtk.gdk.atom_intern("sentence")
     159            atom = Gdk.atom_intern("sentence")
    160160        if self.selectionmode == SELECT_PARAGRAPH:
    161             atom = gtk.gdk.atom_intern("paragraph")
     161            atom = Gdk.atom_intern("paragraph")
    162162        if self.selectionmode == SELECT_SECTION:
    163             atom = gtk.gdk.atom_intern("section")
     163            atom = Gdk.atom_intern("section")
    164164           
    165165        string = cPickle.dumps(a.getSelection())
    166166        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 a317f99..5c7731b 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
     29import sugar3.graphics.style as style
    2930from port.widgets import ToolWidget
    3031
    3132import xol
    from infoslicer.widgets.Reading_View import Reading_View 
    3637
    3738logger = logging.getLogger('infoslicer')
    3839
    39 class View(gtk.EventBox):
     40class View(Gtk.EventBox):
    4041    def sync(self):
    4142        self.wiki.sync()
    4243        self.custom.sync()
    4344
    4445    def __init__(self, activity):
    45         gtk.EventBox.__init__(self)
     46        GObject.GObject.__init__(self)
    4647        self.activity = activity
    4748
    4849        self.wiki = BookView(book.wiki,
    class View(gtk.EventBox): 
    5354        # stubs for empty articles
    5455
    5556        def create_stub(icon_name, head_text, tail_text):
    56             head_label = gtk.Label(head_text)
    57             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)
    5859            head_label_a.add(head_label)
    5960            icon = Icon(icon_name=icon_name,
    60                     icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)
    61             tail_label = gtk.Label(tail_text)
    62             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)
    6364            tail_label_a.add(tail_label)
    64             stub = gtk.VBox()
    65             stub.pack_start(head_label_a)
    66             stub.pack_start(icon, False)
    67             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)
    6869            return stub
    6970
    7071        wiki_stub = create_stub('white-search',
    class View(gtk.EventBox): 
    7980        wiki_prefix = lang_code[0:2] + '.'
    8081        language_order = 0
    8182        order = 0
    82         search_box = gtk.HBox()
     83        search_box = Gtk.HBox()
    8384        self.wikimenu = ToolComboBox(label_text=_('Get article from:'))
    8485        for i in sorted(WIKI.keys()):
    8586            self.wikimenu.combo.append_item(WIKI[i], i)
    class View(gtk.EventBox): 
    8788                language_order = order
    8889            order = order + 1
    8990        self.wikimenu.combo.set_active(language_order)
    90         search_box.pack_start(self.wikimenu, False)
     91        search_box.pack_start(self.wikimenu, False, False, 0)
    9192
    92         self.searchentry = gtk.Entry()
    93         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)
    9495        self.searchentry.set_text(_("Article name"))
    9596        self.searchentry.select_region(0, -1)
    9697        self.searchentry.connect('activate', self._search_activate_cb)
    97         search_box.pack_start(self.searchentry)
     98        search_box.pack_start(self.searchentry, True, True, 0)
    9899        search_box.show_all()
    99100
    100         self.searchbutton = gtk.Button(label=_('Search'))
     101        self.searchbutton = Gtk.Button(label=_('Search'))
    101102        self.searchbutton.connect('clicked', self._search_clicked_cb)
    102         search_box.pack_start(self.searchbutton, False)
     103        search_box.pack_start(self.searchbutton, False, False, 0)
    103104
    104105        wiki_widget = Reading_View()
    105         wiki = gtk.Notebook()
     106        wiki = Gtk.Notebook()
    106107        wiki.props.show_border = False
    107108        wiki.props.show_tabs = False
    108         wiki.append_page(wiki_stub)
    109         wiki.append_page(wiki_widget)
     109        wiki.append_page(wiki_stub, None)
     110        wiki.append_page(wiki_widget, None)
    110111
    111         self.progress = gtk.Label()
     112        self.progress = Gtk.Label()
    112113        #self.progress.set_size_request(-1, style.SMALL_ICON_SIZE+4)
    113         #progress_box = gtk.HBox()
    114         #progress_box.pack_start(gtk.HSeparator(), False)
     114        #progress_box = Gtk.HBox()
     115        #progress_box.pack_start(Gtk.HSeparator(, True, True, 0), False)
    115116        #progress_box.pack_start(self.progress, False)
    116117
    117         wiki_box = gtk.VBox()
    118         wiki_box.pack_start(search_box, False)
    119         wiki_box.pack_start(wiki)
    120         wiki_box.pack_start(self.progress, False)
    121         wiki_box.set_size_request(gtk.gdk.screen_width()/4*3,
    122                 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)
    123124
    124125        custom_widget = Reading_View()
    125         custom = gtk.Notebook()
     126        custom = Gtk.Notebook()
    126127        custom.props.show_border = False
    127128        custom.props.show_tabs = False
    128         custom.append_page(custom_stub)
    129         custom.append_page(custom_widget)
    130         # custom.set_size_request(gtk.gdk.screen_width()/4*3,
    131         #         gtk.gdk.screen_height()/2 - 55)
    132         custom.set_size_request(gtk.gdk.screen_width()/4*3,
    133                 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)
    134135
    135136        # workspace
    136137
    137         articles_box = gtk.HBox()
    138         articles_box.pack_start(self.wiki)
    139         articles_box.pack_start(gtk.VSeparator(), False)
    140         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)
    141142
    142         custom_box = gtk.HBox()
    143         custom_box.pack_start(self.custom)
    144         custom_box.pack_start(gtk.VSeparator(), False)
    145         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)
    146147
    147         workspace = gtk.VBox()
    148         workspace.pack_start(articles_box, False)
    149         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)
    150151        workspace.show_all()
    151152
    152153        self.add(workspace)
  • 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 \
  • port/activity.py

    diff --git a/port/activity.py b/port/activity.py
    index e3b6fdd..769a944 100644
    a b  
    1414
    1515"""Extend sugar-toolkit activity class"""
    1616
    17 import gtk
     17from gi.repository import Gtk
     18from gi.repository import Gdk
    1819import logging
    1920import telepathy
    20 import gobject
     21from gi.repository import GObject
    2122
    22 import sugar.activity.activity as toolkit
    23 from sugar.presence.sugartubeconn import SugarTubeConnection
    24 from sugar.graphics.alert import ConfirmationAlert, NotifyAlert
     23import sugar3.activity.activity as toolkit
     24from sugar3.presence.sugartubeconn import SugarTubeConnection
     25from sugar3.graphics.alert import ConfirmationAlert, NotifyAlert
    2526
    2627_NEW_INSTANCE   = 0
    2728_NEW_INSTANCE   = 1
    class CursorFactory: 
    3637
    3738    def get_cursor(self, cur_type):
    3839        if not self.cursors.has_key(cur_type):
    39             cur = gtk.gdk.Cursor(cur_type)
     40            cur = Gdk.Cursor.new(cur_type)
    4041            self.cursors[cur_type] = cur
    4142        return self.cursors[cur_type]
    4243
    class Activity(toolkit.Activity): 
    108109
    109110        def response(alert, response_id, self, cb, *cb_args):
    110111            self.remove_alert(alert)
    111             if response_id is gtk.RESPONSE_OK:
     112            if response_id is Gtk.ResponseType.OK:
    112113                cb(*cb_args)
    113114
    114115        alert.connect('response', response, self, cb, *cb_args)
    class Activity(toolkit.Activity): 
    119120        return self._cursor
    120121
    121122    def set_cursor(self, cursor):
    122         if not isinstance(cursor, gtk.gdk.Cursor):
     123        if not isinstance(cursor, Gdk.Cursor):
    123124            cursor = CursorFactory().get_cursor(cursor)
    124125
    125126        if self._cursor != cursor:
    126127            self._cursor = cursor
    127             self.window.set_cursor(self._cursor)
     128            self.get_window().set_cursor(self._cursor)
    128129
    129130    def __init__(self, canvas, handle):
    130131        """
    131132        Initialise the Activity.
    132133
    133         canvas -- gtk.Widget
     134        canvas -- Gtk.Widget
    134135            root widget for activity content
    135136
    136         handle -- sugar.activity.activityhandle.ActivityHandle
     137        handle -- sugar3.activity.activityhandle.ActivityHandle
    137138            instance providing the activity id and access to the
    138139            presence service which *may* provide sharing for this
    139140            application
    class Activity(toolkit.Activity): 
    151152        self.__on_save_instance = []
    152153
    153154        self._cursor = None
    154         self.set_cursor(gtk.gdk.LEFT_PTR)
     155        self.set_cursor(Gdk.CursorType.LEFT_PTR)
    155156
    156157        # XXX do it after(possible) read_file() invoking
    157158        # have to rely on calling read_file() from map_cb in sugar-toolkit
    class SharedActivity(Activity): 
    221222        """
    222223        Initialise the Activity.
    223224
    224         canvas -- gtk.Widget
     225        canvas -- Gtk.Widget
    225226            root widget for activity content
    226227
    227228        service -- string
    228229            dbus service for activity
    229230
    230         handle -- sugar.activity.activityhandle.ActivityHandle
     231        handle -- sugar3.activity.activityhandle.ActivityHandle
    231232            instance providing the activity id and access to the
    232233            presence service which *may* provide sharing for this
    233234            application
    class SharedActivity(Activity): 
    238239
    239240        self.connect('shared', self._shared_cb)
    240241
     242        # FIXME: I added this line on the Gtk3 port
     243        self._shared_activity = False
     244
    241245        # Owner.props.key
    242246        if self._shared_activity:
    243247            # We are joining the activity
  • port/widgets.py

    diff --git a/port/widgets.py b/port/widgets.py
    index ffcb2c6..0021bbb 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
    1717import logging
    1818
    19 from sugar.graphics import style
    20 from sugar.graphics.palette import CanvasInvoker, Palette
    21 from sugar.graphics import toolbutton
    22 from sugar.graphics import icon
     19from sugar3.graphics import style
     20from sugar3.graphics.palette import Palette
     21from sugar3.graphics import toolbutton
     22from sugar3.graphics import icon
    2323
    2424class ToolButton(toolbutton.ToolButton):
    2525    def __init__(self,
    2626            icon_name,
    27             size=gtk.ICON_SIZE_SMALL_TOOLBAR,
     27            size=Gtk.IconSize.SMALL_TOOLBAR,
    2828            padding=None,
    2929            **kwargs):
    3030
    class ToolButton(toolbutton.ToolButton): 
    3333        image = icon.Icon(icon_name=icon_name, icon_size=size)
    3434        image.show()
    3535
    36         # The alignment is a hack to work around gtk.ToolButton code
    37         # that sets the icon_size when the icon_widget is a gtk.Image
    38         alignment = gtk.Alignment(0.5, 0.5)
     36        # The alignment is a hack to work around Gtk.ToolButton code
     37        # that sets the icon_size when the icon_widget is a Gtk.Image
     38        # FIXME: not sure about the arguments
     39        alignment = Gtk.Alignment.new(0, 0, 0.5, 0.5)
    3940        alignment.show()
    4041        alignment.add(image)
    4142
    4243        self.set_icon_widget(alignment)
    4344
    44         sizes = { gtk.ICON_SIZE_SMALL_TOOLBAR: style.SMALL_ICON_SIZE,
    45                   gtk.ICON_SIZE_LARGE_TOOLBAR: style.STANDARD_ICON_SIZE }
     45        sizes = { Gtk.IconSize.SMALL_TOOLBAR: style.SMALL_ICON_SIZE,
     46                  Gtk.IconSize.LARGE_TOOLBAR: style.STANDARD_ICON_SIZE }
    4647
    4748        if padding is not None and sizes.has_key(size):
    4849            button_size = sizes[size] + style.DEFAULT_SPACING + padding
    4950            self.set_size_request(button_size, button_size)
    5051
    51 class ToolWidget(gtk.ToolItem):
     52class ToolWidget(Gtk.ToolItem):
    5253    def __init__(self, widget):
    53         gtk.ToolItem.__init__(self)
     54        GObject.GObject.__init__(self)
    5455        self.add(widget)
    5556        widget.show()
  • 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..0796b1e 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
    2929
    3030from infoslicer.processing.NewtifulSoup import NewtifulStoneSoup \
    3131        as BeautifulStoneSoup