class FormImage
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Attributes
pc[RW]
Public Class Methods
new(pc)
click to toggle source
Calls superclass method
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 7 def initialize(pc) @pc=pc super() set_relief(Gtk::ReliefStyle::NONE) signal_connect("clicked"){|me,ev| if @pc.editable? fch=Gtk::FileChooserDialog.new fch.set_action(Gtk::FileChooser::Action::OPEN) fch.signal_connect("file-activated"){|me,ev| set_image(load_file(me.filename)) me.close } fch.signal_connect("delete-event"){|me,ev| me.destroy } fch.run end } end
Public Instance Methods
deserialize_pixdata(raw)
click to toggle source
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 38 def deserialize_pixdata(raw) begin pixdata=Gdk::Pixdata.deserialize(Marshal.load(raw)) pb=pixdata.to_pixbuf(true) Gtk::Image.new(pb) rescue =>e ewarn("cannot load image: #{e}") Gtk::Image.new(Gtk::Stock::MISSING_IMAGE,Gtk::IconSize::MENU) end end
item()
click to toggle source
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 34 def item @pc.item end
load_file(filename)
click to toggle source
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 49 def load_file(filename) im=Gtk::Image.new(filename) if im.storage_type==Gtk::Image::PIXBUF && pc.gtk_attribute('form-image-max-height') && pc.gtk_attribute('form-image-max-height').to_f < im.pixbuf.height nw,nh =im.pixbuf.width*pc.gtk_attribute('form-image-max-height').to_f / im.pixbuf.height, pc.gtk_attribute('form-image-max-height').to_f new_pb=im.pixbuf.scale(nw,nh) im.set_pixbuf(new_pb) end im end
modify_font(font)
click to toggle source
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 71 def modify_font(font) end
set_image(im)
click to toggle source
Calls superclass method
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 59 def set_image(im) super begin item['default']=Marshal.dump(Gdk::Pixdata.from_pixbuf(im.pixbuf,true).serialize) if im.pixbuf rescue =>err ewarn(err) end end
text()
click to toggle source
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 68 def text item["default"] end
update(im=item['default'])
click to toggle source
# File lib/FormHolder/Form/InputHolder/FormImage.rb, line 28 def update(im=item['default']) run_events(item['id'],'info_item-BeforeUpdate') set_image(deserialize_pixdata(im)) run_events(item['id'],'info_item-AfterUpdate') end