/usr/share/gespeaker/src/DialogFileOpenSave.py is in gespeaker 0.8.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 72 73 74 75 76 77 78 79 80 81 | ##
# Project: gespeaker - A GTK frontend for espeak
# Author: Fabio Castelli <muflone@vbsimple.net>
# Copyright: 2009-2013 Fabio Castelli
# License: GPL-2+
# 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 2 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.
#
# On Debian GNU/Linux systems, the full text of the GNU General Public License
# can be found in the file /usr/share/common-licenses/GPL-2.
##
import gtk
class DialogFileOpenSave(gtk.FileChooserDialog):
def __init__(self, useForOpen=True, title=None, initialDir=None, initialFile=None, askOverwrite=True):
gtk.FileChooserDialog.__init__(
self, title=title, parent=None,
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
useForOpen and gtk.STOCK_OPEN or gtk.STOCK_SAVE, gtk.RESPONSE_OK
)
)
self.connect('response', self._response_callback)
if initialDir:
self.set_current_folder(initialDir)
if initialFile:
self.set_current_name(initialFile)
self.set_do_overwrite_confirmation(askOverwrite)
self.filename = None
self.lastFilter = None
def _response_callback(self, *args):
self.response = args[1]
if args[1] == gtk.RESPONSE_OK:
self.filename = self.get_filename()
self.lastFilter = self.get_filter()
self.destroy()
def show(self):
super(self.__class__, self).run()
return self.response==gtk.RESPONSE_OK
def addFilter(self, name, patterns=None, mimetypes=None):
filter = gtk.FileFilter()
filter.set_name(name)
if patterns:
for pattern in patterns:
filter.add_pattern(pattern)
if mimetypes:
for mimetype in mimetypes:
filter.add_mime_type(mimetype)
super(self.__class__, self).add_filter(filter)
class DialogFileSave(DialogFileOpenSave):
def __init__(self, title=None, initialDir=None, initialFile=None, askOverwrite=True):
super(self.__class__, self).__init__(
useForOpen=False,
title=title,
initialDir=initialDir,
initialFile=initialFile,
askOverwrite=askOverwrite
)
class DialogFileOpen(DialogFileOpenSave):
def __init__(self, title=None, initialDir=None, initialFile=None):
super(self.__class__, self).__init__(
useForOpen=True,
title=title,
initialDir=initialDir,
initialFile=initialFile,
askOverwrite=False
)
|