Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2012-07-17 13:10:40 (GMT)
committer Manuel Kaufmann <humitos@gmail.com>2012-07-17 13:10:40 (GMT)
commitc6af5a1adbb570bd0eb21e52d97baa159acf21ed (patch)
treedeeb9f23446eb4a73ad104ada0bfffb291889a18 /activity.py
parent6ea76d7716a86122f8bd02b3d9bd30ed7fc94b17 (diff)
Port to Gtk3 SL #3742
The activity is almost ported but there are some issues that should be solved in the future. Some of them are bugs already reported into pygobject bug tracker. - Drag and Drop Images from the Edit View is not working properly. The image is added twice - The arrow added into the cursor position after drag-n-drop an image to the article is not shown - On "Home View" we are not able to move the articles up or down NOTE: line 104 and 112 of "sugar3/graphics/palette.py" should be commented because Pango.EllipsizeMode.(MIDDLE|END) is not found
Diffstat (limited to 'activity.py')
-rw-r--r--activity.py138
1 files changed, 55 insertions, 83 deletions
diff --git a/activity.py b/activity.py
index 46cf2ad..fa94eab 100644
--- a/activity.py
+++ b/activity.py
@@ -12,34 +12,27 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-import gtk
+from gi.repository import Gtk
+from gi.repository import GObject
from gettext import gettext as _
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.toggletoolbutton import ToggleToolButton
-from sugar.activity.activity import ActivityToolbox
-from sugar.activity import activity
+GObject.threads_init()
-OLD_TOOLBAR = False
-try:
- from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
- from sugar.activity.widgets import StopButton
- from sugar.graphics.radiotoolbutton import RadioToolButton
- from sugar.activity.widgets import ActivityToolbarButton
-except ImportError:
- OLD_TOOLBAR = True
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.graphics.toggletoolbutton import ToggleToolButton
+from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
+from sugar3.activity.widgets import StopButton
+from sugar3.activity import activity
+from sugar3.graphics.radiotoolbutton import RadioToolButton
+from sugar3.activity.widgets import ActivityToolbarButton
import library
import edit
import book
-gtk.gdk.threads_init()
-gtk.gdk.threads_enter()
-
-
class InfoslicerActivity(activity.Activity):
def __init__(self, handle):
- self.notebook = gtk.Notebook()
+ self.notebook = Gtk.Notebook()
self.notebook.show()
self.notebook.props.show_border = False
self.notebook.props.show_tabs = False
@@ -60,71 +53,52 @@ class InfoslicerActivity(activity.Activity):
self.edit = edit.View()
self.library = library.View(self)
- if OLD_TOOLBAR:
- self.edit_toolbar = gtk.Toolbar()
- self.edit_bar = edit.ToolbarBuilder(self.edit, self.edit_toolbar)
- self.edit_toolbar.show_all()
-
- self.library_toolbar = gtk.Toolbar()
- self.library_bar = library.ToolbarBuilder(self.library,
- self.library_toolbar)
- self.library_toolbar.show_all()
-
- toolbox = ActivityToolbox(self)
- toolbox.connect('current-toolbar-changed',
- self._toolbar_changed_cb)
- self.set_toolbox(toolbox)
- toolbox.add_toolbar(_('Library'), self.library_toolbar)
- toolbox.add_toolbar(_('Edit'), self.edit_toolbar)
- toolbox.set_current_toolbar(1)
- else:
- toolbar_box = ToolbarBox()
- activity_button = ActivityToolbarButton(self)
- toolbar_box.toolbar.insert(activity_button, 0)
- self.set_toolbar_box(toolbar_box)
- self._toolbar = toolbar_box.toolbar
-
- tool_group = None
- search_button = RadioToolButton()
- search_button.props.group = tool_group
- tool_group = search_button
- search_button.props.icon_name = 'white-search'
- search_button.set_tooltip(_('Library'))
- search_button.mode = 'search'
- search_button.connect('clicked', self.__mode_button_clicked)
- self._toolbar.insert(search_button, -1)
-
- edit_button = RadioToolButton()
- edit_button.props.group = tool_group
- edit_button.props.icon_name = 'toolbar-edit'
- edit_button.set_tooltip(_('Edit'))
- edit_button.mode = 'edit'
- edit_button.connect('clicked', self.__mode_button_clicked)
- self._toolbar.insert(edit_button, -1)
- self._toolbar.insert(gtk.SeparatorToolItem(), -1)
- self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar)
- self.library_bar = library.ToolbarBuilder(self.library,
- activity_button)
- self.library_bar.publish.show()
-
- edit_fake = gtk.EventBox()
-
- self.notebook.append_page(self.library)
- self.notebook.append_page(self.edit)
- self.notebook.append_page(edit_fake)
+ toolbar_box = ToolbarBox()
+ activity_button = ActivityToolbarButton(self)
+ toolbar_box.toolbar.insert(activity_button, 0)
+ self.set_toolbar_box(toolbar_box)
+ self._toolbar = toolbar_box.toolbar
+
+ tool_group = None
+ search_button = RadioToolButton()
+ search_button.props.group = tool_group
+ tool_group = search_button
+ search_button.props.icon_name = 'white-search'
+ search_button.set_tooltip(_('Library'))
+ search_button.mode = 'search'
+ search_button.connect('clicked', self.__mode_button_clicked)
+ self._toolbar.insert(search_button, -1)
+
+ edit_button = RadioToolButton()
+ edit_button.props.group = tool_group
+ edit_button.props.icon_name = 'toolbar-edit'
+ edit_button.set_tooltip(_('Edit'))
+ edit_button.mode = 'edit'
+ edit_button.connect('clicked', self.__mode_button_clicked)
+ self._toolbar.insert(edit_button, -1)
+ self._toolbar.insert(Gtk.SeparatorToolItem(), -1)
+ self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar)
+ self.library_bar = library.ToolbarBuilder(self.library,
+ activity_button)
+ self.library_bar.publish.show()
+
+ edit_fake = Gtk.EventBox()
+
+ self.notebook.append_page(self.library, None)
+ self.notebook.append_page(self.edit, None)
+ self.notebook.append_page(edit_fake, None)
self.show_all()
- if not OLD_TOOLBAR:
- self.__mode_button_clicked(search_button)
- separator = gtk.SeparatorToolItem()
- separator.props.draw = False
- separator.set_expand(True)
- separator.show()
- self._toolbar.insert(separator, -1)
- stop_button = StopButton(self)
- stop_button.show()
- self._toolbar.insert(stop_button, -1)
+ self.__mode_button_clicked(search_button)
+ separator = Gtk.SeparatorToolItem()
+ separator.props.draw = False
+ separator.set_expand(True)
+ separator.show()
+ self._toolbar.insert(separator, -1)
+ stop_button = StopButton(self)
+ stop_button.show()
+ self._toolbar.insert(stop_button, -1)
def new_instance(self):
self.instance()
@@ -138,9 +112,7 @@ class InfoslicerActivity(activity.Activity):
book.custom.sync(filepath)
def set_edit_sensitive(self, enable):
- if OLD_TOOLBAR:
- #self.edit_toolbar.props.sensitive = enable
- self.edit_page = (enable and 1 or 2)
+ pass
def _toolbar_changed_cb(self, widget, index):
if index > 0: