2009-08-12 11:26:26 +02:00
|
|
|
# Copyright (C) 2009, Aleksey Lim, Simon Schampijer
|
2012-01-31 22:00:22 +01:00
|
|
|
# Copyright (C) 2012, Walter Bender
|
|
|
|
# Copyright (C) 2012, One Laptop Per Child
|
2009-07-30 17:08:55 +02:00
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library 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
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the
|
|
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
# Boston, MA 02111-1307, USA.
|
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
from gi.repository import Gdk
|
|
|
|
from gi.repository import Gtk
|
2009-07-30 17:08:55 +02:00
|
|
|
import gettext
|
2011-11-15 19:29:07 +01:00
|
|
|
from gi.repository import GConf
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2011-10-29 10:44:18 +02:00
|
|
|
from sugar3.graphics.toolbutton import ToolButton
|
|
|
|
from sugar3.graphics.toolbarbox import ToolbarButton
|
|
|
|
from sugar3.graphics.radiopalette import RadioPalette, RadioMenuButton
|
|
|
|
from sugar3.graphics.radiotoolbutton import RadioToolButton
|
|
|
|
from sugar3.graphics.xocolor import XoColor
|
|
|
|
from sugar3.graphics.icon import Icon
|
|
|
|
from sugar3.bundle.activitybundle import ActivityBundle
|
2012-01-31 22:00:22 +01:00
|
|
|
from sugar3.graphics import style
|
2012-11-08 22:47:04 +01:00
|
|
|
from sugar3.graphics.palettemenu import PaletteMenuBox
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2013-09-11 15:59:34 +02:00
|
|
|
|
|
|
|
_ = lambda msg: gettext.dgettext('sugar-toolkit', msg)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-08-17 14:46:47 +02:00
|
|
|
|
2009-09-18 17:09:03 +02:00
|
|
|
def _create_activity_icon(metadata):
|
2011-03-31 22:21:19 +02:00
|
|
|
if metadata is not None and metadata.get('icon-color'):
|
2009-09-18 17:09:03 +02:00
|
|
|
color = XoColor(metadata['icon-color'])
|
|
|
|
else:
|
2011-11-15 19:29:07 +01:00
|
|
|
client = GConf.Client.get_default()
|
2009-09-18 17:09:03 +02:00
|
|
|
color = XoColor(client.get_string('/desktop/sugar/user/color'))
|
|
|
|
|
2011-10-29 10:44:18 +02:00
|
|
|
from sugar3.activity.activity import get_bundle_path
|
2009-08-17 14:46:47 +02:00
|
|
|
bundle = ActivityBundle(get_bundle_path())
|
|
|
|
icon = Icon(file=bundle.get_icon(), xo_color=color)
|
2009-09-18 17:09:03 +02:00
|
|
|
|
2009-08-17 14:46:47 +02:00
|
|
|
return icon
|
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-08-17 14:46:47 +02:00
|
|
|
class ActivityButton(ToolButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-08-17 14:46:47 +02:00
|
|
|
def __init__(self, activity, **kwargs):
|
|
|
|
ToolButton.__init__(self, **kwargs)
|
|
|
|
|
2009-09-18 17:09:03 +02:00
|
|
|
icon = _create_activity_icon(activity.metadata)
|
2009-08-17 14:46:47 +02:00
|
|
|
self.set_icon_widget(icon)
|
|
|
|
icon.show()
|
|
|
|
|
2012-10-22 18:45:02 +02:00
|
|
|
self.props.hide_tooltip_on_click = False
|
|
|
|
self.palette_invoker.props.toggle_palette = True
|
2009-08-17 14:46:47 +02:00
|
|
|
self.props.tooltip = activity.metadata['title']
|
|
|
|
activity.metadata.connect('updated', self.__jobject_updated_cb)
|
|
|
|
|
|
|
|
def __jobject_updated_cb(self, jobject):
|
|
|
|
self.props.tooltip = jobject['title']
|
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
class ActivityToolbarButton(ToolbarButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, activity, **kwargs):
|
2009-08-17 18:22:36 +02:00
|
|
|
toolbar = ActivityToolbar(activity, orientation_left=True)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
|
|
|
ToolbarButton.__init__(self, page=toolbar, **kwargs)
|
|
|
|
|
2009-09-18 17:09:03 +02:00
|
|
|
icon = _create_activity_icon(activity.metadata)
|
2009-07-30 17:08:55 +02:00
|
|
|
self.set_icon_widget(icon)
|
2009-08-17 14:46:47 +02:00
|
|
|
icon.show()
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
class StopButton(ToolButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, activity, **kwargs):
|
2009-07-31 05:49:05 +02:00
|
|
|
ToolButton.__init__(self, 'activity-stop', **kwargs)
|
|
|
|
self.props.tooltip = _('Stop')
|
|
|
|
self.props.accelerator = '<Ctrl>Q'
|
2009-07-30 17:08:55 +02:00
|
|
|
self.connect('clicked', self.__stop_button_clicked_cb, activity)
|
|
|
|
|
|
|
|
def __stop_button_clicked_cb(self, button, activity):
|
|
|
|
activity.close()
|
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
class UndoButton(ToolButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, **kwargs):
|
2009-07-31 05:49:05 +02:00
|
|
|
ToolButton.__init__(self, 'edit-undo', **kwargs)
|
|
|
|
self.props.tooltip = _('Undo')
|
2009-09-14 18:19:09 +02:00
|
|
|
self.props.accelerator = '<Ctrl>Z'
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
class RedoButton(ToolButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, **kwargs):
|
2009-07-31 05:49:05 +02:00
|
|
|
ToolButton.__init__(self, 'edit-redo', **kwargs)
|
|
|
|
self.props.tooltip = _('Redo')
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
class CopyButton(ToolButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, **kwargs):
|
2009-07-31 05:49:05 +02:00
|
|
|
ToolButton.__init__(self, 'edit-copy', **kwargs)
|
|
|
|
self.props.tooltip = _('Copy')
|
2010-06-19 14:23:04 +02:00
|
|
|
self.props.accelerator = '<Ctrl>C'
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
class PasteButton(ToolButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, **kwargs):
|
2009-07-31 05:49:05 +02:00
|
|
|
ToolButton.__init__(self, 'edit-paste', **kwargs)
|
|
|
|
self.props.tooltip = _('Paste')
|
2010-06-19 14:23:04 +02:00
|
|
|
self.props.accelerator = '<Ctrl>V'
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
class ShareButton(RadioMenuButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, activity, **kwargs):
|
|
|
|
palette = RadioPalette()
|
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
self.private = RadioToolButton(
|
2013-05-17 07:16:36 +02:00
|
|
|
icon_name='zoom-home')
|
2009-07-31 05:49:05 +02:00
|
|
|
palette.append(self.private, _('Private'))
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
self.neighborhood = RadioToolButton(
|
2013-05-17 07:16:36 +02:00
|
|
|
icon_name='zoom-neighborhood',
|
|
|
|
group=self.private)
|
2009-07-31 12:25:01 +02:00
|
|
|
self._neighborhood_handle = self.neighborhood.connect(
|
2013-05-17 07:16:36 +02:00
|
|
|
'clicked', self.__neighborhood_clicked_cb, activity)
|
2009-07-31 05:49:05 +02:00
|
|
|
palette.append(self.neighborhood, _('My Neighborhood'))
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
activity.connect('shared', self.__update_share_cb)
|
|
|
|
activity.connect('joined', self.__update_share_cb)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
RadioMenuButton.__init__(self, **kwargs)
|
|
|
|
self.props.palette = palette
|
2009-08-12 11:26:26 +02:00
|
|
|
if activity.max_participants == 1:
|
|
|
|
self.props.sensitive = False
|
2009-07-30 17:08:55 +02:00
|
|
|
|
|
|
|
def __neighborhood_clicked_cb(self, button, activity):
|
|
|
|
activity.share()
|
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
def __update_share_cb(self, activity):
|
2009-07-31 12:25:01 +02:00
|
|
|
self.neighborhood.handler_block(self._neighborhood_handle)
|
2009-07-30 17:08:55 +02:00
|
|
|
try:
|
2010-07-09 17:31:50 +02:00
|
|
|
if activity.shared_activity is not None and \
|
|
|
|
not activity.shared_activity.props.private:
|
2009-07-31 05:49:05 +02:00
|
|
|
self.private.props.sensitive = False
|
|
|
|
self.neighborhood.props.sensitive = False
|
|
|
|
self.neighborhood.props.active = True
|
2009-07-30 17:08:55 +02:00
|
|
|
else:
|
2009-07-31 05:49:05 +02:00
|
|
|
self.private.props.sensitive = True
|
|
|
|
self.neighborhood.props.sensitive = True
|
|
|
|
self.private.props.active = True
|
2009-07-30 17:08:55 +02:00
|
|
|
finally:
|
2009-07-31 12:25:01 +02:00
|
|
|
self.neighborhood.handler_unblock(self._neighborhood_handle)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
class TitleEntry(Gtk.ToolItem):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self, activity, **kwargs):
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.ToolItem.__init__(self)
|
2009-07-31 22:05:40 +02:00
|
|
|
self.set_expand(False)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
self.entry = Gtk.Entry(**kwargs)
|
|
|
|
self.entry.set_size_request(int(Gdk.Screen.width() / 3), -1)
|
2009-07-31 22:05:40 +02:00
|
|
|
self.entry.set_text(activity.metadata['title'])
|
2013-05-17 07:16:36 +02:00
|
|
|
self.entry.connect(
|
|
|
|
'focus-out-event', self.__title_changed_cb, activity)
|
2012-11-27 23:42:51 +01:00
|
|
|
self.entry.connect('button-press-event', self.__button_press_event_cb)
|
2009-07-31 22:05:40 +02:00
|
|
|
self.entry.show()
|
|
|
|
self.add(self.entry)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
|
|
|
activity.metadata.connect('updated', self.__jobject_updated_cb)
|
2011-06-20 17:48:51 +02:00
|
|
|
activity.connect('_closing', self.__closing_cb)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-07-31 22:05:40 +02:00
|
|
|
def modify_bg(self, state, color):
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.ToolItem.modify_bg(self, state, color)
|
2009-08-06 13:32:44 +02:00
|
|
|
self.entry.modify_bg(state, color)
|
2009-07-31 22:05:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __jobject_updated_cb(self, jobject):
|
2011-11-15 19:29:07 +01:00
|
|
|
if self.entry.has_focus():
|
2011-06-20 17:48:51 +02:00
|
|
|
return
|
|
|
|
if self.entry.get_text() == jobject['title']:
|
|
|
|
return
|
2009-07-31 22:05:40 +02:00
|
|
|
self.entry.set_text(jobject['title'])
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2011-06-20 17:48:51 +02:00
|
|
|
def __closing_cb(self, activity):
|
|
|
|
self.save_title(activity)
|
|
|
|
return False
|
|
|
|
|
|
|
|
def __title_changed_cb(self, editable, event, activity):
|
|
|
|
self.save_title(activity)
|
|
|
|
return False
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2012-11-27 23:42:51 +01:00
|
|
|
def __button_press_event_cb(self, widget, event):
|
|
|
|
if widget.is_focus():
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
widget.grab_focus()
|
|
|
|
widget.select_region(0, -1)
|
|
|
|
return True
|
|
|
|
|
2011-06-20 17:48:51 +02:00
|
|
|
def save_title(self, activity):
|
2009-07-31 22:05:40 +02:00
|
|
|
title = self.entry.get_text()
|
2011-06-20 17:48:51 +02:00
|
|
|
if title == activity.metadata['title']:
|
|
|
|
return
|
2009-07-30 17:08:55 +02:00
|
|
|
|
|
|
|
activity.metadata['title'] = title
|
|
|
|
activity.metadata['title_set_by_user'] = '1'
|
|
|
|
activity.save()
|
|
|
|
|
2011-07-24 18:42:48 +02:00
|
|
|
activity.set_title(title)
|
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
shared_activity = activity.get_shared_activity()
|
2009-08-17 14:47:51 +02:00
|
|
|
if shared_activity is not None:
|
2009-07-30 17:08:55 +02:00
|
|
|
shared_activity.props.name = title
|
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2012-11-15 18:09:00 +01:00
|
|
|
class DescriptionItem(ToolButton):
|
2012-01-31 22:00:22 +01:00
|
|
|
|
|
|
|
def __init__(self, activity, **kwargs):
|
2012-11-15 18:09:00 +01:00
|
|
|
ToolButton.__init__(self, 'edit-description', **kwargs)
|
|
|
|
self.set_tooltip(_('Description'))
|
|
|
|
self.palette_invoker.props.toggle_palette = True
|
|
|
|
self.palette_invoker.props.lock_palette = True
|
|
|
|
self.props.hide_tooltip_on_click = False
|
|
|
|
self._palette = self.get_palette()
|
2012-01-31 22:00:22 +01:00
|
|
|
|
2012-11-08 22:47:04 +01:00
|
|
|
description_box = PaletteMenuBox()
|
2012-01-31 22:00:22 +01:00
|
|
|
sw = Gtk.ScrolledWindow()
|
|
|
|
sw.set_size_request(int(Gdk.Screen.width() / 2),
|
|
|
|
2 * style.GRID_CELL_SIZE)
|
|
|
|
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
|
|
|
self._text_view = Gtk.TextView()
|
|
|
|
self._text_view.set_left_margin(style.DEFAULT_PADDING)
|
|
|
|
self._text_view.set_right_margin(style.DEFAULT_PADDING)
|
2012-06-01 19:32:51 +02:00
|
|
|
self._text_view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
|
2012-01-31 22:00:22 +01:00
|
|
|
text_buffer = Gtk.TextBuffer()
|
|
|
|
if 'description' in activity.metadata:
|
|
|
|
text_buffer.set_text(activity.metadata['description'])
|
|
|
|
self._text_view.set_buffer(text_buffer)
|
|
|
|
self._text_view.connect('focus-out-event',
|
2013-05-17 07:16:36 +02:00
|
|
|
self.__description_changed_cb, activity)
|
2012-01-31 22:00:22 +01:00
|
|
|
sw.add(self._text_view)
|
2012-11-08 22:47:04 +01:00
|
|
|
description_box.append_item(sw, vertical_padding=0)
|
2012-01-31 22:00:22 +01:00
|
|
|
self._palette.set_content(description_box)
|
|
|
|
description_box.show_all()
|
|
|
|
|
|
|
|
activity.metadata.connect('updated', self.__jobject_updated_cb)
|
|
|
|
|
2012-11-15 18:09:00 +01:00
|
|
|
def set_expanded(self, expanded):
|
|
|
|
box = self.toolbar_box
|
|
|
|
if not box:
|
|
|
|
return
|
|
|
|
|
|
|
|
if not expanded:
|
|
|
|
self.palette_invoker.notify_popdown()
|
|
|
|
return
|
|
|
|
|
|
|
|
if box.expanded_button is not None:
|
|
|
|
box.expanded_button.queue_draw()
|
|
|
|
if box.expanded_button != self:
|
|
|
|
box.expanded_button.set_expanded(False)
|
|
|
|
box.expanded_button = self
|
|
|
|
|
|
|
|
def get_toolbar_box(self):
|
|
|
|
parent = self.get_parent()
|
|
|
|
if not hasattr(parent, 'owner'):
|
|
|
|
return None
|
|
|
|
return parent.owner
|
|
|
|
|
|
|
|
toolbar_box = property(get_toolbar_box)
|
|
|
|
|
2012-01-31 22:00:22 +01:00
|
|
|
def _get_text_from_buffer(self):
|
|
|
|
buf = self._text_view.get_buffer()
|
|
|
|
start_iter = buf.get_start_iter()
|
|
|
|
end_iter = buf.get_end_iter()
|
|
|
|
return buf.get_text(start_iter, end_iter, False)
|
|
|
|
|
|
|
|
def __jobject_updated_cb(self, jobject):
|
|
|
|
if self._text_view.has_focus():
|
|
|
|
return
|
|
|
|
if 'description' not in jobject:
|
|
|
|
return
|
|
|
|
if self._get_text_from_buffer() == jobject['description']:
|
|
|
|
return
|
|
|
|
buf = self._text_view.get_buffer()
|
|
|
|
buf.set_text(jobject['description'])
|
|
|
|
|
|
|
|
def __description_changed_cb(self, widget, event, activity):
|
|
|
|
description = self._get_text_from_buffer()
|
|
|
|
if 'description' in activity.metadata and \
|
|
|
|
description == activity.metadata['description']:
|
|
|
|
return
|
|
|
|
|
|
|
|
activity.metadata['description'] = description
|
|
|
|
activity.save()
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
class ActivityToolbar(Gtk.Toolbar):
|
2012-01-11 19:52:11 +01:00
|
|
|
"""The Activity toolbar with the Journal entry title and sharing button"""
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-08-17 18:22:36 +02:00
|
|
|
def __init__(self, activity, orientation_left=False):
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.Toolbar.__init__(self)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
|
|
|
self._activity = activity
|
|
|
|
|
|
|
|
if activity.metadata:
|
2009-07-31 22:05:40 +02:00
|
|
|
title_button = TitleEntry(activity)
|
|
|
|
title_button.show()
|
|
|
|
self.insert(title_button, -1)
|
|
|
|
self.title = title_button.entry
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2013-05-17 07:16:36 +02:00
|
|
|
if not orientation_left:
|
2011-11-15 19:29:07 +01:00
|
|
|
separator = Gtk.SeparatorToolItem()
|
2009-08-17 18:22:36 +02:00
|
|
|
separator.props.draw = False
|
|
|
|
separator.set_expand(True)
|
|
|
|
self.insert(separator, -1)
|
|
|
|
separator.show()
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2012-01-31 22:00:22 +01:00
|
|
|
if activity.metadata:
|
|
|
|
description_item = DescriptionItem(activity)
|
|
|
|
description_item.show()
|
|
|
|
self.insert(description_item, -1)
|
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
self.share = ShareButton(activity)
|
|
|
|
self.share.show()
|
|
|
|
self.insert(self.share, -1)
|
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
class EditToolbar(Gtk.Toolbar):
|
2009-07-30 17:08:55 +02:00
|
|
|
"""Provides the standard edit toolbar for Activities.
|
2009-08-01 13:27:56 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
Members:
|
|
|
|
undo -- the undo button
|
|
|
|
redo -- the redo button
|
|
|
|
copy -- the copy button
|
|
|
|
paste -- the paste button
|
|
|
|
separator -- A separator between undo/redo and copy/paste
|
2009-08-01 13:27:56 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
This class only provides the 'edit' buttons in a standard layout,
|
|
|
|
your activity will need to either hide buttons which make no sense for your
|
|
|
|
Activity, or you need to connect the button events to your own callbacks:
|
2009-08-01 13:27:56 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
## Example from Read.activity:
|
|
|
|
# Create the edit toolbar:
|
|
|
|
self._edit_toolbar = EditToolbar(self._view)
|
|
|
|
# Hide undo and redo, they're not needed
|
|
|
|
self._edit_toolbar.undo.props.visible = False
|
|
|
|
self._edit_toolbar.redo.props.visible = False
|
|
|
|
# Hide the separator too:
|
|
|
|
self._edit_toolbar.separator.props.visible = False
|
2009-08-01 13:27:56 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
# As long as nothing is selected, copy needs to be insensitive:
|
|
|
|
self._edit_toolbar.copy.set_sensitive(False)
|
|
|
|
# When the user clicks the button, call _edit_toolbar_copy_cb()
|
|
|
|
self._edit_toolbar.copy.connect('clicked', self._edit_toolbar_copy_cb)
|
2009-08-01 13:27:56 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
# Add the edit toolbar:
|
|
|
|
toolbox.add_toolbar(_('Edit'), self._edit_toolbar)
|
|
|
|
# And make it visible:
|
|
|
|
self._edit_toolbar.show()
|
|
|
|
"""
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-30 17:08:55 +02:00
|
|
|
def __init__(self):
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.Toolbar.__init__(self)
|
2009-07-30 17:08:55 +02:00
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
self.undo = UndoButton()
|
2009-07-30 17:08:55 +02:00
|
|
|
self.insert(self.undo, -1)
|
|
|
|
self.undo.show()
|
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
self.redo = RedoButton()
|
2009-07-30 17:08:55 +02:00
|
|
|
self.insert(self.redo, -1)
|
|
|
|
self.redo.show()
|
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
self.separator = Gtk.SeparatorToolItem()
|
2009-07-30 17:08:55 +02:00
|
|
|
self.separator.set_draw(True)
|
|
|
|
self.insert(self.separator, -1)
|
|
|
|
self.separator.show()
|
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
self.copy = CopyButton()
|
2009-07-30 17:08:55 +02:00
|
|
|
self.insert(self.copy, -1)
|
|
|
|
self.copy.show()
|
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
self.paste = PasteButton()
|
2009-07-30 17:08:55 +02:00
|
|
|
self.insert(self.paste, -1)
|
|
|
|
self.paste.show()
|