def dom_node_to_image(self, dom_node): """From dom_node to Image""" if dom_node.hasAttribute("justification"): justification = dom_node.attributes["justification"].value else: justification = cons.TAG_PROP_LEFT if dom_node.hasAttribute("anchor"): pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( cons.ANCHOR_CHAR, self.dad.anchor_size, self.dad.anchor_size) pixbuf.anchor = dom_node.attributes["anchor"].value elif dom_node.hasAttribute("filename"): pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( cons.FILE_CHAR, self.dad.embfile_size, self.dad.embfile_size) pixbuf.filename = dom_node.attributes["filename"].value pixbuf.embfile = base64.b64decode(dom_node.firstChild.data) pixbuf.time = float(dom_node.attributes["time"].value ) if dom_node.hasAttribute("time") else 0 else: pixbuf = machines.get_pixbuf_from_encoded_buffer( dom_node.firstChild.data) if pixbuf: pixbuf.link = dom_node.attributes[ "link"].value if dom_node.hasAttribute("link") else "" self.dad.image_insert(self.dad.curr_buffer.get_iter_at_mark( self.dad.curr_buffer.get_insert()), pixbuf, image_justification=justification, text_buffer=self.dad.curr_buffer)
def dom_node_to_image(self, dom_node): """From dom_node to Image""" if dom_node.hasAttribute("justification"): justification = dom_node.attributes["justification"].value else: justification = cons.TAG_PROP_LEFT if dom_node.hasAttribute("anchor"): pixbuf = gtk.gdk.pixbuf_new_from_file(cons.ANCHOR_CHAR) pixbuf = pixbuf.scale_simple(self.dad.anchor_size, self.dad.anchor_size, gtk.gdk.INTERP_BILINEAR) pixbuf.anchor = dom_node.attributes["anchor"].value else: pixbuf = machines.get_pixbuf_from_encoded_buffer(dom_node.firstChild.data) if pixbuf: self.dad.image_insert(self.dad.curr_buffer.get_iter_at_mark(self.dad.curr_buffer.get_insert()), pixbuf, image_justification=justification, text_buffer=self.dad.curr_buffer)
def dom_node_to_image(self, dom_node): """From dom_node to Image""" if dom_node.hasAttribute("justification"): justification = dom_node.attributes["justification"].value else: justification = cons.TAG_PROP_LEFT if dom_node.hasAttribute("anchor"): pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(cons.ANCHOR_CHAR, self.dad.anchor_size, self.dad.anchor_size) pixbuf.anchor = dom_node.attributes["anchor"].value elif dom_node.hasAttribute("filename"): pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(cons.FILE_CHAR, self.dad.embfile_size, self.dad.embfile_size) pixbuf.filename = dom_node.attributes["filename"].value pixbuf.embfile = base64.b64decode(dom_node.firstChild.data) pixbuf.time = float(dom_node.attributes["time"].value) if dom_node.hasAttribute("time") else 0 else: pixbuf = machines.get_pixbuf_from_encoded_buffer(dom_node.firstChild.data) if pixbuf: pixbuf.link = dom_node.attributes["link"].value if dom_node.hasAttribute("link") else "" self.dad.image_insert(self.dad.curr_buffer.get_iter_at_mark(self.dad.curr_buffer.get_insert()), pixbuf, image_justification=justification, text_buffer=self.dad.curr_buffer)