Class: MyRendererCombo

Inherits:
Gtk::ComboBox
  • Object
show all
Includes:
GtkAttributes, ManqodCommon
Defined in:
lib/FormHolder/Form/InputHolder/Combo.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])

Direct Known Subclasses

FieldCombo, MyRendererConstCombo

Constant Summary

Constants included from ManqodCommon

ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING

Constants included from Eprint

Eprint::DOMAIN, Eprint::LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GtkAttributes

#default_attribute, #gtk_attribute, #gtk_attribute_of_object, #gtkobjectid, #gtkobjecttype, #set_gtk_attribute

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(pc) ⇒ MyRendererCombo

Returns a new instance of MyRendererCombo.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 9

def initialize(pc)
	@pc=pc
	super(false)
	item['wantnew']=true
	set_model(MyRendererModel.new(self))
	signal_connect('changed'){|me| 
		edebug(inspect+" '#{item['data']}' changed to item #{me.active.inspect}","form-combo","debug")
		pc.changed
		pc.notify_observers(self)
		edebug("'#{item['data']}' emiting 'changed' to observers","form-combo","debug")
		run_events(item['id'],'form_item-Action')
	}
end

Instance Attribute Details

#pcObject

Returns the value of attribute pc.



23
24
25
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 23

def pc
  @pc
end

Instance Method Details

#get_text_from_value(selected_combo_value) ⇒ Object



45
46
47
48
49
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 45

def get_text_from_value(selected_combo_value)
	selected_combo_text=nil
	model.mymodel.each {|model, path, iter| selected_combo_text=iter[0] if iter[1]==selected_combo_value }
	return selected_combo_text
end

#get_value_from_text(selected_combo_text) ⇒ Object



39
40
41
42
43
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 39

def get_value_from_text(selected_combo_text)
	selected_combo_value=nil
	model.mymodel.each {|model, path, iter| selected_combo_value=iter[0] if iter[1]==selected_combo_text }
	return selected_combo_value
end

#itemObject



25
26
27
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 25

def item
	pc.item
end

#parentMObject



74
75
76
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 74

def parentM
pc.parentM
end

#parentselectedObject



71
72
73
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 71

def parentselected
pc.parentselected
end

#select_value(selected_value = ) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 59

def select_value(selected_value=item['default'])
  item['default']=selected_value.to_s
  found_and_selected=false
  model.mymodel.each {|m, path, iter|  
		if iter[0]==item['default']
			set_active_iter(model.convert_child_iter_to_iter(iter))
			found_and_selected=true
		end
  }
  found_and_selected
end

#textObject



51
52
53
54
55
56
57
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 51

def text
	if active_iter
		self.active_iter[0]
		else
		""
	end
end

#to_sObject



77
78
79
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 77

def to_s
"Combo(#{item['description']})"
end

#update(new_value = ) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/FormHolder/Form/InputHolder/Combo.rb', line 30

def update(new_value=item['default'])
item['default']=new_value
edebug("update called for #{inspect}, setting value #{new_value}","form-combo","debug")
run_events(item['id'],'form_item-BeforeUpdate')
model.update
select_value(item['default'])
run_events(item['id'],'form_item-AfterUpdate')
end