visualruby 1.0.19 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Splash.rb +40 -0
- data/bin/editor/VR_Document.rb +81 -74
- data/bin/editor/VR_TabSearch.rb +5 -7
- data/bin/editor/VR_Tabs.rb +57 -36
- data/bin/editor/VR_TextShell.rb +12 -34
- data/bin/editor/VR_TextViewCommon.rb +9 -28
- data/bin/main/NewProjectGUI.rb +14 -13
- data/bin/main/OpenProject.rb +69 -0
- data/bin/main/ProjectChooserView.rb +3 -2
- data/bin/main/ProjectTree.rb +25 -0
- data/bin/main/RubygemsAPI.rb +15 -11
- data/bin/main/VR_ENV.rb +38 -60
- data/bin/main/VR_ENV_GLOBAL.rb +45 -44
- data/bin/main/VR_File_Tree.rb +29 -21
- data/bin/main/VR_Local_Gem_Tree.rb +4 -19
- data/bin/main/VR_Main.rb +128 -144
- data/bin/main/VR_Remote_Gem_Tree.rb +6 -19
- data/bin/main/glade/NewProjectGUI.glade +94 -98
- data/bin/main/glade/OpenProject.glade +259 -0
- data/bin/main/glade/RubygemsAPI.glade +98 -62
- data/bin/main/glade/VR_ENV.glade +46 -55
- data/bin/main/glade/VR_ENV_GLOBAL.glade +251 -180
- data/bin/main/glade/VR_File_Tree.glade +25 -16
- data/bin/main/glade/VR_Local_Gem_Tree.glade +16 -8
- data/bin/main/glade/VR_Main.glade +410 -449
- data/bin/main/glade/VR_Remote_Gem_Tree.glade +33 -31
- data/bin/tools/VR_Tools.rb +60 -46
- data/{visualruby_examples → examples}/active_record/active_record.rb +16 -10
- data/{visualruby_examples → examples}/active_record/bin/ChoosePerson.rb +7 -0
- data/examples/active_record/bin/Person.rb +21 -0
- data/examples/active_record/bin/glade/ChoosePerson.glade +89 -0
- data/examples/active_record/bin/glade/Person.glade +197 -0
- data/{visualruby_examples → examples}/active_record/db/development.sqlite3 +0 -0
- data/{visualruby_examples → examples}/active_record2/bin/CompanyGUI.rb +7 -7
- data/{visualruby_examples → examples}/active_record2/bin/Employee.rb +0 -0
- data/{visualruby_examples → examples}/active_record2/bin/Employer.rb +0 -0
- data/{visualruby_examples → examples}/active_record2/bin/Paycheck.rb +0 -0
- data/examples/active_record2/bin/glade/CompanyGUI.glade +149 -0
- data/examples/active_record2/bin/glade/Employee.glade +126 -0
- data/{visualruby_examples → examples}/active_record2/bin/glade/Employer.glade +0 -0
- data/{visualruby_examples → examples}/active_record2/bin/glade/Paycheck.glade +0 -0
- data/{visualruby_examples → examples}/active_record2/db/development.sqlite3 +0 -0
- data/{visualruby_examples → examples}/active_record2/main.rb +15 -9
- data/examples/alert_box/bin/AlertBoxDemo.rb +80 -0
- data/examples/alert_box/bin/glade/AlertBoxDemo.glade +234 -0
- data/examples/alert_box/main.rb +12 -0
- data/{visualruby_examples → examples}/all_widgets/bin/AllWidgets.rb +18 -10
- data/{visualruby_examples → examples}/all_widgets/bin/glade/AllWidgets.glade +52 -16
- data/{visualruby_examples → examples}/all_widgets/bin/splash.png +0 -0
- data/examples/all_widgets/main.rb +12 -0
- data/{visualruby_examples → examples}/calculator/bin/Calculator.rb +23 -22
- data/{visualruby_examples → examples}/calculator/bin/glade/Calculator.glade +81 -51
- data/examples/calculator/main.rb +13 -0
- data/examples/child_window/bin/ChildWindowDemo.rb +52 -0
- data/examples/child_window/bin/ModalWindow.rb +9 -0
- data/examples/child_window/bin/ModelessWindow.rb +9 -0
- data/examples/child_window/bin/MyChildClass.rb +21 -0
- data/examples/child_window/bin/glade/ChildWindowDemo.glade +87 -0
- data/examples/child_window/bin/glade/ModalWindow.glade +61 -0
- data/examples/child_window/bin/glade/ModelessWindow.glade +61 -0
- data/{visualruby_examples → examples}/child_window/bin/glade/MyChildClass.glade +14 -12
- data/examples/child_window/main.rb +12 -0
- data/{visualruby_examples → examples}/drag_drop/bin/DragDropDemo.rb +9 -10
- data/examples/drag_drop/bin/glade/DragDropDemo.glade +161 -0
- data/{visualruby_examples → examples}/drag_drop/img/folder.png +0 -0
- data/{visualruby_examples → examples}/drag_drop/img/glade.png +0 -0
- data/{visualruby_examples → examples}/drag_drop/img/gtk-edit.png +0 -0
- data/{visualruby_examples → examples}/drag_drop/img/obj.png +0 -0
- data/{visualruby_examples → examples}/drag_drop/img/png.png +0 -0
- data/{visualruby_examples → examples}/drag_drop/img/rb.png +0 -0
- data/{visualruby_examples → examples}/drag_drop/img/ruby.png +0 -0
- data/{visualruby_examples → examples}/drag_drop/img/unknown.png +0 -0
- data/examples/drag_drop/main.rb +11 -0
- data/examples/filetreeview/bin/ProjectTree.rb +32 -0
- data/examples/filetreeview/bin/ProjectTreeGUI.rb +28 -0
- data/examples/filetreeview/bin/glade/ProjectTreeGUI.glade +156 -0
- data/examples/filetreeview/main.rb +13 -0
- data/{visualruby_examples → examples}/listview/bin/SongListView.rb +24 -20
- data/{visualruby_examples → examples}/listview/bin/SongListViewGUI.rb +12 -11
- data/{visualruby_examples → examples}/listview/bin/audio-x-generic.png +0 -0
- data/examples/listview/bin/glade/SongListViewGUI.glade +195 -0
- data/examples/listview/main.rb +10 -0
- data/examples/listview_objects/bin/DataObject.rb +53 -0
- data/{visualruby_examples → examples}/listview_objects/bin/ListViewObjects.rb +7 -4
- data/examples/listview_objects/bin/ListViewObjectsGUI.rb +26 -0
- data/examples/listview_objects/bin/glade/DataObject.glade +196 -0
- data/examples/listview_objects/bin/glade/ListViewObjectsGUI.glade +87 -0
- data/examples/listview_objects/main.rb +12 -0
- data/examples/settings_file/bin/MainApp.rb +38 -0
- data/examples/settings_file/bin/SavableSettings.rb +39 -0
- data/examples/settings_file/bin/glade/MainApp.glade +87 -0
- data/examples/settings_file/bin/glade/SavableSettings.glade +162 -0
- data/examples/settings_file/main.rb +14 -0
- data/examples/settings_file/settings.yaml +15 -0
- data/examples/simple_ruby_gui/bin/DataObjectGUI.rb +21 -0
- data/examples/simple_ruby_gui/bin/glade/DataObjectGUI.glade +195 -0
- data/examples/simple_ruby_gui/main.rb +16 -0
- data/{visualruby_examples → examples}/treeview/bin/MyClass.rb +1 -5
- data/examples/treeview/bin/glade/MyClass.glade +24 -0
- data/examples/treeview/main.rb +13 -0
- data/skeleton/document/New.glade +3 -4
- data/skeleton/document/NewWindow.rb +1 -1
- data/skeleton/project/bin/MyClass.rb +2 -2
- data/skeleton/project/bin/glade/MyClass.glade +12 -26
- data/skeleton/project/main.rb +4 -8
- data/vr +41 -37
- data/vrlib/lib/Alert.rb +67 -0
- data/vrlib/lib/DragDrop.rb +90 -0
- data/vrlib/lib/GladeGUI.rb +433 -0
- data/vrlib/lib/IconHash.rb +18 -0
- data/vrlib/lib/SavableClass.rb +56 -0
- data/vrlib/lib/SimpleComboBoxEntry.rb +8 -0
- data/vrlib/lib/glade/Alert.glade +119 -0
- data/vrlib/lib/treeview/FileTreeView.rb +113 -0
- data/vrlib/lib/treeview/IterMethods.rb +82 -0
- data/vrlib/lib/treeview/ListView.rb +85 -0
- data/vrlib/lib/treeview/TreeView.rb +43 -0
- data/vrlib/lib/treeview/ViewCommon.rb +370 -0
- data/vrlib/lib/treeview/columns/CalendarCol.rb +89 -0
- data/vrlib/lib/treeview/columns/CellRendererCombo.rb +66 -0
- data/vrlib/lib/treeview/columns/CellRendererDate.rb +45 -0
- data/vrlib/lib/treeview/columns/CellRendererObject.rb +57 -0
- data/vrlib/lib/treeview/columns/CellRendererPhone.rb +45 -0
- data/vrlib/lib/treeview/columns/CellRendererPixbuf.rb +16 -0
- data/vrlib/lib/treeview/columns/CellRendererProgress.rb +17 -0
- data/vrlib/lib/treeview/columns/CellRendererSpin.rb +37 -0
- data/vrlib/lib/treeview/columns/CellRendererText.rb +38 -0
- data/vrlib/lib/treeview/columns/CellRendererToggle.rb +47 -0
- data/vrlib/lib/treeview/columns/ComboCol.rb +43 -0
- data/vrlib/lib/treeview/columns/CurrencyCol.rb +23 -0
- data/vrlib/lib/treeview/columns/DateCol.rb +20 -0
- data/vrlib/lib/treeview/columns/ImageCol.rb +27 -0
- data/vrlib/lib/treeview/columns/ProgressCol.rb +27 -0
- data/vrlib/lib/treeview/columns/SpinCol.rb +11 -0
- data/vrlib/lib/treeview/columns/TextCol.rb +65 -0
- data/vrlib/lib/treeview/columns/TreeViewColumn.rb +93 -0
- data/{bin/main/glade/ProjectChooserGUI.glade → vrlib/lib/treeview/columns/glade/CalendarCol.glade} +71 -63
- data/{bin/main/glade/Splash.glade → vrlib/lib/treeview/columns/glade/ImageCol.glade} +5 -6
- data/vrlib/lib/treeview/columns/glade/TextCol.glade +82 -0
- data/vrlib/rdoc_replace.yaml +77 -0
- data/vrlib/vrlib.rb +7 -0
- metadata +163 -136
- data/bin/editor/glade/VR_Document.glade +0 -160
- data/bin/main/ProjectChooserGUI.rb +0 -41
- data/bin/main/Splash.rb +0 -22
- data/visualruby_examples/active_record/.vr_settings.yaml +0 -47
- data/visualruby_examples/active_record/bin/Person.rb +0 -13
- data/visualruby_examples/active_record/bin/glade/ChoosePerson.glade +0 -61
- data/visualruby_examples/active_record/bin/glade/Person.glade +0 -148
- data/visualruby_examples/active_record2/.vr_settings.yaml +0 -16
- data/visualruby_examples/active_record2/bin/glade/CompanyGUI.glade +0 -167
- data/visualruby_examples/active_record2/bin/glade/Employee.glade +0 -123
- data/visualruby_examples/all_widgets/.vr_settings.yaml +0 -13
- data/visualruby_examples/all_widgets/main.rb +0 -14
- data/visualruby_examples/calculator/.vr_settings.yaml +0 -11
- data/visualruby_examples/calculator/main.rb +0 -13
- data/visualruby_examples/child_window/.vr_settings.yaml +0 -16
- data/visualruby_examples/child_window/bin/ChildWindowDemo.rb +0 -39
- data/visualruby_examples/child_window/bin/MyChildClass.rb +0 -40
- data/visualruby_examples/child_window/bin/glade/ChildWindowDemo.glade +0 -101
- data/visualruby_examples/child_window/main.rb +0 -13
- data/visualruby_examples/drag_drop/.vr_settings.yaml +0 -12
- data/visualruby_examples/drag_drop/bin/glade/DragDropDemo.glade +0 -143
- data/visualruby_examples/drag_drop/main.rb +0 -14
- data/visualruby_examples/listview/.vr_settings.yaml +0 -12
- data/visualruby_examples/listview/bin/glade/SongListViewGUI.glade +0 -220
- data/visualruby_examples/listview/main.rb +0 -19
- data/visualruby_examples/listview_objects/.vr_settings.yaml +0 -16
- data/visualruby_examples/listview_objects/bin/DataObject.rb +0 -32
- data/visualruby_examples/listview_objects/bin/DataObjectGUI.rb +0 -41
- data/visualruby_examples/listview_objects/bin/ListViewObjectsGUI.rb +0 -18
- data/visualruby_examples/listview_objects/bin/glade/DataObject.glade +0 -198
- data/visualruby_examples/listview_objects/bin/glade/ListViewObjectsGUI.glade +0 -102
- data/visualruby_examples/listview_objects/main.rb +0 -13
- data/visualruby_examples/simple_ruby_gui/.vr_settings.yaml +0 -16
- data/visualruby_examples/simple_ruby_gui/bin/DataObjectGUI.rb +0 -20
- data/visualruby_examples/simple_ruby_gui/bin/glade/DataObjectGUI.glade +0 -163
- data/visualruby_examples/simple_ruby_gui/main.rb +0 -16
- data/visualruby_examples/treeview/.vr_settings.yaml +0 -12
- data/visualruby_examples/treeview/bin/glade/MyClass.glade +0 -48
- data/visualruby_examples/treeview/main.rb +0 -14
data/bin/main/NewProjectGUI.rb
CHANGED
@@ -3,30 +3,31 @@ class NewProjectGUI
|
|
3
3
|
|
4
4
|
include GladeGUI
|
5
5
|
|
6
|
+
attr_accessor :my_var
|
7
|
+
|
6
8
|
def initialize(parent)
|
7
9
|
@parent = parent
|
8
|
-
@
|
9
|
-
end
|
10
|
-
|
11
|
-
def before_show
|
12
|
-
@builder["labelHomePath"].label = File.join(ENV["HOME"], "visualruby" + "/")
|
10
|
+
@projects_home = $VR_ENV_GLOBAL.projects_home + "/"
|
13
11
|
end
|
14
12
|
|
15
|
-
def buttonCreate__clicked(*
|
13
|
+
def buttonCreate__clicked(*args)
|
16
14
|
fn = @builder["entryFolderName"].text
|
17
|
-
fn = fn.gsub(/[^\w
|
18
|
-
path = File.
|
15
|
+
fn = fn.gsub(/[^\w\.\/]/, '_')
|
16
|
+
path = File.join($VR_ENV_GLOBAL.projects_home + "/" + fn)
|
19
17
|
if File.directory?(path)
|
20
|
-
|
18
|
+
alert "The folder <b>" + path + "</b> is already ok disk. You can open it using the <b>Open Project</b> button.",
|
19
|
+
:headline=> "Project Already Exists", :parent => self, :width => 500
|
21
20
|
else
|
22
|
-
|
21
|
+
FileUtils.mkpath path
|
22
|
+
VR_Tools.copy_skeleton_project(path)
|
23
23
|
@parent.proj_path = path
|
24
|
-
|
24
|
+
@builder["window1"].destroy
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def buttonCancel__clicked(*
|
29
|
-
|
28
|
+
def buttonCancel__clicked(*args)
|
29
|
+
@my_var = "Hello"
|
30
|
+
# @builder["window1"].destroy
|
30
31
|
end
|
31
32
|
|
32
33
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
class OpenProject
|
3
|
+
|
4
|
+
include GladeGUI
|
5
|
+
|
6
|
+
def initialize(parent)
|
7
|
+
@parent = parent
|
8
|
+
@projects_home = $VR_ENV_GLOBAL.projects_home
|
9
|
+
end
|
10
|
+
|
11
|
+
def before_show
|
12
|
+
@ftv = ProjectTree.new()
|
13
|
+
@ftv.set_show_expanders(false)
|
14
|
+
@builder["view"].add(@ftv)
|
15
|
+
@ftv.visible = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def ftv__cursor_changed(*a)
|
19
|
+
return unless row = @ftv.selected_rows.first
|
20
|
+
@ftv.expand_or_collapse_folder()
|
21
|
+
end
|
22
|
+
|
23
|
+
def ftv__row_activated(_self, path, col)
|
24
|
+
buttonOpen__clicked
|
25
|
+
end
|
26
|
+
|
27
|
+
def buttonChange__clicked(*a)
|
28
|
+
$VR_ENV_GLOBAL.show_glade(self)
|
29
|
+
@projects_home = $VR_ENV_GLOBAL.projects_home
|
30
|
+
@ftv.refresh(:root => @projects_home)
|
31
|
+
@builder[:projects_home].label = @projects_home
|
32
|
+
end
|
33
|
+
|
34
|
+
def buttonDelete__clicked(*a)
|
35
|
+
return unless row = @ftv.selected_rows.first
|
36
|
+
return if row[:path] == Dir.pwd #can't delete current project
|
37
|
+
if alert("Do you really want to delete \n<b>" + row[:path] + " </b>?",
|
38
|
+
parent: self, headline: "Warning!", button_yes: "Delete", button_no: "Cancel", width: 400)
|
39
|
+
FileUtils.remove_dir(row[:path], true)
|
40
|
+
@ftv.refresh()
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def buttonOpen__clicked(*a)
|
45
|
+
return unless row = @ftv.selected_rows.first
|
46
|
+
test_file = File.join(row[:path], VR_ENV::SETTINGS_FILE)
|
47
|
+
if File.exists?(test_file)
|
48
|
+
@parent.proj_path = row[:path]
|
49
|
+
buttonCancel__clicked
|
50
|
+
else
|
51
|
+
# alert("This is not a visualruby project. It's a folder that holds visualruby projects.", :parent=>self, :width=>400)
|
52
|
+
@ftv.expand_or_collapse_folder()
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def buttonNew__clicked(*a)
|
57
|
+
old_proj_path = @parent.proj_path
|
58
|
+
NewProjectGUI.new(@parent).show_glade(self)
|
59
|
+
@builder[:window1].destroy if @parent.proj_path != old_proj_path #new path created!
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def buttonCancel__clicked(*a) #save state
|
64
|
+
$VR_ENV_GLOBAL.projects_home_open_folders = @ftv.get_open_folders()
|
65
|
+
VR::save_yaml($VR_ENV_GLOBAL)
|
66
|
+
@builder["window1"].destroy
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -11,7 +11,7 @@ class ProjectChooserView < VR::ListView
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def refresh(show_backup = false)
|
14
|
-
model.set_sort_column_id(1)
|
14
|
+
# model.set_sort_column_id(1, :ascending)
|
15
15
|
self.model.clear
|
16
16
|
pattern = ""
|
17
17
|
backup_path = Dir.pwd.gsub(ENV["HOME"], File.join(ENV["HOME"], "visualruby_backup"))
|
@@ -31,7 +31,8 @@ class ProjectChooserView < VR::ListView
|
|
31
31
|
row[:file_name] = File.dirname(fn)
|
32
32
|
row[:modified] = DateTime.parse(t.to_s)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
|
+
# model.set_sort_column_id(id(:modified), :descending)
|
35
36
|
end
|
36
37
|
|
37
38
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
class ProjectTree < VR::FileTreeView #(change name)
|
3
|
+
|
4
|
+
attr_accessor :ftv
|
5
|
+
|
6
|
+
include GladeGUI
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
path = $VR_ENV_GLOBAL.projects_home
|
10
|
+
icon_path = File.expand_path(File.join(File.path(__FILE__), "..", "..", "..", "img"))
|
11
|
+
super(path, icon_path)
|
12
|
+
@test_block = proc { |folder| has_settings_file?(folder) }
|
13
|
+
open_folders($VR_ENV_GLOBAL.projects_home_open_folders)
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_settings_file?(path)
|
17
|
+
Find.find(path) do |file|
|
18
|
+
if File.basename(file) == VR_ENV::SETTINGS_FILE
|
19
|
+
return true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/bin/main/RubygemsAPI.rb
CHANGED
@@ -3,16 +3,16 @@ class RubygemsAPI
|
|
3
3
|
|
4
4
|
include GladeGUI
|
5
5
|
|
6
|
-
CREDENTIALS_FILE = ENV['HOME']
|
6
|
+
CREDENTIALS_FILE = File.join(ENV['HOME'], ".gem", "credentials")
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
load_glade(__FILE__)
|
10
9
|
uri = URI.parse("https://rubygems.org")
|
11
10
|
@http = Net::HTTP.new(uri.host, uri.port)
|
12
11
|
@http.use_ssl = true
|
13
12
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
13
|
+
load_glade()
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def get_key()
|
17
17
|
if File.file?(CREDENTIALS_FILE)
|
18
18
|
return Gem.configuration.rubygems_api_key
|
@@ -28,17 +28,19 @@ class RubygemsAPI
|
|
28
28
|
@builder["dialog1"].run do |response_id|
|
29
29
|
if response_id == 1 #Ok Button
|
30
30
|
get_glade_all() #gets @username, @password
|
31
|
+
alert "You: " + @username + @password
|
31
32
|
path = "/api/v1/api_key.yaml"
|
32
33
|
@http.start() do |h|
|
33
34
|
req = Net::HTTP::Get.new(path)
|
34
35
|
req.basic_auth @username, @password
|
35
36
|
response = h.request(req)
|
36
37
|
obj = YAML.load(response.body)
|
38
|
+
alert obj.to_s
|
37
39
|
key = obj[:rubygems_api_key]
|
38
40
|
if key
|
39
|
-
File.open(CREDENTIALS_FILE,"w") { |f| f.write(YAML.dump(obj)) }
|
41
|
+
File.open(CREDENTIALS_FILE,"w",0600) { |f| f.write(YAML.dump(obj)) }
|
40
42
|
else
|
41
|
-
|
43
|
+
alert obj.values[0]
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -56,19 +58,21 @@ class RubygemsAPI
|
|
56
58
|
return obj = YAML.load(response.body)
|
57
59
|
}
|
58
60
|
end
|
59
|
-
|
60
|
-
|
61
|
-
# in Windows, the File.open { read } doesn't work for the gemfile.
|
62
|
-
# also, you must set a variable (bod) to close the io stream
|
61
|
+
|
62
|
+
|
63
|
+
# in Windows, the File.open { read } doesn't work for the gemfile.
|
64
|
+
# also, you must set a variable (bod) to close the io stream
|
63
65
|
|
64
66
|
def push_gem(fn)
|
65
|
-
|
67
|
+
unless key = get_key()
|
68
|
+
return "No Rubygems Credentials"
|
69
|
+
end
|
66
70
|
path = "https://rubygems.org/api/v1/gems"
|
67
71
|
req = Net::HTTP::Post.new(path)
|
68
72
|
req.add_field('Authorization', key)
|
69
73
|
req.content_type = 'application/octet-stream'
|
70
74
|
bod = File.open(fn, "rb") {|io| io.read } # no good in win: File.open(fn).read
|
71
|
-
req.body = bod #must do it like this to close io ??!?!
|
75
|
+
req.body = bod #must do it like this to close io ??!?!
|
72
76
|
req.content_length = req.body.size
|
73
77
|
@http.start() do |h|
|
74
78
|
response = h.request(req)
|
data/bin/main/VR_ENV.rb
CHANGED
@@ -1,61 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
class VR_ENV
|
2
|
+
|
3
|
+
include GladeGUI
|
4
|
+
|
6
5
|
SETTINGS_FILE = ".vr_settings.yaml"
|
7
|
-
|
8
|
-
|
9
|
-
attr_accessor :
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@run_command_line
|
19
|
-
@open_files
|
20
|
-
@open_folders
|
21
|
-
@current_file
|
22
|
-
@
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
# end
|
42
|
-
|
43
|
-
def self.load_yaml()
|
44
|
-
if File.file?(SETTINGS_FILE)
|
45
|
-
me = YAML::load(File.open(SETTINGS_FILE).read)
|
46
|
-
return VR_ENV.new() if me.settings_file_version.nil?
|
47
|
-
return VR_ENV.new() if me.settings_file_version < SETTINGS_FILE_VERSION
|
48
|
-
return me
|
49
|
-
else
|
50
|
-
VR_ENV.new()
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def save_yaml()
|
55
|
-
data = YAML.dump(self)
|
56
|
-
File.open(Dir.pwd + "/" + SETTINGS_FILE, "w") {|f| f.puts(data)}
|
57
|
-
return self
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
end
|
6
|
+
|
7
|
+
attr_accessor :width, :height, :panel_pos, :rdoc_command_line
|
8
|
+
attr_accessor :run_command_line, :open_files, :open_folders, :current_file
|
9
|
+
attr_accessor :notebook_panel_position, :current_line
|
10
|
+
|
11
|
+
#to add setting, just add to list
|
12
|
+
def defaults
|
13
|
+
@width ||= 800
|
14
|
+
@height ||= 600
|
15
|
+
@panel_pos ||= 360
|
16
|
+
@notebook_panel_position ||= 400
|
17
|
+
@run_command_line ||= "ruby main.rb"
|
18
|
+
@open_files ||= []
|
19
|
+
@open_folders ||= []
|
20
|
+
@current_file ||= ""
|
21
|
+
@current_line ||= 1
|
22
|
+
@rdoc_command_line ||= "rdoc -x README"
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
#todo validate
|
27
|
+
def buttonSave_clicked
|
28
|
+
get_glade_variables
|
29
|
+
VR::save_yaml(self)
|
30
|
+
@builder["window1"].destroy
|
31
|
+
end
|
32
|
+
|
33
|
+
def buttonCancel__clicked(*args)
|
34
|
+
@builder["window1"].destroy
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
data/bin/main/VR_ENV_GLOBAL.rb
CHANGED
@@ -1,64 +1,65 @@
|
|
1
1
|
|
2
2
|
class VR_ENV_GLOBAL
|
3
3
|
|
4
|
-
GLOBAL_SETTINGS_FILE = File.join(ENV["HOME"], "visualruby", ".
|
5
|
-
SETTINGS_FILE_VERSION = 1
|
4
|
+
GLOBAL_SETTINGS_FILE = File.join(ENV["HOME"], "visualruby", ".global_settings.yaml")
|
6
5
|
|
7
6
|
include GladeGUI
|
8
7
|
|
9
|
-
attr_accessor :browser, :tab_spaces, :glade_path
|
10
|
-
attr_accessor :font_name, :settings_file_version
|
11
|
-
|
12
|
-
def
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
|
8
|
+
attr_accessor :browser, :tab_spaces, :glade_path, :default_project, :projects_home_open_folders
|
9
|
+
attr_accessor :font_name, :settings_file_version, :projects_home
|
10
|
+
|
11
|
+
def defaults()
|
12
|
+
@browser ||= "firefox"
|
13
|
+
@tab_spaces ||= 2
|
14
|
+
@font_name ||= "Monospace 10"
|
15
|
+
@glade_path ||= "glade"
|
16
|
+
@projects_home ||= File.join(ENV["HOME"], "visualruby")
|
17
|
+
@projects_home_open_folders ||= [@projects_home]
|
18
|
+
@default_project ||= File.join(ENV["HOME"], "visualruby", "examples", "treeview")
|
19
19
|
end
|
20
20
|
|
21
|
-
def before_show
|
22
|
-
@glade_box = VR::SimpleComboBoxEntry.new(@glade_path, "glade-gtk2", "glade", "glade-3", "C:\\Program Files (x86)\\Gtk+\\bin\\glade-3")
|
23
|
-
@builder["hboxGlade"].add(@glade_box)
|
24
|
-
@browser_box = VR::SimpleComboBoxEntry.new(@browser, "xdg-open", "chromium-browser", "firefox", "google-chrome", "chrome", "chromium", "iexplore", "start iexplore", "start firefox", "start google-chrome", "start chrome", "start chromium", "C:\\Program Files\\iexplorer\\iexplore.exe")
|
25
|
-
@builder["hboxBrowser"].add(@browser_box)
|
21
|
+
def before_show
|
26
22
|
@builder["font_name"].show_size = true
|
27
23
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
save_yaml()
|
37
|
-
destroy_window()
|
24
|
+
|
25
|
+
def buttonSave_clicked
|
26
|
+
if valid?
|
27
|
+
get_glade_variables
|
28
|
+
@tab_spaces = @builder['tab_spaces'].text.to_i
|
29
|
+
VR::save_yaml(self)
|
30
|
+
@builder["window1"].destroy
|
31
|
+
end
|
38
32
|
end
|
39
33
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
34
|
+
def valid? # must validate form, not variables
|
35
|
+
tab_spaces = @builder['tab_spaces'].text.to_i
|
36
|
+
if tab_spaces < 0 or tab_spaces > 9
|
37
|
+
alert("Tab spaces must be between 1 and 9", :parent=>self)
|
38
|
+
return false
|
39
|
+
elsif not File.directory?(@builder[:projects_home].text)
|
40
|
+
alert("Projects home folder is not valid.", :parent=>self)
|
41
|
+
return false
|
42
|
+
elsif not File.exists?(File.join(@builder[:default_project].text,VR_ENV::SETTINGS_FILE))
|
43
|
+
alert("Default project is not valid.", :parent=>self)
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
return true
|
43
47
|
end
|
44
48
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
return VR_ENV_GLOBAL.new() if me.settings_file_version.nil?
|
49
|
-
return VR_ENV_GLOBAL.new() if me.settings_file_version < SETTINGS_FILE_VERSION
|
50
|
-
return me
|
51
|
-
else
|
52
|
-
VR_ENV_GLOBAL.new()
|
53
|
-
end
|
54
|
-
end
|
49
|
+
def buttonCancel__clicked(*args)
|
50
|
+
@builder["window1"].destroy
|
51
|
+
end
|
55
52
|
|
56
|
-
def buttonTryGlade__clicked(*argv)
|
57
|
-
VR_Tools.popen(@
|
53
|
+
def buttonTryGlade__clicked(*argv)
|
54
|
+
VR_Tools.popen(@glade_path)
|
58
55
|
end
|
59
56
|
|
60
|
-
def buttonTryBrowser__clicked(*argv)
|
61
|
-
VR_Tools.popen(@
|
57
|
+
def buttonTryBrowser__clicked(*argv)
|
58
|
+
VR_Tools.popen(@browser)
|
59
|
+
end
|
60
|
+
|
61
|
+
def buttonCurrent__clicked(*argv)
|
62
|
+
@builder["default_project"].text = Dir.pwd
|
62
63
|
end
|
63
64
|
|
64
65
|
end
|
data/bin/main/VR_File_Tree.rb
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
class VR_File_Tree < VR::FileTreeView
|
3
3
|
|
4
4
|
include GladeGUI
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(main, icon_path)
|
7
|
-
super(icon_path)
|
7
|
+
super(Dir.pwd,icon_path)
|
8
8
|
@main = main
|
9
9
|
@api = RubygemsAPI.new
|
10
|
-
load_glade(
|
10
|
+
load_glade()
|
11
|
+
# set_show_expanders(false)
|
11
12
|
end
|
12
13
|
|
13
14
|
def self__row_activated(*args)
|
@@ -15,8 +16,10 @@ class VR_File_Tree < VR::FileTreeView
|
|
15
16
|
file_name = rows.first[:path]
|
16
17
|
if File.extname(file_name) == ".glade"
|
17
18
|
VR_Tools.popen("#{$VR_ENV_GLOBAL.glade_path} #{file_name} ")
|
18
|
-
|
19
|
-
|
19
|
+
elsif File.directory?(file_name)
|
20
|
+
expand_or_collapse_folder()
|
21
|
+
else
|
22
|
+
@main.tabs.load_tab(file_name)
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
@@ -40,7 +43,7 @@ class VR_File_Tree < VR::FileTreeView
|
|
40
43
|
end
|
41
44
|
|
42
45
|
def menuRDoc_clicked
|
43
|
-
return unless @main.tabs.try_to_save_all(false)
|
46
|
+
return unless @main.tabs.try_to_save_all(:ask => false)
|
44
47
|
fn = get_selected_path()
|
45
48
|
old_dir = Dir.pwd
|
46
49
|
FileUtils.cd(fn)
|
@@ -53,20 +56,25 @@ class VR_File_Tree < VR::FileTreeView
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def popBuildGem_clicked
|
56
|
-
file_name = get_selected_path()
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
file_name = get_selected_path()
|
60
|
+
root = File.dirname(file_name)
|
61
|
+
unless root == Dir.pwd
|
62
|
+
alert("You must create gems from the root folder.")
|
63
|
+
return
|
64
|
+
end
|
65
|
+
@main.tabs.try_to_save_all(:ask => false)
|
66
|
+
gem_builder = "Loading .gemspec file: " + file_name + "\n"
|
67
|
+
begin
|
68
|
+
Gem::Specification.reset
|
63
69
|
spec = Gem::Specification.load(file_name)
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
gem_file_name = Gem::Package.build(spec)
|
71
|
+
gem_builder = gem_builder + "Built Gem: " + gem_file_name + "\n"
|
72
|
+
gem_path = File.join(root, gem_file_name)
|
73
|
+
add_file(gem_path) if File.exists?(gem_path)
|
74
|
+
rescue
|
75
|
+
gem_builder = gem_builder + "Error: " + gem_file_name.to_s
|
67
76
|
end
|
68
|
-
@main.shell.buffer.text = gem_builder
|
69
|
-
refresh()
|
77
|
+
@main.shell.buffer.text = gem_builder
|
70
78
|
end
|
71
79
|
|
72
80
|
def popGlade_clicked
|
@@ -85,9 +93,9 @@ class VR_File_Tree < VR::FileTreeView
|
|
85
93
|
else
|
86
94
|
VR_Tools.popen("#{$VR_ENV_GLOBAL.glade_path} #{glade_file}")
|
87
95
|
end
|
88
|
-
end
|
96
|
+
end
|
89
97
|
|
90
|
-
def self__button_release_event(w, event) # right
|
98
|
+
def self__button_release_event(w, event) # right click
|
91
99
|
return unless path = get_selected_path() and event.button == 3
|
92
100
|
if File.file?(path) and (File.extname(path) == ".rb" or File.extname(path) == "")
|
93
101
|
@builder['popFile'].popup(nil, nil, event.button, event.time)
|
@@ -103,7 +111,7 @@ class VR_File_Tree < VR::FileTreeView
|
|
103
111
|
def self__key_press_event(view, evt)
|
104
112
|
return unless evt.keyval == 65535 #delete
|
105
113
|
return unless file_name = get_selected_path()
|
106
|
-
return unless
|
114
|
+
return unless alert("Delete: <b>" + File.basename(file_name) + "</b> ?" , :button_yes => "Delete", :button_no=>"Cancel", :parent=>self, :headline => "Delete FIle?")
|
107
115
|
if File.file?(file_name)
|
108
116
|
@main.tabs.destroy_file_tab(file_name)
|
109
117
|
File.delete(file_name)
|
@@ -6,8 +6,8 @@ class VR_Local_Gem_Tree < GemTree
|
|
6
6
|
def initialize(main)
|
7
7
|
super()
|
8
8
|
@main = main
|
9
|
-
|
10
|
-
|
9
|
+
load_glade()
|
10
|
+
parse_signals()
|
11
11
|
end
|
12
12
|
|
13
13
|
def refresh()
|
@@ -19,11 +19,10 @@ class VR_Local_Gem_Tree < GemTree
|
|
19
19
|
add_row( :pix => RUBY_ICON, :gem => "#{gem} (#{v})" )
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
23
|
-
|
22
|
+
end
|
24
23
|
|
25
24
|
#todo
|
26
|
-
def popViewSpec_clicked
|
25
|
+
def popViewSpec_clicked
|
27
26
|
gem, ver = selected_gem()
|
28
27
|
spec = `gem specification #{gem} -v #{ver}`
|
29
28
|
@main.tabs.load_tab()
|
@@ -56,19 +55,6 @@ class VR_Local_Gem_Tree < GemTree
|
|
56
55
|
end
|
57
56
|
|
58
57
|
|
59
|
-
# def popUninstall_clicked
|
60
|
-
# gem, ver = selected_gem()
|
61
|
-
# #command = "gem uninstall " + gem_name.gsub("("," -x -v ").gsub(")","")
|
62
|
-
# command = "gem uninstall #{gem} -x -v '#{ver}' 2>&1"
|
63
|
-
# @main.shell.buffer.text = VR_Tools.sudo_command(command)
|
64
|
-
# refresh()
|
65
|
-
# end
|
66
|
-
|
67
|
-
# def get_name_ver(line)
|
68
|
-
# match = /^(.*)\s+\((.*)\)/.match(line)
|
69
|
-
# return match[1], match[2]
|
70
|
-
# end
|
71
|
-
|
72
58
|
def selected_gem
|
73
59
|
row = self.selection.selected[1].split(" (")
|
74
60
|
ver = row[1].gsub(")","")
|
@@ -77,4 +63,3 @@ class VR_Local_Gem_Tree < GemTree
|
|
77
63
|
|
78
64
|
end
|
79
65
|
|
80
|
-
|