Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-02-24 23:55:48 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-03-02 06:29:54 (GMT)
commit766eed3bf106a9ada4c15fdcc2847704c8f6f77a (patch)
tree9da210a64a22213229d2d02539b1e164a4970977
parentfe6730ffdaabf68f10b041ba2cf1e5311bb1e391 (diff)
Unwind tabs
-rw-r--r--COPYING (renamed from LICENSE.txt)0
-rw-r--r--GUI_Components/Pane.py8
-rw-r--r--Infoslicer_GUI.py154
-rw-r--r--README (renamed from INFO.txt)0
-rw-r--r--activity.py78
-rw-r--r--activity/activity.info5
-rw-r--r--[-rwxr-xr-x]activity/slicelogo.svg0
-rw-r--r--document.py87
-rw-r--r--edit.py37
-rw-r--r--library.py61
-rw-r--r--shared.py131
-rw-r--r--sugaractivity.py139
12 files changed, 403 insertions, 297 deletions
diff --git a/LICENSE.txt b/COPYING
index 63e41a4..63e41a4 100644
--- a/LICENSE.txt
+++ b/COPYING
diff --git a/GUI_Components/Pane.py b/GUI_Components/Pane.py
index ab1560c..033dfb8 100644
--- a/GUI_Components/Pane.py
+++ b/GUI_Components/Pane.py
@@ -9,7 +9,11 @@ class Pane:
An instance of the Pane class has a panel which is the main view,
a toolbar which interacts with the panel,
and methods for getting and setting the source and working articles.
-
+
+ - name
+ - toolbar
+ - panel
+
"""
def __init__(self):
@@ -29,4 +33,4 @@ class Pane:
return self.source
def set_source_article(self, article):
- self.source = article \ No newline at end of file
+ self.source = article
diff --git a/Infoslicer_GUI.py b/Infoslicer_GUI.py
deleted file mode 100644
index 5d432e6..0000000
--- a/Infoslicer_GUI.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# Copyright (C) IBM Corporation 2008
-
-import pygtk
-import sys
-pygtk.require('2.0')
-import gtk
-import time
-import platform
-from GUI_Components.Edit_Pane import Edit_Pane
-from GUI_Components.Format_Pane import Format_Pane
-from GUI_Components.Library_Pane import Library_Pane
-from GUI_Components.Image_Pane import Image_Pane
-from GUI_Components.Publish_Pane import Publish_Pane
-from Processing.Article.Article import Article
-from Processing.IO_Manager import IO_Manager
-import logging
-
-logger = logging.getLogger('infoslicer')
-
-class Infoslicer_GUI:
- """
- Created by Jonathan Mace
-
- This is an abstract class. Whichever platform decides to run the app
- must created a subclass of this class.
-
- """
-
- def __init__(self):
- logger.info(
- "InfoSlicer version 0.1, Copyright (C) 2008 IBM Corporation; " \
- "InfoSlicer comes with ABSOLUTELY NO WARRANTY; " \
- "for details see LICENSE.txt file.")
- self.__set_up_GUI()
-
- def setpanel(self, panel):
- """
- This method sets the main display to the panel specified.
- """
- pass
-
- def clearpanel(self):
- """
- This method clears the main display (if setpanel does not clear it before setting)
- """
- pass
-
- def settoolbars(self):
- """
- This method sets the toolbars. Toolbars are stored in self.toolbars and the
- corresponding toolbar names are stored in self.toolbarnames
- """
- pass
-
- def switch_page(self, page_num):
- """
- This method sets the current page to page_num when called.
- """
- pass
-
- """
- Change tab shown and available to the user.
- """
- def mode_switched(self, mode):
- # Mode is the index of the tab that has been switched to
- if self.currentindex != mode:
- pane = self.panes[mode]
- if self.currentpane != None:
- self.source = self.currentpane.get_source_article()
- self.working = self.currentpane.get_working_article()
- pane.set_source_article(self.source)
- pane.set_working_article(self.working)
- self.clearpanel()
- self.setpanel(pane.panel)
- self.currentpane = pane
- self.currentindex = mode
-
- def __set_up_GUI(self):
- # Set up dummy library if appropriate
- running_on = platform.system()
- if running_on == "Linux" and "olpc" in platform.platform().lower():
- themes = IO_Manager().get_themes()
- if themes == []:
- IO_Manager().install_library()
- # Instantiate the panels to be displayed by the GUI
- self.library = Library_Pane()
- self.panes = [self.library,
- Edit_Pane(),
- Format_Pane(),
- Image_Pane(),
- Publish_Pane()]
-
- # Create the original and edited articles to be used by the GUI
-
- self.source = Article()
- self.working = Article()
- ignore = False
-
-
- themes = IO_Manager().get_themes()
- if _("Wikipedia Articles") in themes:
- i = themes.index(_("Wikipedia Articles"))
- del themes[i]
-
- wikiarticles = IO_Manager().get_pages_in_theme(_("Wikipedia Articles"))
- for theme in themes:
- articles = IO_Manager().get_pages_in_theme(theme)
- for article in articles:
- if ignore == True:
- break
- for wikiarticle in wikiarticles:
- if article in wikiarticle:
- self.source = IO_Manager().load_article(wikiarticle, _("Wikipedia Articles"))
- self.working = IO_Manager().load_article(article, theme)
- logger.debug("loading source %s from %s" %
- (wikiarticle, "Wikipedia Articles"))
- logger.debug("loading edit %s from %s" %
- (article, theme))
- ignore = True
-
- self.currentpane = None
-
- self.library.panel.connect("key-press-event", self.go_arrange_mode, None)
-
- # Add toolbars and panels but keep hidden]
- toolbars = [pane.toolbar for pane in self.panes]
- toolbarnames = [pane.name for pane in self.panes]
- self.settoolbars(toolbars, toolbarnames)
-
- # Set the current index to -1 so that the first pane will always be shown
- self.currentindex = -1
-
- """
- Respond to function key presses
- """
- def go_arrange_mode(self, widget, event, data):
- key = event.keyval
- if key == gtk.keysyms.F1:
- logger.debug("f1")
- self.switch_page(0)
- if key == gtk.keysyms.F2:
- logger.debug("f2")
- self.switch_page(1)
- if key == gtk.keysyms.F3:
- logger.debug("f3")
- self.switch_page(2)
-
- """
- Save and quit current article
- """
- def do_quit_event(self):
- logger.debug("quitting")
- article = self.currentpane.get_working_article()
- IO_Manager().save_article(article)
diff --git a/INFO.txt b/README
index aedfd0b..aedfd0b 100644
--- a/INFO.txt
+++ b/README
diff --git a/activity.py b/activity.py
new file mode 100644
index 0000000..4b6188e
--- /dev/null
+++ b/activity.py
@@ -0,0 +1,78 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import gtk
+from gettext import gettext as _
+
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.toggletoolbutton import ToggleToolButton
+from sugar.activity.activity import ActivityToolbox
+
+from shared import SharedActivity
+import library
+import edit
+
+gtk.gdk.threads_init()
+gtk.gdk.threads_enter()
+
+class InfoslicerActivity(SharedActivity):
+ def __init__(self, handle):
+ self.notebook = gtk.Notebook()
+ SharedActivity.__init__(self, self.notebook, 'SERVICE', handle)
+
+ self.connect('init', self._init_cb)
+ self.connect('tube', self._tube_cb)
+
+ self.notebook.show()
+ self.notebook.props.show_border = False
+ self.notebook.props.show_tabs = False
+
+ self.library = library.View()
+ self.library.show()
+ self.notebook.append_page(self.library)
+
+ self.edit = edit.View()
+ self.edit.show()
+ self.notebook.append_page(self.edit)
+
+ toolbox = ActivityToolbox(self)
+ toolbox.show()
+ toolbox.connect('current-toolbar-changed', self._toolbar_changed_cb)
+ self.set_toolbox(toolbox)
+
+ library_bar = library.Toolbar(self.library)
+ library_bar.show()
+ toolbox.add_toolbar(_('Library'), library_bar)
+
+ edit_bar = edit.Toolbar(self.edit)
+ edit_bar.show()
+ toolbox.add_toolbar(_('Edit'), edit_bar)
+
+ toolbox.set_current_toolbar(1)
+
+ def read_file(self, filepath):
+ pass
+
+ def write_file(self, filepath):
+ pass
+
+ def _init_cb(self, sender):
+ pass
+
+ def _tube_cb(self, activity, tube_conn, initiating):
+ pass
+
+ def _toolbar_changed_cb(self, widget, index):
+ if index > 0:
+ self.notebook.set_current_page(index-1)
diff --git a/activity/activity.info b/activity/activity.info
index 51bb6d2..fe0dc74 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -2,7 +2,8 @@
name = InfoSlicer
activity_version = 2
host_version = 1
+bundle_id = org.sugarlabs.InfoSlicer
icon = slicelogo
-bundle_id = org.sugarlabs.infoslicer
-exec = sugar-activity sugaractivity.sugaractivity
+exec = sugar-activity activity.InfoslicerActivity -s
show_launcher = yes
+license = GPLv2+
diff --git a/activity/slicelogo.svg b/activity/slicelogo.svg
index 49e7786..49e7786 100755..100644
--- a/activity/slicelogo.svg
+++ b/activity/slicelogo.svg
diff --git a/document.py b/document.py
new file mode 100644
index 0000000..204d34f
--- /dev/null
+++ b/document.py
@@ -0,0 +1,87 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+from gettext import gettext as _
+
+def read_file(self, file_path):
+ logger.debug("reading the file")
+ """
+ At the moment, the format of a saved file will just be:
+ sourcetitle
+ edittitle
+ edittheme
+ currentindex
+ """
+
+ file = open(file_path, 'r')
+ text = file.read()
+ file.close()
+ lines = text.splitlines()
+ if len(lines) < 3:
+ return
+ sourcetitle = lines[0]
+ workingtitle = lines[1]
+ workingtheme = lines[2]
+ currentindex = int(lines[3])
+
+ logger.debug("file read")
+ logger.debug("sourcetitle: %s, workingtitle: %s," \
+ "workingtheme: %s, currentindex: %s" %
+ (sourcetitle, workingtitle, workingtheme, currentindex))
+
+ iomanager = IO_Manager()
+ if iomanager.page_exists(sourcetitle, "Wikipedia Articles"):
+ sourcearticle = iomanager.load_article(sourcetitle, "Wikipedia Articles")
+ else:
+ sourcearticle = Article()
+ sourcearticle.article_title = sourcetitle
+ sourcearticle.article_theme = "Wikipedia Articles"
+ if iomanager.page_exists(workingtitle, workingtheme):
+ workingarticle = iomanager.load_article(workingtitle, workingtheme)
+ else:
+ workingarticle = Article()
+ workingarticle.article_title = workingtitle
+ workingarticle.article_theme = workingtheme
+
+ self.switch_page(currentindex)
+
+ self.currentpane.set_source_article(sourcearticle)
+ self.currentpane.set_working_article(workingarticle)
+
+def write_file(self, file_path):
+ #article = self.currentpane.get_working_article()
+ #IO_Manager().save_article(article)
+
+ logger.debug("writing the file to %s" % file_path)
+ sourcearticle = self.currentpane.get_source_article()
+ workingarticle = self.currentpane.get_working_article()
+
+ sourcetitle = sourcearticle.article_title
+ if not sourcetitle:
+ sourcetitle = "none"
+ workingtitle = workingarticle.article_title
+ if not workingtitle:
+ workingtitle = "none"
+ workingtheme = workingarticle.article_theme
+ if not workingtheme:
+ workingtheme = "none"
+ currentindex = self.currentindex
+
+ file = open(file_path, 'w')
+ logger.debug("writing source: %s, working: %s, theme: %s" %
+ (sourcetitle, workingtitle, workingtheme))
+ file.write("%s\n%s\n%s\n%s" % (sourcetitle, workingtitle, workingtheme, str(currentindex)))
+ file.close()
+
+
diff --git a/edit.py b/edit.py
new file mode 100644
index 0000000..8f6071d
--- /dev/null
+++ b/edit.py
@@ -0,0 +1,37 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import gtk
+from gettext import gettext as _
+
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.toggletoolbutton import ToggleToolButton
+from sugar.activity.activity import ActivityToolbox
+
+from GUI_Components.Edit_Pane import Edit_Pane
+from GUI_Components.Format_Pane import Format_Pane
+from GUI_Components.Image_Pane import Image_Pane
+
+class View(gtk.EventBox):
+ def __init__(self):
+ gtk.EventBox.__init__(self)
+
+ self.pane = Edit_Pane()
+ self.pane.panel.show()
+ self.add(self.pane.panel)
+
+class Toolbar(gtk.Toolbar):
+ def __init__(self, edit):
+ gtk.Toolbar.__init__(self)
+ self.edit = edit
diff --git a/library.py b/library.py
new file mode 100644
index 0000000..9b71f69
--- /dev/null
+++ b/library.py
@@ -0,0 +1,61 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import gtk
+from gettext import gettext as _
+
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.toggletoolbutton import ToggleToolButton
+from sugar.activity.activity import ActivityToolbox
+
+from GUI_Components.Library_Pane import Library_Pane
+
+class View(gtk.EventBox):
+ def __init__(self):
+ gtk.EventBox.__init__(self)
+
+ self.pane = Library_Pane()
+ self.pane.panel.show()
+ self.add(self.pane.panel)
+
+ """
+ # Set up dummy library if appropriate
+ IO_Manager().install_library()
+
+ themes = IO_Manager().get_themes()
+ if "Wikipedia Articles" in themes:
+ i = themes.index("Wikipedia Articles")
+ del themes[i]
+
+ wikiarticles = IO_Manager().get_pages_in_theme("Wikipedia Articles")
+ for theme in themes:
+ articles = IO_Manager().get_pages_in_theme(theme)
+ for article in articles:
+ if ignore == True:
+ break
+ for wikiarticle in wikiarticles:
+ if article in wikiarticle:
+ self.source = IO_Manager().load_article(wikiarticle, "Wikipedia Articles")
+ self.working = IO_Manager().load_article(article, theme)
+ logger.debug("loading source %s from %s" %
+ (wikiarticle, "Wikipedia Articles"))
+ logger.debug("loading edit %s from %s" %
+ (article, theme))
+ ignore = True
+ """
+
+class Toolbar(gtk.Toolbar):
+ def __init__(self, library):
+ gtk.Toolbar.__init__(self)
+ self.library = library
diff --git a/shared.py b/shared.py
new file mode 100644
index 0000000..c03c713
--- /dev/null
+++ b/shared.py
@@ -0,0 +1,131 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import logging
+import telepathy
+from gobject import property, SIGNAL_RUN_FIRST, TYPE_PYOBJECT
+
+from sugar.activity.activity import Activity
+from sugar.presence.sugartubeconn import SugarTubeConnection
+
+logger = logging.getLogger('infoslicer')
+
+class CanvasActivity(Activity):
+ __gsignals__ = {
+ 'init' : (SIGNAL_RUN_FIRST, None, []) }
+
+ def __init__(self, canvas, *args):
+ Activity.__init__(self, *args)
+
+ self._inited = False
+
+ # XXX do it after(possible) read_file() invoking
+ # have to rely on calling read_file() from map_cb in sugar-toolkit
+ canvas.connect_after('map', self._map_canvasactivity_cb)
+ self.set_canvas(canvas)
+
+ def get_inited(self):
+ return self._inited
+
+ inited = property(type=bool, default=False, getter=get_inited, setter=None)
+
+ def _map_canvasactivity_cb(self, widget):
+ self._inited = True
+ self.emit('init')
+ return False
+
+class SharedActivity(CanvasActivity):
+ __gsignals__ = {
+ 'tube' : (SIGNAL_RUN_FIRST, None, 2*[TYPE_PYOBJECT]) }
+
+ def __init__(self, canvas, service, *args):
+ CanvasActivity.__init__(self, canvas, *args)
+
+ self.service = service
+ self._postpone_tubes = []
+
+ self.connect_after('init', self._init_sharedactivity_cb)
+ self.connect('shared', self._shared_cb)
+
+ # Owner.props.key
+ if self._shared_activity:
+ # We are joining the activity
+ self.connect('joined', self._joined_cb)
+ if self.get_shared():
+ # We've already joined
+ self._joined_cb()
+
+ def _init_sharedactivity_cb(self, sender):
+ for i in self._postpone_tubes:
+ self.emit('tube', i, self._initiating)
+ self._postpone_tubes = []
+
+ def _shared_cb(self, activity):
+ logger.debug('My activity was shared')
+ self._initiating = True
+ self._sharing_setup()
+
+ logger.debug('This is my activity: making a tube...')
+ id = self._tubes_chan[telepathy.CHANNEL_TYPE_TUBES].OfferDBusTube(
+ self.service, {})
+
+ def _joined_cb(self, activity):
+ if not self._shared_activity:
+ return
+
+ logger.debug('Joined an existing shared activity')
+
+ self._initiating = False
+ self._sharing_setup()
+
+ logger.debug('This is not my activity: waiting for a tube...')
+ self._tubes_chan[telepathy.CHANNEL_TYPE_TUBES].ListTubes(
+ reply_handler=self._list_tubes_reply_cb,
+ error_handler=self._list_tubes_error_cb)
+
+ def _sharing_setup(self):
+ if self._shared_activity is None:
+ logger.error('Failed to share or join activity')
+ return
+ self._conn = self._shared_activity.telepathy_conn
+ self._tubes_chan = self._shared_activity.telepathy_tubes_chan
+ self._text_chan = self._shared_activity.telepathy_text_chan
+
+ self._tubes_chan[telepathy.CHANNEL_TYPE_TUBES].connect_to_signal('NewTube', self._new_tube_cb)
+
+ def _list_tubes_reply_cb(self, tubes):
+ for tube_info in tubes:
+ self._new_tube_cb(*tube_info)
+
+ def _list_tubes_error_cb(self, e):
+ logger.error('ListTubes() failed: %s', e)
+
+ def _new_tube_cb(self, id, initiator, type, service, params, state):
+ logger.debug('New tube: ID=%d initator=%d type=%d service=%s '
+ 'params=%r state=%d', id, initiator, type, service,
+ params, state)
+
+ if (type == telepathy.TUBE_TYPE_DBUS and
+ service == self.service):
+ if state == telepathy.TUBE_STATE_LOCAL_PENDING:
+ self._tubes_chan[telepathy.CHANNEL_TYPE_TUBES].AcceptDBusTube(id)
+
+ tube_conn = SugarTubeConnection(self._conn,
+ self._tubes_chan[telepathy.CHANNEL_TYPE_TUBES],
+ id, group_iface=self._text_chan[telepathy.CHANNEL_INTERFACE_GROUP])
+
+ if self.get_inited():
+ self.emit('tube', tube_conn, self._initiating)
+ else:
+ self._postpone_tubes.append(tube_conn)
diff --git a/sugaractivity.py b/sugaractivity.py
deleted file mode 100644
index 116412c..0000000
--- a/sugaractivity.py
+++ /dev/null
@@ -1,139 +0,0 @@
-# Copyright (C) IBM Corporation 2008
-
-import gtk
-from Infoslicer_GUI import Infoslicer_GUI
-from sugar.activity import activity
-from gettext import gettext as _
-from Processing.IO_Manager import IO_Manager
-from Processing.Article.Article import Article
-import logging
-
-logger = logging.getLogger('infoslicer')
-
-class sugaractivity( activity.Activity, Infoslicer_GUI ):
- """
- Created by Jonathan Mace
-
- This is the Sugar implementation of the infoslicer GUI.
-
- It sets things in the sugar.activity class in the abstract methods.
- """
-
- """
- Set up Sugar specific GUI config and show interface
- """
- def __init__(self, handle):
- activity.Activity.__init__(self, handle)
- gtk.gdk.threads_init()
- gtk.gdk.threads_enter()
- self.toolbox = activity.ActivityToolbox(self)
- Infoslicer_GUI.__init__(self)
- self._name = handle
- self.toolbox.connect("current-toolbar-changed", self.page_switched, None)
-
- self.set_title(_('InfoSlicer'))
-
- self.set_toolbox(self.toolbox)
- self.toolbox.show()
-
- self.show_all()
- self.toolbox.set_current_toolbar(2)
-
- logger.debug("dictionary:")
- logger.debug(handle.get_dict())
-
- """
- Operating system specific file reading and writing methods are below
- """
- def read_file(self, file_path):
- logger.debug("reading the file")
- """
- At the moment, the format of a saved file will just be:
- sourcetitle
- edittitle
- edittheme
- currentindex
- """
-
- file = open(file_path, 'r')
- text = file.read()
- file.close()
- lines = text.splitlines()
- if len(lines) < 3:
- return
- sourcetitle = lines[0]
- workingtitle = lines[1]
- workingtheme = lines[2]
- currentindex = int(lines[3])
-
- logger.debug("file read")
- logger.debug("sourcetitle: %s, workingtitle: %s," \
- "workingtheme: %s, currentindex: %s" %
- (sourcetitle, workingtitle, workingtheme, currentindex))
-
- iomanager = IO_Manager()
- if iomanager.page_exists(sourcetitle, _("Wikipedia Articles")):
- sourcearticle = iomanager.load_article(sourcetitle, _("Wikipedia Articles"))
- else:
- sourcearticle = Article()
- sourcearticle.article_title = sourcetitle
- sourcearticle.article_theme = _("Wikipedia Articles")
- if iomanager.page_exists(workingtitle, workingtheme):
- workingarticle = iomanager.load_article(workingtitle, workingtheme)
- else:
- workingarticle = Article()
- workingarticle.article_title = workingtitle
- workingarticle.article_theme = workingtheme
-
- self.switch_page(currentindex)
-
- self.currentpane.set_source_article(sourcearticle)
- self.currentpane.set_working_article(workingarticle)
-
- def write_file(self, file_path):
- logger.debug("writing the file to %s" % file_path)
- sourcearticle = self.currentpane.get_source_article()
- workingarticle = self.currentpane.get_working_article()
-
- sourcetitle = sourcearticle.article_title
- if not sourcetitle:
- sourcetitle = "none"
- workingtitle = workingarticle.article_title
- if not workingtitle:
- workingtitle = "none"
- workingtheme = workingarticle.article_theme
- if not workingtheme:
- workingtheme = "none"
- currentindex = self.currentindex
-
- file = open(file_path, 'w')
- logger.debug("writing source: %s, working: %s, theme: %s" %
- (sourcetitle, workingtitle, workingtheme))
- file.write("%s\n%s\n%s\n%s" % (sourcetitle, workingtitle, workingtheme, str(currentindex)))
- file.close()
-
-
-
- def settoolbars(self, toolbars, toolbarnames):
- for i in range(0, len(toolbars)):
- self.toolbox.add_toolbar(toolbarnames[i], toolbars[i])
- toolbars[i].show()
-
-
- def setpanel(self, panel):
- self._main_view = panel
- self.set_canvas(self._main_view)
- self._main_view.show()
-
-
- def page_switched(self, widget, page_num, data):
- logger.debug("page_switched to %s" % (page_num))
- if page_num > 0:
- self.mode_switched(page_num - 1)
-
- def switch_page(self, page_num):
- self.mode_switched(page_num)
-
- def can_close(self):
- self.do_quit_event()
- return True