visualruby 3.0.18 → 3.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc6bb765611f2160433ba3069412ab60ed4e37b0
4
- data.tar.gz: 909e5bf1145974f0b30d2eb3e8c5e9f54e89ab4d
3
+ metadata.gz: 89d53a929e3dbdde72949eeb3945e44314d87ce9
4
+ data.tar.gz: ff359a662d2424710d155da67f4fc3d997aeb1db
5
5
  SHA512:
6
- metadata.gz: 4a6d8205200d782fe4c8e7a6034afabffca2960f707fc97b97c23fdb1efc6436bd609536bc0db76d79b8fe8a3a9c86ce1f8a81ab89b0bc09d2a48f1fb6d87656
7
- data.tar.gz: d5c2a5d933f5a4716a546856dacce21bab642b3d0872f52da1f00a578643056ab196e6a6e71c48c2191cccd233eb3630f4da54a226bf6acbfaf67c6db66385cd
6
+ metadata.gz: 96baa38366574fd0324da84dac789b71d212cb90d97208ef116e8a21295a21c52a72c18208b73339e8c6304ca6d87f8888ebdb74e9c1c9a5b9d27e4a678b4c31
7
+ data.tar.gz: 750f9cab07db1069f8d783fe8e1d23adfc987745009d5e0d1d27958134914309f71c37a97286c4399e9aa58632ab19dfb92f67744d91fd99cf04f43d49633731
data/.vr_settings.yaml CHANGED
@@ -1,23 +1,26 @@
1
1
  --- !ruby/object:VR_ENV
2
2
  vr_yaml_file: "/home/eric/vrp/vr3/.vr_settings.yaml"
3
- width: 1308
4
- height: 761
5
- panel_pos: 268
6
- notebook_panel_position: 532
3
+ width: 1389
4
+ height: 874
5
+ panel_pos: 360
6
+ notebook_panel_position: 629
7
7
  run_command_line: ruby vr
8
8
  open_files:
9
- - "/home/eric/vrp/vr3/lib/GladeGUI.rb"
9
+ - "/home/eric/vrp/vr3/lib/SavableClass.rb"
10
+ - "/home/eric/vrp/vr3/src/main/VR_Main.rb"
11
+ - "/home/eric/vrp/vr3/examples/settings_file/bin/MainApp.rb"
12
+ - "/home/eric/vrp/vr3/examples/settings_file/bin/SavableSettings.rb"
10
13
  - "/home/eric/vrp/vr3/src/editor/VR_Tabs.rb"
11
- - "/home/eric/vrp/vr3/yard_hack/index.html"
14
+ - "/home/eric/vrp/vr3/src/main/VR_File_Tree.rb"
12
15
  - "/home/eric/vrp/vr3/src/editor/VR_Document.rb"
13
- - "/home/eric/vrp/vr3/examples/settings_file/bin/SavableSettings.rb"
14
- - "/home/eric/vrp/vr3/examples/settings_file/bin/MainApp.rb"
15
- - "/home/eric/vrp/vr3/lib/SavableClass.rb"
16
- - "/home/eric/vrp/vr3/vr.gemspec"
17
16
  open_folders:
18
17
  - "/home/eric/vrp/vr3"
19
- current_file: "/home/eric/vrp/vr3/lib/GladeGUI.rb"
20
- current_line: 310
21
- rdoc_command_line: yardoc lib - site/*.*
18
+ - "/home/eric/vrp/vr3/lib"
19
+ - "/home/eric/vrp/vr3/src"
20
+ - "/home/eric/vrp/vr3/src/editor"
21
+ - "/home/eric/vrp/vr3/yard_hack"
22
+ current_file: "/home/eric/vrp/vr3/src/editor/VR_Document.rb"
23
+ current_line: 145
24
+ rdoc_command_line: ruby ./../yard/bin/yardoc - site/README.md site/*.*
22
25
  builder: !ruby/object:Gtk::Builder {}
23
26
  top_level_window: false
@@ -5,7 +5,7 @@ class MainApp #(change name)
5
5
 
6
6
  # make $ENV global object available everywhere
7
7
  def before_show()
8
- $ENV = VR::load_yaml(:class => SavableSettings, :file_name => "settings.yaml")
8
+ $ENV = VR::load_yaml(SavableSettings, "settings.yaml")
9
9
  @builder[:window1].resize $ENV.width, $ENV.height
10
10
  refresh()
11
11
  end
data/lib/ActLikeAHash.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # @private
2
- module ActLikeAHash
3
-
4
- def [] (key)
5
- instance_variable_get("@" + key.to_s)
6
- end
7
-
8
- def []= (key, val)
9
- instance_variable_put("@" + key_to_s, val)
10
- end
11
-
12
- end
2
+ #module ActLikeAHash
3
+ #
4
+ # def [] (key)
5
+ # instance_variable_get("@" + key.to_s)
6
+ # end
7
+ #
8
+ # def []= (key, val)
9
+ # instance_variable_put("@" + key_to_s, val)
10
+ # end
11
+ #
12
+ #end
data/lib/GladeGUI.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # =GladeGUI
2
- #
2
+ #
3
3
  # GladeGUI connects your class to a glade form.
4
4
  # It will load a .glade
5
5
  # file into memory, enabling your ruby programs to have a GUI interface.
@@ -11,8 +11,7 @@
11
11
  # = Include the GladeGUI interface
12
12
  #
13
13
  # To use the GladeGUI interface, include this line in your code:
14
- #
15
- #
14
+ #
16
15
  # class MyClass
17
16
  # include GladeGUI
18
17
  # end
@@ -56,15 +55,15 @@
56
55
  #
57
56
  # After show_glade() is called, you can access any of your form's windows or widgets
58
57
  # using the @builder variable:
59
- # ```ruby
58
+ #
60
59
  # @builder["window1"].title = "This is the title that appears at the top."
61
- # ```
60
+ #
62
61
  #
63
62
  # Here's another example: Suppose you have a glade form with a Gtk::Entry box on it named "email."
64
63
  # You could set the text that appears in the Gtk::Entry by setting the Gtk::Entry#text property:
65
- # ```ruby
64
+ #
66
65
  # @builder["email"].text = "harvey@harveyserver.com"
67
- # ```
66
+ #
68
67
  # Now the email adddess is set with a new value:
69
68
  #
70
69
  # http://visualruby.net/img/gladegui_simple.jpg
@@ -114,7 +113,8 @@ end
114
113
 
115
114
 
116
115
  ##
117
- # This will Load the glade form according to the naming convention: MyClass.rb => MyClass.glade.
116
+ # This will Load the glade form according to the naming convention:
117
+ # MyClass.rb => MyClass.glade.
118
118
  # It will create a Gtk::Builder object from your glade file.
119
119
  # The Gtk::Builder object is stored in the instance variable, @builder.
120
120
  # You can get a reference to any of the widgets on the glade form by
@@ -197,11 +197,9 @@ end
197
197
  # set_glade_variables()
198
198
  #
199
199
  # So, to set all the values of a form, simply call the set_glade_all() method instead.
200
-
201
200
  def set_glade_all(obj = self)
202
201
  set_glade_active_record(obj)
203
202
  set_glade_variables(obj)
204
- # set_glade_hash(obj) if obj.is_a?(Hash) #only needed for Hash subclass. needed?
205
203
  end
206
204
 
207
205
  # This method is the most useful method to retreive values from a glade form. It will
@@ -212,7 +210,6 @@ end
212
210
  # get_glade_variables()
213
211
  #
214
212
  # So, to retreive all the values of a form back into your ActiveRecord object and instance variables, simply call the set_glade_all() method instead.
215
-
216
213
  def get_glade_all(obj = self)
217
214
  get_glade_active_record(obj)
218
215
  get_glade_variables(obj)
@@ -285,7 +282,7 @@ end
285
282
  end
286
283
  end
287
284
 
288
-
285
+ # @private
289
286
  def fill_control(glade_name, val)
290
287
  control = @builder[glade_name]
291
288
  return unless control
@@ -368,6 +365,7 @@ end
368
365
  end
369
366
  end
370
367
 
368
+ # @private
371
369
  def get_control_value(glade_name)
372
370
  return unless control = @builder[glade_name]
373
371
  case control
@@ -405,7 +403,7 @@ end
405
403
  end
406
404
  end
407
405
 
408
- # @private
406
+ # @private
409
407
  def self.included(obj)
410
408
  temp = caller[0].split(":") #correct for windows C:\Users\george etc.
411
409
  caller_path_to_class_file, = temp[0].size == 1 ? temp[0] + ":" + temp[1] : temp[0]
data/lib/SavableClass.rb CHANGED
@@ -1,58 +1,40 @@
1
1
  module VR
2
2
 
3
- def self.load_yaml(flags)
3
+ # Loads or creates a yaml file with a given object type (class).
4
+ # If the file exists already, the object will be returned. If not,
5
+ # a new instance will be returned, and the file will instantly be saved.
6
+ # @param [Class] klass The class of the object to be loaded or created
7
+ # @param [String] file_name File name to save. Should be named .yaml
8
+ # @param [Splat] args Optional arguments to pass to contructor of class. Not used often.
9
+ # @return [Object] Object of type klass that was loaded or created.
10
+ def self.load_yaml(klass, file_name, *args)
4
11
  me = nil
5
- if File.file?(flags[:file_name])
6
- me = YAML.load(File.open(flags[:file_name]).read)
7
- elsif flags[:class]
8
- me = flags[:class].new()
12
+ if File.file?(file_name)
13
+ me = YAML.load(File.open(file_name).read)
14
+ else
15
+ me = klass.new(*args)
9
16
  end
10
- file_name = File.expand_path(flags[:file_name])
17
+ file_name = File.expand_path(file_name)
11
18
  me.instance_variable_set(:@vr_yaml_file, file_name)
12
19
  me.defaults() if me.respond_to?(:defaults)
13
20
  VR::save_yaml(me)
14
21
  return me
15
22
  end
16
23
 
17
- # todo create folders if don't exist
18
- def self.save_yaml(obj, filename = nil)
19
- filename ||= obj.instance_variable_get(:@vr_yaml_file)
20
- dirname = File.dirname(filename)
21
- FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
22
- File.open(filename, "w") {|f| f.puts(obj.to_yaml)}
24
+ # Saves an object likely loaded with #load_yaml to disk.
25
+ # @param [Object] obj Object to save in yaml format
26
+ # @param [String] file_name Optional file name to save yaml file to. When omitted,
27
+ # it will save file to path where it was opened from. Only supply this param if you want to
28
+ # make another copy of the yaml file.
29
+ def self.save_yaml(obj, file_name = nil)
30
+ file_name ||= obj.instance_variable_get(:@vr_yaml_file)
31
+ dir = File.dirname(file_name)
32
+ unless File.directory?(dir)
33
+ FileUtils.mkdir_p(dir)
34
+ end
35
+ File.open(file_name, "w") {|f| f.puts(obj.to_yaml)}
23
36
  end
24
-
37
+ # Note: can't remove @builder or @top_level_window variables because needed to close window.
25
38
  end
26
39
 
27
- #
28
- #class VR::SavableClass
29
- #
30
- # def initialize(filename = nil)
31
- # @filename = filename
32
- # defaults
33
- # end
34
- #
35
- # def self.load_yaml(filename)
36
- # if File.file?(filename)
37
- # me = YAML.load(File.open(filename).read)
38
- # me.filename = filename
39
- # me.defaults()
40
- # return me
41
- # else
42
- # return nil
43
- # end
44
- # end
45
- #
46
- # def save_yaml(new_filename = nil)
47
- # @filename = new_filename if new_filename
48
- # data = YAML.dump(self)
49
- # File.open(@filename, "w") {|f| f.puts(data)}
50
- # end
51
- #
52
- #
53
- #end
54
-
55
-
56
-
57
-
58
-
40
+
data/my_yard.yaml CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:MyYard
2
2
  project_root: "/home/eric/vrp/vr3"
3
3
  output_dir: doc
4
- theme: visualruby
4
+ theme: default
5
5
  template: default
6
- files: lib/**/*.rb
7
- extra_files: site/*.*
8
- exclude: ''
6
+ files: "*/**/*.rb */**/*.c"
7
+ extra_files: "*/**/*.md */**/*.rdoc"
8
+ exclude: "*.glade"
9
9
  include_public: true
10
10
  include_private: false
11
11
  include_protected: false
12
- no_private: true
13
- export_db: true
14
- title: Visual Ruby
12
+ no_private: false
13
+ export_db: false
14
+ title: Get outta my yard!
15
15
  vr_yaml_file: "/home/eric/vrp/vr3/my_yard.yaml"
16
- main: index.html
16
+ main: README.md
17
17
  builder: !ruby/object:Gtk::Builder {}
18
18
  top_level_window: true
19
- answer: !ruby/object:VR::Alert::DialogAnswer
20
- answer: true
@@ -3,7 +3,7 @@ class VR_Document < GtkSource::View
3
3
 
4
4
  include GladeGUI
5
5
  include VR_TextViewCommon
6
-
6
+
7
7
  attr_accessor :full_path_file, :title
8
8
 
9
9
  def initialize(full_path_file, title_label, main)
@@ -51,13 +51,14 @@ class VR_Document < GtkSource::View
51
51
  text = "The file: <b>#{@full_path_file}</b>\n has been modified since you loaded it:\n\nYou loaded: #{@modified_time}\nOn disk: #{mod_time().to_s}\n\nDo you wnat to keep this version?\n"
52
52
  ans = alert(text, headline: "Warning!", width: 400, button_yes: "Keep Current Version",
53
53
  button_no: "Reload Disk Version", button_cancel: "Cancel", parent: @main)
54
- if ans == true # yes, keep current
54
+ if ans == true # yes, keep current ok
55
55
  write_to_disk()
56
56
  return true
57
- elsif ans == false # Reload From Disk
58
- reload_from_disk()
57
+ elsif ans == false # Reload From Disk ok
58
+ reload_from_disk()
59
+ return true
59
60
  end
60
- return false #abort!
61
+ return false # abort! No resolution.
61
62
  end
62
63
 
63
64
  def write_to_disk(fn = @full_path_file)
@@ -65,15 +66,10 @@ class VR_Document < GtkSource::View
65
66
  File.open(fn, "w") { |f| f.puts(buffer.text) }
66
67
  buffer.modified = false
67
68
  @modified_time = mod_time()
68
- @title.label = File.basename(fn)
69
- return true
69
+ @title.label = File.basename(fn)
70
70
  end
71
-
72
-
73
-
74
-
75
71
 
76
- def jump_to_line(line_num, search_str = nil)
72
+ def jump_to_line(line_num, search_str = nil)
77
73
  while (Gtk.events_pending?)
78
74
  Gtk.main_iteration
79
75
  end
@@ -47,27 +47,24 @@ class VR_Tabs < Gtk::Notebook
47
47
  return save_as()
48
48
  else
49
49
  return @docs[page].write_to_disk()
50
- end
50
+ end
51
51
  elsif answer == false # Discard Changes
52
52
  @docs[page].reload_from_disk()
53
53
  return true #continue without saving
54
54
  end
55
55
  return false #abort!
56
56
  end
57
-
57
+
58
58
  def try_to_save(ask = true)
59
- return false if not @docs[page].modified_time_matches()
59
+ # return false if not @docs[page].modified_time_matches()
60
60
  return true if @docs[page].empty?
61
- if (@docs[page].title.label == "Untitled")
62
- return save_changes?
63
- elsif (@docs[page].buffer.modified? and ask)
64
- return save_changes?
65
- elsif @docs[page].buffer.modified?
61
+ if (@docs[page].title.label == "Untitled") or (@docs[page].buffer.modified? and ask)
62
+ return save_changes?
63
+ end
64
+ if @docs[page].buffer.modified?
66
65
  @docs[page].write_to_disk()
67
- return true
68
- else
69
- return true
70
- end
66
+ end
67
+ return true
71
68
  end
72
69
 
73
70
 
@@ -75,18 +72,21 @@ class VR_Tabs < Gtk::Notebook
75
72
  @docs.each { |doc| doc.update_style() }
76
73
  end
77
74
 
75
+ def modified_times_ok()
76
+ answers = @docs.each.collect { |doc| doc.modified_time_matches }
77
+ return !answers.include?(false)
78
+ end
79
+
78
80
  # Tries to save and/or close all open documents
79
81
  # @param [Hash] flags Optiions
80
82
  # @option [Boolean] ask Whether or not to ask to save or save without asking.
81
- # @option [Boolean] close Close tab when finished
82
- # @option [String] folder operate only on folders matching this string. Default = "/"
83
- def try_to_save_all(flags)
84
- ask = flags[:ask]
85
- folder ||= "/"
83
+ # @option [Boolean] close Close tab when finished
84
+ def try_to_save_all(flags)
85
+ return false unless modified_times_ok()
86
86
  passed = true
87
87
  (0..n_pages-1).each do |i|
88
- page = i
89
- unless try_to_save(ask)
88
+ self.page = i
89
+ unless try_to_save(flags[:ask])
90
90
  passed = false
91
91
  end
92
92
  end
@@ -94,20 +94,7 @@ class VR_Tabs < Gtk::Notebook
94
94
  return passed
95
95
  end
96
96
 
97
- ##todo update file_tree!
98
- # def try_to_save_all(ask = true)
99
- # @docs.each do |doc|
100
- # return false unless doc.try_to_save(ask)
101
- # end
102
- # end
103
- #
104
- ##todo update file_tree!
105
- # def try_to_close_all(ask = true)
106
- # return false unless try_to_save_all(ask)
107
- # (n_pages).times { destroy_tab() }
108
- # end
109
-
110
-
97
+
111
98
  def switch_to(path)
112
99
  i = tab_number(path)
113
100
  return false if i.nil?
@@ -5,7 +5,7 @@ class NewProjectGUI
5
5
 
6
6
  def initialize(parent)
7
7
  @parent = parent
8
- @projects_home = $VR_ENV_GLOBAL.projects_home # sets in glade
8
+ @projects_home = $VR_ENV_GLOBAL.projects_home + "/" # sets in glade
9
9
  end
10
10
 
11
11
  def buttonCreate__clicked(*args)
@@ -9,7 +9,7 @@ class VR_File_Tree < VR::FileTreeView
9
9
  @api = RubygemsAPI.new
10
10
  load_glade() # loads menus
11
11
  end
12
-
12
+
13
13
  def self__row_activated(*args)
14
14
  return unless rows = selected_rows
15
15
  file_name = rows.first[:path]
data/src/main/VR_Main.rb CHANGED
@@ -17,7 +17,7 @@ class VR_Main
17
17
  menuInstallExamples__activate if not File.directory?(required_project)
18
18
 
19
19
  # load global settings (requires /home/visuaruby folder exists
20
- $VR_ENV_GLOBAL = VR::load_yaml(:class => VR_ENV_GLOBAL, :file_name => VR_ENV_GLOBAL::GLOBAL_SETTINGS_FILE)
20
+ $VR_ENV_GLOBAL = VR::load_yaml(VR_ENV_GLOBAL, VR_ENV_GLOBAL::GLOBAL_SETTINGS_FILE)
21
21
 
22
22
  # try to open right project
23
23
  if not project_valid?(@proj_path)
@@ -253,7 +253,7 @@ class VR_Main
253
253
  end
254
254
 
255
255
  def load_state
256
- $VR_ENV = VR::load_yaml(:class => VR_ENV, :file_name => VR_ENV::SETTINGS_FILE)
256
+ $VR_ENV = VR::load_yaml(VR_ENV, VR_ENV::SETTINGS_FILE)
257
257
  @builder["window1"].resize($VR_ENV.width, $VR_ENV.height)
258
258
  @builder['panelMain'].set_position($VR_ENV.panel_pos)
259
259
  @builder["panelNotebook"].set_position($VR_ENV.notebook_panel_position)
@@ -309,8 +309,7 @@ class VR_Main
309
309
  # needed so tabs can be saved, called before destroy, must return false to close wndow.
310
310
  def window1__delete_event(*args)
311
311
  save_state
312
- return true unless @tabs.try_to_save_all(:ask=>true)
313
- return false #ok to close
312
+ return !@tabs.try_to_save_all(:ask=>true)
314
313
  end
315
314
 
316
315
  def menuQuit__activate(*a)
@@ -320,6 +319,8 @@ class VR_Main
320
319
  def tabs__switch_page(_self, x, page_num)
321
320
  return unless tab = @tabs.docs[page_num] # needed. sometimes nil
322
321
  @builder[:labelStatus].label = "Project: #{@proj_path} File: #{tab.full_path_file}"
322
+ tab.modified_time_matches()
323
323
  end
324
324
 
325
325
  end
326
+
data/src/main/VR_Tools.rb CHANGED
@@ -45,7 +45,7 @@ module VR_Tools
45
45
  Gem::Specification.new do |s|
46
46
  s.name = "#{File.basename(Dir.pwd).downcase}" # i.e. visualruby. This name will show up in the gem list.
47
47
  s.version = "0.0.1" # i.e. (major,non-backwards compatable).(backwards compatable).(bugfix)
48
- s.add_dependency "visualruby", ">= 3.0.15"
48
+ s.add_dependency "visualruby", ">= 3.0.18"
49
49
  s.add_dependency "require_all", ">= 1.2.0"
50
50
  s.has_rdoc = false
51
51
  s.authors = ["Your Name"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visualruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.18
4
+ version: 3.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Cunningham
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir:
10
10
  - "."
11
11
  cert_chain: []
12
- date: 2016-06-28 00:00:00.000000000 Z
12
+ date: 2016-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gtk3