Пример #1
0
 def on_imgmenuFileSaveAs_activate(self, widget, filename=None):
   "Saves the whole text in the specified filename"
   if not filename:
     dialog = DialogFileSave(
       title=_('Please select where to save the text file'),
       initialDir=os.path.expanduser('~'))
     txtFilter = _('Text files (*.txt)')
     dialog.addFilter(txtFilter, ['*.txt'], None)
     dialog.addFilter(_('All files'), ['*'], None)
     dialog.set_icon_from_file(handlepaths.get_app_logo())
     if dialog.show():
       filename = dialog.filename
       if dialog.lastFilter.get_name() == txtFilter and filename[-4:] != '.txt':
         filename += '.txt'
       dialog.destroy()
   # Save selected filename
   if filename:
     print 'saving text in %s' % filename
     file = None
     try:
       file = open(filename, 'w')
       file.write(TextBuffer_get_text(self.txvBuffer))
       print 'file %s saved' % filename
     except IOError, (errno, strerror):
       ShowDialogError(
         text=_('Error saving the file') + '\n\n%s' % strerror,
         showOk=True,
         icon=handlepaths.get_app_logo()
       )
       print 'unable to save %s (I/O error %s: %s)' % (
         filename, errno, strerror
       )
     except:
Пример #2
0
 def on_imgmenuFileSaveAs_activate(self, widget, filename=None):
   "Saves the whole text in the specified filename"
   if not filename:
     dialog = DialogFileSave(
       title=_('Please select where to save the text file'),
       initialDir=os.path.expanduser('~'))
     txtFilter = _('Text files (*.txt)')
     dialog.addFilter(txtFilter, ['*.txt'], None)
     dialog.addFilter(_('All files'), ['*'], None)
     dialog.set_icon_from_file(handlepaths.get_app_logo())
     if dialog.show():
       filename = dialog.filename
       if dialog.lastFilter.get_name() == txtFilter and filename[-4:] != '.txt':
         filename += '.txt'
       dialog.destroy()
   # Save selected filename
   if filename:
     print 'saving text in %s' % filename
     file = None
     try:
       file = open(filename, 'w')
       file.write(TextBuffer_get_text(self.txvBuffer))
       print 'file %s saved' % filename
     except IOError, (errno, strerror):
       ShowDialogError(
         text=_('Error saving the file') + '\n\n%s' % strerror,
         showOk=True,
         icon=handlepaths.get_app_logo()
       )
       print 'unable to save %s (I/O error %s: %s)' % (
         filename, errno, strerror
       )
     except:
Пример #3
0
 def on_tlbRecord_toggled(self, widget, data=None):
   # Workaround to avoid dialog show if the record was requested through dbus
   if self.recordToFileRequested:
     return
   self.recordToFile = None
   if self.tlbRecord.get_active():
     dialog = DialogFileSave(
       title=_('Please select where to save the recorded file'),
       initialDir=os.path.expanduser('~'))
     dialog.set_icon_from_file(handlepaths.get_app_logo())
     dialog.addFilter(_('Wave files (*.wav)'), ['*.wav'], None)
     dialog.addFilter(_('All files'), ['*'], None)
     if dialog.show():
       filename = dialog.filename
       if filename[-4:] != '.wav':
         filename += '.wav'
       self.set_record(filename)
     else:
       self.tlbRecord.set_active(False)
     dialog.destroy()
   else:
     self.stbStatus.pop(self.statusContextId)
Пример #4
0
 def on_tlbRecord_toggled(self, widget, data=None):
   # Workaround to avoid dialog show if the record was requested through dbus
   if self.recordToFileRequested:
     return
   self.recordToFile = None
   if self.tlbRecord.get_active():
     dialog = DialogFileSave(
       title=_('Please select where to save the recorded file'),
       initialDir=os.path.expanduser('~'))
     dialog.set_icon_from_file(handlepaths.get_app_logo())
     dialog.addFilter(_('Wave files (*.wav)'), ['*.wav'], None)
     dialog.addFilter(_('All files'), ['*'], None)
     if dialog.show():
       filename = dialog.filename
       if filename[-4:] != '.wav':
         filename += '.wav'
       self.set_record(filename)
     else:
       self.tlbRecord.set_active(False)
     dialog.destroy()
   else:
     self.stbStatus.pop(self.statusContextId)