[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-treev-cbbr

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 10月 14日 (日) 06:48:20 JST


-------------------------
REMOTE_ADDR = 184.145.82.7
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-cbbr
-------------------------
@@ -328,7 +328,6 @@
 
  #!/usr/bin/env ruby
  require 'gtk2'
- 
  # Add two columns to the Gtk::TreeView. The first will display
  # location as text, and the second the progress bar.
  def setup_tree_view(treeview)
@@ -346,13 +345,10 @@
    )
    treeview.append_column(column) 
  end
- 
  class ActList
    attr_accessor :location, :action
    def initialize(l, a); @location, @action = l, a; end
  end
  LOCATION_COLUMN = 0; VALUE_COLUMN = 1; PBTEXT_COLUMN = 2
- 
  list = [
    ActList.new("www.alpha.net",    0),
    ActList.new("www.boby.com",     0),
@@ -360,11 +357,6 @@
    ActList.new("www.kwackers.org", 0),
    ActList.new("www.wealthy.org",  0)
  ]
- 
- # Create a new tree model with two columns, as 
+  # Create a new tree model with two columns, as 
  # string and integer.
  treeview = Gtk::TreeView.new(store = Gtk::ListStore.new(String, Integer, String))
- 
  # Add all of the products to the GtkListStore.
  list.each_with_index do |e, i|
      iter = store.append
@@ -373,9 +368,3 @@
      iter[PBTEXT_COLUMN]  = nil
      iter.next!
  end
+  setup_tree_view(treeview)
  
- setup_tree_view(treeview)
- 
  # Create as many threads as there are items in the list containing ActList objects.
  # Each thread updates a progress bar for one line in our tree view, by setting the
  # VALUE_COLUMN column in the store list model.   
@@ -387,7 +0,0 @@
      iiter = aiter[ii]
      r_factor = rand(20) + 1
      Thread.current[:id] = "#{ii}: #{iiter[LOCATION_COLUMN]}"
- 
      loop do
        break if iiter[VALUE_COLUMN] >= 100
        iiter[VALUE_COLUMN] = iiter[VALUE_COLUMN] + 5 if iiter[VALUE_COLUMN] < 100
@@ -400,7 +393,-1 @@
    end
    iter.next!
  end
- 
  sleep 0.1 # wait for threads to be created
  Thread.new do	# This thread finishes after all threads are done!
    Thread.list.each {|t| puts "DEBUG: thread's value=[#{t.value}]" if t.key?(:id)}
@@ -409,7 +401,-2 @@
  scrolled_win = Gtk::ScrolledWindow.new
  scrolled_win.add(treeview)
  scrolled_win.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
- 
  window = Gtk::Window.new("Progress List")
  window.resizable = true
  window.border_width = 10




ruby-gnome2-cvs メーリングリストの案内
Back to archive index