Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/desktop/sweetener/basic_options.py
blob: bdb5bfccfe96832b0fbe7e78dee1f1621d8efcd2 (plain)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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):
    def __init__(self, activity, box, export_formats=None):
        # TRANS: This string could be already translated at hello-integration, if not, please translate there, not only here.
        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],
                                   # TRANS: This string could be already translated at hello-integration, if not, please translate there, not only here.
                                    _('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)