"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib/dialog.py" between
revelation-0.5.3.tar.xz and revelation-0.5.4.tar.xz

About: Revelation is a password manager for the GNOME 3 desktop.

dialog.py  (revelation-0.5.3.tar.xz):dialog.py  (revelation-0.5.4.tar.xz)
skipping to change at line 142 skipping to change at line 142
child.show_all() child.show_all()
def show(self, x = None, y = None): def show(self, x = None, y = None):
"Show the dialog" "Show the dialog"
if x != None and y != None: if x != None and y != None:
self.move(x, y) self.move(x, y)
self.show_all() self.show_all()
GObject.signal_new("closed", Popup, GObject.SIGNAL_ACTION, GObject.TYPE_BOOLEAN, GObject.signal_new("closed", Popup, GObject.SignalFlags.ACTION,
()) GObject.TYPE_BOOLEAN, ())
class Utility(Dialog): class Utility(Dialog):
"A utility dialog" "A utility dialog"
def __init__(self, parent, title): def __init__(self, parent, title):
Dialog.__init__(self, parent, title) Dialog.__init__(self, parent, title)
self.set_border_width(12) self.set_border_width(12)
self.vbox.set_spacing(18) self.vbox.set_spacing(18)
self.sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self.sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)
def add_section(self, title, description = None): def add_section(self, title, description = None):
"Adds an input section to the dialog" "Adds an input section to the dialog"
section = ui.InputSection(title, description, self.sizegroup) section = ui.InputSection(title, description, self.sizegroup)
self.vbox.pack_start(section, True, True, 0) self.vbox.pack_start(section, True, True, 0)
return section return section
class Message(Dialog): class Message(Dialog):
skipping to change at line 303 skipping to change at line 304
class FileChangesQuit(FileChanges): class FileChangesQuit(FileChanges):
"Asks the user to save changes when quitting" "Asks the user to save changes when quitting"
def __init__(self, parent): def __init__(self, parent):
FileChanges.__init__( FileChanges.__init__(
self, parent, _('Save changes before quitting?'), self, parent, _('Save changes before quitting?'),
_('You have made changes which have not been saved. If you quit with out saving, then these changes will be lost.') _('You have made changes which have not been saved. If you quit with out saving, then these changes will be lost.')
) )
class FileChangesClose(FileChanges):
"Asks the user to save changes when closing"
def __init__(self, parent):
FileChanges.__init__(
self, parent, _('Save changes before closing?'),
_('You have made changes which have not been saved. If you close wit
hout saving, then these changes will be lost.')
)
class FileReplace(Warning): class FileReplace(Warning):
"Asks for confirmation when replacing a file" "Asks for confirmation when replacing a file"
def __init__(self, parent, file): def __init__(self, parent, file):
Warning.__init__( Warning.__init__(
self, parent, _('Replace existing file?'), self, parent, _('Replace existing file?'),
_('The file \'%s\' already exists - do you wish to replace this file ?') % file _('The file \'%s\' already exists - do you wish to replace this file ?') % file
) )
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
skipping to change at line 349 skipping to change at line 359
"Runs the dialog" "Runs the dialog"
if Warning.run(self) == Gtk.ResponseType.OK: if Warning.run(self) == Gtk.ResponseType.OK:
return True return True
else: else:
raise CancelError raise CancelError
##### FILE SELECTION DIALOGS ##### ##### FILE SELECTION DIALOGS #####
class FileSelector(Gtk.FileChooserDialog): class FileSelector(Gtk.FileChooserNative):
"A normal file selector" "A normal file selector"
def __init__(self, parent, title = None, action = Gtk.FileChooserAction.OPEN def __init__(self, parent, title=None,
, stockbutton = None): action=Gtk.FileChooserAction.OPEN):
if stockbutton is None:
if action == Gtk.FileChooserAction.OPEN:
stockbutton = Gtk.STOCK_OPEN
elif action == Gtk.FileChooserAction.SAVE:
stockbutton = Gtk.STOCK_SAVE
Gtk.FileChooserDialog.__init__(self, title, parent, action)
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
self.add_button(stockbutton, Gtk.ResponseType.OK)
Gtk.FileChooserNative.__init__(self, title=title, action=action)
self.set_transient_for(parent)
self.set_local_only(False) self.set_local_only(False)
self.set_default_response(Gtk.ResponseType.OK)
self.inputsection = None self.inputsection = None
def add_widget(self, title, widget): def add_widget(self, title, widget):
"Adds a widget to the file selection" "Adds a widget to the file selection"
if self.inputsection == None: if self.inputsection is None:
self.inputsection = ui.InputSection() self.inputsection = ui.InputSection()
self.set_extra_widget(self.inputsection) self.set_extra_widget(self.inputsection)
self.inputsection.append_widget(title, widget) self.inputsection.append_widget(title, widget)
def get_filename(self): def get_filename(self):
"Returns the file URI" "Returns the file URI"
uri = self.get_uri() uri = self.get_uri()
if uri == None: if uri is None:
return None return None
else: else:
return io.file_normpath(urllib.parse.unquote(uri)) return io.file_normpath(urllib.parse.unquote(uri))
def run(self): def run(self):
"Displays and runs the file selector, returns the filename" "Displays and runs the file selector, returns the filename"
self.show_all() response = Gtk.FileChooserNative.run(self)
response = Gtk.FileChooserDialog.run(self)
filename = self.get_filename() filename = self.get_filename()
self.destroy() self.destroy()
if response == Gtk.ResponseType.OK: if response == Gtk.ResponseType.ACCEPT:
return filename return filename
else: else:
raise CancelError raise CancelError
class ExportFileSelector(FileSelector): class ExportFileSelector(FileSelector):
"A file selector for exporting files" "A file selector for exporting files"
def __init__(self, parent): def __init__(self, parent):
FileSelector.__init__( FileSelector.__init__(
self, parent, _('Select File to Export to'), self, parent, _('Select File to Export to'),
Gtk.FileChooserAction.SAVE, ui.STOCK_EXPORT Gtk.FileChooserAction.SAVE
) )
# set up filetype dropdown # set up filetype dropdown
self.dropdown = ui.DropDown() self.dropdown = ui.DropDown()
self.add_widget(_('Filetype'), self.dropdown) self.add_widget(_('Filetype'), self.dropdown)
for handler in datahandler.get_export_handlers(): for handler in datahandler.get_export_handlers():
self.dropdown.append_item(handler.name, None, handler) self.dropdown.append_item(handler.name, None, handler)
for index in range(self.dropdown.get_num_items()): for index in range(self.dropdown.get_num_items()):
if self.dropdown.get_item(index)[2] == datahandler.RevelationXML: if self.dropdown.get_item(index)[2] == datahandler.RevelationXML:
self.dropdown.set_active(index) self.dropdown.set_active(index)
def run(self): def run(self):
"Displays the dialog" "Displays the dialog"
self.show_all()
self.inputsection.show_all() self.inputsection.show_all()
if Gtk.FileChooserDialog.run(self) == Gtk.ResponseType.OK: if Gtk.FileChooserNative.run(self) == Gtk.ResponseType.ACCEPT:
filename = self.get_filename() filename = self.get_filename()
handler = self.dropdown.get_active_item()[2] handler = self.dropdown.get_active_item()[2]
self.destroy() self.destroy()
return filename, handler return filename, handler
else: else:
self.destroy() self.destroy()
raise CancelError raise CancelError
class ImportFileSelector(FileSelector): class ImportFileSelector(FileSelector):
"A file selector for importing files" "A file selector for importing files"
def __init__(self, parent): def __init__(self, parent):
FileSelector.__init__( FileSelector.__init__(
self, parent, _('Select File to Import'), self, parent, _('Select File to Import'),
Gtk.FileChooserAction.OPEN, ui.STOCK_IMPORT Gtk.FileChooserAction.OPEN
) )
# set up filetype dropdown # set up filetype dropdown
self.dropdown = ui.DropDown() self.dropdown = ui.DropDown()
self.add_widget(_('Filetype'), self.dropdown) self.add_widget(_('Filetype'), self.dropdown)
self.dropdown.append_item(_('Automatically detect')) self.dropdown.append_item(_('Automatically detect'))
for handler in datahandler.get_import_handlers(): for handler in datahandler.get_import_handlers():
self.dropdown.append_item(handler.name, None, handler) self.dropdown.append_item(handler.name, None, handler)
def run(self): def run(self):
"Displays the dialog" "Displays the dialog"
self.show_all()
self.inputsection.show_all() self.inputsection.show_all()
if Gtk.FileChooserDialog.run(self) == Gtk.ResponseType.OK: if Gtk.FileChooserNative.run(self) == Gtk.ResponseType.ACCEPT:
filename = self.get_filename() filename = self.get_filename()
handler = self.dropdown.get_active_item()[2] handler = self.dropdown.get_active_item()[2]
self.destroy() self.destroy()
return filename, handler return filename, handler
else: else:
self.destroy() self.destroy()
raise CancelError raise CancelError
class OpenFileSelector(FileSelector): class OpenFileSelector(FileSelector):
"A file selector for opening files" "A file selector for opening files"
def __init__(self, parent): def __init__(self, parent):
FileSelector.__init__( FileSelector.__init__(
self, parent, _('Select File to Open'), self, parent, _('Select File to Open'),
Gtk.FileChooserAction.OPEN, Gtk.STOCK_OPEN Gtk.FileChooserAction.OPEN
) )
filter = Gtk.FileFilter() filter = Gtk.FileFilter()
filter.set_name(_('Revelation files')) filter.set_name(_('Revelation files'))
filter.add_mime_type("application/x-revelation") filter.add_mime_type("application/x-revelation")
self.add_filter(filter) self.add_filter(filter)
filter = Gtk.FileFilter() filter = Gtk.FileFilter()
filter.set_name(_('All files')) filter.set_name(_('All files'))
filter.add_pattern("*") filter.add_pattern("*")
self.add_filter(filter) self.add_filter(filter)
class SaveFileSelector(FileSelector): class SaveFileSelector(FileSelector):
"A file selector for saving files" "A file selector for saving files"
def __init__(self, parent): def __init__(self, parent):
FileSelector.__init__( FileSelector.__init__(
self, parent, _('Select File to Save to'), self, parent, _('Select File to Save to'),
Gtk.FileChooserAction.SAVE, Gtk.STOCK_SAVE Gtk.FileChooserAction.SAVE
) )
filter = Gtk.FileFilter() filter = Gtk.FileFilter()
filter.set_name(_('Revelation files')) filter.set_name(_('Revelation files'))
filter.add_mime_type("application/x-revelation") filter.add_mime_type("application/x-revelation")
self.add_filter(filter) self.add_filter(filter)
filter = Gtk.FileFilter() filter = Gtk.FileFilter()
filter.set_name(_('All files')) filter.set_name(_('All files'))
filter.add_pattern("*") filter.add_pattern("*")
skipping to change at line 551 skipping to change at line 543
self.set_default_response(Gtk.ResponseType.OK) self.set_default_response(Gtk.ResponseType.OK)
self.entries = [] self.entries = []
self.sect_passwords = ui.InputSection() self.sect_passwords = ui.InputSection()
self.contents.pack_start(self.sect_passwords, True, True, 0) self.contents.pack_start(self.sect_passwords, True, True, 0)
def add_entry(self, name, entry = None): def add_entry(self, name, entry = None):
"Adds a password entry to the dialog" "Adds a password entry to the dialog"
if entry == None: if entry is None:
entry = ui.Entry() entry = ui.Entry()
entry.set_visibility(False) entry.set_visibility(False)
self.sect_passwords.append_widget(name, entry) self.sect_passwords.append_widget(name, entry)
self.entries.append(entry) self.entries.append(entry)
return entry return entry
def run(self): def run(self):
"Displays the dialog" "Displays the dialog"
 End of changes. 23 change blocks. 
38 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)