From: Eugene Gagarin Date: Mon, 18 May 2009 08:46:09 +0000 (+0400) Subject: Added 'Save to file' dialog to files.out_table X-Git-Url: http://git.maemo.org/git/?p=findit;a=commitdiff_plain;h=9d41de950eb735e2f86fcc8fb764b9e98e8889d7 Added 'Save to file' dialog to files.out_table --- diff --git a/src/files/out_table.py b/src/files/out_table.py index b9af363..52b5b9b 100755 --- a/src/files/out_table.py +++ b/src/files/out_table.py @@ -21,6 +21,7 @@ class Cli_Presentation(object): class Gtk_Presentation(object): def __init__(self, results): ### import gtk + global gtk # for save_results import gobject self.filelist, self.start_path = results @@ -47,7 +48,6 @@ class Gtk_Presentation(object): path_col = gtk.TreeViewColumn(_('Path')) cell2 = gtk.CellRendererText() path_col.pack_start(cell2, True) - #path_col.add_attribute(cell2, 'text', 0) path_col.add_attribute(cell2, 'markup', 0) treeview.append_column(path_col) @@ -113,10 +113,21 @@ class Gtk_Presentation(object): size, bsize]) def save_results(self, btn): - outfile = open('results', 'w') - for bsize, path, size in self.filelist: - outfile.write(`bsize` + '\t' + abspath(path) + '\n') - outfile.close() + # 'Save to file' dialog + dialog = gtk.FileChooserDialog(title='Save to...', + action='save', + buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, + gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + dialog.show_all() + response = dialog.run() + if response == gtk.RESPONSE_OK: + filepath = dialog.get_filename() + outfile = open(filepath, 'w') + # Saving results as "bite size\tabsolute path" + for bsize, path, size in self.filelist: + outfile.write(`bsize` + '\t' + abspath(path) + '\n') + outfile.close() + dialog.destroy() #==============================================================================