Class: Bitcoin::Gui::ConnView

Inherits:
TreeView
  • Object
show all
Defined in:
lib/bitcoin/gui/conn_view.rb

Instance Attribute Summary

Attributes inherited from TreeView

#model, #view

Instance Method Summary collapse

Methods inherited from TreeView

#embed, #format_address_col, #format_bool_col, #format_uptime_col, #format_value_col, #format_version_col, #tree_view_col

Methods included from Helpers

#add_wallet_filters, #dialog, #display_tx, #format_address, #format_uptime, #format_value, #format_version, #message, #method_missing, #wallet_preview

Constructor Details

#initialize(gui) ⇒ ConnView

Returns a new instance of ConnView.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/bitcoin/gui/conn_view.rb', line 5

def initialize gui
  super(gui, :conn_view, [
      [GObject::TYPE_STRING, "Host"],
      [GObject::TYPE_INT, "Port"],
      [GObject::TYPE_STRING, "State"],
      [GObject::TYPE_INT, "Version", :format_version_col],
      [GObject::TYPE_INT, "Block"],
      [GObject::TYPE_INT, "Uptime", :format_uptime_col],
      [GObject::TYPE_STRING, "User Agent"]])
  @view.set_model @model
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bitcoin::Gui::Helpers

Instance Method Details

#connected(data) ⇒ Object



17
18
19
20
21
22
# File 'lib/bitcoin/gui/conn_view.rb', line 17

def connected data
  row = @model.append(nil)
  data.each_with_index do |pair, i|
    @model.set_value(row, i, pair[1] || "")
  end
end

#disconnected(data) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bitcoin/gui/conn_view.rb', line 24

def disconnected data
  valid, i = @model.get_iter_first
  while valid
    host = @model.get_value(i, 0).get_string
    port = @model.get_value(i, 1).get_int
    if host == data[0] && port == data[1]
      @model.remove(i)
      break
    end
    valid = @model.iter_next(i.to_ptr)
  end
end