Class: MyImage
- Inherits:
-
Gtk::Image
- Object
- Gtk::Image
- MyImage
- Includes:
- ManqodCommon
- Defined in:
- lib/Common/MyImage.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Constant Summary
Constants included from ManqodCommon
ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING
Constants included from Eprint
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#image_id ⇒ Object
readonly
Returns the value of attribute image_id.
-
#pb ⇒ Object
readonly
Returns the value of attribute pb.
Instance Method Summary collapse
-
#initialize(image_id, from_client = false) ⇒ MyImage
constructor
A new instance of MyImage.
- #resize(icon_size_name = nil) ⇒ Object
- #to_s ⇒ Object
Methods included from ManqodCommon
#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick
Methods included from Eprint
#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception
Constructor Details
#initialize(image_id, from_client = false) ⇒ MyImage
Returns a new instance of MyImage.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/Common/MyImage.rb', line 7 def initialize(image_id,from_client=false) @image_id=image_id @filename=nil begin row=if from_client then ManqodDB.instance.ccache.get("im[#{image_id}]") else ManqodDB.instance.cache.get("im[#{image_id}]") end if row @filename=row["filename"] a=Array.new row['filedata'].each_byte{|v|a.push(v)} pixdata=Gdk::Pixdata.deserialize(a) @pb=pixdata.to_pixbuf(true) super(pb) else raise end rescue =>e ewarn("cannot load image #{from_client ? "client":""} #{image_id}: #{e}") super(Gtk::Stock::MISSING_IMAGE,Gtk::IconSize::MENU) end end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
28 29 30 |
# File 'lib/Common/MyImage.rb', line 28 def filename @filename end |
#image_id ⇒ Object (readonly)
Returns the value of attribute image_id.
28 29 30 |
# File 'lib/Common/MyImage.rb', line 28 def image_id @image_id end |
#pb ⇒ Object (readonly)
Returns the value of attribute pb.
28 29 30 |
# File 'lib/Common/MyImage.rb', line 28 def pb @pb end |
Instance Method Details
#resize(icon_size_name = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/Common/MyImage.rb', line 30 def resize(icon_size_name=nil) new_pb=nil if storage_type==Gtk::Image::PIXBUF && icon_size_name case icon_size_name.class.name when 'Fixnum' then nw,nh =[ icon_size_name,icon_size_name] when 'String' then nw,nh =Gtk::IconSize.lookup(Gtk::IconSize.from_name(icon_size_name)) end new_pb=pb.scale(nw,nh) end edebug("resized from #{pixbuf.height if pb}x#{pixbuf.width if pb} to #{new_pb.height if new_pb}x#{new_pb.width if new_pb}","image") new_pb end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/Common/MyImage.rb', line 43 def to_s "MyImage{id:#{image_id},name:#{filename}}" end |