visualruby 1.0.19 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/Splash.rb +40 -0
  3. data/bin/editor/VR_Document.rb +81 -74
  4. data/bin/editor/VR_TabSearch.rb +5 -7
  5. data/bin/editor/VR_Tabs.rb +57 -36
  6. data/bin/editor/VR_TextShell.rb +12 -34
  7. data/bin/editor/VR_TextViewCommon.rb +9 -28
  8. data/bin/main/NewProjectGUI.rb +14 -13
  9. data/bin/main/OpenProject.rb +69 -0
  10. data/bin/main/ProjectChooserView.rb +3 -2
  11. data/bin/main/ProjectTree.rb +25 -0
  12. data/bin/main/RubygemsAPI.rb +15 -11
  13. data/bin/main/VR_ENV.rb +38 -60
  14. data/bin/main/VR_ENV_GLOBAL.rb +45 -44
  15. data/bin/main/VR_File_Tree.rb +29 -21
  16. data/bin/main/VR_Local_Gem_Tree.rb +4 -19
  17. data/bin/main/VR_Main.rb +128 -144
  18. data/bin/main/VR_Remote_Gem_Tree.rb +6 -19
  19. data/bin/main/glade/NewProjectGUI.glade +94 -98
  20. data/bin/main/glade/OpenProject.glade +259 -0
  21. data/bin/main/glade/RubygemsAPI.glade +98 -62
  22. data/bin/main/glade/VR_ENV.glade +46 -55
  23. data/bin/main/glade/VR_ENV_GLOBAL.glade +251 -180
  24. data/bin/main/glade/VR_File_Tree.glade +25 -16
  25. data/bin/main/glade/VR_Local_Gem_Tree.glade +16 -8
  26. data/bin/main/glade/VR_Main.glade +410 -449
  27. data/bin/main/glade/VR_Remote_Gem_Tree.glade +33 -31
  28. data/bin/tools/VR_Tools.rb +60 -46
  29. data/{visualruby_examples → examples}/active_record/active_record.rb +16 -10
  30. data/{visualruby_examples → examples}/active_record/bin/ChoosePerson.rb +7 -0
  31. data/examples/active_record/bin/Person.rb +21 -0
  32. data/examples/active_record/bin/glade/ChoosePerson.glade +89 -0
  33. data/examples/active_record/bin/glade/Person.glade +197 -0
  34. data/{visualruby_examples → examples}/active_record/db/development.sqlite3 +0 -0
  35. data/{visualruby_examples → examples}/active_record2/bin/CompanyGUI.rb +7 -7
  36. data/{visualruby_examples → examples}/active_record2/bin/Employee.rb +0 -0
  37. data/{visualruby_examples → examples}/active_record2/bin/Employer.rb +0 -0
  38. data/{visualruby_examples → examples}/active_record2/bin/Paycheck.rb +0 -0
  39. data/examples/active_record2/bin/glade/CompanyGUI.glade +149 -0
  40. data/examples/active_record2/bin/glade/Employee.glade +126 -0
  41. data/{visualruby_examples → examples}/active_record2/bin/glade/Employer.glade +0 -0
  42. data/{visualruby_examples → examples}/active_record2/bin/glade/Paycheck.glade +0 -0
  43. data/{visualruby_examples → examples}/active_record2/db/development.sqlite3 +0 -0
  44. data/{visualruby_examples → examples}/active_record2/main.rb +15 -9
  45. data/examples/alert_box/bin/AlertBoxDemo.rb +80 -0
  46. data/examples/alert_box/bin/glade/AlertBoxDemo.glade +234 -0
  47. data/examples/alert_box/main.rb +12 -0
  48. data/{visualruby_examples → examples}/all_widgets/bin/AllWidgets.rb +18 -10
  49. data/{visualruby_examples → examples}/all_widgets/bin/glade/AllWidgets.glade +52 -16
  50. data/{visualruby_examples → examples}/all_widgets/bin/splash.png +0 -0
  51. data/examples/all_widgets/main.rb +12 -0
  52. data/{visualruby_examples → examples}/calculator/bin/Calculator.rb +23 -22
  53. data/{visualruby_examples → examples}/calculator/bin/glade/Calculator.glade +81 -51
  54. data/examples/calculator/main.rb +13 -0
  55. data/examples/child_window/bin/ChildWindowDemo.rb +52 -0
  56. data/examples/child_window/bin/ModalWindow.rb +9 -0
  57. data/examples/child_window/bin/ModelessWindow.rb +9 -0
  58. data/examples/child_window/bin/MyChildClass.rb +21 -0
  59. data/examples/child_window/bin/glade/ChildWindowDemo.glade +87 -0
  60. data/examples/child_window/bin/glade/ModalWindow.glade +61 -0
  61. data/examples/child_window/bin/glade/ModelessWindow.glade +61 -0
  62. data/{visualruby_examples → examples}/child_window/bin/glade/MyChildClass.glade +14 -12
  63. data/examples/child_window/main.rb +12 -0
  64. data/{visualruby_examples → examples}/drag_drop/bin/DragDropDemo.rb +9 -10
  65. data/examples/drag_drop/bin/glade/DragDropDemo.glade +161 -0
  66. data/{visualruby_examples → examples}/drag_drop/img/folder.png +0 -0
  67. data/{visualruby_examples → examples}/drag_drop/img/glade.png +0 -0
  68. data/{visualruby_examples → examples}/drag_drop/img/gtk-edit.png +0 -0
  69. data/{visualruby_examples → examples}/drag_drop/img/obj.png +0 -0
  70. data/{visualruby_examples → examples}/drag_drop/img/png.png +0 -0
  71. data/{visualruby_examples → examples}/drag_drop/img/rb.png +0 -0
  72. data/{visualruby_examples → examples}/drag_drop/img/ruby.png +0 -0
  73. data/{visualruby_examples → examples}/drag_drop/img/unknown.png +0 -0
  74. data/examples/drag_drop/main.rb +11 -0
  75. data/examples/filetreeview/bin/ProjectTree.rb +32 -0
  76. data/examples/filetreeview/bin/ProjectTreeGUI.rb +28 -0
  77. data/examples/filetreeview/bin/glade/ProjectTreeGUI.glade +156 -0
  78. data/examples/filetreeview/main.rb +13 -0
  79. data/{visualruby_examples → examples}/listview/bin/SongListView.rb +24 -20
  80. data/{visualruby_examples → examples}/listview/bin/SongListViewGUI.rb +12 -11
  81. data/{visualruby_examples → examples}/listview/bin/audio-x-generic.png +0 -0
  82. data/examples/listview/bin/glade/SongListViewGUI.glade +195 -0
  83. data/examples/listview/main.rb +10 -0
  84. data/examples/listview_objects/bin/DataObject.rb +53 -0
  85. data/{visualruby_examples → examples}/listview_objects/bin/ListViewObjects.rb +7 -4
  86. data/examples/listview_objects/bin/ListViewObjectsGUI.rb +26 -0
  87. data/examples/listview_objects/bin/glade/DataObject.glade +196 -0
  88. data/examples/listview_objects/bin/glade/ListViewObjectsGUI.glade +87 -0
  89. data/examples/listview_objects/main.rb +12 -0
  90. data/examples/settings_file/bin/MainApp.rb +38 -0
  91. data/examples/settings_file/bin/SavableSettings.rb +39 -0
  92. data/examples/settings_file/bin/glade/MainApp.glade +87 -0
  93. data/examples/settings_file/bin/glade/SavableSettings.glade +162 -0
  94. data/examples/settings_file/main.rb +14 -0
  95. data/examples/settings_file/settings.yaml +15 -0
  96. data/examples/simple_ruby_gui/bin/DataObjectGUI.rb +21 -0
  97. data/examples/simple_ruby_gui/bin/glade/DataObjectGUI.glade +195 -0
  98. data/examples/simple_ruby_gui/main.rb +16 -0
  99. data/{visualruby_examples → examples}/treeview/bin/MyClass.rb +1 -5
  100. data/examples/treeview/bin/glade/MyClass.glade +24 -0
  101. data/examples/treeview/main.rb +13 -0
  102. data/skeleton/document/New.glade +3 -4
  103. data/skeleton/document/NewWindow.rb +1 -1
  104. data/skeleton/project/bin/MyClass.rb +2 -2
  105. data/skeleton/project/bin/glade/MyClass.glade +12 -26
  106. data/skeleton/project/main.rb +4 -8
  107. data/vr +41 -37
  108. data/vrlib/lib/Alert.rb +67 -0
  109. data/vrlib/lib/DragDrop.rb +90 -0
  110. data/vrlib/lib/GladeGUI.rb +433 -0
  111. data/vrlib/lib/IconHash.rb +18 -0
  112. data/vrlib/lib/SavableClass.rb +56 -0
  113. data/vrlib/lib/SimpleComboBoxEntry.rb +8 -0
  114. data/vrlib/lib/glade/Alert.glade +119 -0
  115. data/vrlib/lib/treeview/FileTreeView.rb +113 -0
  116. data/vrlib/lib/treeview/IterMethods.rb +82 -0
  117. data/vrlib/lib/treeview/ListView.rb +85 -0
  118. data/vrlib/lib/treeview/TreeView.rb +43 -0
  119. data/vrlib/lib/treeview/ViewCommon.rb +370 -0
  120. data/vrlib/lib/treeview/columns/CalendarCol.rb +89 -0
  121. data/vrlib/lib/treeview/columns/CellRendererCombo.rb +66 -0
  122. data/vrlib/lib/treeview/columns/CellRendererDate.rb +45 -0
  123. data/vrlib/lib/treeview/columns/CellRendererObject.rb +57 -0
  124. data/vrlib/lib/treeview/columns/CellRendererPhone.rb +45 -0
  125. data/vrlib/lib/treeview/columns/CellRendererPixbuf.rb +16 -0
  126. data/vrlib/lib/treeview/columns/CellRendererProgress.rb +17 -0
  127. data/vrlib/lib/treeview/columns/CellRendererSpin.rb +37 -0
  128. data/vrlib/lib/treeview/columns/CellRendererText.rb +38 -0
  129. data/vrlib/lib/treeview/columns/CellRendererToggle.rb +47 -0
  130. data/vrlib/lib/treeview/columns/ComboCol.rb +43 -0
  131. data/vrlib/lib/treeview/columns/CurrencyCol.rb +23 -0
  132. data/vrlib/lib/treeview/columns/DateCol.rb +20 -0
  133. data/vrlib/lib/treeview/columns/ImageCol.rb +27 -0
  134. data/vrlib/lib/treeview/columns/ProgressCol.rb +27 -0
  135. data/vrlib/lib/treeview/columns/SpinCol.rb +11 -0
  136. data/vrlib/lib/treeview/columns/TextCol.rb +65 -0
  137. data/vrlib/lib/treeview/columns/TreeViewColumn.rb +93 -0
  138. data/{bin/main/glade/ProjectChooserGUI.glade → vrlib/lib/treeview/columns/glade/CalendarCol.glade} +71 -63
  139. data/{bin/main/glade/Splash.glade → vrlib/lib/treeview/columns/glade/ImageCol.glade} +5 -6
  140. data/vrlib/lib/treeview/columns/glade/TextCol.glade +82 -0
  141. data/vrlib/rdoc_replace.yaml +77 -0
  142. data/vrlib/vrlib.rb +7 -0
  143. metadata +163 -136
  144. data/bin/editor/glade/VR_Document.glade +0 -160
  145. data/bin/main/ProjectChooserGUI.rb +0 -41
  146. data/bin/main/Splash.rb +0 -22
  147. data/visualruby_examples/active_record/.vr_settings.yaml +0 -47
  148. data/visualruby_examples/active_record/bin/Person.rb +0 -13
  149. data/visualruby_examples/active_record/bin/glade/ChoosePerson.glade +0 -61
  150. data/visualruby_examples/active_record/bin/glade/Person.glade +0 -148
  151. data/visualruby_examples/active_record2/.vr_settings.yaml +0 -16
  152. data/visualruby_examples/active_record2/bin/glade/CompanyGUI.glade +0 -167
  153. data/visualruby_examples/active_record2/bin/glade/Employee.glade +0 -123
  154. data/visualruby_examples/all_widgets/.vr_settings.yaml +0 -13
  155. data/visualruby_examples/all_widgets/main.rb +0 -14
  156. data/visualruby_examples/calculator/.vr_settings.yaml +0 -11
  157. data/visualruby_examples/calculator/main.rb +0 -13
  158. data/visualruby_examples/child_window/.vr_settings.yaml +0 -16
  159. data/visualruby_examples/child_window/bin/ChildWindowDemo.rb +0 -39
  160. data/visualruby_examples/child_window/bin/MyChildClass.rb +0 -40
  161. data/visualruby_examples/child_window/bin/glade/ChildWindowDemo.glade +0 -101
  162. data/visualruby_examples/child_window/main.rb +0 -13
  163. data/visualruby_examples/drag_drop/.vr_settings.yaml +0 -12
  164. data/visualruby_examples/drag_drop/bin/glade/DragDropDemo.glade +0 -143
  165. data/visualruby_examples/drag_drop/main.rb +0 -14
  166. data/visualruby_examples/listview/.vr_settings.yaml +0 -12
  167. data/visualruby_examples/listview/bin/glade/SongListViewGUI.glade +0 -220
  168. data/visualruby_examples/listview/main.rb +0 -19
  169. data/visualruby_examples/listview_objects/.vr_settings.yaml +0 -16
  170. data/visualruby_examples/listview_objects/bin/DataObject.rb +0 -32
  171. data/visualruby_examples/listview_objects/bin/DataObjectGUI.rb +0 -41
  172. data/visualruby_examples/listview_objects/bin/ListViewObjectsGUI.rb +0 -18
  173. data/visualruby_examples/listview_objects/bin/glade/DataObject.glade +0 -198
  174. data/visualruby_examples/listview_objects/bin/glade/ListViewObjectsGUI.glade +0 -102
  175. data/visualruby_examples/listview_objects/main.rb +0 -13
  176. data/visualruby_examples/simple_ruby_gui/.vr_settings.yaml +0 -16
  177. data/visualruby_examples/simple_ruby_gui/bin/DataObjectGUI.rb +0 -20
  178. data/visualruby_examples/simple_ruby_gui/bin/glade/DataObjectGUI.glade +0 -163
  179. data/visualruby_examples/simple_ruby_gui/main.rb +0 -16
  180. data/visualruby_examples/treeview/.vr_settings.yaml +0 -12
  181. data/visualruby_examples/treeview/bin/glade/MyClass.glade +0 -48
  182. data/visualruby_examples/treeview/main.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7192ef3fc85bc4b795a31210c16af1270a939f5e
4
- data.tar.gz: 0f8f7694df78b11a6bb71d38c55e69a50d06a5a5
3
+ metadata.gz: dfad4ea2ab9c0dc40116d83d3527b2c37eca5707
4
+ data.tar.gz: 0545e9a2bb43d8f25456f002be2f6de45d4a909d
5
5
  SHA512:
6
- metadata.gz: f357c4e45a899939125cb4f8cf6e811e9a00535396d3ac06f343d2792cbf9e267d469ce409b12254645cf599baddbaec555a3f751abb38027004ecb5db38f98c
7
- data.tar.gz: 4a928510cf42bbd62700de6a1ab040f70394e0a77953059ddb391da196d0834350eded0824a01c377efa06d6f900b3d787a82fae97ebecc1ae0304000bf2fd20
6
+ metadata.gz: 9d7a3d89a2780640937a303dd9eb51688e5cffa914241a808862fd84c589f7b92713f98927aa3f0963d70a936b435aad41061614372cea9ff159755d9074bd8d
7
+ data.tar.gz: 87860ddce8263104e234e071876270923cefc297eb8162ceb911f756c4bd44c3e74e492841c0c77aba890bb82ef2de4d2acec013b44b3bf434134d2827e0a873
data/Splash.rb ADDED
@@ -0,0 +1,40 @@
1
+ require "gtk3"
2
+
3
+ def load_everything
4
+ require "rubygems"
5
+ require "gtksourceview3"
6
+ require "yaml" #needed
7
+ require "net/http" #needed
8
+ require "net/https" #needed
9
+ require "find" #needed
10
+ require "fileutils" #needed
11
+ require "rubygems/installer"
12
+ require "rubygems/uninstaller"
13
+ require "rubygems/package"
14
+ require "rubygems/specification"
15
+ require "date"
16
+
17
+ require 'require_all'
18
+
19
+ require_rel 'vrlib/lib/'
20
+ require_rel 'bin/'
21
+
22
+ VR_Main.new(ARGV).show_glade()
23
+
24
+ end
25
+
26
+ $splash = Gtk::Window.new()
27
+ image = Gtk::Image.new(:file => "img/splash.png")
28
+ $splash.add image
29
+ $splash.decorated = false
30
+ $splash.position = :center_always
31
+ $splash.show_all
32
+
33
+
34
+ GLib::Timeout.add(40) {
35
+ load_everything
36
+ }
37
+
38
+ Gtk.main
39
+
40
+
@@ -1,6 +1,6 @@
1
1
 
2
- class VR_Document < Gtk::SourceView
3
-
2
+ class VR_Document < GtkSource::View
3
+
4
4
  include GladeGUI
5
5
  include VR_TextViewCommon
6
6
 
@@ -12,36 +12,36 @@ class VR_Document < Gtk::SourceView
12
12
  super()
13
13
  @title = title_label #reference to label on tab
14
14
  reload_from_disk(full_path_file)
15
- signal_connect("visibility_notify_event") { scroll_to_cursor() }
16
15
  hilight_current_line = true
17
16
  show_right_margin = true
18
17
  right_margin_position = 80
19
18
  auto_indent = true
20
- lang = Gtk::SourceLanguageManager.new.get_language(get_language(full_path_file)) # 'ruby') if [".rb", "", ".gemspec"].include? File.extname(full_path_file)
19
+ lang = GtkSource::LanguageManager.new.get_language(get_language(full_path_file))
21
20
  buffer.language = lang
22
21
  buffer.highlight_syntax = true
23
- # buffer.highlight_matching_brackets = true
24
- wrap_mode = Gtk::TextTag::WRAP_WORD
25
- buffer.create_tag("hilight", { "background" => "#FFF0A0" })
26
- buffer.create_tag("hilight_red",{ "background" => "#FFC0C0" })
27
- buffer.signal_connect("changed") { remove_tag("hilight") }
28
- self.show_line_numbers = true
29
- load_glade(__FILE__) #for save dialogs
22
+ buffer.highlight_matching_brackets = false
23
+ @hilight = buffer.create_tag("hilight", { "background" => "#FFF0A0" })
24
+ buffer.signal_connect("changed") { remove_tag(@hilight) }
25
+ self.show_line_numbers = true
26
+ self.insert_spaces_instead_of_tabs = true
27
+ self.indent_width = $VR_ENV_GLOBAL.tab_spaces.to_i
28
+ self.highlight_current_line = true
29
+ self.set_cursor_visible(true)
30
30
  update_style()
31
31
  end
32
-
33
- def get_language(fn)
34
- case File.extname(full_path_file)
35
- when ".rb", "", ".gemspec" ; return "ruby"
36
- when ".erb", ".html" ; return "html"
37
- else ; return ""
38
- end
32
+
33
+ def get_language(fn)
34
+ case File.extname(full_path_file)
35
+ when ".rb", "", ".gemspec" ; return "ruby"
36
+ when ".erb", ".html" ; return "html"
37
+ else ; return ""
38
+ end
39
39
  end
40
40
 
41
41
  def update_style()
42
- modify_font(Pango::FontDescription.new($VR_ENV_GLOBAL.font_name))
42
+ override_font(Pango::FontDescription.new($VR_ENV_GLOBAL.font_name))
43
43
  tab_array = Pango::TabArray.new(1, true)
44
- tab_array.set_tab(0, Pango::TAB_LEFT, $VR_ENV_GLOBAL.tab_spaces * 8)
44
+ tab_array.set_tab(0, Pango::TAB_LEFT, $VR_ENV_GLOBAL.tab_spaces.to_i * 8)
45
45
  set_tabs(tab_array)
46
46
  end
47
47
 
@@ -49,24 +49,24 @@ class VR_Document < Gtk::SourceView
49
49
  @full_path_file = fn
50
50
  @title.label = File.basename(@full_path_file)
51
51
  buffer.text = File.open(@full_path_file, "r").read if File.file?(@full_path_file.to_s) #protect against nil to_s
52
- buffer.modified = false
52
+ buffer.modified = false
53
53
  @modified_time = mod_time()
54
54
  end
55
-
55
+
56
56
  def modified_time_matches()
57
- return true if @modified_time == mod_time()
58
- d = @builder["dialogModifiedTime"]
59
- @builder["labelModified"].markup = "<big><big><b>WARNING!</b></big></big>\n\nThe 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"
60
- resp = d.run
61
- d.hide
62
- if resp == 2 # Keep Current Version
57
+ return true if @modified_time == mod_time()
58
+ 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"
59
+ ans = alert(text, headline: "Warning!", width: 400, button_yes: "Keep Current Version",
60
+ button_no: "Reload Disk Version", button_cancel: "Cancel", parent: @main)
61
+ if ans == true # yes, keep current
63
62
  write_to_disk()
64
63
  return true
65
- elsif resp == 1 # Reload From Disk
64
+ elsif ans == false # Reload From Disk
66
65
  reload_from_disk()
67
66
  end
68
67
  return false #abort!
69
- end
68
+ end
69
+
70
70
 
71
71
  def try_to_save(ask = true)
72
72
  return false if not modified_time_matches()
@@ -84,7 +84,6 @@ class VR_Document < Gtk::SourceView
84
84
  end
85
85
 
86
86
  def write_to_disk(fn = @full_path_file)
87
- # modify_base(Gtk::STATE_NORMAL, Gdk::Color.parse("#FFFFFF"))
88
87
  @full_path_file = fn
89
88
  File.open(fn, "w") { |f| f.puts(buffer.text) }
90
89
  buffer.modified = false
@@ -92,105 +91,113 @@ class VR_Document < Gtk::SourceView
92
91
  @title.label = File.basename(fn)
93
92
  return true
94
93
  end
95
-
94
+
96
95
  def save_changes?
97
- d = @builder["dialogSave"]
98
- @builder["labelSave"].markup = "Save changes to: <b>#{File.basename(@full_path_file)}</b>?"
99
- resp = d.run
100
- d.hide
101
- if resp == 2 # Save Changes
102
- return @title.label == "Untitled" ? save_as() : write_to_disk()
103
- elsif resp == 1 # Discard Changes
96
+ answer = alert "Save chages to: <b> #{File.basename(@full_path_file)}</b> ?",
97
+ parent: @main,
98
+ button_yes: "Save Changes", button_no: "Discard Changes",
99
+ headline: "Save Changes?", button_cancel: "Cancel"
100
+ if answer == true # save
101
+ return @title.label == "Untitled" ? save_as() : write_to_disk()
102
+ elsif answer == false # Discard Changes
104
103
  reload_from_disk()
105
104
  return true #continue without saving
106
- else
107
- return false #abort!
108
105
  end
109
- end
106
+ return false #abort!
107
+ end
108
+
109
+
110
110
 
111
111
  #todo update file tree, parent window?
112
112
  def save_as() # returns false or complete file name.
113
- dialog = Gtk::FileChooserDialog.new("Save File As...",
114
- @builder['window1'],
115
- Gtk::FileChooser::ACTION_SAVE,
116
- nil,
117
- [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
118
- [Gtk::Stock::SAVE, Gtk::Dialog::RESPONSE_ACCEPT])
119
- dialog.current_folder = File.dirname(@full_path_file)
113
+ dialog = Gtk::FileChooserDialog.new(
114
+ title: "Save File As...",
115
+ parent: @main.builder[:window1],
116
+ action: :save,
117
+ buttons: [["_Cancel", :cancel], ["_Save", :accept]])
118
+
119
+ dialog.current_folder = File.dirname(@full_path_file)
120
120
  dialog.current_name = VR_Document.get_class_title(buffer.text)
121
121
  resp = dialog.run
122
122
  dialog.hide
123
- if resp == Gtk::Dialog::RESPONSE_ACCEPT
123
+ if resp == :accept
124
124
  write_to_disk(dialog.filename)
125
- @main.file_tree.insert(dialog.filename)
125
+ @main.file_tree.refresh()
126
126
  return true
127
127
  end
128
128
  return false
129
- end
129
+ end
130
130
 
131
- def jump_to_line(line_num, search_str="")
131
+ def jump_to_line(line_num, search_str = nil)
132
+ while (Gtk.events_pending?)
133
+ Gtk.main_iteration
134
+ end
132
135
  hilight_line(line_num)
133
- iter = buffer.get_iter_at_line(line_num)
134
- mark = buffer.create_mark("error", iter, true)
135
- scroll_to_mark(mark, 0.0, true, 0.0, 0.5)
136
- buffer.place_cursor(iter)
137
- scroll_to_cursor
138
- select_text(line_num, search_str)
136
+ iter = buffer.get_iter_at(:line => line_num - 1)
137
+ buffer.place_cursor(iter)
138
+ mark = buffer.get_mark("insert")
139
+ scroll_to_mark(mark, 0.1, true, 0.0, 0.5)
140
+ select_text(line_num - 1, search_str) if search_str
139
141
  end
140
142
 
141
143
  def hilight_line(line)
142
- remove_tag("hilight")
143
- apply_tag_to_line(line, "hilight", nil)
144
+ remove_tag(@hilight)
145
+ apply_tag_to_line(line-1, @hilight, nil)
144
146
  end
145
147
 
146
- def indent(spaces)
148
+ def indent(spaces)
149
+ return unless buffer.has_selection?
147
150
  s,e = get_selected_lines()
148
151
  (s..e).each do |i|
149
- iter = buffer.get_iter_at_line(i)
152
+ iter = buffer.get_iter_at(:line => i)
150
153
  buffer.insert(iter, " " * spaces)
151
154
  end
152
155
  end
153
156
 
154
- def unindent(spaces)
157
+ def unindent(spaces)
158
+ return unless buffer.has_selection?
155
159
  s,e = get_selected_lines()
156
160
  (s..e).each do |i|
157
161
  iter, iter_end = get_line_iters(i)
158
162
  if iter_end.offset >= iter.offset + 2
159
163
  iter_end.offset = iter.offset + 2
160
- t = buffer.get_text(iter, iter_end)
164
+ t = buffer.get_text(iter, iter_end, false)
161
165
  buffer.delete(iter, iter_end)
162
166
  buffer.insert(iter,t.lstrip)
163
167
  end
164
168
  end
165
169
  end
166
170
 
167
- def comment()
171
+ def comment()
172
+ return unless buffer.has_selection?
168
173
  s,e = get_selected_lines()
169
174
  (s..e).each do |i|
170
175
  iter, iter_end = get_line_iters(i)
171
176
  iter_end.offset = iter.offset+1
172
- chr = buffer.get_text(iter, iter_end)
177
+ chr = buffer.get_text(iter, iter_end, false)
173
178
  buffer.insert(iter, "#")
174
179
  end
175
180
  end
176
181
 
177
- def un_comment()
182
+ def un_comment()
183
+ return unless buffer.has_selection?
178
184
  s,e = get_selected_lines()
179
185
  (s..e).each do |i|
180
186
  iter, iter_end = get_line_iters(i)
181
187
  next if iter_end.offset <= iter.offset + 1
182
188
  iter_end.offset = iter.offset+1
183
- chr = buffer.get_text(iter, iter_end)
189
+ chr = buffer.get_text(iter, iter_end, false)
184
190
  buffer.delete(iter, iter_end) if chr == "#"
185
191
  end
186
192
  end
187
193
 
188
- def get_selected_lines()
189
- s,e = buffer.selection_bounds
190
- return s.line, e.line
194
+ def get_selected_lines()
195
+ return unless buffer.has_selection?
196
+ s,e = buffer.selection_bounds
197
+ return s.line, e.line
191
198
  end
192
199
 
193
- def replace(str)
200
+ def replace(str)
194
201
  return unless buffer.has_selection?
195
202
  s,e = buffer.selection_bounds
196
203
  buffer.delete(s,e)
@@ -199,7 +206,7 @@ class VR_Document < Gtk::SourceView
199
206
 
200
207
  def selected_text()
201
208
  s,e = buffer.selection_bounds
202
- buffer.get_text(s, e)
209
+ buffer.get_text(s, e, false)
203
210
  end
204
211
 
205
212
  def empty?()
@@ -1,5 +1,5 @@
1
-
2
- module VR_TabSearch #grh
1
+
2
+ module VR_TabSearch
3
3
 
4
4
  def find_in_tabs(str)
5
5
  out = "Search Results for: " + str + "\n"
@@ -13,7 +13,7 @@ module VR_TabSearch #grh
13
13
  end
14
14
 
15
15
  def find_in_all(str)
16
- out = "Search Res ults for: " + str + "\n"
16
+ out = "Search Results for: " + str + "\n"
17
17
  Find.find(Dir.pwd) do |path|
18
18
  Find.prune if path =~ /\/glade$/ or path =~ /\/doc$/ #or File.directory?(path)
19
19
  if (File.extname(path) == ".rb" or File.extname(path) == ".erb") and not File.directory?(path)
@@ -41,10 +41,8 @@ module VR_TabSearch #grh
41
41
 
42
42
  def jump_to(line)
43
43
  return if line.nil?
44
- if not switch_to(line[:path]) #full path file
45
- load_tab(line[:path])
46
- end
47
- @docs[self.page].jump_to_line(line[:line] - 1, line[:search_str])
44
+ load_tab(line[:path])
45
+ @docs[self.page].jump_to_line(line[:line], line[:search_str])
48
46
  end
49
47
 
50
48
  end
@@ -5,35 +5,50 @@ class VR_Tabs < Gtk::Notebook
5
5
 
6
6
  include VR_TabSearch
7
7
 
8
- def initialize(main)
8
+ def initialize(main)
9
+ super()
9
10
  @docs = Array.new
10
11
  @main = main
11
- @pix_close = Gdk::Pixbuf.new(File.dirname(__FILE__) + '/../../img/close.png')
12
- super()
12
+ @pix_close = Gdk::Pixbuf.new(File.dirname(__FILE__) + '/../../img/close.png')
13
+ @close_filename = File.dirname(__FILE__) + '/../../img/close.png'
14
+ self.scrollable = true #after super
15
+ self.expand = true
13
16
  end
14
17
 
15
18
  def update_style_all()
16
19
  @docs.each { |doc| doc.update_style() }
17
20
  end
21
+
22
+ def try_to_save_all(flags)
23
+ ask = flags[:ask]
24
+ passed = true
25
+ @docs.each do |doc|
26
+ unless doc.try_to_save(ask)
27
+ passed = false
28
+ end
29
+ end
30
+ (n_pages).times { destroy_tab() } if flags[:close]
31
+ return passed
32
+ end
18
33
 
19
- #todo update file_tree!
20
- def try_to_save_all(ask = true)
21
- @docs.each do |doc|
22
- return false unless doc.try_to_save(ask)
23
- end
24
- end
25
-
26
- #todo update file_tree!
27
- def try_to_close_all(ask = true)
28
- return false unless try_to_save_all(ask)
29
- (n_pages).times { destroy_tab() }
30
- end
34
+ ##todo update file_tree!
35
+ # def try_to_save_all(ask = true)
36
+ # @docs.each do |doc|
37
+ # return false unless doc.try_to_save(ask)
38
+ # end
39
+ # end
40
+ #
41
+ ##todo update file_tree!
42
+ # def try_to_close_all(ask = true)
43
+ # return false unless try_to_save_all(ask)
44
+ # (n_pages).times { destroy_tab() }
45
+ # end
31
46
 
32
47
 
33
48
  def switch_to(path)
34
49
  i = @docs.index{ |d| d.full_path_file == path }
35
- return false if i.nil?
36
- self.page = i if i != self.page
50
+ return false if i.nil?
51
+ self.page = i if i != self.page
37
52
  return true
38
53
  end
39
54
 
@@ -45,16 +60,16 @@ class VR_Tabs < Gtk::Notebook
45
60
  end
46
61
 
47
62
  def load_tab(full_path_file = Dir.pwd + "/Untitled")
48
- return if switch_to(full_path_file)
49
- tab = Gtk::HBox.new
63
+ return if switch_to(full_path_file)
50
64
  box = Gtk::EventBox.new
51
- img = Gtk::Image.new(@pix_close)
65
+ tab = Gtk::Box.new(:horizontal)
66
+ img = Gtk::Image.new(:pixbuf => @pix_close)
52
67
  box.add(img)
53
68
  title = Gtk::Label.new(File.basename(full_path_file))
54
- tab.pack_start(title, true, true, 2)
55
- tab.pack_start(box)
56
- tab.show_all
57
- text = VR_Document.new(full_path_file, title, @main)
69
+ tab.pack_start(title, :expand=>true, :fill=>true, :padding=>2)
70
+ tab.pack_start(box)
71
+ tab.show_all #needed
72
+ text = VR_Document.new(full_path_file, title, @main)
58
73
  child = Gtk::ScrolledWindow.new
59
74
  child.add(text)
60
75
  box.signal_connect("button_release_event") {remove_id(text.object_id)}
@@ -62,28 +77,34 @@ class VR_Tabs < Gtk::Notebook
62
77
  if @docs.size == 1 and @docs[0].buffer.text.strip == ""
63
78
  @docs[0] = text
64
79
  self.remove_page(0)
65
- end
66
- append_page(child, tab)
67
- @main.builder['window1'].show_all
68
- self.page = self.n_pages-1
69
- @docs[self.page] = text
80
+ end
81
+ child.show_all #needed
82
+ append_page(child, tab)
83
+ self.page = self.n_pages - 1
84
+ @docs[self.page] = text
70
85
  end
71
86
 
72
87
  #used when little 'x' image is clicked to close.
73
88
  def remove_id(object_id)
74
- i = @docs.index { |doc| doc.object_id == object_id }
75
- destroy_tab(i) if @docs[i].try_to_save()
76
- # remove_tab(i) #if not i.nil?
89
+ i = @docs.index { |doc| doc.object_id == object_id }
90
+ if @docs[i].try_to_save(true)
91
+ destroy_tab(i)
92
+ end
77
93
  end
78
94
 
79
95
  #if its there, destroys it
80
96
  def destroy_file_tab(file_name)
81
97
  destroy_tab() if switch_to(file_name)
82
98
  end
83
-
84
- def destroy_tab(tab = self.page)
85
- @docs.delete_at(tab)
86
- self.remove_page(tab)
99
+
100
+ # this spits out a bunch of warnings on remove_page
101
+ def destroy_tab(tab = self.page)
102
+ self.page = self.page - 1 # stops some warnings
103
+ VR_Tools.clear_events
104
+ # self.set_tab_label(get_nth_page(tab), nil)
105
+ self.remove_page(tab)
106
+ VR_Tools.clear_events
107
+ @docs.delete_at(tab)
87
108
  load_tab() if @docs.empty?
88
109
  end
89
110
 
@@ -1,5 +1,5 @@
1
1
 
2
- class VR_TextShell < Gtk::TextView
2
+ class VR_TextShell < GtkSource::View
3
3
 
4
4
  include VR_TextViewCommon
5
5
 
@@ -9,49 +9,25 @@ class VR_TextShell < Gtk::TextView
9
9
  @current_line = 0
10
10
  @lines = [] #needed
11
11
  self.editable = false
12
- buffer.create_tag("blue", { "foreground" => "#0000A0", "underline" => Pango::UNDERLINE_SINGLE })
13
- buffer.create_tag("hilight", { "background" => "#FFF0A0" } )
14
- signal_connect("button_release_event") { jump_to(line_at_cursor() +1) } #buffer's lines start at 1
15
- signal_connect("key_release_event") { jump_to(line_at_cursor() +1) } #buffer's lines start at 1
16
- # self.buffer.signal_connect("changed") { buffer__changed() }
12
+ @blue = buffer.create_tag("blue", { "foreground" => "#0000A0", "underline" => Pango::UNDERLINE_SINGLE })
13
+ self.highlight_current_line = true
14
+ # @hilight = buffer.create_tag("hilight", { "background" => "#FFF0A0" } )
15
+ signal_connect("button_release_event") { puts "release" ; jump_to(line_at_cursor() - 1) } #buffer's lines start at 1
16
+ signal_connect("key_release_event") { jump_to(line_at_cursor() - 1) } #buffer's lines start at 1
17
17
  end
18
18
 
19
- # @buffer.signal_connect("changed") {
20
- # eob_mark =
21
- #@output.buffer.create_mark(nil,@output.buffer.start_iter.forward_to_end,false)
22
- # @output.scroll_mark_onscreen(eob_mark)
23
- # }
24
-
25
- def buffer__move_cursor
26
- remove_tag("hilight")
27
- # place_cursor_onscreen
28
- line = line_at_cursor()
29
- apply_tag_to_line(line, "hilight")
30
- end
31
-
32
- # def buffer__changed
33
- # iter = buffer.end_iter
34
- # scroll_to_iter(iter, 0.0, false, 0, 0)
35
- # self.queue_draw
36
- ## self.hide
37
- #
38
- ## self.show
39
- #
40
- # end
41
19
 
42
20
  def hilight_links(text, jump_to_first)
43
21
  self.buffer.text = text
44
22
  first_valid_line = load_lines()
45
23
  (0..@lines.size - 1).each do |i|
46
24
  next if @lines[i].nil?
47
- apply_tag_to_line(i, "blue", @lines[i][:file_name] + ":" + @lines[i][:line].to_s)
25
+ apply_tag_to_line(i, @blue, @lines[i][:file_name] + ":" + @lines[i][:line].to_s)
48
26
  end
49
27
  @current_line = 0
50
28
  @tabs.jump_to(first_valid_line) if jump_to_first and first_valid_line
51
29
  end
52
30
 
53
-
54
-
55
31
  def load_lines()
56
32
  @lines = []
57
33
  first = nil
@@ -72,10 +48,12 @@ class VR_TextShell < Gtk::TextView
72
48
  end
73
49
 
74
50
  def jump_to(line_no = @current_line+1)
75
- return false if line_no > @lines.size - 1
51
+ puts "fed: " + line_no.to_s
52
+ return false if line_no > @lines.size
76
53
  @current_line = line_no
77
- remove_tag("hilight")
78
- apply_tag_to_line(@current_line, "hilight", nil)
54
+ # remove_tag(@hilight)
55
+ # apply_tag_to_line(@current_line, @hilight, nil)
56
+ puts "jumping to " + line_no.to_s + " = " + @lines[line_no].to_s
79
57
  @tabs.jump_to(@lines[@current_line])
80
58
  return false #must return false for button_up event
81
59
  end
@@ -1,34 +1,23 @@
1
-
2
-
3
1
  module VR_TextViewCommon
4
2
 
5
- def get_line_text(line)
6
- return nil if line > buffer.line_count - 1
7
- iter, iter_end = get_line_iters(line)
8
- return buffer.get_text(iter, iter_end)
9
- end
10
-
11
3
  def get_line_iters(line, search_str = nil)
12
- s = buffer.get_iter_at_line(line)
4
+ s = buffer.get_iter_at(:line => line)
13
5
  e = get_end_iter(s)
14
6
  if !search_str.nil?
15
- s, e = s.forward_search(search_str, Gtk::TextIter::SEARCH_TEXT_ONLY, e)
7
+ s, e = s.forward_search(search_str, :text_only, e)
16
8
  end
17
9
  return s, e
18
10
  end
19
11
 
20
12
  def select_text(line, search_str = nil)
21
13
  s, e = get_line_iters(line, search_str)
22
- buffer.move_mark("insert",s)
23
- buffer.move_mark("selection_bound", e)
14
+ return if s.nil? or e.nil?
15
+ buffer.place_cursor(s)
16
+ # buffer.move_mark(buffer.get_mark("insert"),s)
17
+ buffer.move_mark(buffer.get_mark("selection_bound"), e)
24
18
  end
25
19
 
26
20
 
27
- # def get_text_scan_iters(line_num, search_str)
28
- # st, en = get_line_iters(line_num)
29
- # s, e = st.forward_search(search_str, Gtk::TextIter::SEARCH_TEXT_ONLY, en)
30
- # end
31
-
32
21
  def apply_tag_to_line(line, tag, search_str = nil)
33
22
  s, e = get_line_iters(line, search_str)
34
23
  buffer.apply_tag(tag, s, e)
@@ -40,7 +29,7 @@ module VR_TextViewCommon
40
29
  if iter.line == buffer.line_count - 1 # last line
41
30
  return buffer.end_iter
42
31
  end
43
- return buffer.get_iter_at_line(iter.line+1)
32
+ return buffer.get_iter_at(:line => iter.line+1)
44
33
  end
45
34
 
46
35
  def remove_tag(tag)
@@ -48,18 +37,10 @@ module VR_TextViewCommon
48
37
  buffer.remove_tag(tag, s, e)
49
38
  end
50
39
 
51
-
52
40
  def line_at_cursor()
53
41
  cursor_pos = buffer.cursor_position
54
- iter = buffer.get_iter_at_offset(cursor_pos)
55
- return iter.line-1
56
- end
57
-
58
- def scroll_to_cursor()
59
- os = buffer.cursor_position
60
- return if os > buffer.char_count - 1 or os == 0
61
- iter = buffer.get_iter_at_offset(os)
62
- scroll_to_iter(iter, 0.0, true, 1.0, 0.5)
42
+ iter = buffer.get_iter_at(:offset => cursor_pos) #get_iter_at_offset depricated
43
+ return iter.line + 1
63
44
  end
64
45
 
65
46
  end