summaryrefslogtreecommitdiff
path: root/grc/gui/FileDialogs.py
diff options
context:
space:
mode:
authorGlenn Richardson <glenn.richardson@live.com>2015-08-28 13:27:53 -0400
committerSebastian Koslowski <koslowski@kit.edu>2015-10-01 21:51:52 +0200
commit5b3a80d03a890492e1e219ec91d5275e6b5dafd1 (patch)
treeca79c9a7b9cccca1345d071cf1edc98280396e48 /grc/gui/FileDialogs.py
parent7983bfda035153495bb6b01451484593ecfcf8d3 (diff)
grc: simple dialog for selecting QSS theme for QT GUI apps
Diffstat (limited to 'grc/gui/FileDialogs.py')
-rw-r--r--grc/gui/FileDialogs.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py
index 96cbd94f20..730ac6fba0 100644
--- a/grc/gui/FileDialogs.py
+++ b/grc/gui/FileDialogs.py
@@ -35,6 +35,7 @@ OPEN_FLOW_GRAPH = 'open flow graph'
SAVE_FLOW_GRAPH = 'save flow graph'
SAVE_REPORTS = 'save reports'
SAVE_IMAGE = 'save image'
+OPEN_QSS_THEME = 'open qss theme'
FILE_OVERWRITE_MARKUP_TMPL="""\
File <b>$encode($filename)</b> Exists!\nWould you like to overwrite the existing file?"""
@@ -72,6 +73,13 @@ def get_all_files_filter():
filter.add_pattern('*')
return filter
+##the filter for qss files
+def get_qss_themes_filter():
+ filter = gtk.FileFilter()
+ filter.set_name('QSS Themes')
+ filter.add_pattern('*.qss')
+ return filter
+
##################################################
# File Dialogs
##################################################
@@ -126,6 +134,10 @@ class FileDialog(FileDialogHelper):
self.add_and_set_filter(get_image_files_filter())
current_file_path = current_file_path + IMAGE_FILE_EXTENSION
self.set_current_name(path.basename(current_file_path)) #show the current filename
+ elif self.type == OPEN_QSS_THEME:
+ FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a QSS theme...')
+ self.add_and_set_filter(get_qss_themes_filter())
+ self.set_select_multiple(False)
self.set_current_folder(path.dirname(current_file_path)) #current directory
def add_and_set_filter(self, filter):
@@ -171,7 +183,7 @@ class FileDialog(FileDialogHelper):
#############################################
# Handle Open Dialogs
#############################################
- elif self.type in (OPEN_FLOW_GRAPH,):
+ elif self.type in (OPEN_FLOW_GRAPH, OPEN_QSS_THEME):
filenames = self.get_filenames()
for filename in filenames:
if not path.exists(filename): #show a warning and re-run
@@ -195,5 +207,6 @@ class FileDialog(FileDialogHelper):
class OpenFlowGraphFileDialog(FileDialog): type = OPEN_FLOW_GRAPH
class SaveFlowGraphFileDialog(FileDialog): type = SAVE_FLOW_GRAPH
+class OpenQSSFileDialog(FileDialog): type = OPEN_QSS_THEME
class SaveReportsFileDialog(FileDialog): type = SAVE_REPORTS
class SaveImageFileDialog(FileDialog): type = SAVE_IMAGE