diff options
Diffstat (limited to 'grc')
-rw-r--r-- | grc/base/FlowGraph.py | 20 | ||||
-rw-r--r-- | grc/blocks/options.xml | 10 | ||||
-rw-r--r-- | grc/gui/ActionHandler.py | 15 | ||||
-rw-r--r-- | grc/gui/Block.py | 10 | ||||
-rw-r--r-- | grc/gui/Constants.py | 7 | ||||
-rw-r--r-- | grc/gui/Messages.py | 8 | ||||
-rw-r--r-- | grc/gui/Param.py | 5 | ||||
-rw-r--r-- | grc/gui/Port.py | 8 |
8 files changed, 51 insertions, 32 deletions
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py index 02d1b112c4..fb25b46821 100644 --- a/grc/base/FlowGraph.py +++ b/grc/base/FlowGraph.py @@ -17,11 +17,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ +import time from . import odict from Element import Element from .. gui import Messages from . Constants import FLOW_GRAPH_FILE_FORMAT_VERSION + class FlowGraph(Element): def __init__(self, platform): @@ -36,6 +38,8 @@ class FlowGraph(Element): """ #initialize Element.__init__(self, platform) + self._elements = [] + self._timestamp = time.ctime() #inital blank import self.import_data() @@ -51,12 +55,14 @@ class FlowGraph(Element): """ index = 0 while True: - id = '%s_%d'%(base_id, index) - index = index + 1 + id = '%s_%d' % (base_id, index) + index += 1 #make sure that the id is not used by another block if not filter(lambda b: b.get_id() == id, self.get_blocks()): return id - def __str__(self): return 'FlowGraph - %s(%s)'%(self.get_option('title'), self.get_option('id')) + def __str__(self): + return 'FlowGraph - %s(%s)' % (self.get_option('title'), self.get_option('id')) + def rewrite(self): def refactor_bus_structure(): @@ -242,9 +248,8 @@ class FlowGraph(Element): Returns: a nested data odict """ - import time n = odict() - n['timestamp'] = time.ctime() + n['timestamp'] = self._timestamp n['block'] = [block.export_data() for block in self.get_blocks()] n['connection'] = [connection.export_data() for connection in self.get_connections()] instructions = odict({ @@ -273,6 +278,7 @@ class FlowGraph(Element): file_format = 0 #use blank data if none provided fg_n = n and n.find('flow_graph') or odict() + self._timestamp = fg_n.find('timestamp') or time.ctime() blocks_n = fg_n.findall('block') connections_n = fg_n.findall('connection') #create option block @@ -384,7 +390,7 @@ def _initialize_dummy_block(block, block_n): """ block._key = block_n.find('key') block.is_dummy_block = lambda: True - block.is_valid = lambda: False + block.is_valid = lambda: False block.get_enabled = lambda: False for param_n in block_n.findall('param'): if param_n['key'] not in block.get_param_keys(): @@ -393,7 +399,7 @@ def _initialize_dummy_block(block, block_n): def _dummy_block_add_port(block, key, dir): - """This is so ugly... Add a port to a dummy-fied block""" + """This is so ugly... Add a port to a dummy-field block""" port_n = odict({'name': '?', 'key': key, 'type': ''}) port = block.get_parent().get_parent().Port(block=block, n=port_n, dir=dir) if port.is_source(): diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml index 0c3a804fd7..c1c94e4e24 100644 --- a/grc/blocks/options.xml +++ b/grc/blocks/options.xml @@ -58,17 +58,17 @@ else: self.stop(); self.wait()</callback> <param> <name>Generate Options</name> <key>generate_options</key> - <value>wx_gui</value> + <value>qt_gui</value> <type>enum</type> <option> - <name>WX GUI</name> - <key>wx_gui</key> - </option> - <option> <name>QT GUI</name> <key>qt_gui</key> </option> <option> + <name>WX GUI</name> + <key>wx_gui</key> + </option> + <option> <name>No GUI</name> <key>no_gui</key> </option> 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) |