summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
Diffstat (limited to 'grc')
-rw-r--r--grc/gui/Block.py31
-rw-r--r--grc/gui/Element.py8
-rw-r--r--grc/python/Block.py6
-rw-r--r--grc/python/block.dtd4
4 files changed, 23 insertions, 26 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 019418d0b..25c37505b 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -21,6 +21,7 @@ from Element import Element
import Utils
import Colors
from .. base import odict
+
from Constants import BORDER_PROXIMITY_SENSITIVITY
from Constants import \
BLOCK_LABEL_PADDING, \
@@ -37,8 +38,8 @@ BLOCK_MARKUP_TMPL="""\
class Block(Element):
"""The graphical signal block."""
-
- def __init__(self):
+ """ image_path from ../python/Block.py"""
+ def __init__(self, image_path):
"""
Block contructor.
Add graphics related params to the block.
@@ -65,8 +66,8 @@ class Block(Element):
})
))
- Element.__init__(self)
-
+ self.image_path= image_path
+
def get_coordinate(self):
"""
Get the coordinate from the position param.
@@ -131,18 +132,6 @@ class Block(Element):
Element.create_labels(self)
self._bg_color = self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR
layouts = list()
-
-
- #### Hack Hack Hack
- '''
- ## DEBUG
- for i in dir(self.get_params()[0]):
- print i," --> " , self.get_params()[0].__getattribute__(i)
- '''
-
- self.block_list = ['gr_serial']
-
- #### End Hack
#create the main layout
layout = gtk.DrawingArea().create_pango_layout('')
@@ -163,6 +152,7 @@ class Block(Element):
self.label_height += h + LABEL_SEPARATION
width = self.label_width
height = self.label_height
+
#setup the pixmap
pixmap = self.get_parent().new_pixmap(width, height)
gc = pixmap.new_gc()
@@ -200,13 +190,14 @@ class Block(Element):
x, y = self.get_coordinate()
#draw main block
- if self.block_list.__contains__(self.get_key_parent(str(self.get_params()[0]._parent))):
- self.new_pixbuf = gtk.gdk.pixbuf_new_from_file("/home/manoj/Pictures/new.jpg")
+ # If the image path is NOT ''
+ if self.image_path != '':
+ self.new_pixbuf = gtk.gdk.pixbuf_new_from_file(self.image_path)
Element.draw_image(
- self, gc, window, bg_color=gtk.gdk.Color(red=65535, blue=0, green=0),
+ self, gc, window, bg_color=self._bg_color,
border_color=self.is_highlighted() and Colors.HIGHLIGHT_COLOR or Colors.BORDER_COLOR, pixbuf = self.new_pixbuf
)
-
+
else:
Element.draw(
self, gc, window, bg_color=self._bg_color,
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index 43c7d15a8..6e79fd9f6 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -91,6 +91,7 @@ class Element(object):
gc.set_foreground(border_color)
window.draw_line(gc, X+x1, Y+y1, X+x2, Y+y2)
+ # Function which draws the image
def draw_image(self, gc, window, border_color, bg_color, pixbuf):
"""
Draw in the given window.
@@ -103,10 +104,11 @@ class Element(object):
for (rX,rY),(W,H) in self._areas_list:
aX = X + rX
aY = Y + rY
-
- window.draw_pixbuf(None, pixbuf, 0,0, X,Y)
+
+ # Needs Tweaking
+ window.draw_pixbuf(None, pixbuf, 0,0, aX, aY, -1, -1) # (gc, pixbuf, src_x, src_y, dest_x, dest_y, W, H)
#window.draw_rectangle(gc, True, aX, aY, W, H)
- #gc.set_foreground(border_color)
+ gc.set_foreground(border_color)
#window.draw_rectangle(gc, False, aX, aY, W, H)
for (x1, y1),(x2, y2) in self._lines_list:
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 2c334dfc2..34f232e93 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -46,16 +46,18 @@ class Block(_Block, _GUIBlock):
self._checks = n.findall('check')
self._callbacks = n.findall('callback')
self._throttle = n.find('throttle') or ''
+ self._image = n.find('image') or ''
+
#build the block
_Block.__init__(
self,
flow_graph=flow_graph,
n=n,
)
- _GUIBlock.__init__(self)
+ _GUIBlock.__init__(self, self._image)
def throttle(self): return bool(self._throttle)
-
+
def validate(self):
"""
Validate this block.
diff --git a/grc/python/block.dtd b/grc/python/block.dtd
index 292ea06cb..f47ba34bf 100644
--- a/grc/python/block.dtd
+++ b/grc/python/block.dtd
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Top level element.
A block contains a name, ...parameters list, and list of IO ports.
-->
-<!ELEMENT block (name, key, category?, throttle?, import*, var_make?, make, callback*, param*, check*, sink*, source*, doc?, grc_source?)>
+<!ELEMENT block (name, key, category?, image?, throttle?, import*, var_make?, make, callback*, param*, check*, sink*, source*, doc?, grc_source?)>
<!--
Sub level elements.
-->
@@ -42,6 +42,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
<!ELEMENT doc (#PCDATA)>
<!ELEMENT grc_source (#PCDATA)>
<!ELEMENT name (#PCDATA)>
+<!ELEMENT image (#PCDATA)>
+
<!ELEMENT key (#PCDATA)>
<!ELEMENT check (#PCDATA)>
<!ELEMENT opt (#PCDATA)>