Class: Ig3tool::PeopleWindow
- Inherits:
-
GladeHelper
- Object
- GladeHelper
- Ig3tool::PeopleWindow
- Includes:
- GetText
- Defined in:
- lib/ui/peoplewindow.rb
Constant Summary collapse
- MENU_PATH =
["Leden"]
- ICON =
"members_xklein.png"
- FIELDS =
%w(firstname lastname email username rolnummer phone mobile)
- ALLFIELDS =
%w(firstname lastname email username rolnummer phone mobile address1 address2 barcode)
Constants inherited from GladeHelper
Instance Attribute Summary collapse
-
#glade ⇒ Object
readonly
Returns the value of attribute glade.
Instance Method Summary collapse
- #clear(widget) ⇒ Object
- #clear_all(widget, clearnotification = true) ⇒ Object
- #clear_most(widget, clearnotification = true) ⇒ Object
- #delete(widget) ⇒ Object
- #find(widget) ⇒ Object
- #find_by_barcode(widget) ⇒ Object
- #fix(field) ⇒ Object
-
#initialize ⇒ PeopleWindow
constructor
A new instance of PeopleWindow.
- #log_row_activated(widget, arg0, arg1) ⇒ Object
- #notification_focus_in_event_cb(widget, arg0) ⇒ Object
- #refresh(widget) ⇒ Object
- #refreshhist(widget) ⇒ Object
- #save(widget) ⇒ Object
- #select(widget, path, column) ⇒ Object
- #smart_search(widget) ⇒ Object
- #tabfocus(widget, arg0, arg1) ⇒ Object
- #username_del(widget, arg0, arg1) ⇒ Object
- #username_ins(widget, arg0, arg1, arg2) ⇒ Object
Methods inherited from GladeHelper
#_get_widget, #add_window_colorer, #load_sounds, #make_debugger_combo, #make_eval_widget, #make_status_combo, #number_eval_widget, #play, #present, #show, #speak
Constructor Details
#initialize ⇒ PeopleWindow
Returns a new instance of PeopleWindow.
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ui/peoplewindow.rb', line 16 def initialize super("people.glade") @username = @glade.("username") @firstname = @glade.("firstname") @lastname = @glade.("lastname") @barcode = @glade.("barcode") @email = @glade.("email") @notification = @glade.("notification") @status = @glade.("status") @mobile = @glade.("mobile") @address1 = @glade.("address1") @address2 = @glade.("address2") @phone = @glade.("phone") @rolnummer = @glade.("rolnummer") @statussearch = @glade.("statussearch") @people_view = _@glade.("names") @people_view.model = @people_store = Gtk::ListStore.new(Object, String) r = Gtk::CellRendererText.new @people_view.insert_column(-1, "name", r, :text => 1) @people_view.enable_search = true @history = @glade.("history") @history.model = @history_store = Gtk::ListStore.new(Object, String, String, String, String) ll = Gtk::CellRendererText.new @history.insert_column(-1, "year", ll) do |tvc, cell, m ,iter| cell.text = iter[0].year end @history.insert_column(-1, "username", ll) do |tvc, cell, m ,iter| cell.text = iter[0].username end @history.insert_column(-1, "status", ll) do |tvc, cell, m ,iter| cell.text = iter[0].status end @history.insert_column(-1, "barcode", ll) do |tvc, cell, m ,iter| cell.text = iter[0]. end @statussearch.active = 0 @statushash = {"non-member" => 0, "member" => 1, "debugger" => 2, "honorary member" => 3, "ex-debugger" => 4} @statushashi = @statushash.invert end |
Instance Attribute Details
#glade ⇒ Object (readonly)
Returns the value of attribute glade.
14 15 16 |
# File 'lib/ui/peoplewindow.rb', line 14 def glade @glade end |
Instance Method Details
#clear(widget) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/ui/peoplewindow.rb', line 108 def clear() @statussearch.active = 0 if @statussearch.active == -1 #@statussearch.active = 0 # met of zonder if? clear_all(nil) end |
#clear_all(widget, clearnotification = true) ⇒ Object
209 210 211 212 213 |
# File 'lib/ui/peoplewindow.rb', line 209 def clear_all(, clearnotification=true) @username.text = "" clear_most(,clearnotification) @people_view.grab_focus end |
#clear_most(widget, clearnotification = true) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/ui/peoplewindow.rb', line 215 def clear_most(, clearnotification=true) @email.text = "" @firstname.text = "" @lastname.text = "" @barcode.text = "" @phone.text = "" @rolnummer.text = "" @mobile.text = "" @address1.text = "" @address2.text = "" @notification.text = "" if clearnotification #@statussearch.active = 0 @status.active = -1 @history_store.clear end |
#delete(widget) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ui/peoplewindow.rb', line 70 def delete() username = @username.text.strip begin raise Needed, "please fill in a username..." if username.empty? $client.person_remove!("username" => username) @notification.text = "the imps killed username, they left no traces..." rescue Exception => e @notification.text = e. end end |
#find(widget) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/ui/peoplewindow.rb', line 175 def find() attrs = {} FIELDS.each do |k| #v = _get_widget(k).text.strip v = @glade.(k).text.strip fld = fix(k) attrs[fld] = v unless v.nil? or v.empty? end begin people = $client.person_lookup(attrs) _show(people[0]) if people.size == 1 _update_names(people) rescue Exception => e @notification.text = "Error: Lookup: #{e.}" end end |
#find_by_barcode(widget) ⇒ Object
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ui/peoplewindow.rb', line 98 def () begin = @barcode.text p = $client.person_member() clear_all(nil) _show(p) rescue Exception => e @notification.text = "no user with barcode #{} found..." end end |
#fix(field) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/ui/peoplewindow.rb', line 160 def fix(field) case field when "firstname" "first_name" when "lastname" "last_name" when "rolnummer" "rolnr" when "mobile" "gsm" else field end end |
#log_row_activated(widget, arg0, arg1) ⇒ Object
118 119 120 |
# File 'lib/ui/peoplewindow.rb', line 118 def log_row_activated(, arg0, arg1) clear_most(nil) end |
#notification_focus_in_event_cb(widget, arg0) ⇒ Object
196 197 198 |
# File 'lib/ui/peoplewindow.rb', line 196 def notification_focus_in_event_cb(, arg0) puts "notification_focus_in_event_cb() is not implemented yet." end |
#refresh(widget) ⇒ Object
114 115 116 117 |
# File 'lib/ui/peoplewindow.rb', line 114 def refresh() puts "refresh!" _update_names(nil) unless @statussearch.active == -1 end |
#refreshhist(widget) ⇒ Object
80 81 82 |
# File 'lib/ui/peoplewindow.rb', line 80 def refreshhist() puts "refreshhist() is not implemented yet." end |
#save(widget) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/ui/peoplewindow.rb', line 128 def save() attrs = {} ALLFIELDS.each do |k| #v = _get_widget(k).text.strip v = @glade.(k).text.strip fld = fix(k) attrs[fld] = v unless v.nil? or v.empty? end if attrs["address1"] and attrs["address2"] attrs["address"] = attrs["address1"] + ", " + attrs["address2"] elsif attrs["address1"] attrs["address"] = attrs["address1"] elsif attrs["address2"] attrs["address"] = attrs["address2"] end attrs.delete "address1" attrs.delete "address2" attrs["status"] = @statushashi[@status.active] begin $client.person_save!(attrs) @notification.text = "Person succesfully saved, clearing the form..." sleep 2 clear_all(nil) _update_names rescue Exception => e @notification.text = "Error: Save: #{e.}" end end |
#select(widget, path, column) ⇒ Object
202 203 204 205 206 207 |
# File 'lib/ui/peoplewindow.rb', line 202 def select (, path, column) iter = .model.get_iter(path) clear_all(nil) u = $client.person_lookup("username", iter[0].username.to_s)[0] _show(u) end |
#smart_search(widget) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ui/peoplewindow.rb', line 83 def smart_search() username = @username.text if username.strip.empty? @notification.text = "please fill in a username..." else p = $client.person_lookup("username", username)[0] if p.nil? @notification.text = "no user with username #{username} found..." else clear_all(nil) _show(p) end end end |
#tabfocus(widget, arg0, arg1) ⇒ Object
124 125 126 |
# File 'lib/ui/peoplewindow.rb', line 124 def tabfocus(, arg0, arg1) puts "tabfocus() is not implemented yet." end |
#username_del(widget, arg0, arg1) ⇒ Object
121 122 123 |
# File 'lib/ui/peoplewindow.rb', line 121 def username_del(, arg0, arg1) clear_most(nil) end |
#username_ins(widget, arg0, arg1, arg2) ⇒ Object
199 200 201 |
# File 'lib/ui/peoplewindow.rb', line 199 def username_ins(, arg0, arg1, arg2) puts "username_ins() is not implemented yet." end |