summaryrefslogtreecommitdiff
path: root/grc/gui/FileDialogs.py
diff options
context:
space:
mode:
authorSeth Hitefield <sdh11@vt.edu>2014-08-19 15:17:09 -0400
committerSebastian Koslowski <koslowski@kit.edu>2014-08-26 17:48:45 +0200
commit8aeb5b7e8b52701d1d5c6f40735db469121e6e67 (patch)
tree77d8ca1c48f80d8279faa0f39ceb8599bcd73645 /grc/gui/FileDialogs.py
parentbcee01bf9bb04eeda82158e564949d79715bfca3 (diff)
grc: added save_reports action.
Diffstat (limited to 'grc/gui/FileDialogs.py')
-rw-r--r--grc/gui/FileDialogs.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py
index daea7e450f..96cbd94f20 100644
--- a/grc/gui/FileDialogs.py
+++ b/grc/gui/FileDialogs.py
@@ -22,7 +22,7 @@ pygtk.require('2.0')
import gtk
from Dialogs import MessageDialogHelper
from Constants import \
- DEFAULT_FILE_PATH, IMAGE_FILE_EXTENSION, \
+ DEFAULT_FILE_PATH, IMAGE_FILE_EXTENSION, TEXT_FILE_EXTENSION, \
NEW_FLOGRAPH_TITLE
import Preferences
from os import path
@@ -33,6 +33,7 @@ import Utils
##################################################
OPEN_FLOW_GRAPH = 'open flow graph'
SAVE_FLOW_GRAPH = 'save flow graph'
+SAVE_REPORTS = 'save reports'
SAVE_IMAGE = 'save image'
FILE_OVERWRITE_MARKUP_TMPL="""\
@@ -51,6 +52,12 @@ def get_flow_graph_files_filter():
filter.add_pattern('*'+Preferences.file_extension())
return filter
+def get_text_files_filter():
+ filter = gtk.FileFilter()
+ filter.set_name('Text Files')
+ filter.add_pattern('*'+TEXT_FILE_EXTENSION)
+ return filter
+
##the filter for image files
def get_image_files_filter():
filter = gtk.FileFilter()
@@ -108,7 +115,12 @@ class FileDialog(FileDialogHelper):
elif self.type == SAVE_FLOW_GRAPH:
FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph to a File...')
self.add_and_set_filter(get_flow_graph_files_filter())
- self.set_current_name(path.basename(current_file_path)) #show the current filename
+ self.set_current_name(path.basename(current_file_path))
+ elif self.type == SAVE_REPORTS:
+ FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save Reports to a File...')
+ self.add_and_set_filter(get_text_files_filter())
+ file_path = path.splitext(path.basename(current_file_path))[0]
+ self.set_current_name(file_path) #show the current filename
elif self.type == SAVE_IMAGE:
FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph Screen Shot...')
self.add_and_set_filter(get_image_files_filter())
@@ -140,10 +152,11 @@ class FileDialog(FileDialogHelper):
#############################################
# Handle Save Dialogs
#############################################
- if self.type in (SAVE_FLOW_GRAPH, SAVE_IMAGE):
+ if self.type in (SAVE_FLOW_GRAPH, SAVE_REPORTS, SAVE_IMAGE):
filename = self.get_filename()
extension = {
SAVE_FLOW_GRAPH: Preferences.file_extension(),
+ SAVE_REPORTS: TEXT_FILE_EXTENSION,
SAVE_IMAGE: IMAGE_FILE_EXTENSION,
}[self.type]
#append the missing file extension if the filter matches
@@ -182,4 +195,5 @@ class FileDialog(FileDialogHelper):
class OpenFlowGraphFileDialog(FileDialog): type = OPEN_FLOW_GRAPH
class SaveFlowGraphFileDialog(FileDialog): type = SAVE_FLOW_GRAPH
+class SaveReportsFileDialog(FileDialog): type = SAVE_REPORTS
class SaveImageFileDialog(FileDialog): type = SAVE_IMAGE