1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
"""
This module provides a "File" menu at desktops and an ActivityToolbar at Sugar.
See class BasicOptions.
"""
# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# 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 3 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 Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
from gettext import gettext as _
import gtk
import stock
from item import Item
from itemgroup import ItemGroup
DOCUMENT = 0
CONFIG = 1
class BasicOptions(ItemGroup):
"""This class has the basic options for your program."""
def __init__(self, activity, box, export_formats=None):
"""Create and append the basic items to a ItemBox.
activity -- The activity used as argument at Canvas and Options.
box -- sweetener.itembox.ItemBox of the activity.
export_formats -- list of tuples or none. Each tuple should have:
['generic_type', 'mime_type', 'mime_filter', 'filter_name']
"""
ItemGroup.__init__(self, box, _('_File'), None)
if activity.save_type != CONFIG:
new = Item(gtk.STOCK_NEW, True)
new.connect('activate', lambda w: activity.new())
self.append_item(new)
_open = Item(gtk.STOCK_OPEN, True)
_open.connect('activate', lambda w: activity.open())
self.append_item(_open)
self.append_separator()
save_option = Item(gtk.STOCK_SAVE, True)
save_option.connect('activate', lambda w: activity.save())
self.append_item(save_option)
save_as_option = Item(gtk.STOCK_SAVE_AS)
save_as_option.connect('activate', lambda w: activity.save_as())
self.append_item(save_as_option)
if export_formats != None:
if len(export_formats) == 1:
stock.register('sweetener-%s' % export_formats[0][1],
_('Export as %s') % export_formats[0][0],
None, export_formats[0][1].replace('/',
'-'))
export = Item('sweetener-%s' % export_formats[0][1])
export.connect('activate', activity.export,
export_formats[0])
self.append_item(export)
self.append_separator()
_quit = Item(gtk.STOCK_QUIT)
_quit.connect('activate', lambda w: activity.stop())
self.append_item(_quit)
|