summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/ActionHandler.py15
-rw-r--r--grc/gui/Block.py10
-rw-r--r--grc/gui/Constants.py7
-rw-r--r--grc/gui/Messages.py8
-rw-r--r--grc/gui/Param.py5
-rw-r--r--grc/gui/Port.py8
6 files changed, 33 insertions, 20 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index f8963fa472..6c56a94e9c 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -495,9 +495,11 @@ class ActionHandler:
ExecFlowGraphThread(self)
elif action == Actions.FLOW_GRAPH_KILL:
if self.get_page().get_proc():
- try: self.get_page().get_proc().kill()
- except: print "could not kill process: %d"%self.get_page().get_proc().pid
- elif action == Actions.PAGE_CHANGE: #pass and run the global actions
+ try:
+ self.get_page().get_proc().kill()
+ except:
+ print "could not kill process: %d" % self.get_page().get_proc().pid
+ elif action == Actions.PAGE_CHANGE: # pass and run the global actions
pass
elif action == Actions.RELOAD_BLOCKS:
self.platform.load_blocks()
@@ -583,7 +585,7 @@ class ActionHandler:
sensitive = self.get_flow_graph().is_valid() and not self.get_page().get_proc()
Actions.FLOW_GRAPH_GEN.set_sensitive(sensitive)
Actions.FLOW_GRAPH_EXEC.set_sensitive(sensitive)
- Actions.FLOW_GRAPH_KILL.set_sensitive(self.get_page().get_proc() != None)
+ Actions.FLOW_GRAPH_KILL.set_sensitive(self.get_page().get_proc() is not None)
class ExecFlowGraphThread(Thread):
"""Execute the flow graph as a new process and wait on it to finish."""
@@ -619,13 +621,14 @@ class ExecFlowGraphThread(Thread):
"""
#handle completion
r = "\n"
- while(r):
+ while r:
gobject.idle_add(Messages.send_verbose_exec, r)
r = os.read(self.p.stdout.fileno(), 1024)
+ self.p.poll()
gobject.idle_add(self.done)
def done(self):
"""Perform end of execution tasks."""
- Messages.send_end_exec()
+ Messages.send_end_exec(self.p.returncode)
self.page.set_proc(None)
self.update_exec_stop()
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 1a32f6c2ba..9b8d3b1b56 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -25,7 +25,7 @@ from Constants import BORDER_PROXIMITY_SENSITIVITY
from Constants import \
BLOCK_LABEL_PADDING, \
PORT_SEPARATION, LABEL_SEPARATION, \
- PORT_BORDER_SEPARATION, POSSIBLE_ROTATIONS
+ PORT_BORDER_SEPARATION, POSSIBLE_ROTATIONS, BLOCK_FONT, PARAM_FONT
import Actions
import pygtk
pygtk.require('2.0')
@@ -34,7 +34,7 @@ import pango
BLOCK_MARKUP_TMPL="""\
#set $foreground = $block.is_valid() and 'black' or 'red'
-<span foreground="$foreground" font_desc="Sans 8"><b>$encode($block.get_name())</b></span>"""
+<span foreground="$foreground" font_desc="$font"><b>$encode($block.get_name())</b></span>"""
class Block(Element):
"""The graphical signal block."""
@@ -146,11 +146,13 @@ class Block(Element):
#create the main layout
layout = gtk.DrawingArea().create_pango_layout('')
layouts.append(layout)
- layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
+ layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self, font=BLOCK_FONT))
self.label_width, self.label_height = layout.get_pixel_size()
#display the params
if self.is_dummy_block():
- markups = ['<span foreground="black" font_desc="Sans 7.5"><b>key: </b>{}</span>'.format(self._key)]
+ markups = [
+ '<span foreground="black" font_desc="$font"><b>key: </b>{key}</span>'.format(font=PARAM_FONT, key=self._key)
+ ]
else:
markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
if markups:
diff --git a/grc/gui/Constants.py b/grc/gui/Constants.py
index 7db291df99..0dc6279fd2 100644
--- a/grc/gui/Constants.py
+++ b/grc/gui/Constants.py
@@ -41,6 +41,13 @@ MIN_DIALOG_HEIGHT = 500
##default sizes
DEFAULT_BLOCKS_WINDOW_WIDTH = 100
DEFAULT_REPORTS_WINDOW_WIDTH = 100
+## flow-graph canvas fonts
+FONT_FAMILY = "Sans"
+FONT_SIZE = 8
+BLOCK_FONT = "%s %f" % (FONT_FAMILY, FONT_SIZE)
+PORT_FONT = BLOCK_FONT
+PARAM_FONT = "%s %f" % (FONT_FAMILY, FONT_SIZE - 0.5)
+
##The size of the state saving cache in the flow graph (for undo/redo functionality)
STATE_CACHE_SIZE = 42
diff --git a/grc/gui/Messages.py b/grc/gui/Messages.py
index f220b6dd06..90f508d770 100644
--- a/grc/gui/Messages.py
+++ b/grc/gui/Messages.py
@@ -24,15 +24,17 @@ import os
## A list of functions that can receive a message.
MESSENGERS_LIST = list()
+
def register_messenger(messenger):
"""
Append the given messenger to the list of messengers.
Args:
- messenger: a method thats takes a string
+ messenger: a method that takes a string
"""
MESSENGERS_LIST.append(messenger)
+
def send(message):
"""
Give the message to each of the messengers.
@@ -102,8 +104,8 @@ def send_start_exec(file_path):
def send_verbose_exec(verbose):
send(verbose)
-def send_end_exec():
- send('\n>>> Done\n')
+def send_end_exec(returncode=0):
+ send('\n>>> Done%s\n' % (" (return code %s)" % returncode if returncode else ""))
################# functions for saving flow graphs ########################################
def send_fail_save(file_path):
diff --git a/grc/gui/Param.py b/grc/gui/Param.py
index 499af2e2ed..76dafdf3cc 100644
--- a/grc/gui/Param.py
+++ b/grc/gui/Param.py
@@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import Utils
from Element import Element
+from . Constants import PARAM_FONT
import pygtk
pygtk.require('2.0')
import gtk
@@ -184,7 +185,7 @@ class FileParam(EntryParam):
PARAM_MARKUP_TMPL="""\
#set $foreground = $param.is_valid() and 'black' or 'red'
-<span foreground="$foreground" font_desc="Sans 7.5"><b>$encode($param.get_name()): </b>$encode(repr($param))</span>"""
+<span foreground="$foreground" font_desc="$font"><b>$encode($param.get_name()): </b>$encode(repr($param))</span>"""
PARAM_LABEL_MARKUP_TMPL="""\
#set $foreground = $modified and 'blue' or $param.is_valid() and 'black' or 'red'
@@ -249,4 +250,4 @@ class Param(Element):
Returns:
a pango markup string
"""
- return Utils.parse_template(PARAM_MARKUP_TMPL, param=self)
+ return Utils.parse_template(PARAM_MARKUP_TMPL, param=self, font=PARAM_FONT)
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index 364ca6a5b9..2a87573911 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -21,7 +21,7 @@ from Element import Element
from Constants import \
PORT_SEPARATION, CONNECTOR_EXTENSION_MINIMAL, \
CONNECTOR_EXTENSION_INCREMENT, \
- PORT_LABEL_PADDING, PORT_MIN_WIDTH, PORT_LABEL_HIDDEN_WIDTH
+ PORT_LABEL_PADDING, PORT_MIN_WIDTH, PORT_LABEL_HIDDEN_WIDTH, PORT_FONT
import Utils
import Actions
import Colors
@@ -29,10 +29,8 @@ import pygtk
pygtk.require('2.0')
import gtk
-PORT_HIDDEN_MARKUP_TMPL="""\
-<span foreground="black" font_desc="Sans 7.5"> </span>"""
PORT_MARKUP_TMPL="""\
-<span foreground="black" font_desc="Sans 7.5">$encode($port.get_name())</span>"""
+<span foreground="black" font_desc="$font">$encode($port.get_name())</span>"""
class Port(Element):
@@ -115,7 +113,7 @@ class Port(Element):
self._bg_color = Colors.get_color(self.get_color())
#create the layout
layout = gtk.DrawingArea().create_pango_layout('')
- layout.set_markup(Utils.parse_template(PORT_MARKUP_TMPL, port=self))
+ layout.set_markup(Utils.parse_template(PORT_MARKUP_TMPL, port=self, font=PORT_FONT))
self.w, self.h = layout.get_pixel_size()
self.W, self.H = 2*PORT_LABEL_PADDING + self.w, 2*PORT_LABEL_PADDING+self.h
self.H = self.modify_height(self.H)