Class: MyCellRendererCombo

Inherits:
Gtk::CellRendererCombo
  • Object
show all
Includes:
ManqodCommon
Defined in:
lib/ListHolder/EditableList/CellRenderers/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

MyCellRendererConstCombo

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 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(column) ⇒ MyCellRendererCombo

Returns a new instance of MyCellRendererCombo.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 7

def initialize(column)
	@mycombomodel=Gtk::ListStore.new(String,String)
	@jump_to_next=false
	super()
	set_model(@mycombomodel)
	set_text_column(1)
	set_has_entry(false)
	
	set_ellipsize(column.pango_ellipsize)
	set_ellipsize_set(true)
	set_mode(Gtk::CellRenderer::MODE_EDITABLE)

	signal_connect("edited"){|me,path,new_text|
		if selected_combo_value=get_value_from_text(new_text)
			view.list_model.change_value_of_path(path,column.header['data'],selected_combo_value)
		end
		if @jump_to_next
			if next_col=view.next_editable_column(column)
				view.set_cursor(view.list_model.iter_at_cursor.path,next_col,true)#  if next_col.header["type"]!="gtk_toggle"
			end
			@jump_to_next=false
		end
		true
	}
	signal_connect("editing-started"){|cell, editable_widget, path|
		if !editable_widget.nil?
			editable_widget.signal_connect("key-release-event"){|me,event|
				@jump_to_next= Gdk::Keyval.to_name(event.keyval) == "Return"
				false
			}
		end
	}

end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



43
44
45
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 43

def column
  @column
end

#model_col_numObject

Returns the value of attribute model_col_num.



41
42
43
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 41

def model_col_num
  @model_col_num
end

#viewObject

Returns the value of attribute view.



42
43
44
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 42

def view
  @view
end

Instance Method Details

#append_row(cdata, cdisplay) ⇒ Object



80
81
82
83
84
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 80

def append_row(cdata,cdisplay)
	iter=@mycombomodel.append
	iter[0]=cdata
	iter[1]=cdisplay
end

#callerObject



90
91
92
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 90

def caller
	view
end

#dataObject



86
87
88
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 86

def data
	@header["data"]
end

#get_text_from_value(selected_combo_value) ⇒ Object



69
70
71
72
73
74
75
76
77
78
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 69

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

#get_value_from_text(selected_combo_text) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 59

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

#set_column(column) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ListHolder/EditableList/CellRenderers/Combo.rb', line 45

def set_column(column)
	@column=column
@view=column.list
@model_col_num=column.colnum

if column.header['admin'] then
  admin_rows(column.header['querySQL'],column.header['key'].include?(".")){|row| append_row(row[column.header['key']],row[column.header['display']])}
  else
  rows(column.header['querySQL'],column.header['key'].include?(".")){|row| append_row(row[column.header['key']],row[column.header['display']])}
end unless column.header['querySQL'].length == 0

set_editable(column.header['editable'])
end