summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
Diffstat (limited to 'grc')
-rw-r--r--grc/gui/ActionHandler.py6
-rw-r--r--grc/gui/Actions.py2
-rw-r--r--grc/gui/BlockTreeWindow.py2
-rw-r--r--grc/gui/Colors.py3
-rw-r--r--grc/gui/DrawingArea.py27
-rw-r--r--grc/gui/FileDialogs.py15
-rw-r--r--grc/gui/Preferences.py4
7 files changed, 48 insertions, 11 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index 7766a0a853..0f227d08f5 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -34,7 +34,7 @@ from .ParserErrorsDialog import ParserErrorsDialog
from .MainWindow import MainWindow
from .PropsDialog import PropsDialog
from .FileDialogs import (OpenFlowGraphFileDialog, SaveFlowGraphFileDialog,
- SaveReportsFileDialog, SaveImageFileDialog,
+ SaveReportsFileDialog, SaveScreenShotDialog,
OpenQSSFileDialog)
from .Constants import DEFAULT_CANVAS_SIZE, IMAGE_FILE_EXTENSION, GR_PREFIX
@@ -521,9 +521,9 @@ class ActionHandler:
self.main_window.tool_bar.refresh_submenus()
self.main_window.menu_bar.refresh_submenus()
elif action == Actions.FLOW_GRAPH_SCREEN_CAPTURE:
- file_path = SaveImageFileDialog(self.get_page().get_file_path()).run()
+ file_path, background_transparent = SaveScreenShotDialog(self.get_page().get_file_path()).run()
if file_path is not None:
- pixbuf = self.get_flow_graph().get_drawing_area().get_pixbuf()
+ pixbuf = self.get_flow_graph().get_drawing_area().get_screenshot(background_transparent)
pixbuf.save(file_path, IMAGE_FILE_EXTENSION[1:])
##################################################
# Gen/Exec/Stop
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index 9b32b3e601..d53375f291 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -386,7 +386,7 @@ FLOW_GRAPH_KILL = Action(
keypresses=(gtk.keysyms.F7, NO_MODS_MASK),
)
FLOW_GRAPH_SCREEN_CAPTURE = Action(
- label='Sc_reen Capture',
+ label='Screen Ca_pture',
tooltip='Create a screen capture of the flow graph',
stock_id=gtk.STOCK_PRINT,
keypresses=(gtk.keysyms.Print, NO_MODS_MASK),
diff --git a/grc/gui/BlockTreeWindow.py b/grc/gui/BlockTreeWindow.py
index 6b3ebf7807..f6968198d2 100644
--- a/grc/gui/BlockTreeWindow.py
+++ b/grc/gui/BlockTreeWindow.py
@@ -139,7 +139,7 @@ class BlockTreeWindow(gtk.VBox):
sub_category = category[:i+1]
if sub_category not in categories:
iter = treestore.insert_before(categories[sub_category[:-1]], None)
- treestore.set_value(iter, NAME_INDEX, '[ %s ]'%cat_name)
+ treestore.set_value(iter, NAME_INDEX, cat_name)
treestore.set_value(iter, KEY_INDEX, '')
treestore.set_value(iter, DOC_INDEX, Utils.parse_template(CAT_MARKUP_TMPL, cat=cat_name))
categories[sub_category] = iter
diff --git a/grc/gui/Colors.py b/grc/gui/Colors.py
index 52c95e8edf..050b363cdd 100644
--- a/grc/gui/Colors.py
+++ b/grc/gui/Colors.py
@@ -33,8 +33,9 @@ try:
PARAM_ENTRY_TEXT_COLOR = get_color('black')
ENTRYENUM_CUSTOM_COLOR = get_color('#EEEEEE')
#flow graph color constants
- FLOWGRAPH_BACKGROUND_COLOR = get_color('#FFF9FF')
+ FLOWGRAPH_BACKGROUND_COLOR = get_color('#FFFFFF')
COMMENT_BACKGROUND_COLOR = get_color('#F3F3F3')
+ FLOWGRAPH_EDGE_COLOR = COMMENT_BACKGROUND_COLOR
#block color constants
BLOCK_ENABLED_COLOR = get_color('#F1ECFF')
BLOCK_DISABLED_COLOR = get_color('#CCCCCC')
diff --git a/grc/gui/DrawingArea.py b/grc/gui/DrawingArea.py
index 4412129809..6a1df27a8c 100644
--- a/grc/gui/DrawingArea.py
+++ b/grc/gui/DrawingArea.py
@@ -20,7 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import pygtk
pygtk.require('2.0')
import gtk
+
from Constants import MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT, DND_TARGETS
+import Colors
+
class DrawingArea(gtk.DrawingArea):
"""
@@ -68,13 +71,21 @@ class DrawingArea(gtk.DrawingArea):
self.set_flags(gtk.CAN_FOCUS) # self.set_can_focus(True)
self.connect('focus-out-event', self._handle_focus_lost_event)
- def new_pixmap(self, width, height): return gtk.gdk.Pixmap(self.window, width, height, -1)
- def get_pixbuf(self):
- width, height = self._pixmap.get_size()
- pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8, width, height)
- pixbuf.get_from_drawable(self._pixmap, self._pixmap.get_colormap(), 0, 0, 0, 0, width, height)
+ def new_pixmap(self, width, height):
+ return gtk.gdk.Pixmap(self.window, width, height, -1)
+
+ def get_screenshot(self, transparent_bg=False):
+ pixmap = self._pixmap
+ W, H = pixmap.get_size()
+ pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8, W, H)
+ pixbuf.fill(0xFF + Colors.FLOWGRAPH_BACKGROUND_COLOR.pixel << 8)
+ pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, W-1, H-1)
+ if transparent_bg:
+ bgc = Colors.FLOWGRAPH_BACKGROUND_COLOR
+ pixbuf = pixbuf.add_alpha(True, bgc.red, bgc.green, bgc.blue)
return pixbuf
+
##########################################################################
## Handlers
##########################################################################
@@ -149,6 +160,12 @@ class DrawingArea(gtk.DrawingArea):
gc = self.window.new_gc()
self._flow_graph.draw(gc, self._pixmap)
self.window.draw_drawable(gc, self._pixmap, 0, 0, 0, 0, -1, -1)
+ # draw a light grey line on the bottom and right end of the canvas.
+ # this is useful when the theme uses the same panel bg color as the canvas
+ W, H = self._pixmap.get_size()
+ gc.set_foreground(Colors.FLOWGRAPH_EDGE_COLOR)
+ self.window.draw_line(gc, 0, H-1, W, H-1)
+ self.window.draw_line(gc, W-1, 0, W-1, H)
def _handle_focus_lost_event(self, widget, event):
# don't clear selection while context menu is active
diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py
index 730ac6fba0..4b5770ad21 100644
--- a/grc/gui/FileDialogs.py
+++ b/grc/gui/FileDialogs.py
@@ -210,3 +210,18 @@ 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
+
+
+class SaveScreenShotDialog(SaveImageFileDialog):
+
+ def __init__(self, current_file_path=''):
+ SaveImageFileDialog.__init__(self, current_file_path)
+ self._button = button = gtk.CheckButton('_Background transparent')
+ self._button.set_active(Preferences.screen_shot_background_transparent())
+ self.set_extra_widget(button)
+
+ def run(self):
+ filename = SaveImageFileDialog.run(self)
+ bg_transparent = self._button.get_active()
+ Preferences.screen_shot_background_transparent(bg_transparent)
+ return filename, bg_transparent
diff --git a/grc/gui/Preferences.py b/grc/gui/Preferences.py
index 3ebee24345..ad2206ca29 100644
--- a/grc/gui/Preferences.py
+++ b/grc/gui/Preferences.py
@@ -150,3 +150,7 @@ def blocks_window_position(pos=None):
def xterm_missing(cmd=None):
return entry('xterm_missing', cmd, default='INVALID_XTERM_SETTING')
+
+
+def screen_shot_background_transparent(transparent=None):
+ return entry('screen_shot_background_transparent', transparent, default=False)