commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 74/101: grc: gtk3: minor gui flowgraph clea


From: git
Subject: [Commit-gnuradio] [gnuradio] 74/101: grc: gtk3: minor gui flowgraph cleanup
Date: Thu, 16 Mar 2017 14:58:10 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch python3
in repository gnuradio.

commit f85df8b8d9bf2a88a6b87b91d0b55fdcb8161f46
Author: Sebastian Koslowski <address@hidden>
Date:   Tue Aug 30 16:26:13 2016 +0200

    grc: gtk3: minor gui flowgraph cleanup
---
 grc/gui/ActionHandler.py |  2 +-
 grc/gui/Block.py         |  7 ++++---
 grc/gui/Connection.py    |  2 +-
 grc/gui/DrawingArea.py   |  2 +-
 grc/gui/Element.py       |  2 +-
 grc/gui/FlowGraph.py     | 47 ++++++++++++++++++++---------------------------
 grc/gui/MainWindow.py    |  4 ++--
 grc/gui/Port.py          |  2 +-
 8 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index ca16a7e..85b68a9 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 6cbfa5f..4b6c5b8 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 b5238bc..9862328 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 c729bba..f279d50 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 81a5cbf..8418bef 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 7333519..f082e4f 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 efa8573..6114438 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 258ae24..8ac32dc 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.
         """



reply via email to

[Prev in Thread] Current Thread [Next in Thread]