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 12 12 # along with this program; if not, write to the Free Software 13 13 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 14 15 import gtk 15 from gi.repository import Gtk 16 from gi.repository import Gdk 16 17 from gettext import gettext as _ 17 18 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 19 from sugar3.graphics.toolbutton import ToolButton 20 from sugar3.graphics.toggletoolbutton import ToggleToolButton 21 from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton 22 from sugar3.activity.widgets import StopButton 23 from sugar3.graphics.radiotoolbutton import RadioToolButton 24 from sugar3.activity.widgets import ActivityToolbarButton 29 25 from port.activity import SharedActivity 30 26 31 27 import library 32 28 import edit 33 29 import book 34 30 35 gtk.gdk.threads_init()36 gtk.gdk.threads_enter()31 Gdk.threads_init() 32 Gdk.threads_enter() 37 33 38 34 class InfoslicerActivity(SharedActivity): 39 35 def __init__(self, handle): 40 self.notebook = gtk.Notebook()36 self.notebook = Gtk.Notebook() 41 37 self.notebook.show() 42 38 self.notebook.props.show_border = False 43 39 self.notebook.props.show_tabs = False … … class InfoslicerActivity(SharedActivity): 53 49 self.edit = edit.View() 54 50 self.library = library.View(self) 55 51 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() 104 82 105 83 self.notebook.append_page(self.library) 106 84 self.notebook.append_page(self.edit) … … class InfoslicerActivity(SharedActivity): 108 86 109 87 self.show_all() 110 88 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) 121 98 122 99 def new_instance(self): 123 100 self.instance() … … class InfoslicerActivity(SharedActivity): 131 108 book.custom.sync(filepath) 132 109 133 110 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 137 112 138 113 def _toolbar_changed_cb(self, widget, index): 139 114 if index > 0: -
book.py
diff --git a/book.py b/book.py index f28ff99..ea40951 100644
a b 13 13 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 14 15 15 import os 16 import gtk17 16 import uuid 18 17 import logging 19 import gobject18 from gi.repository import GObject 20 19 import cjson 21 20 import shutil 22 21 import zipfile 23 from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT24 22 from gettext import gettext as _ 25 23 26 from sugar .activity.activity import get_bundle_path, get_activity_root24 from sugar3.activity.activity import get_bundle_path, get_activity_root 27 25 28 26 import net 29 27 from infoslicer.processing.Article import Article … … custom = None 36 34 37 35 image_root = os.path.join(get_activity_root(), 'data', 'book') 38 36 39 class Book( gobject.GObject):37 class Book(GObject.GObject): 40 38 __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]) } 44 42 45 43 def get_article(self): 46 44 return self._article … … class Book(gobject.GObject): 71 69 72 70 self._article.uid = entry['uid'] 73 71 self._article.article_title = title 74 gobject.idle_add(self._emit_article_selected)72 GObject.idle_add(self._emit_article_selected) 75 73 76 article = gobject.property(type=object,74 article = GObject.property(type=object, 77 75 getter=get_article, setter=set_article) 78 76 79 77 def _emit_article_selected(self): … … class Book(gobject.GObject): 132 130 self.sync_index() 133 131 134 132 def __init__(self, preinstalled, root): 135 gobject.GObject.__init__(self)133 GObject.GObject.__init__(self) 136 134 self.root = root 137 135 self.index = [] 138 136 self.uid = None -
bookview.py
diff --git a/bookview.py b/bookview.py index 8b049d6..f90ce8a 100644
a b 13 13 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 14 15 15 import os 16 import gtk16 from gi.repository import Gtk 17 17 import logging 18 import gobject18 from gi.repository import GObject 19 19 from gettext import gettext as _ 20 20 21 from sugar .graphics.toolbutton import ToolButton22 from sugar .activity.activity import get_bundle_path, get_activity_root23 from sugar .graphics.style import *21 from sugar3.graphics.toolbutton import ToolButton 22 from sugar3.activity.activity import get_bundle_path, get_activity_root 23 from sugar3.graphics.style import * 24 24 from port.widgets import ToolWidget, ToolButton 25 25 26 26 logger = logging.getLogger('infoslicer') … … logger = logging.getLogger('infoslicer') 28 28 PUBLISH = 0 29 29 TITLE = 1 30 30 31 class BookView( gtk.VBox):31 class BookView(Gtk.VBox): 32 32 def sync(self): 33 33 if not self._changing: 34 34 return 35 gobject.source_remove(self._changing)35 GObject.source_remove(self._changing) 36 36 index, column = self.tree.get_cursor() 37 37 self._cursor_changed(index) 38 38 39 39 def __init__(self, book, name, tooltip, custom): 40 gtk.VBox.__init__(self)40 GObject.GObject.__init__(self) 41 41 self.book = book 42 42 self._changing = None 43 43 self._check = None 44 44 45 title = gtk.Toolbar()45 title = Gtk.Toolbar() 46 46 47 47 # title checkbox 48 48 49 49 if custom: 50 self._check = gtk.CheckButton()50 self._check = Gtk.CheckButton() 51 51 self._check.props.can_focus = False 52 52 self._check.props.tooltip_text = \ 53 53 _('Articles are ready to be published') 54 54 self._check.connect('toggled', self._check_toggled_cb) 55 check_box = gtk.HBox()55 check_box = Gtk.HBox() 56 56 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) 58 58 title.insert(ToolWidget(check_box), -1) 59 59 else: 60 title.insert(ToolWidget( gtk.Label(' ')), -1)60 title.insert(ToolWidget(Gtk.Label(label=' ')), -1) 61 61 62 62 # title caption 63 63 64 caption_label = gtk.Label(name)64 caption_label = Gtk.Label(label=name) 65 65 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() 70 70 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()) 72 72 title.insert(ToolWidget(caption), -1) 73 73 74 separator = gtk.SeparatorToolItem()74 separator = Gtk.SeparatorToolItem() 75 75 separator.props.draw = False 76 76 separator.set_expand(True) 77 77 title.insert(separator, -1) … … class BookView(gtk.VBox): 111 111 112 112 # tree 113 113 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) 116 116 self.tree.props.headers_visible = False 117 117 self.tree.connect('cursor-changed', self._cursor_changed_cb) 118 118 119 cell = gtk.CellRendererToggle()119 cell = Gtk.CellRendererToggle() 120 120 cell.connect('toggled', self._cell_toggled_cb) 121 121 cell.props.activatable = True 122 122 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 127 128 128 cell = gtk.CellRendererText()129 cell = Gtk.CellRendererText() 129 130 cell.connect('edited', self._cell_edited_cb) 130 131 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) 132 133 133 134 for i in self.book.index: 134 135 self.store.append((i['ready'], i['title'])) 135 136 136 137 # scrolled tree 137 138 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) 140 141 tree_scroll.add(self.tree) 141 142 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) 144 145 145 146 if len(self.store): 146 147 self.tree.set_cursor(0, self.tree.get_column(1), False) … … class BookView(gtk.VBox): 163 164 return find_name(list, prefix, uniq+1) 164 165 165 166 if self._changing: 166 gobject.source_remove(self._changing)167 GObject.source_remove(self._changing) 167 168 self._changing = None 168 169 169 170 name = find_name(self.store, _('New article'), 0) … … class BookView(gtk.VBox): 179 180 index = index[0] 180 181 181 182 if self._changing: 182 gobject.source_remove(self._changing)183 GObject.source_remove(self._changing) 183 184 self._changing = None 184 185 185 186 self.book.remove(self.store[index][TITLE]) … … class BookView(gtk.VBox): 234 235 235 236 def _cursor_changed_cb(self, widget): 236 237 if self._changing: 237 gobject.source_remove(self._changing)238 GObject.source_remove(self._changing) 238 239 239 240 index, column = self.tree.get_cursor() 240 241 241 242 if index != None: 242 self._changing = gobject.timeout_add(500, self._cursor_changed,243 self._changing = GObject.timeout_add(500, self._cursor_changed, 243 244 index) 244 245 245 246 def _cursor_changed(self, index): -
edit.py
diff --git a/edit.py b/edit.py index d21a989..e48509e 100644
a b 12 12 # along with this program; if not, write to the Free Software 13 13 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 14 15 import gtk 15 from gi.repository import Gtk 16 from gi.repository import GObject 16 17 from gettext import gettext as _ 17 18 18 from sugar.graphics.toolbutton import ToolButton 19 from sugar.graphics.toggletoolbutton import ToggleToolButton 20 from sugar.activity.activity import ActivityToolbox 19 from sugar3.graphics.toolbutton import ToolButton 20 from sugar3.graphics.toggletoolbutton import ToggleToolButton 21 21 22 22 from infoslicer.widgets.Edit_Pane import Edit_Pane 23 23 from infoslicer.widgets.Format_Pane import Format_Pane … … TABS = (Edit_Pane(), 28 28 Image_Pane(), 29 29 Format_Pane()) 30 30 31 class View( gtk.Notebook):31 class View(Gtk.Notebook): 32 32 def __init__(self): 33 gtk.Notebook.__init__(self)33 GObject.GObject.__init__(self) 34 34 self.props.show_border = False 35 35 self.props.show_tabs = False 36 36 37 37 for i in TABS: 38 self.append_page(i )38 self.append_page(i, None) 39 39 i.show() 40 40 41 41 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 1 1 # Copyright (C) IBM Corporation 2008 2 2 3 import pygtk 4 pygtk.require('2.0') 5 import gtk 3 import gi 4 gi.require_version('Gtk', '3.0') 5 from gi.repository import Gtk 6 6 7 from random import Random 7 8 from Article_Data import * 8 9 from Section import * … … class Article: 35 36 """ 36 37 Created by Jonathan Mace 37 38 38 The Article class maintains a concrete representation of the article, in the form of a gtk.TextBuffer39 The Article class maintains a concrete representation of the article, in the form of a Gtk.TextBuffer 39 40 40 Positions within the text are represented by gtk.TextIter41 Positions within the text are represented by Gtk.TextIter 41 42 42 43 The class contains methods for inserting and deleting new sentences, paragraphs and sections. 43 44 … … class Article: 56 57 """ 57 58 Create default text buffer and set to empty 58 59 """ 59 self.__buf = gtk.TextBuffer()60 self.__buf = Gtk.TextBuffer() 60 61 self.__buf.set_text("") 61 62 insertionpoint = self.__buf.get_end_iter() 62 63 insertionmark = self.__buf.create_mark(None, insertionpoint, False) … … class Article: 468 469 469 470 def getBuffer(self): 470 471 """ 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. 472 473 """ 473 474 return self.__buf 474 475 … … class Article: 638 639 self.markmark = self.__buf.create_mark(None, lociter, True) 639 640 self.__buf.insert(lociter, " ") 640 641 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) 642 643 self.__buf.insert_pixbuf(lociter, arrow) 643 644 644 645 -
infoslicer/processing/Paragraph.py
diff --git a/infoslicer/processing/Paragraph.py b/infoslicer/processing/Paragraph.py index 7c743c7..038011b 100644
a b class RawParagraph: 152 152 def mark(self): 153 153 markiter = self.getStart() 154 154 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) 156 156 self.buf.insert_pixbuf(markiter, arrow) 157 157 158 158 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: 214 214 def mark(self): 215 215 markiter = self.getStart() 216 216 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) 218 218 self.buf.insert_pixbuf(markiter, arrow) 219 219 220 220 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 1 1 # Copyright (C) IBM Corporation 2008 2 2 3 import pygtk4 pygtk.require('2.0')3 import gi 4 gi.require_version('Gtk', '3.0') 5 5 import os 6 import gtk6 from gi.repository import Gtk 7 7 import logging 8 8 9 9 from Article_Data import * … … class Picture( RawSentence ): 159 159 leftmark = buf.create_mark(None, insertioniter, False) 160 160 161 161 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) 163 163 buf.insert_pixbuf(insertioniter, pixbuf) 164 164 else: 165 165 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import Gdk 6 from gi.repository import GObject 5 7 import logging 6 8 from gettext import gettext as _ 7 9 8 from sugar .graphics.toolcombobox import ToolComboBox10 from sugar3.graphics.toolcombobox import ToolComboBox 9 11 10 12 from Reading_View import Reading_View 11 13 from Editing_View import Editing_View … … from infoslicer.processing.Article import Article 13 15 14 16 logger = logging.getLogger('infoslicer') 15 17 16 class Edit_Pane( gtk.HBox):18 class Edit_Pane(Gtk.HBox): 17 19 """ 18 20 Created by Jonathan Mace 19 21 … … class Edit_Pane(gtk.HBox): 30 32 """ 31 33 32 34 def __init__(self): 33 gtk.HBox.__init__(self)35 GObject.GObject.__init__(self) 34 36 self.toolitems = [] 35 37 36 readarticle_box = gtk.VBox()38 readarticle_box = Gtk.VBox() 37 39 readarticle_box.show() 38 40 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")) 41 43 readarticle_box.pack_start(labeleb, False, False, 0) 42 44 labeleb.show() 43 45 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) 46 48 labeleb.add(self.articletitle) 47 49 self.articletitle.show() 48 50 49 vbox = gtk.VBox()51 vbox = Gtk.VBox() 50 52 51 53 snap = ToolComboBox(label_text=_('Snap selection to:')) 52 54 snap.combo.append_item(0, _("Nothing")) … … class Edit_Pane(gtk.HBox): 54 56 snap.combo.append_item(2, _("Paragraphs")) 55 57 snap.combo.append_item(3, _("Sections")) 56 58 snap.combo.set_active(1) 57 vbox.pack_start(snap, False )59 vbox.pack_start(snap, False, False, 0) 58 60 59 61 """ 60 62 Create reading and editing panels 61 63 """ 62 64 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) 64 66 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) 67 69 68 self.pack_start(vbox, False )70 self.pack_start(vbox, False, False, 0) 69 71 70 72 self.editarticle = Editing_View() 71 self.pack_start(self.editarticle )73 self.pack_start(self.editarticle, True, True, 0) 72 74 self.editarticle.show() 73 75 74 76 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import Gdk 6 from gi.repository import GObject 7 from gi.repository import Pango 5 8 import cPickle 6 import pango7 9 import copy 8 10 from Textbox import Textbox 9 11 … … class Editable_Textbox( Textbox ): 18 20 """ 19 21 20 22 def __init__(self): 21 gtk.TextView.__init__(self)23 GObject.GObject.__init__(self) 22 24 self.set_border_width(1) 23 25 self.set_cursor_visible(True) 24 26 self.set_editable(True) 25 self.set_wrap_mode( gtk.WRAP_WORD)27 self.set_wrap_mode(Gtk.WrapMode.WORD) 26 28 self.article = None 27 29 self.set_mode(SNAP_SENTENCE) 28 30 self.changed = False … … class Editable_Textbox( Textbox ): 30 32 31 33 self.selecting = False 32 34 self.handlers = [] 33 self.modify_font( pango.FontDescription('arial 9'))35 self.modify_font(Pango.FontDescription('arial 9')) 34 36 self.ignore_snap_self = True 35 37 self.drag_source = False 36 38 self.edited = False … … class Editable_Textbox( Textbox ): 47 49 self.article.delete() 48 50 49 51 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) 51 53 mouseClickPositionIter = self.get_iter_at_location(click_coords[0], click_coords[1]) 52 54 return mouseClickPositionIter 53 55 … … class Editable_Textbox( Textbox ): 59 61 self.disconnect(handler) 60 62 61 63 buffer.connect("changed", self.text_changed, None) 62 gtk.TextView.set_buffer(self, buffer)64 Gtk.TextView.set_buffer(self, buffer) 63 65 64 66 self.handlers = [] 65 67 … … class Editable_Textbox( Textbox ): 143 145 self.block = True 144 146 145 147 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: 147 149 self.stop_emission("button_press_event") 148 150 return 149 151 if event.button == 3: … … class Editable_Textbox( Textbox ): 280 282 a = self.article 281 283 282 284 if self.snapto == SNAP_SENTENCE: 283 atom = gtk.gdk.atom_intern("sentence")285 atom = Gdk.atom_intern("sentence") 284 286 if self.snapto == SNAP_PARAGRAPH: 285 atom = gtk.gdk.atom_intern("paragraph")287 atom = Gdk.atom_intern("paragraph") 286 288 if self.snapto == SNAP_SECTION: 287 atom = gtk.gdk.atom_intern("section")289 atom = Gdk.atom_intern("section") 288 290 289 291 string = cPickle.dumps(a.getSelection()) 290 292 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import Gdk 6 from gi.repository import GObject 5 7 from Editable_Textbox import Editable_Textbox 6 8 7 class Editing_View( gtk.VBox ):9 class Editing_View( Gtk.VBox ): 8 10 """ 9 11 Created by Jonathan Mace 10 12 This class wraps an editable textbox into a scrollable window and 11 13 gives it a title. 12 14 """ 13 15 def __init__(self): 14 gtk.VBox.__init__(self)16 GObject.GObject.__init__(self) 15 17 self.set_border_width(0) 16 18 self.set_spacing(2) 17 19 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")) 20 22 self.pack_start(labeleb, False, False, 0) 21 23 labeleb.show() 22 24 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) 25 27 labeleb.add(self.articletitle) 26 28 self.articletitle.show() 27 29 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) 31 33 self.textwindow.show() 32 34 33 35 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk3 pygtk.require('2.0')4 import gtk2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 5 from gettext import gettext as _ 6 6 7 7 from Editing_View import Editing_View … … class Format_Pane(Editing_View): 22 22 self.toolitems = [] 23 23 24 24 """ 25 self.combocontainer = gtk.ToolItem()25 self.combocontainer = Gtk.ToolItem() 26 26 self.combocontainer.add(self.combobox) 27 27 self.toolbar.insert(self.combocontainer, -1) 28 28 self.combocontainer.show() 29 29 30 self.boldbutton = gtk.ToolButton(gtk.STOCK_BOLD)30 self.boldbutton = Gtk.ToolButton(Gtk.STOCK_BOLD) 31 31 self.boldbutton.set_expand(False) 32 32 self.toolbar.insert(self.boldbutton, -1) 33 33 self.boldbutton.show() 34 34 35 self.italicbutton = gtk.ToolButton(gtk.STOCK_ITALIC)35 self.italicbutton = Gtk.ToolButton(Gtk.STOCK_ITALIC) 36 36 self.italicbutton.set_expand(False) 37 37 self.toolbar.insert(self.italicbutton, -1) 38 38 self.italicbutton.show() 39 39 40 self.underlinebutton = gtk.ToolButton(gtk.STOCK_UNDERLINE)40 self.underlinebutton = Gtk.ToolButton(Gtk.STOCK_UNDERLINE) 41 41 self.underlinebutton.set_expand(False) 42 42 self.toolbar.insert(self.underlinebutton, -1) 43 43 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import Gdk 6 from gi.repository import GObject 5 7 import os 6 8 import cPickle 7 9 import logging … … import book 13 15 14 16 logger = logging.getLogger('infoslicer') 15 17 16 class Gallery_View( gtk.HBox ):18 class Gallery_View( Gtk.HBox ): 17 19 """ 18 20 Created by Christopher Leonard 19 21 Drag-and-drop methods added by Jonathan Mace … … class Gallery_View( gtk.HBox ): 33 35 34 36 def __init__(self): 35 37 self.image_list = [] 36 gtk.HBox.__init__(self)38 GObject.GObject.__init__(self) 37 39 38 40 self.current_index = -1 39 41 40 left_button = gtk.Button(label="\n\n << \n\n")42 left_button = Gtk.Button(label="\n\n << \n\n") 41 43 42 right_button = gtk.Button(label="\n\n >> \n\n")44 right_button = Gtk.Button(label="\n\n >> \n\n") 43 45 44 self.imagenumberlabel = gtk.Label()46 self.imagenumberlabel = Gtk.Label() 45 47 46 self.image = gtk.Image()48 self.image = Gtk.Image() 47 49 48 self.imagebox = gtk.EventBox()50 self.imagebox = Gtk.EventBox() 49 51 self.imagebox.add(self.image) 50 52 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) 52 56 self.imagebox.connect("drag-begin", self.drag_begin_event, None) 53 57 self.imagebox.connect("drag-data-get", self.drag_data_get_event, None) 54 58 55 self.caption = gtk.Label("")59 self.caption = Gtk.Label(label="") 56 60 self.caption.set_line_wrap(True) 57 61 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) 77 82 78 83 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) 82 87 83 88 self._source_article = None 84 89 self.show_all() … … class Gallery_View( gtk.HBox ): 99 104 self.current_index += 1 100 105 if self.current_index == len(self.image_list): 101 106 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]) 103 108 self.image.set_from_pixbuf(self.imagebuf) 104 109 self.caption.set_text("\n" + self.image_list[self.current_index][1]) 105 110 self.imagenumberlabel.set_text("(%d / %d)\n" % (self.current_index+1, len(self.image_list))) … … class Gallery_View( gtk.HBox ): 115 120 if self.current_index == 0: 116 121 self.current_index = len(self.image_list) 117 122 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]) 119 124 self.image.set_from_pixbuf(self.imagebuf) 120 125 self.caption.set_text("\n" + self.image_list[self.current_index][1]) 121 126 self.imagenumberlabel.set_text("(%d / %d)\n" % (self.current_index+1, len(self.image_list))) … … class Gallery_View( gtk.HBox ): 129 134 self.image.clear() 130 135 return 131 136 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]) 133 138 self.image.set_from_pixbuf(self.imagebuf) 134 139 self.caption.set_text("\n" + self.image_list[self.current_index][1]) 135 140 logger.debug("setting text to:") … … class Gallery_View( gtk.HBox ): 147 152 148 153 def drag_data_get_event(self, widget, context, selection_data, info, timestamp, data): 149 154 logger.debug("getting data") 150 atom = gtk.gdk.atom_intern("section")155 atom = Gdk.atom_intern("section") 151 156 imagedata = Picture_Data(self.source_article_id, 152 157 self.image_list[self.current_index][0], 153 158 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import Gdk 6 from gi.repository import GObject 5 7 import logging 6 8 from gettext import gettext as _ 7 9 … … from infoslicer.processing.Article import Article 11 13 12 14 logger = logging.getLogger('infoslicer') 13 15 14 class Image_Pane( gtk.HBox):16 class Image_Pane(Gtk.HBox): 15 17 """ 16 18 Created by Christopher Leonard 17 19 … … class Image_Pane(gtk.HBox): 23 25 """ 24 26 25 27 def __init__(self): 26 gtk.HBox.__init__(self)28 GObject.GObject.__init__(self) 27 29 self.toolitems = [] 28 30 29 gallery_box = gtk.VBox()31 gallery_box = Gtk.VBox() 30 32 gallery_box.show() 31 33 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")) 34 36 gallery_box.pack_start(labeleb, False, False, 0) 35 37 labeleb.show() 36 38 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) 39 41 labeleb.add(self.articletitle) 40 42 self.articletitle.show() 41 43 42 44 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) 45 47 46 self.pack_start(gallery_box, False )48 self.pack_start(gallery_box, False, False, 0) 47 49 self.editarticle = Editing_View() 48 self.pack_start(self.editarticle )50 self.pack_start(self.editarticle, True, True, 0) 49 51 self.editarticle.show_all() 50 52 51 53 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import GObject 5 6 from Readonly_Textbox import Readonly_Textbox 6 7 import logging 7 8 8 9 logger = logging.getLogger('infoslicer') 9 10 elogger = logging.getLogger('infoslicer::except') 10 11 11 class Reading_View( gtk.VBox ):12 class Reading_View( Gtk.VBox ): 12 13 """ 13 14 Created by Jonathan Mace 14 15 … … class Reading_View( gtk.VBox ): 21 22 """ 22 23 23 24 def __init__(self): 24 gtk.VBox.__init__(self)25 GObject.GObject.__init__(self) 25 26 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) 29 30 self.articlewindow.show() 30 31 31 32 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk3 pygtk.require('2.0')4 import gtk5 import pango2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import Pango 6 6 import cPickle 7 7 from Textbox import Textbox 8 8 … … class Readonly_Textbox( Textbox ): 24 24 self.use_as_drag_source = use_as_drag_source 25 25 self.set_mode(SELECT_SENTENCE) 26 26 self.block = True 27 self.modify_font( pango.FontDescription('arial 9'))27 self.modify_font(Pango.FontDescription('arial 9')) 28 28 29 29 30 30 def set_mode(self, mode): … … class Readonly_Textbox( Textbox ): 45 45 self.event_handlers.append(self.connect("drag-motion", self.drag_motion, None)) 46 46 47 47 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) 49 49 return True 50 50 51 51 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: 53 53 self.stop_emission("button_press_event") 54 54 return 55 55 if event.button == 3: … … class Readonly_Textbox( Textbox ): 156 156 a = self.article 157 157 158 158 if self.selectionmode == SELECT_SENTENCE: 159 atom = gtk.gdk.atom_intern("sentence")159 atom = Gdk.atom_intern("sentence") 160 160 if self.selectionmode == SELECT_PARAGRAPH: 161 atom = gtk.gdk.atom_intern("paragraph")161 atom = Gdk.atom_intern("paragraph") 162 162 if self.selectionmode == SELECT_SECTION: 163 atom = gtk.gdk.atom_intern("section")163 atom = Gdk.atom_intern("section") 164 164 165 165 string = cPickle.dumps(a.getSelection()) 166 166 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 1 1 # Copyright (C) IBM Corporation 2008 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 2 import gi 3 gi.require_version('Gtk', '3.0') 4 from gi.repository import Gtk 5 from gi.repository import GObject 6 from gi.repository import Pango 5 7 import cPickle 6 8 import pango 7 9 8 10 SELECT_SENTENCE, SELECT_PARAGRAPH, SELECT_SECTION, FULL_EDIT = range(4) 9 11 10 class Textbox( gtk.TextView ):12 class Textbox( Gtk.TextView ): 11 13 """ 12 14 Created by Jonathan Mace 13 15 The Textbox class is the base class for our own custom textboxes which implement … … class Textbox( gtk.TextView ): 19 21 20 22 21 23 def __init__(self): 22 gtk.TextView.__init__(self)24 GObject.GObject.__init__(self) 23 25 self.set_border_width(1) 24 26 self.event_handlers = [] 25 self.set_wrap_mode( gtk.WRAP_WORD)27 self.set_wrap_mode(Gtk.WrapMode.WORD) 26 28 self.set_cursor_visible(False) 27 29 self.set_editable(False) 28 self.modify_font( pango.FontDescription('arial 9'))30 self.modify_font(Pango.FontDescription('arial 9')) 29 31 self.article = None 30 32 self.set_property("left-margin", 5) 31 33 … … class Textbox( gtk.TextView ): 37 39 return self.article 38 40 39 41 def show(self): 40 gtk.TextView.show(self)42 Gtk.TextView.show(self) 41 43 42 44 def clear(self): 43 45 self.article.delete() … … class Textbox( gtk.TextView ): 51 53 52 54 def get_mouse_iter(self, x, y): 53 55 # 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) 55 57 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 12 12 # along with this program; if not, write to the Free Software 13 13 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 14 15 import gtk 15 from gi.repository import Gtk 16 from gi.repository import Gdk 17 from gi.repository import GObject 16 18 import logging 17 19 from threading import Timer 18 20 from datetime import datetime 19 21 from gettext import gettext as _ 20 22 import locale 21 23 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 24 from sugar3.graphics.toolbutton import ToolButton 25 from sugar3.graphics.toggletoolbutton import ToggleToolButton 26 from sugar3.graphics.toolcombobox import ToolComboBox 27 from sugar3.graphics.icon import Icon 28 from sugar3.datastore import datastore 29 import sugar3.graphics.style as style 29 30 from port.widgets import ToolWidget 30 31 31 32 import xol … … from infoslicer.widgets.Reading_View import Reading_View 36 37 37 38 logger = logging.getLogger('infoslicer') 38 39 39 class View( gtk.EventBox):40 class View(Gtk.EventBox): 40 41 def sync(self): 41 42 self.wiki.sync() 42 43 self.custom.sync() 43 44 44 45 def __init__(self, activity): 45 gtk.EventBox.__init__(self)46 GObject.GObject.__init__(self) 46 47 self.activity = activity 47 48 48 49 self.wiki = BookView(book.wiki, … … class View(gtk.EventBox): 53 54 # stubs for empty articles 54 55 55 56 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) 58 59 head_label_a.add(head_label) 59 60 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) 63 64 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) 68 69 return stub 69 70 70 71 wiki_stub = create_stub('white-search', … … class View(gtk.EventBox): 79 80 wiki_prefix = lang_code[0:2] + '.' 80 81 language_order = 0 81 82 order = 0 82 search_box = gtk.HBox()83 search_box = Gtk.HBox() 83 84 self.wikimenu = ToolComboBox(label_text=_('Get article from:')) 84 85 for i in sorted(WIKI.keys()): 85 86 self.wikimenu.combo.append_item(WIKI[i], i) … … class View(gtk.EventBox): 87 88 language_order = order 88 89 order = order + 1 89 90 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) 91 92 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) 94 95 self.searchentry.set_text(_("Article name")) 95 96 self.searchentry.select_region(0, -1) 96 97 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) 98 99 search_box.show_all() 99 100 100 self.searchbutton = gtk.Button(label=_('Search'))101 self.searchbutton = Gtk.Button(label=_('Search')) 101 102 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) 103 104 104 105 wiki_widget = Reading_View() 105 wiki = gtk.Notebook()106 wiki = Gtk.Notebook() 106 107 wiki.props.show_border = False 107 108 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) 110 111 111 self.progress = gtk.Label()112 self.progress = Gtk.Label() 112 113 #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) 115 116 #progress_box.pack_start(self.progress, False) 116 117 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) 123 124 124 125 custom_widget = Reading_View() 125 custom = gtk.Notebook()126 custom = Gtk.Notebook() 126 127 custom.props.show_border = False 127 128 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) 134 135 135 136 # workspace 136 137 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) 141 142 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) 146 147 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) 150 151 workspace.show_all() 151 152 152 153 self.add(workspace) -
net.py
diff --git a/net.py b/net.py index e3a13cf..968f407 100644
a b import urllib 18 18 import logging 19 19 from gettext import gettext as _ 20 20 21 from sugar .activity.activity import get_bundle_path21 from sugar3.activity.activity import get_bundle_path 22 22 23 23 import book 24 24 from infoslicer.processing.NewtifulSoup import NewtifulStoneSoup \ -
port/activity.py
diff --git a/port/activity.py b/port/activity.py index e3b6fdd..769a944 100644
a b 14 14 15 15 """Extend sugar-toolkit activity class""" 16 16 17 import gtk 17 from gi.repository import Gtk 18 from gi.repository import Gdk 18 19 import logging 19 20 import telepathy 20 import gobject21 from gi.repository import GObject 21 22 22 import sugar .activity.activity as toolkit23 from sugar .presence.sugartubeconn import SugarTubeConnection24 from sugar .graphics.alert import ConfirmationAlert, NotifyAlert23 import sugar3.activity.activity as toolkit 24 from sugar3.presence.sugartubeconn import SugarTubeConnection 25 from sugar3.graphics.alert import ConfirmationAlert, NotifyAlert 25 26 26 27 _NEW_INSTANCE = 0 27 28 _NEW_INSTANCE = 1 … … class CursorFactory: 36 37 37 38 def get_cursor(self, cur_type): 38 39 if not self.cursors.has_key(cur_type): 39 cur = gtk.gdk.Cursor(cur_type)40 cur = Gdk.Cursor.new(cur_type) 40 41 self.cursors[cur_type] = cur 41 42 return self.cursors[cur_type] 42 43 … … class Activity(toolkit.Activity): 108 109 109 110 def response(alert, response_id, self, cb, *cb_args): 110 111 self.remove_alert(alert) 111 if response_id is gtk.RESPONSE_OK:112 if response_id is Gtk.ResponseType.OK: 112 113 cb(*cb_args) 113 114 114 115 alert.connect('response', response, self, cb, *cb_args) … … class Activity(toolkit.Activity): 119 120 return self._cursor 120 121 121 122 def set_cursor(self, cursor): 122 if not isinstance(cursor, gtk.gdk.Cursor):123 if not isinstance(cursor, Gdk.Cursor): 123 124 cursor = CursorFactory().get_cursor(cursor) 124 125 125 126 if self._cursor != cursor: 126 127 self._cursor = cursor 127 self. window.set_cursor(self._cursor)128 self.get_window().set_cursor(self._cursor) 128 129 129 130 def __init__(self, canvas, handle): 130 131 """ 131 132 Initialise the Activity. 132 133 133 canvas -- gtk.Widget134 canvas -- Gtk.Widget 134 135 root widget for activity content 135 136 136 handle -- sugar .activity.activityhandle.ActivityHandle137 handle -- sugar3.activity.activityhandle.ActivityHandle 137 138 instance providing the activity id and access to the 138 139 presence service which *may* provide sharing for this 139 140 application … … class Activity(toolkit.Activity): 151 152 self.__on_save_instance = [] 152 153 153 154 self._cursor = None 154 self.set_cursor( gtk.gdk.LEFT_PTR)155 self.set_cursor(Gdk.CursorType.LEFT_PTR) 155 156 156 157 # XXX do it after(possible) read_file() invoking 157 158 # have to rely on calling read_file() from map_cb in sugar-toolkit … … class SharedActivity(Activity): 221 222 """ 222 223 Initialise the Activity. 223 224 224 canvas -- gtk.Widget225 canvas -- Gtk.Widget 225 226 root widget for activity content 226 227 227 228 service -- string 228 229 dbus service for activity 229 230 230 handle -- sugar .activity.activityhandle.ActivityHandle231 handle -- sugar3.activity.activityhandle.ActivityHandle 231 232 instance providing the activity id and access to the 232 233 presence service which *may* provide sharing for this 233 234 application … … class SharedActivity(Activity): 238 239 239 240 self.connect('shared', self._shared_cb) 240 241 242 # FIXME: I added this line on the Gtk3 port 243 self._shared_activity = False 244 241 245 # Owner.props.key 242 246 if self._shared_activity: 243 247 # We are joining the activity -
port/widgets.py
diff --git a/port/widgets.py b/port/widgets.py index ffcb2c6..0021bbb 100644
a b 12 12 # along with this program; if not, write to the Free Software 13 13 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 14 15 import gtk16 import gobject15 from gi.repository import Gtk 16 from gi.repository import GObject 17 17 import logging 18 18 19 from sugar .graphics import style20 from sugar .graphics.palette import CanvasInvoker,Palette21 from sugar .graphics import toolbutton22 from sugar .graphics import icon19 from sugar3.graphics import style 20 from sugar3.graphics.palette import Palette 21 from sugar3.graphics import toolbutton 22 from sugar3.graphics import icon 23 23 24 24 class ToolButton(toolbutton.ToolButton): 25 25 def __init__(self, 26 26 icon_name, 27 size= gtk.ICON_SIZE_SMALL_TOOLBAR,27 size=Gtk.IconSize.SMALL_TOOLBAR, 28 28 padding=None, 29 29 **kwargs): 30 30 … … class ToolButton(toolbutton.ToolButton): 33 33 image = icon.Icon(icon_name=icon_name, icon_size=size) 34 34 image.show() 35 35 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) 39 40 alignment.show() 40 41 alignment.add(image) 41 42 42 43 self.set_icon_widget(alignment) 43 44 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 } 46 47 47 48 if padding is not None and sizes.has_key(size): 48 49 button_size = sizes[size] + style.DEFAULT_SPACING + padding 49 50 self.set_size_request(button_size, button_size) 50 51 51 class ToolWidget( gtk.ToolItem):52 class ToolWidget(Gtk.ToolItem): 52 53 def __init__(self, widget): 53 gtk.ToolItem.__init__(self)54 GObject.GObject.__init__(self) 54 55 self.add(widget) 55 56 widget.show() -
setup.py
diff --git a/setup.py b/setup.py index bb74f5a..83abd2a 100755
a b 14 14 # along with this program; if not, write to the Free Software 15 15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 16 17 from sugar .activity import bundlebuilder17 from sugar3.activity import bundlebuilder 18 18 if __name__ == "__main__": 19 19 bundlebuilder.start() 20 20 -
toolbar.py
diff --git a/toolbar.py b/toolbar.py index 811f93a..dbb2101 100644
a b 12 12 # along with this program; if not, write to the Free Software 13 13 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 14 14 15 import gtk16 import gobject15 from gi.repository import Gtk 16 from gi.repository import GObject 17 17 18 from sugar .graphics.icon import Icon19 import sugar .graphics.style as style18 from sugar3.graphics.icon import Icon 19 import sugar3.graphics.style as style 20 20 21 class WidgetItem( gtk.ToolItem):21 class WidgetItem(Gtk.ToolItem): 22 22 def __init__(self, widget): 23 gtk.ToolItem.__init__(self)23 GObject.GObject.__init__(self) 24 24 self.add(widget) 25 25 widget.show() 26 26 27 class ButtonItem( gtk.ToolButton):28 def __init__(self, icon_name, size= gtk.ICON_SIZE_SMALL_TOOLBAR, **kwargs):29 gobject.GObject.__init__(self, **kwargs)27 class ButtonItem(Gtk.ToolButton): 28 def __init__(self, icon_name, size=Gtk.IconSize.SMALL_TOOLBAR, **kwargs): 29 GObject.GObject.__init__(self, **kwargs) 30 30 31 31 icon = Icon(icon_name=icon_name, icon_size=size) 32 # The alignment is a hack to work around gtk.ToolButton code33 # that sets the icon_size when the icon_widget is a gtk.Image34 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) 35 35 alignment.add(icon) 36 36 self.set_icon_widget(alignment) 37 37 38 if size == gtk.ICON_SIZE_SMALL_TOOLBAR:38 if size == Gtk.IconSize.SMALL_TOOLBAR: 39 39 button_size = style.SMALL_ICON_SIZE + 8 40 40 self.set_size_request(button_size, button_size) -
xol.py
diff --git a/xol.py b/xol.py index f9eeb73..0796b1e 100644
a b 15 15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 16 17 17 import os 18 import gtk18 from gi.repository import Gtk 19 19 import zipfile 20 20 import uuid 21 21 import logging … … import parse 23 23 from glob import glob 24 24 from gettext import gettext as _ 25 25 26 from sugar .activity.activity import get_bundle_path, get_activity_root, get_bundle_name27 from sugar .datastore import datastore28 from sugar import activity26 from sugar3.activity.activity import get_bundle_path, get_activity_root, get_bundle_name 27 from sugar3.datastore import datastore 28 from sugar3 import activity 29 29 30 30 from infoslicer.processing.NewtifulSoup import NewtifulStoneSoup \ 31 31 as BeautifulStoneSoup