summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/ActionHandler.py2
-rw-r--r--grc/gui/Block.py7
-rw-r--r--grc/gui/Connection.py2
-rw-r--r--grc/gui/DrawingArea.py2
-rw-r--r--grc/gui/Element.py2
-rw-r--r--grc/gui/FlowGraph.py47
-rw-r--r--grc/gui/MainWindow.py4
-rw-r--r--grc/gui/Port.py2
8 files changed, 31 insertions, 37 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index ca16a7e7fd..85b68a9629 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -675,7 +675,7 @@ class ActionHandler:
main.update()
flow_graph.update_selected()
- flow_graph.queue_draw()
+ page.drawing_area.queue_draw()
return True # action was handled
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 6cbfa5f4f5..4b6c5b8e9e 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -244,7 +244,7 @@ class Block(CoreBlock, Element):
else:
self._comment_layout = None
- def draw(self, widget, cr):
+ def draw(self, cr):
"""
Draw the signal block with label and inputs/outputs.
"""
@@ -253,7 +253,7 @@ class Block(CoreBlock, Element):
for port in self.active_ports(): # ports first
cr.save()
- port.draw(widget, cr)
+ port.draw(cr)
cr.restore()
cr.rectangle(*self._area)
@@ -295,7 +295,7 @@ class Block(CoreBlock, Element):
return port_selected
return Element.what_is_selected(self, coor, coor_m)
- def draw_comment(self, widget, cr):
+ def draw_comment(self, cr):
if not self._comment_layout:
return
x, y = self.coordinate
@@ -375,3 +375,4 @@ class Block(CoreBlock, Element):
except:
pass
return changed
+
diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py
index b5238bc2a6..9862328d6a 100644
--- a/grc/gui/Connection.py
+++ b/grc/gui/Connection.py
@@ -156,7 +156,7 @@ class Connection(CoreConnection, Element):
self._line = [p0, p1, point, p2, p3]
self.bounds_from_line(self._line)
- def draw(self, widget, cr):
+ def draw(self, cr):
"""
Draw the connection.
"""
diff --git a/grc/gui/DrawingArea.py b/grc/gui/DrawingArea.py
index c729bbad24..f279d50557 100644
--- a/grc/gui/DrawingArea.py
+++ b/grc/gui/DrawingArea.py
@@ -194,7 +194,7 @@ class DrawingArea(Gtk.DrawingArea):
cr.scale(self.zoom_factor, self.zoom_factor)
cr.fill()
- self._flow_graph.draw(widget, cr)
+ self._flow_graph.draw(cr)
def _translate_event_coords(self, event):
return event.x / self.zoom_factor, event.y / self.zoom_factor
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index 81a5cbfc40..8418bef0cc 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -108,7 +108,7 @@ class Element(object):
Call this base method before creating shapes in the element.
"""
- def draw(self, widget, cr):
+ def draw(self, cr):
raise NotImplementedError()
def bounds_from_area(self, area):
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 7333519a4f..f082e4f7f0 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -134,14 +134,15 @@ class FlowGraph(CoreFlowgraph, Element):
coor: an optional coordinate or None for random
"""
id = self._get_unique_id(key)
- #calculate the position coordinate
- h_adj = self.get_scroll_pane().get_hadjustment()
- v_adj = self.get_scroll_pane().get_vadjustment()
+ scroll_pane = self.drawing_area.get_parent().get_parent()
+ # calculate the position coordinate
+ h_adj = scroll_pane.get_hadjustment()
+ v_adj = scroll_pane.get_vadjustment()
if coor is None: coor = (
int(random.uniform(.25, .75)*h_adj.get_page_size() + h_adj.get_value()),
int(random.uniform(.25, .75)*v_adj.get_page_size() + v_adj.get_value()),
)
- #get the new block
+ # get the new block
block = self.new_block(key)
block.coordinate = coor
block.get_param('id').set_value(id)
@@ -190,15 +191,6 @@ class FlowGraph(CoreFlowgraph, Element):
return success
###########################################################################
- # Access Drawing Area
- ###########################################################################
- def get_drawing_area(self): return self.drawing_area
- def queue_draw(self): self.get_drawing_area().queue_draw()
- def get_scroll_pane(self): return self.drawing_area.get_parent().get_parent()
- def get_ctrl_mask(self): return self.drawing_area.ctrl_mask
- def get_mod1_mask(self): return self.drawing_area.mod1_mask
-
- ###########################################################################
# Copy Paste
###########################################################################
def copy_to_clipboard(self):
@@ -241,9 +233,10 @@ class FlowGraph(CoreFlowgraph, Element):
selected = set()
(x_min, y_min), blocks_n, connections_n = clipboard
old_id2block = dict()
- #recalc the position
- h_adj = self.get_scroll_pane().get_hadjustment()
- v_adj = self.get_scroll_pane().get_vadjustment()
+ # recalc the position
+ scroll_pane = self.drawing_area.get_parent().get_parent()
+ h_adj = scroll_pane.get_hadjustment()
+ v_adj = scroll_pane.get_vadjustment()
x_off = h_adj.get_value() - x_min + h_adj.get_page_size() / 4
y_off = v_adj.get_value() - y_min + v_adj.get_page_size() / 4
if len(self.get_elements()) <= 1:
@@ -486,15 +479,15 @@ class FlowGraph(CoreFlowgraph, Element):
for element in self._elements_to_draw:
yield element.draw
- def draw(self, widget, cr):
+ def draw(self, cr):
"""Draw blocks connections comment and select rectangle"""
for draw_element in self._drawables():
cr.save()
- draw_element(widget, cr)
+ draw_element(cr)
cr.restore()
# draw multi select rectangle
- if self.mouse_pressed and (not self.selected_elements or self.get_ctrl_mask()):
+ if self.mouse_pressed and (not self.selected_elements or self.drawing_area.ctrl_mask):
x1, y1 = self.press_coor
x2, y2 = self.coordinate
x, y = int(min(x1, x2)), int(min(y1, y2))
@@ -529,18 +522,18 @@ class FlowGraph(CoreFlowgraph, Element):
new_selections = self.what_is_selected(self.coordinate)
# update the selections if the new selection is not in the current selections
# allows us to move entire selected groups of elements
- if self.get_ctrl_mask() or new_selections not in self.selected_elements:
+ if self.drawing_area.ctrl_mask or new_selections not in self.selected_elements:
selected_elements = new_selections
if self._old_selected_port:
self._old_selected_port.force_show_label = False
self.create_shapes()
- self.queue_draw()
+ self.drawing_area.queue_draw()
elif self._new_selected_port:
self._new_selected_port.force_show_label = True
else: # called from a mouse release
- if not self.element_moved and (not self.selected_elements or self.get_ctrl_mask()):
+ if not self.element_moved and (not self.selected_elements or self.drawing_area.ctrl_mask):
selected_elements = self.what_is_selected(self.coordinate, self.press_coor)
# this selection and the last were ports, try to connect them
@@ -552,7 +545,7 @@ class FlowGraph(CoreFlowgraph, Element):
return
# if ctrl, set the selected elements to the union - intersection of old and new
- if self.get_ctrl_mask():
+ if self.drawing_area.ctrl_mask:
self.selected_elements ^= selected_elements
else:
self.selected_elements.clear()
@@ -729,7 +722,7 @@ class FlowGraph(CoreFlowgraph, Element):
if redraw:
# self.create_labels()
self.create_shapes()
- self.queue_draw()
+ self.drawing_area.queue_draw()
def _handle_mouse_motion_drag(self, coordinate):
# remove the connection if selected in drag event
@@ -738,15 +731,15 @@ class FlowGraph(CoreFlowgraph, Element):
# move the selected elements and record the new coordinate
x, y = coordinate
- if not self.get_ctrl_mask():
+ if not self.drawing_area.ctrl_mask:
X, Y = self.coordinate
dX, dY = int(x - X), int(y - Y)
- active = Actions.TOGGLE_SNAP_TO_GRID.get_active() or self.get_mod1_mask()
+ active = Actions.TOGGLE_SNAP_TO_GRID.get_active() or self.drawing_area.mod1_mask
if not active or abs(dX) >= Utils.CANVAS_GRID_SIZE or abs(dY) >= Utils.CANVAS_GRID_SIZE:
self.move_selected((dX, dY))
self.coordinate = (x, y)
# queue draw for animation
- self.queue_draw()
+ self.drawing_area.queue_draw()
def get_max_coords(self, initial=(0, 0)):
w, h = initial
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index efa8573c3b..61144386b4 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -77,7 +77,7 @@ class MainWindow(Gtk.Window):
# Create the notebook
self.notebook = Gtk.Notebook()
self.page_to_be_closed = None
- self.current_page = None
+ self.current_page = None # type: NotebookPage
self.notebook.set_show_border(False)
self.notebook.set_scrollable(True) # scroll arrows for page tabs
self.notebook.connect('switch-page', self._handle_page_change)
@@ -370,7 +370,7 @@ class MainWindow(Gtk.Window):
Returns:
the focus flag
"""
- return self.current_page.get_drawing_area().get_focus_flag()
+ return self.current_page.drawing_area.get_focus_flag()
############################################################
# Helpers
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index 258ae244ab..8ac32dc25f 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -125,7 +125,7 @@ class Port(_Port, Element):
self._label_layout_offsets[1] += Constants.PORT_EXTRA_BUS_HEIGHT / 2
self.height += self.height % 2 # uneven height
- def draw(self, widget, cr):
+ def draw(self, cr):
"""
Draw the socket with a label.
"""