diff options
Diffstat (limited to 'grc/gui/Element.py')
-rw-r--r-- | grc/gui/Element.py | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/grc/gui/Element.py b/grc/gui/Element.py index 9385424772..4e88df375f 100644 --- a/grc/gui/Element.py +++ b/grc/gui/Element.py @@ -17,10 +17,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ -from Constants import LINE_SELECT_SENSITIVITY -from Constants import POSSIBLE_ROTATIONS +from __future__ import absolute_import +from .Constants import LINE_SELECT_SENSITIVITY +from .Constants import POSSIBLE_ROTATIONS -import gtk +import gi +from six.moves import zip +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk +from gi.repository import Gdk class Element(object): @@ -38,9 +43,11 @@ class Element(object): self.set_coordinate((0, 0)) self.clear() self.set_highlighted(False) - self.line_attributes = [ - 0, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER - ] + self.line_attributes = [] + """ # No idea where this is in pygobject + 0, Gdk.LINE_SOLID, Gdk.CAP_BUTT, Gdk.JOIN_MITER + ]""" + def is_horizontal(self, rotation=None): """ @@ -85,29 +92,33 @@ class Element(object): self.clear() for child in self.get_children(): child.create_shapes() - def draw(self, gc, window, border_color, bg_color): + def draw(self, widget, cr, border_color, bg_color): """ Draw in the given window. Args: - gc: the graphics context - window: the gtk window to draw on + widget: + cr: border_color: the color for lines and rectangle borders bg_color: the color for the inside of the rectangle """ X, Y = self.get_coordinate() - gc.set_line_attributes(*self.line_attributes) + # TODO: gc.set_line_attributes(*self.line_attributes) for (rX, rY), (W, H) in self._areas_list: aX = X + rX aY = Y + rY - gc.set_foreground(bg_color) - window.draw_rectangle(gc, True, aX, aY, W, H) - gc.set_foreground(border_color) - window.draw_rectangle(gc, False, aX, aY, W, H) + cr.set_source_rgb(*bg_color) + cr.rectangle(aX, aY, W, H) + cr.fill() + cr.set_source_rgb(*border_color) + cr.rectangle(aX, aY, W, H) + cr.stroke() + for (x1, y1), (x2, y2) in self._lines_list: - gc.set_foreground(border_color) - gc.set_background(bg_color) - window.draw_line(gc, X+x1, Y+y1, X+x2, Y+y2) + cr.set_source_rgb(*border_color) + cr.move_to(X + x1, Y + y1) + cr.line_to(X + x2, Y + y2) + cr.stroke() def rotate(self, rotation): """ |