""" This module provides a "File" menu at desktops and an ActivityToolbar at Sugar. See class BasicOptions. """ # Copyright (C) 2012-2013 S. Daniel Francis # # 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 _ from gi.repository 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)