Class: DrbImages

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/Common/Images.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])

Instance Method Summary collapse

Instance Method Details

#client_eachObject



34
35
36
37
38
# File 'lib/Common/Images.rb', line 34

def client_each
	@cimages.each{|im_id,myim|
		yield im_id,myim
	}
end

#client_image_of_id(id_of_image = nil, resize = nil) ⇒ Object



19
20
21
# File 'lib/Common/Images.rb', line 19

def client_image_of_id(id_of_image=nil,resize=nil)
	image_of_id(id_of_image, resize,true)
end

#image_of_id(id_of_image = nil, resize = nil, client = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/Common/Images.rb', line 22

def image_of_id(id_of_image=nil,resize=nil,client=false)
	imh=if client then @cimages else @images end
	if !id_of_image.nil? and imh.has_key?(id_of_image.to_i)
		im=imh[id_of_image.to_i]
		ret=resize ? im.resize(resize) : im.pixbuf
	else
		ret=Gtk::Image.new(Gtk::Stock::MISSING_IMAGE,Gtk::IconSize::MENU).pixbuf
		ewarn("no image found for id: #{id_of_image}!","image") unless id_of_image==0
	end
	ret
end

#load_imagesObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/Common/Images.rb', line 8

def load_images
	@images=Hash.new if @images.nil?
	@cimages=Hash.new if @cimages.nil?
	if ManqodDB.instance.ccache
		keys=ManqodDB.instance.ccache.get("imkeys")
		keys.each{|key,addr| @cimages[key]=MyImage.new(key,true)}
	end
	keys=ManqodDB.instance.cache.get("imkeys")
	keys.each{|key,addr| @images[key]=MyImage.new(key)}
end