summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/ActionHandler.py9
-rw-r--r--grc/gui/Block.py25
-rw-r--r--grc/gui/Connection.py16
-rw-r--r--grc/gui/Element.py16
-rw-r--r--grc/gui/FlowGraph.py7
-rw-r--r--grc/gui/Param.py9
-rw-r--r--grc/gui/Platform.py45
-rw-r--r--grc/gui/Port.py25
8 files changed, 103 insertions, 49 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index 0f227d08f5..726784f7cf 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -17,16 +17,18 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import os
import subprocess
from threading import Thread
+import os
import pygtk
+
pygtk.require('2.0')
import gtk
import gobject
-from .. base import ParseXML, Constants
+from grc.python.base import Constants
+from grc.python.base import ParseXML
from .. python.Constants import XTERM_EXECUTABLE
from . import Dialogs, Messages, Preferences, Actions
@@ -560,7 +562,8 @@ class ActionHandler:
self.platform.load_blocks()
self.main_window.btwin.clear()
self.platform.load_block_tree(self.main_window.btwin)
- Actions.XML_PARSER_ERRORS_DISPLAY.set_sensitive(bool(ParseXML.xml_failures))
+ Actions.XML_PARSER_ERRORS_DISPLAY.set_sensitive(bool(
+ ParseXML.xml_failures))
Messages.send_xml_errors_if_any(ParseXML.xml_failures)
# Force a redraw of the graph, by getting the current state and re-importing it
self.main_window.update_pages()
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 67b80695fa..f961c2281e 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -17,22 +17,26 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-from Element import Element
-import Utils
+import pygtk
+
+import Actions
import Colors
-from .. base import odict
-from .. python.Param import num_to_str
-from Constants import BORDER_PROXIMITY_SENSITIVITY
+import Utils
from Constants import (
BLOCK_LABEL_PADDING, PORT_SPACING, PORT_SEPARATION, LABEL_SEPARATION,
PORT_BORDER_SEPARATION, POSSIBLE_ROTATIONS, BLOCK_FONT, PARAM_FONT
)
-import Actions
-import pygtk
+from Constants import BORDER_PROXIMITY_SENSITIVITY
+from Element import Element
+from grc.python.base import odict
+from .. python.Param import num_to_str
+
pygtk.require('2.0')
import gtk
import pango
+from ..python.Block import Block as _Block
+
BLOCK_MARKUP_TMPL="""\
#set $foreground = $block.is_valid() and 'black' or 'red'
<span foreground="$foreground" font_desc="$font"><b>$encode($block.get_name())</b></span>"""
@@ -52,15 +56,16 @@ COMMENT_COMPLEXITY_MARKUP_TMPL="""\
"""
-
-class Block(Element):
+class Block(Element, _Block):
"""The graphical signal block."""
- def __init__(self):
+ def __init__(self, flow_graph, n):
"""
Block contructor.
Add graphics related params to the block.
"""
+ _Block.__init__(self, flow_graph, n)
+
self.W = 0
self.H = 0
#add the position param
diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py
index badf8e8a82..9a7777434d 100644
--- a/grc/gui/Connection.py
+++ b/grc/gui/Connection.py
@@ -17,15 +17,18 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import Utils
-from Element import Element
+import gtk
+
import Colors
+import Utils
from Constants import CONNECTOR_ARROW_BASE, CONNECTOR_ARROW_HEIGHT
-import gtk
+from Element import Element
+
+from ..python.base.Constants import GR_MESSAGE_DOMAIN
+from ..python.Connection import Connection as _Connection
-from .. base.Constants import GR_MESSAGE_DOMAIN
-class Connection(Element):
+class Connection(Element, _Connection):
"""
A graphical connection for ports.
The connection has 2 parts, the arrow and the wire.
@@ -35,8 +38,9 @@ class Connection(Element):
The arrow coloring exposes the enabled and valid states.
"""
- def __init__(self):
+ def __init__(self, **kwargs):
Element.__init__(self)
+ _Connection.__init__(self, **kwargs)
# can't use Colors.CONNECTION_ENABLED_COLOR here, might not be defined (grcc)
self._bg_color = self._arrow_color = self._color = None
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index 18fb321929..9385424772 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -132,14 +132,14 @@ class Element(object):
"""
self.coor = coor
- def get_parent(self):
- """
- Get the parent of this element.
-
- Returns:
- the parent
- """
- return self.parent
+ # def get_parent(self):
+ # """
+ # Get the parent of this element.
+ #
+ # Returns:
+ # the parent
+ # """
+ # return self.parent
def set_highlighted(self, highlighted):
"""
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 867a7cd2e8..9cd8067966 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -30,20 +30,23 @@ from . Element import Element
from . Constants import SCROLL_PROXIMITY_SENSITIVITY, SCROLL_DISTANCE
from . external_editor import ExternalEditor
+from ..python.FlowGraph import FlowGraph as _Flowgraph
-class FlowGraph(Element):
+
+class FlowGraph(Element, _Flowgraph):
"""
FlowGraph is the data structure to store graphical signal blocks,
graphical inputs and outputs,
and the connections between inputs and outputs.
"""
- def __init__(self):
+ def __init__(self, **kwargs):
"""
FlowGraph constructor.
Create a list for signal blocks and connections. Connect mouse handlers.
"""
Element.__init__(self)
+ _Flowgraph.__init__(self, **kwargs)
#when is the flow graph selected? (used by keyboard event handler)
self.is_selected = lambda: bool(self.get_selected_elements())
#important vars dealing with mouse event tracking
diff --git a/grc/gui/Param.py b/grc/gui/Param.py
index 6884d6530a..ddfbdcbb1a 100644
--- a/grc/gui/Param.py
+++ b/grc/gui/Param.py
@@ -24,7 +24,9 @@ pygtk.require('2.0')
import gtk
from . import Colors, Utils, Constants, Dialogs
-from . Element import Element
+from .Element import Element
+
+from ..python.Param import Param as _Param
class InputParam(gtk.HBox):
@@ -378,11 +380,12 @@ Error:
#end if"""
-class Param(Element):
+class Param(Element, _Param):
"""The graphical parameter."""
- def __init__(self):
+ def __init__(self, **kwargs):
Element.__init__(self)
+ _Param.__init__(self, **kwargs)
def get_input(self, *args, **kwargs):
"""
diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py
index eda28a0e94..fa0bcf65ea 100644
--- a/grc/gui/Platform.py
+++ b/grc/gui/Platform.py
@@ -17,12 +17,47 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-from Element import Element
+import os
+import sys
+
+from .Element import Element
+
+from ..python.Platform import Platform as _Platform
+from ..python.Constants import PREFS_FILE, PREFS_FILE_OLD
+
+from .Block import Block as _Block
+from .FlowGraph import FlowGraph as _FlowGraph
+from .Param import Param as _Param
+from .Port import Port as _Port
+from .Connection import Connection as _Connection
-class Platform(Element):
- def __init__(self, prefs_file):
- Element.__init__(self)
- self._prefs_file = prefs_file
+class Platform(Element, _Platform):
+
+ def __init__(self):
+ Element.__init__(self)
+ _Platform.__init__(self)
+ self._move_old_pref_file()
+ self._prefs_file = PREFS_FILE
def get_prefs_file(self): return self._prefs_file
+
+ @staticmethod
+ def _move_old_pref_file():
+ if PREFS_FILE == PREFS_FILE_OLD:
+ return # prefs file overridden with env var
+ if os.path.exists(PREFS_FILE_OLD) and not os.path.exists(PREFS_FILE):
+ try:
+ import shutil
+ shutil.move(PREFS_FILE_OLD, PREFS_FILE)
+ except Exception as e:
+ print >> sys.stderr, e
+
+ ##############################################
+ # Constructors
+ ##############################################
+ FlowGraph = _FlowGraph
+ Connection = _Connection
+ Block = _Block
+ Port = _Port
+ Param = _Param
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index ae1a1d223f..849465fc69 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -17,32 +17,33 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-from Element import Element
-from Constants import (
- PORT_SEPARATION, PORT_SPACING, CONNECTOR_EXTENSION_MINIMAL,
- CONNECTOR_EXTENSION_INCREMENT, CANVAS_GRID_SIZE,
- PORT_LABEL_PADDING, PORT_MIN_WIDTH, PORT_LABEL_HIDDEN_WIDTH, PORT_FONT
-)
-from .. base.Constants import DEFAULT_DOMAIN, GR_MESSAGE_DOMAIN
-import Utils
-import Actions
-import Colors
import pygtk
pygtk.require('2.0')
import gtk
+from . import Actions, Colors, Utils
+from .Constants import (
+ PORT_SEPARATION, PORT_SPACING, CONNECTOR_EXTENSION_MINIMAL,
+ CONNECTOR_EXTENSION_INCREMENT, PORT_LABEL_PADDING, PORT_MIN_WIDTH, PORT_LABEL_HIDDEN_WIDTH, PORT_FONT
+)
+from .Element import Element
+from ..python.base.Constants import DEFAULT_DOMAIN, GR_MESSAGE_DOMAIN
+
+from ..python.Port import Port as _Port
+
PORT_MARKUP_TMPL="""\
<span foreground="black" font_desc="$font">$encode($port.get_name())</span>"""
-class Port(Element):
+class Port(_Port, Element):
"""The graphical port."""
- def __init__(self):
+ def __init__(self, block, n, dir):
"""
Port contructor.
Create list of connector coordinates.
"""
+ _Port.__init__(self, block, n, dir)
Element.__init__(self)
self.W = self.H = self.w = self.h = 0
self._connector_coordinate = (0, 0)