<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>config.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,6 @@
 class Capfile
+  attr_reader :file_name
+  
   def initialize(file_name)
     DRb.start_service
     @capfile = DRbObject.new(nil, 'druby://localhost:9000')</diff>
      <filename>cap_client.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,44 +9,67 @@ require 'drb'
 
 require 'cap_client'
 require 'project'
+require 'config'
 
-projects = [
-  Project.new(Capfile.new('/Users/alex/Documents/Code/reporting/Capfile'), 'Helicoid Stats'),
-  Project.new(Capfile.new('/Users/alex/Documents/Code/tiktrac/branch/live/Capfile'), 'Tiktrac')
-]
-
-app_width = 640
-
-Shoes.app :width =&gt; app_width, :height =&gt; 480 do
-  stack do
-    background black
-    flow do
-      title 'Captor', :weight =&gt; 'bold', :size =&gt; 22, :stroke =&gt; white
-      @title_stack = flow :width =&gt; 200, :margin =&gt; 10, :margin_left =&gt; 30
+class Projects
+  def initialize
+    Settings.app_name = 'Captor'
+    @projects = []
+    @projects = Settings.load.collect do |name, capfile|
+      Project.new name, Capfile.new(capfile)
     end
   end
 
-  @project_stack = stack :margin_top =&gt; 2, :height =&gt; -200, :scroll =&gt; true, :width =&gt; app_width
-  @output_stack = stack :margin_top =&gt; 2, :height =&gt; 140, :scroll =&gt; true
+  def all
+    @projects
+  end
   
-  show_output = Proc.new do |output|
-    @output_stack.clear
-    @output_stack.flow do
-      background white
-      para code(output, :width =&gt; '100%', :height =&gt; 140)
-    end
+  def names
+    all.collect { |project| project.name }
   end
   
-  show_output.call &quot;Captor Ready\n\n\n\n\n\n&quot;
+  def add(project)
+    @projects &lt;&lt; project
+  end
+  
+  def list=(project_list)
+    @project_list = project_list
+  end
+  
+  def list
+    @project_list
+  end
+  
+  def update_list
+    @project_list.items = names
+    Settings.save @projects.collect { |project| [project.name, project.capfile.file_name] }
+  end
+  
+  def selected
+    @projects[names.index(@project_list.text)]
+  end
   
-  project_names = projects.collect { |project| project.name }
+  def selected_index
+    names.index(@project_list.text)
+  end
+  
+  def remove
+    @projects.delete_at selected_index
+    update_list
+  end
+end
+
+Shoes.app :width =&gt; 640, :height =&gt; 480 do
+  @projects = projects = Projects.new
   
-  show_project = Proc.new do |project|
+  def show_project(project)
+    return if @projects.all.size == 0
+    
     @project_stack.clear
     longest_task_name = project.capfile.task_names.max { |task_name| task_name.size }.size
     task_column_width = longest_task_name * 9
     run_column_width = 50
-    description_column_width = app_width - task_column_width - run_column_width - 40
+    description_column_width = width() - task_column_width - run_column_width - 40
     colour_state = true
     
     project.capfile.task_names.each do |task_name|
@@ -60,16 +83,79 @@ Shoes.app :width =&gt; app_width, :height =&gt; 480 do
           para project.capfile.description(task_name)
         end
         flow :width =&gt; run_column_width do
-          para link('Run', :stroke =&gt; black, :fill =&gt; nil).click { show_output.call project.capfile.execute(task_name) }
+          para link('Run', :stroke =&gt; black, :fill =&gt; nil).click { show_output project.capfile.execute(task_name) }
         end
       end
     end
   end
-  
-  show_project.call(projects.first)
-  
-  @title_stack.list_box :items =&gt; project_names do |list|
-    selected = project_names.index(list.text)
-    show_project.call projects[selected]
+
+  def show_output(output)
+    @output_stack.clear
+    @output_stack.flow do
+      background white
+      para code(output, :width =&gt; '100%', :height =&gt; 140)
+    end
   end
+
+  stack do
+    background black
+    flow do
+      title 'Captor', :weight =&gt; 'bold', :size =&gt; 22, :stroke =&gt; white
+      flow :width =&gt; 200, :margin =&gt; 10, :margin_left =&gt; 30 do
+        projects.list = list_box :items =&gt; projects.names, :width =&gt; 180 do |list|
+          selected = projects.names.index(list.text)
+          show_project projects.all[selected]
+        end
+      end
+      flow :width =&gt; 200, :margin =&gt; 10 do
+        button 'Add' do
+          window :width =&gt; 340, :height =&gt; 260 do
+            stack do
+              background black
+              title 'Add Project', :weight =&gt; 'bold', :size =&gt; 22, :stroke =&gt; white
+            end
+            stack :margin =&gt; 10 do
+              para 'Name: '
+              edit_line { |line| @name = line.text }
+            end
+            flow :margin =&gt; 10 do
+              para 'Capfile: '
+              button 'Open' do
+                @capfile = ask_open_file
+              end
+            end
+            flow :margin_left =&gt; 8 do
+              button 'Save' do
+                if @capfile.nil? or !File.exists?(@capfile)
+                  alert &quot;Error: Please enter a valid filename for your Capfile&quot;
+                elsif @name.nil?
+                  alert &quot;Error: Please enter a project name&quot;
+                else
+                  projects.add Project.new(@name, Capfile.new(@capfile))
+                  projects.update_list
+                  close
+                end
+              end
+              button 'Cancel' do
+                close
+              end
+            end
+          end
+        end
+        
+        button 'Remove' do
+          if confirm(&quot;Are you sure?&quot;)
+            projects.remove
+            show_project projects.selected
+          end
+        end
+      end
+    end
+  end
+
+  @project_stack = stack :margin_top =&gt; 2, :height =&gt; -200, :scroll =&gt; true, :width =&gt; width()
+  @output_stack = stack :margin_top =&gt; 2, :height =&gt; 140, :scroll =&gt; true
+  
+  show_output &quot;Captor Ready\n\n\n\n\n\n&quot;
+  show_project projects.all.first
 end
\ No newline at end of file</diff>
      <filename>captor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-class Project &lt; Struct.new(:capfile, :name, :stack); end
+class Project &lt; Struct.new(:name, :capfile); end</diff>
      <filename>project.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>573cd9b1c8639cd017a493225ad1d4b737e57c7e</id>
    </parent>
  </parents>
  <author>
    <name>My Name</name>
    <email>alex@helicoid.net</email>
  </author>
  <url>http://github.com/alexyoung/captor/commit/2c92602813ee9e7a3b9125130f43ff30c7fa2ba2</url>
  <id>2c92602813ee9e7a3b9125130f43ff30c7fa2ba2</id>
  <committed-date>2008-10-08T13:53:20-07:00</committed-date>
  <authored-date>2008-10-08T13:53:20-07:00</authored-date>
  <message>Captor now loads and saves projects to disk.  You can add projects through a dialog.  I removed the clumsy use of Procs in the last version, I'm still getting the hang of how the self switching confusingly messes up instance_variables in Shoes.</message>
  <tree>af7975ca0b5c521bdfb27bc8ef30d61186f8ebd8</tree>
  <committer>
    <name>My Name</name>
    <email>alex@helicoid.net</email>
  </committer>
</commit>
