shoes 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. data/.gitignore +12 -0
  2. data/CHANGELOG +29 -0
  3. data/COPYING +30 -0
  4. data/README.md +76 -0
  5. data/README.old +117 -0
  6. data/Rakefile +130 -0
  7. data/Rakefile.bk +651 -0
  8. data/app.yaml +7 -0
  9. data/bin/main.skel +104 -0
  10. data/bugs/issue-012e9468ddc7b0cb7e1503413a8a11c4f8707b67.yaml +21 -0
  11. data/bugs/issue-0711ff8b67baa63586f11d0096fee9dd4436bf58.yaml +23 -0
  12. data/bugs/issue-07f87998d93eb401e22395c11085676389b935c4.yaml +22 -0
  13. data/bugs/issue-0bff2d80008803cbc7efbcdacdc60ef2163664d2.yaml +22 -0
  14. data/bugs/issue-0c66f223d19efbca7b692f3b91961f407ad7abec.yaml +24 -0
  15. data/bugs/issue-183bc3c7a8f575aff2b24e0bf22aa0dfcc8e4fc2.yaml +29 -0
  16. data/bugs/issue-1bad1e60a04cb3adb6a8f3ded128af2e16b56ffe.yaml +18 -0
  17. data/bugs/issue-1f1d43f76bf4de79d7f94adbae6dd506a9d81633.yaml +41 -0
  18. data/bugs/issue-320924117cadb045cc91f2a6fca922b4d81d4bb5.yaml +20 -0
  19. data/bugs/issue-33e5c8355fbf65252ea9e939714651df8bd8cb3b.yaml +25 -0
  20. data/bugs/issue-36f7c8262a72bcd5e28cfa4ed29328b8237ea79b.yaml +20 -0
  21. data/bugs/issue-39bf04ee50c3bef67b89b8e9beb28657805587ce.yaml +18 -0
  22. data/bugs/issue-3e28ba7754f73d02ef416eef989af707a8c00f01.yaml +23 -0
  23. data/bugs/issue-3f638cc03f41f9c3fdf217355321f1563f8fee45.yaml +22 -0
  24. data/bugs/issue-41e48e14f1ef4f6deb69be68165d7dd3ffd99156.yaml +22 -0
  25. data/bugs/issue-4c9408166a2aa5dd333bbb05520deebf4ded08e0.yaml +22 -0
  26. data/bugs/issue-55c687e108ecd5aeb8e0d0aeb4294984f84acd3e.yaml +18 -0
  27. data/bugs/issue-5811d34692cc292717a58ec1df1f8948cf30d826.yaml +28 -0
  28. data/bugs/issue-5a7c1f59a0526f9cea7fb366867cf1e6ed8ef69d.yaml +22 -0
  29. data/bugs/issue-688a2c2566bef6a03efa57a4ae1f7cfa8fc74444.yaml +21 -0
  30. data/bugs/issue-78b16c7988ade2ef96e716fa8cb9a004bd4ced65.yaml +33 -0
  31. data/bugs/issue-804ee49f9800154eddf0650690c7a9bb5626253f.yaml +27 -0
  32. data/bugs/issue-807dd1c610b2e941a5d454e26b2eac27e89a0ab4.yaml +22 -0
  33. data/bugs/issue-822ee33ec11ebd25f90ea86e8438de7891e63aee.yaml +18 -0
  34. data/bugs/issue-82ff7152cebb8a1cb065b864cb4fe22de2328146.yaml +29 -0
  35. data/bugs/issue-856afbdcdd4970ad54b8ce4a6c017fbaab45f49d.yaml +31 -0
  36. data/bugs/issue-8d49e32fb21522651c67490adb4d80076dbb14e1.yaml +24 -0
  37. data/bugs/issue-91583359653a9d530c1e32be72d874d847a306e7.yaml +21 -0
  38. data/bugs/issue-af41a5229613172764e7d3c98431172db337053d.yaml +20 -0
  39. data/bugs/issue-bd9856b3788dd429c998a5af1b2aae8221cb80b7.yaml +28 -0
  40. data/bugs/issue-be22aef5c564fb7b5e9938343136a9cd6a2edb7b.yaml +22 -0
  41. data/bugs/issue-bf8697523c77c326e7e35fc82cf3dd739ae92310.yaml +27 -0
  42. data/bugs/issue-cdd4b4795f34d6ff46e56ece10f8216a4a5456b2.yaml +25 -0
  43. data/bugs/issue-d9bfb5581d745ef9deb3b9b2e08ef74d1cd43082.yaml +20 -0
  44. data/bugs/issue-e0ce2f687cc096f35715d28b0af88589f4ab6cc6.yaml +18 -0
  45. data/bugs/issue-e4b0aca4a10a574b333aeaecaaf221dbc5ed22c6.yaml +38 -0
  46. data/bugs/issue-f263746594b95ba778455730478ee8df60ee639d.yaml +22 -0
  47. data/bugs/project.yaml +72 -0
  48. data/builddeps.sh +102 -0
  49. data/fonts/Coolvetica.ttf +0 -0
  50. data/fonts/Lacuna.ttf +0 -0
  51. data/gemlib/shoes.rb +1 -0
  52. data/lib/shoes.rb +548 -0
  53. data/lib/shoes/cache.rb +54 -0
  54. data/lib/shoes/chipmunk.rb +35 -0
  55. data/lib/shoes/data.rb +39 -0
  56. data/lib/shoes/help.rb +468 -0
  57. data/lib/shoes/image.rb +25 -0
  58. data/lib/shoes/inspect.rb +128 -0
  59. data/lib/shoes/log.rb +48 -0
  60. data/lib/shoes/minitar.rb +986 -0
  61. data/lib/shoes/override.rb +38 -0
  62. data/lib/shoes/pack.rb +543 -0
  63. data/lib/shoes/search.rb +46 -0
  64. data/lib/shoes/setup.rb +329 -0
  65. data/lib/shoes/shy.rb +131 -0
  66. data/lib/shoes/shybuilder.rb +44 -0
  67. data/lib/shoes/version.rb +3 -0
  68. data/make/darwin/deps.vlc +12 -0
  69. data/make/darwin/dylibs.shoes +22 -0
  70. data/make/darwin/dylibs.video +11 -0
  71. data/make/darwin/env.rb +81 -0
  72. data/make/darwin/tasks.rb +105 -0
  73. data/make/linux/env.rb +65 -0
  74. data/make/linux/tasks.rb +61 -0
  75. data/make/make.rb +85 -0
  76. data/make/mingw/dlls +19 -0
  77. data/make/mingw/env.rb +69 -0
  78. data/make/mingw/tasks.rb +70 -0
  79. data/make/rakefile_common.rb +8 -0
  80. data/manual-snapshots/class-book.png +0 -0
  81. data/manual-snapshots/expert-definr.png +0 -0
  82. data/manual-snapshots/expert-funnies.png +0 -0
  83. data/manual-snapshots/expert-irb.png +0 -0
  84. data/manual-snapshots/expert-minesweeper.png +0 -0
  85. data/manual-snapshots/expert-othello.png +0 -0
  86. data/manual-snapshots/expert-pong.png +0 -0
  87. data/manual-snapshots/expert-tankspank.png +0 -0
  88. data/manual-snapshots/good-arc.png +0 -0
  89. data/manual-snapshots/good-clock.png +0 -0
  90. data/manual-snapshots/good-follow.png +0 -0
  91. data/manual-snapshots/good-reminder.png +0 -0
  92. data/manual-snapshots/good-vjot.png +0 -0
  93. data/manual-snapshots/simple-accordion.png +0 -0
  94. data/manual-snapshots/simple-anim-shapes.png +0 -0
  95. data/manual-snapshots/simple-anim-text.png +0 -0
  96. data/manual-snapshots/simple-arc.png +0 -0
  97. data/manual-snapshots/simple-bounce.png +0 -0
  98. data/manual-snapshots/simple-calc.png +0 -0
  99. data/manual-snapshots/simple-chipmunk.png +0 -0
  100. data/manual-snapshots/simple-control-sizes.png +0 -0
  101. data/manual-snapshots/simple-curve.png +0 -0
  102. data/manual-snapshots/simple-dialogs.png +0 -0
  103. data/manual-snapshots/simple-downloader.png +0 -0
  104. data/manual-snapshots/simple-draw.png +0 -0
  105. data/manual-snapshots/simple-editor.png +0 -0
  106. data/manual-snapshots/simple-form.png +0 -0
  107. data/manual-snapshots/simple-mask.png +0 -0
  108. data/manual-snapshots/simple-menu.png +0 -0
  109. data/manual-snapshots/simple-menu1.png +0 -0
  110. data/manual-snapshots/simple-rubygems.png +0 -0
  111. data/manual-snapshots/simple-slide.png +0 -0
  112. data/manual-snapshots/simple-sphere.png +0 -0
  113. data/manual-snapshots/simple-sqlite3.png +0 -0
  114. data/manual-snapshots/simple-timer.png +0 -0
  115. data/manual-snapshots/simple-video.png +0 -0
  116. data/platform/mac/Info.plist +55 -0
  117. data/platform/mac/build-deps.sh +658 -0
  118. data/platform/mac/command-manual.rb +1 -0
  119. data/platform/mac/deps-osx.patch +159 -0
  120. data/platform/mac/dmg_ds_store +0 -0
  121. data/platform/mac/pangorc +2 -0
  122. data/platform/mac/pkg-dmg +1447 -0
  123. data/platform/mac/shoes +31 -0
  124. data/platform/mac/shoes-launch +7 -0
  125. data/platform/mac/stub.m +178 -0
  126. data/platform/mac/version.plist +14 -0
  127. data/platform/msw/base.nsi +644 -0
  128. data/platform/msw/installer-1.bmp +0 -0
  129. data/platform/msw/installer-2.bmp +0 -0
  130. data/platform/msw/shoes.exe.manifest +17 -0
  131. data/platform/msw/shoes.ico +0 -0
  132. data/platform/msw/stub-inject.c +59 -0
  133. data/platform/msw/stub.c +271 -0
  134. data/platform/msw/stub32.h +14 -0
  135. data/platform/msw/stub32.rc +16 -0
  136. data/platform/nix/INSTALL +56 -0
  137. data/platform/nix/Makefile +144 -0
  138. data/platform/nix/shoes.launch +20 -0
  139. data/platform/skel.rb +27 -0
  140. data/rakefile_darwin.rb +7 -0
  141. data/rakefile_linux.rb +3 -0
  142. data/rakefile_mingw.rb +7 -0
  143. data/samples/class-book.rb +43 -0
  144. data/samples/class-book.yaml +387 -0
  145. data/samples/expert-definr.rb +23 -0
  146. data/samples/expert-funnies.rb +51 -0
  147. data/samples/expert-irb.rb +112 -0
  148. data/samples/expert-minesweeper.rb +267 -0
  149. data/samples/expert-othello.rb +319 -0
  150. data/samples/expert-pong.rb +62 -0
  151. data/samples/expert-tankspank.rb +385 -0
  152. data/samples/good-arc.rb +37 -0
  153. data/samples/good-clock.rb +51 -0
  154. data/samples/good-follow.rb +26 -0
  155. data/samples/good-reminder.rb +174 -0
  156. data/samples/good-vjot.rb +56 -0
  157. data/samples/simple-accordion.rb +75 -0
  158. data/samples/simple-anim-shapes.rb +17 -0
  159. data/samples/simple-anim-text.rb +13 -0
  160. data/samples/simple-arc.rb +23 -0
  161. data/samples/simple-bounce.rb +24 -0
  162. data/samples/simple-calc.rb +70 -0
  163. data/samples/simple-chipmunk.rb +26 -0
  164. data/samples/simple-control-sizes.rb +24 -0
  165. data/samples/simple-curve.rb +26 -0
  166. data/samples/simple-dialogs.rb +29 -0
  167. data/samples/simple-downloader.rb +27 -0
  168. data/samples/simple-draw.rb +13 -0
  169. data/samples/simple-editor.rb +28 -0
  170. data/samples/simple-form.rb +28 -0
  171. data/samples/simple-form.shy +0 -0
  172. data/samples/simple-mask.rb +21 -0
  173. data/samples/simple-menu.rb +31 -0
  174. data/samples/simple-menu1.rb +35 -0
  175. data/samples/simple-rubygems.rb +29 -0
  176. data/samples/simple-slide.rb +45 -0
  177. data/samples/simple-sphere.rb +28 -0
  178. data/samples/simple-sqlite3.rb +13 -0
  179. data/samples/simple-timer.rb +13 -0
  180. data/samples/simple-video.rb +13 -0
  181. data/shoes.gemspec +21 -0
  182. data/shoes/app.c +591 -0
  183. data/shoes/app.h +110 -0
  184. data/shoes/appwin32.h +13 -0
  185. data/shoes/appwin32.rc +28 -0
  186. data/shoes/canvas.c +2202 -0
  187. data/shoes/canvas.h +682 -0
  188. data/shoes/code.h +14 -0
  189. data/shoes/config.h +232 -0
  190. data/shoes/effects.c +243 -0
  191. data/shoes/effects.h +7 -0
  192. data/shoes/http.h +44 -0
  193. data/shoes/http/common.h +86 -0
  194. data/shoes/http/curl.c +259 -0
  195. data/shoes/http/nsurl.m +274 -0
  196. data/shoes/http/windownload.c +114 -0
  197. data/shoes/http/winhttp.c +216 -0
  198. data/shoes/http/winhttp.h +19 -0
  199. data/shoes/image.c +1020 -0
  200. data/shoes/internal.c +46 -0
  201. data/shoes/internal.h +63 -0
  202. data/shoes/native.h +110 -0
  203. data/shoes/native/cocoa.h +105 -0
  204. data/shoes/native/cocoa.m +1557 -0
  205. data/shoes/native/gtk.c +1257 -0
  206. data/shoes/native/windows.c +2392 -0
  207. data/shoes/ruby.c +5221 -0
  208. data/shoes/ruby.h +299 -0
  209. data/shoes/world.c +243 -0
  210. data/shoes/world.h +63 -0
  211. data/static/Shoes.icns +0 -0
  212. data/static/avatar.png +0 -0
  213. data/static/code_highlighter.js +188 -0
  214. data/static/code_highlighter_ruby.js +26 -0
  215. data/static/icon-debug.png +0 -0
  216. data/static/icon-error.png +0 -0
  217. data/static/icon-info.png +0 -0
  218. data/static/icon-warn.png +0 -0
  219. data/static/listbox_button1.png +0 -0
  220. data/static/listbox_button2.png +0 -0
  221. data/static/man-app.png +0 -0
  222. data/static/man-builds.png +0 -0
  223. data/static/man-builds1.png +0 -0
  224. data/static/man-editor-notepad.png +0 -0
  225. data/static/man-editor-osx.png +0 -0
  226. data/static/man-ele-background.png +0 -0
  227. data/static/man-ele-border.png +0 -0
  228. data/static/man-ele-button.png +0 -0
  229. data/static/man-ele-check.png +0 -0
  230. data/static/man-ele-editbox.png +0 -0
  231. data/static/man-ele-editline.png +0 -0
  232. data/static/man-ele-image.png +0 -0
  233. data/static/man-ele-listbox.png +0 -0
  234. data/static/man-ele-progress.png +0 -0
  235. data/static/man-ele-radio.png +0 -0
  236. data/static/man-ele-shape.png +0 -0
  237. data/static/man-ele-textblock.png +0 -0
  238. data/static/man-ele-video.png +0 -0
  239. data/static/man-intro-dmg.png +0 -0
  240. data/static/man-intro-exe.png +0 -0
  241. data/static/man-look-tiger.png +0 -0
  242. data/static/man-look-ubuntu.png +0 -0
  243. data/static/man-look-vista.png +0 -0
  244. data/static/man-run-osx.png +0 -0
  245. data/static/man-run-vista.png +0 -0
  246. data/static/man-run-xp.png +0 -0
  247. data/static/man-shot1.png +0 -0
  248. data/static/manual-en.txt +3531 -0
  249. data/static/manual-ja.txt +2825 -0
  250. data/static/manual.css +167 -0
  251. data/static/menu-corner1.png +0 -0
  252. data/static/menu-corner2.png +0 -0
  253. data/static/menu-gray.png +0 -0
  254. data/static/menu-left.png +0 -0
  255. data/static/menu-right.png +0 -0
  256. data/static/menu-top.png +0 -0
  257. data/static/shoes-dmg.jpg +0 -0
  258. data/static/shoes-icon-blue.png +0 -0
  259. data/static/shoes-icon.png +0 -0
  260. data/static/shoes-manual-apps.gif +0 -0
  261. data/static/shoes_main_window.png +0 -0
  262. data/static/stripe.png +0 -0
  263. data/static/stubs/blank.exe +0 -0
  264. data/static/stubs/blank.hfz +0 -0
  265. data/static/stubs/blank.run +375 -0
  266. data/static/stubs/cocoa-install +0 -0
  267. data/static/stubs/sh-install +49 -0
  268. data/static/stubs/shoes-stub-inject.exe +0 -0
  269. data/static/stubs/shoes-stub.exe +0 -0
  270. data/static/tutor-back.png +0 -0
  271. data/test/shoes_test.rb +8 -0
  272. data/test/test_helper.rb +25 -0
  273. data/use-deps +12 -0
  274. data/use-tmp-dep +8 -0
  275. metadata +509 -0
@@ -0,0 +1,38 @@
1
+ module Override
2
+ def self.extended mod
3
+ def mod.list_box args = {}
4
+ l, t, w, h = args[:left], args[:top], args[:width], 20
5
+ w ||= 200
6
+ bcolor = rgb(123, 158, 189)
7
+ selected, fimg, bimg = [], nil, nil
8
+
9
+ f = flow :left => l, :top => t, :width => w, :height => h do
10
+ border bcolor
11
+ selected[0] = inscription
12
+ fimg = image "#{DIR}/static/listbox_button1.png", :left => w-17, :top => 2
13
+ bimg = image("#{DIR}/static/listbox_button2.png", :left => w-17, :top => 2).hide
14
+ fimg.hover{bimg.show}
15
+ bimg.leave{bimg.hide}
16
+ bimg.click{bimg.show}
17
+ end
18
+
19
+ rects, inscs = [], []
20
+ args[:items].length.times do |i|
21
+ x, y = l, t+(i+1)*h
22
+ r = rect(x, y, w-1, h, :stroke => bcolor, :fill => white).hide
23
+ s = inscription(args[:items][i], :left => x, :top => y).hide
24
+ r.hover{r.style :fill => blue}
25
+ r.leave{r.style :fill => white}
26
+ r.click{selected[0].text = s.text; selected[1] = r}
27
+ rects << r
28
+ inscs << s
29
+ end
30
+
31
+ f.click do
32
+ rects.each{|r| r.toggle; r.style(:fill => blue) if r == selected[1]}
33
+ inscs.each{|i| i.toggle}
34
+ end
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,543 @@
1
+ #
2
+ # lib/shoes/pack.rb
3
+ # Packing apps into Windows, OS X and Linux binaries
4
+ #
5
+ require 'shoes/shy'
6
+ require 'binject'
7
+ require 'open-uri'
8
+
9
+ class Shoes
10
+ module Pack
11
+ def self.rewrite a, before, hsh
12
+ File.open(before) do |b|
13
+ b.each do |line|
14
+ a << line.gsub(/\#\{(\w+)\}/) { hsh[$1] }
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.pkg(platform, opt)
20
+ $stderr.puts "#{platform} #{opt}"
21
+ extension = case platform
22
+ when "win32" then
23
+ "exe"
24
+ when "linux" then
25
+ "run"
26
+ when "osx" then
27
+ "dmg"
28
+ else
29
+ raise "Unknown platform"
30
+ end
31
+
32
+ case opt
33
+ when Shoes::I_YES then
34
+ url = "http://shoes.heroku.com/pkg/#{Shoes::RELEASE_NAME.downcase}/#{platform}/shoes"
35
+ local_file_path = File.join(LIB_DIR, Shoes::RELEASE_NAME.downcase, platform, "latest_shoes.#{extension}")
36
+ when Shoes::I_NOV then
37
+ url = "http://shoes.heroku.com/pkg/#{Shoes::RELEASE_NAME.downcase}/#{platform}/shoes-novideo"
38
+ local_file_path = File.join(LIB_DIR, Shoes::RELEASE_NAME.downcase, platform, "latest_shoes-novideo.#{extension}")
39
+ when I_NET then
40
+ url = false
41
+ else
42
+ raise "missing download option #{opt}"
43
+ end
44
+
45
+ FileUtils.makedirs File.join(LIB_DIR, Shoes::RELEASE_NAME.downcase, platform)
46
+
47
+ if url then
48
+ begin
49
+ url = open(url).read.strip
50
+ debug url
51
+ internet_ok = true
52
+ rescue Exception => e
53
+ error e
54
+ internet_ok = false
55
+ end
56
+
57
+ if File.exists? local_file_path
58
+ return open(local_file_path)
59
+ elsif internet_ok then
60
+ begin
61
+ debug "Downloading #{url}..."
62
+ downloaded = open(url)
63
+ debug "Download of #{url} finished"
64
+ rescue Exception => e
65
+ error "Could not download from the internet at #{url}\n" + e
66
+ internet_ok = false
67
+ end
68
+ if internet_ok then
69
+ begin
70
+ File.open(local_file_path, "wb") do |f|
71
+ f.write(downloaded.read)
72
+ end
73
+ return open(local_file_path)
74
+ rescue Exception => e
75
+ raise "The download failed from\n#{url}\nor could not write to local files" + e
76
+ end
77
+ end
78
+ else
79
+ noHopeMsg = "Failed to find an existing Shoes at:\n#{local_file_path}\nor download from\n#{url} to include with your script."
80
+ raise noHopeMsg
81
+ end
82
+ end
83
+ end
84
+
85
+ def self.exe(script, opt, &blk)
86
+ size = File.size(script)
87
+ f = File.open(script, 'rb')
88
+ exe = Binject::EXE.new(File.join(DIR, "static", "stubs", "blank.exe"))
89
+ size += script.length
90
+ exe.inject("SHOES_FILENAME", File.basename(script))
91
+ size += File.size(script)
92
+ exe.inject("SHOES_PAYLOAD", f)
93
+ f2 = pkg("win32", opt)
94
+ if f2
95
+ size += File.size(f2.path)
96
+ f3 = File.open(f2.path, 'rb')
97
+ exe.inject("SHOES_SETUP", f3)
98
+
99
+ count, last = 0, 0.0
100
+ exe.save(script.gsub(/\.\w+$/, '') + ".exe") do |len|
101
+ count += len
102
+ prg = count.to_f / size.to_f
103
+ blk[last = prg] if blk and prg - last > 0.02 and prg < 1.0
104
+ end
105
+
106
+ f.close
107
+ f2.close
108
+ f3.close
109
+ else
110
+ Dir.chdir DIR + '/static/stubs' do
111
+ `.\\shoes-stub-inject.exe #{script.gsub('/', "\\")}`
112
+ end
113
+ end
114
+ blk[1.0] if blk
115
+ end
116
+
117
+ def self.dmg(script, opt, &blk)
118
+ name = File.basename(script).gsub(/\.\w+$/, '')
119
+ app_name = name.capitalize.gsub(/[-_](\w)/) { $1.capitalize }
120
+ vol_name = name.capitalize.gsub(/[-_](\w)/) { " " + $1.capitalize }
121
+ app_app = "#{app_name}.app"
122
+ vers = [1, 0]
123
+
124
+ tmp_dir = File.join(LIB_DIR, "+dmg")
125
+ FileUtils.rm_rf(tmp_dir)
126
+ FileUtils.mkdir_p(tmp_dir)
127
+ FileUtils.cp(File.join(DIR, "static", "stubs", "blank.hfz"),
128
+ File.join(tmp_dir, "blank.hfz"))
129
+ app_dir = File.join(tmp_dir, app_app)
130
+ res_dir = File.join(tmp_dir, app_app, "Contents", "Resources")
131
+ mac_dir = File.join(tmp_dir, app_app, "Contents", "MacOS")
132
+ [res_dir, mac_dir].map { |x| FileUtils.mkdir_p(x) }
133
+ FileUtils.cp(File.join(DIR, "static", "Shoes.icns"), app_dir)
134
+ FileUtils.cp(File.join(DIR, "static", "Shoes.icns"), res_dir)
135
+ File.open(File.join(app_dir, "Contents", "PkgInfo"), 'w') do |f|
136
+ f << "APPL????"
137
+ end
138
+ File.open(File.join(app_dir, "Contents", "Info.plist"), 'w') do |f|
139
+ f << <<END
140
+ <?xml version="1.0" encoding="UTF-8"?>
141
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
142
+ <plist version="1.0">
143
+ <dict>
144
+ <key>CFBundleGetInfoString</key>
145
+ <string>#{app_name} #{vers.join(".")}</string>
146
+ <key>CFBundleExecutable</key>
147
+ <string>#{name}-launch</string>
148
+ <key>CFBundleIdentifier</key>
149
+ <string>org.hackety.#{name}</string>
150
+ <key>CFBundleName</key>
151
+ <string>#{app_name}</string>
152
+ <key>CFBundleIconFile</key>
153
+ <string>Shoes.icns</string>
154
+ <key>CFBundleShortVersionString</key>
155
+ <string>#{vers.join(".")}</string>
156
+ <key>CFBundleInfoDictionaryVersion</key>
157
+ <string>6.0</string>
158
+ <key>CFBundlePackageType</key>
159
+ <string>APPL</string>
160
+ <key>IFMajorVersion</key>
161
+ <integer>#{vers[0]}</integer>
162
+ <key>IFMinorVersion</key>
163
+ <integer>#{vers[1]}</integer>
164
+ </dict>
165
+ </plist>
166
+ END
167
+ end
168
+ File.open(File.join(app_dir, "Contents", "version.plist"), 'w') do |f|
169
+ f << <<END
170
+ <?xml version="1.0" encoding="UTF-8"?>
171
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
172
+ <plist version="1.0">
173
+ <dict>
174
+ <key>BuildVersion</key>
175
+ <string>1</string>
176
+ <key>CFBundleVersion</key>
177
+ <string>#{vers.join(".")}</string>
178
+ <key>ProjectName</key>
179
+ <string>#{app_name}</string>
180
+ <key>SourceVersion</key>
181
+ <string>#{Time.now.strftime("%Y%m%d")}</string>
182
+ </dict>
183
+ </plist>
184
+ END
185
+ end
186
+ File.open(File.join(mac_dir, "#{name}-launch"), 'w') do |f|
187
+ f << <<END
188
+ #!/bin/bash
189
+ SHOESPATH=/Applications/Shoes.app/Contents/MacOS
190
+ APPPATH="${0%/*}"
191
+ unset DYLD_LIBRARY_PATH
192
+ cd "$APPPATH"
193
+ echo "[Pango]" > /tmp/pangorc
194
+ echo "ModuleFiles=$SHOESPATH/pango.modules" >> /tmp/pangorc
195
+ if [ ! -d /Applications/Shoes.app ]
196
+ then ./cocoa-install
197
+ fi
198
+ open -a /Applications/Shoes.app "#{File.basename(script)}"
199
+ # DYLD_LIBRARY_PATH=$SHOESPATH PANGO_RC_FILE="$APPPATH/pangorc" $SHOESPATH/shoes-bin "#{File.basename(script)}"
200
+ END
201
+ end
202
+ FileUtils.cp(script, File.join(mac_dir, File.basename(script)))
203
+ FileUtils.cp(File.join(DIR, "static", "stubs", "cocoa-install"),
204
+ File.join(mac_dir, "cocoa-install"))
205
+
206
+ dmg = Binject::DMG.new(File.join(tmp_dir, "blank.hfz"), vol_name)
207
+ f2 = pkg("osx", opt)
208
+ if f2
209
+ dmg.grow(10)
210
+ dmg.inject_file("setup.dmg", f2.path)
211
+ end
212
+ dmg.inject_dir(app_app, app_dir)
213
+ dmg.chmod_file(0755, "#{app_app}/Contents/MacOS/#{name}-launch")
214
+ dmg.chmod_file(0755, "#{app_app}/Contents/MacOS/cocoa-install")
215
+ dmg.save(script.gsub(/\.\w+$/, '') + ".dmg") do |perc|
216
+ blk[perc * 0.01] if blk
217
+ end
218
+ FileUtils.rm_rf(tmp_dir)
219
+ blk[1.0] if blk
220
+ end
221
+
222
+ def self.linux(script, opt, &blk)
223
+ name = File.basename(script).gsub(/\.\w+$/, '')
224
+ app_name = name.capitalize.gsub(/[-_](\w)/) { $1.capitalize }
225
+ run_path = script.gsub(/\.\w+$/, '') + ".run"
226
+ tgz_path = script.gsub(/\.\w+$/, '') + ".tgz"
227
+ tmp_dir = File.join(LIB_DIR, "+run")
228
+ FileUtils.mkdir_p(tmp_dir)
229
+ pkgf = pkg("linux", opt)
230
+ prog = 1.0
231
+ if pkgf
232
+ size = Shy.hrun(pkgf)
233
+ pblk = Shy.progress(size) do |name, perc, left|
234
+ blk[perc * 0.5]
235
+ end if blk
236
+ Shy.xzf(pkgf, tmp_dir, &pblk)
237
+ prog -= 0.5
238
+ end
239
+
240
+ FileUtils.cp(script, File.join(tmp_dir, File.basename(script)))
241
+ File.open(File.join(tmp_dir, "sh-install"), 'wb') do |a|
242
+ rewrite a, File.join(DIR, "static", "stubs", "sh-install"),
243
+ 'SCRIPT' => "./#{File.basename(script)}"
244
+ end
245
+ FileUtils.chmod 0755, File.join(tmp_dir, "sh-install")
246
+
247
+ raw = Shy.du(tmp_dir)
248
+ File.open(tgz_path, 'wb') do |f|
249
+ pblk = Shy.progress(raw) do |name, perc, left|
250
+ blk[prog + (perc * prog)]
251
+ end if blk
252
+ Shy.czf(f, tmp_dir, &pblk)
253
+ end
254
+
255
+ md5, fsize = Shy.md5sum(tgz_path), File.size(tgz_path)
256
+ File.open(run_path, 'wb') do |f|
257
+ rewrite f, File.join(DIR, "static", "stubs", "blank.run"),
258
+ 'CRC' => '0000000000', 'MD5' => md5, 'LABEL' => app_name, 'NAME' => name,
259
+ 'SIZE' => fsize, 'RAWSIZE' => (raw / 1024) + 1, 'TIME' => Time.now, 'FULLSIZE' => raw
260
+ File.open(tgz_path, 'rb') do |f2|
261
+ f.write f2.read(8192) until f2.eof
262
+ end
263
+ end
264
+ FileUtils.chmod 0755, run_path
265
+ FileUtils.rm_rf(tgz_path)
266
+ FileUtils.rm_rf(tmp_dir)
267
+ blk[1.0] if blk
268
+ end
269
+ end
270
+
271
+ Shoes::I_NET = "No, download Shoes if it's absent."
272
+ Shoes::I_YES = "Yes, I want Shoes included."
273
+ Shoes::I_NOV = "Yes, include Shoes, but without video support."
274
+ PackMake = proc do
275
+ background "#DDD"
276
+
277
+ @page1 = stack do
278
+ stack do
279
+ background white
280
+ background "#FFF".."#EEE", :height => 50, :bottom => 50
281
+ border "#CCC", :height => 2, :bottom => 0
282
+ stack :margin => 20 do
283
+ selt = proc { @sel1.toggle; @sel2.toggle }
284
+ @path = ""
285
+ @shy_path = nil
286
+ @sel1 =
287
+ flow do
288
+ para "File to package:"
289
+ inscription " (or a ", link("directory", &selt), ")"
290
+ edit1 = edit_line :width => -120
291
+ @bb = button "Browse...", :width => 100 do
292
+ @path = edit1.text = ask_open_file
293
+ #est_recount
294
+ end
295
+ end
296
+ @sel2 =
297
+ flow :hidden => true do
298
+ para "Directory:"
299
+ inscription " (or a ", link("single file", &selt), ")"
300
+ edit2 = edit_line :width => -120
301
+ @bf = button "Folder...", :width => 100 do
302
+ @path = edit2.text = ask_open_folder
303
+ #est_recount
304
+ end
305
+ end
306
+
307
+ para "Packaging options"
308
+ para "Should Shoes be included with your script or should the script ",
309
+ "download Shoes when the user runs it? Not all options are available on all ",
310
+ "systems. The defaults work."
311
+ flow :margin_left => 20 do
312
+ @shy = check
313
+ para "Shoes (.shy) for users who have Shoes already", :margin_right => 20
314
+ end
315
+ items = [Shoes::I_NET, Shoes::I_YES, Shoes::I_NOV]
316
+ items.shift unless ::RUBY_PLATFORM =~ /mswin|mingw/
317
+ flow :margin_left => 20 do
318
+ flow :width => 0.25 do
319
+ @exe = check
320
+ para "Windows"
321
+ end
322
+ @incWin = list_box :items => items, :width => 0.6, :height => 30, do
323
+ @downOpt = @incWin.text
324
+ est_recount
325
+ end
326
+ @incWin.choose items[0]
327
+ end
328
+ flow :margin_left => 20 do
329
+ flow :width => 0.25 do
330
+ @dmg = check
331
+ para "OS X", :margin_right => 47
332
+ end
333
+ osxop = [Shoes::I_NET, Shoes::I_NOV]
334
+ @incOSX = list_box :items => osxop, :width => 0.6, :height => 30 do
335
+ @downOpt = @incOSX.text
336
+ est_recount
337
+ end
338
+ @incOSX.choose(Shoes::I_NOV)
339
+ end
340
+ flow :margin_left => 20 do
341
+ flow :width => 0.25 do
342
+ @run = check
343
+ para "Linux", :margin_right => 49
344
+ end
345
+ @incLinux = list_box :items => [Shoes::I_NET], :width => 0.6,
346
+ :height => 30 do
347
+ est_recount
348
+ end
349
+ @incLinux.choose(Shoes::I_NET)
350
+ end
351
+ end
352
+ end
353
+
354
+ stack :margin => 20 do
355
+ @est = para "Estimated size of your choice: ", strong("0k"), :margin => 0, :margin_bottom => 4
356
+ def est_recount
357
+ base =
358
+ case @downOpt
359
+ when Shoes::I_NET; 98
360
+ when Shoes::I_YES; 11600
361
+ when Shoes::I_NOV; 7000
362
+ end
363
+ base += ((File.directory?(@path) ? Shy.du(@path) : File.size(@path)) rescue 0) / 1024
364
+ @est.replace "Estimated size of each app: ", strong(base > 1024 ?
365
+ "%0.1fM" % [base / 1024.0] : "#{base}K")
366
+ end
367
+ def build_thread
368
+ @shy_path = nil
369
+ if File.directory? @path
370
+ @shy_path = @path.gsub(%r![\\/]+$!, '') + ".shy"
371
+ elsif @shy.style[:checked]
372
+ @shy_path = @path.gsub(/\.\w+$/, '') + ".shy"
373
+ end
374
+ if @shy_path and not @shy_meta
375
+ @page_shy.show
376
+ @shy_para.text = File.basename(@shy_path)
377
+ @shy_launch.items = Shy.launchable(@path)
378
+ return
379
+ end
380
+ @page2.show
381
+ @path2.replace File.basename(@path)
382
+ #inc_text = @inc.text
383
+ inc_win_text, inc_osx_text, inc_linux_text = @incWin.text, @incOSX.text, @incLinux.text
384
+ Thread.start do
385
+ begin
386
+ sofar, stage = 0.0, 1.0 / [@shy.style[:checked], @exe.style[:checked], @dmg.style[:checked], @run.style[:checked]].
387
+ select { |x| x }.size
388
+ blk = proc do |frac|
389
+ @prog.style(:width => sofar + (frac * stage))
390
+ end
391
+
392
+ if @shy_path
393
+ @status.replace "Compressing the script's folder."
394
+ pblk = Shy.progress(Shy.du(@path)) do |name, perc, left|
395
+ blk[perc]
396
+ end
397
+ Shy.c(@shy_path, @shy_meta, @path, &pblk)
398
+ @path = @shy_path
399
+ @prog.style(:width => sofar += stage)
400
+ end
401
+ if @exe.style[:checked]
402
+ @status.replace "Working on an .exe for Windows."
403
+ Shoes::Pack.exe(@path, inc_win_text, &blk)
404
+ @prog.style(:width => sofar += stage)
405
+ end
406
+ if @dmg.style[:checked]
407
+ @status.replace "Working on a .dmg for Mac OS X."
408
+ Shoes::Pack.dmg(@path, inc_osx_text, &blk)
409
+ @prog.style(:width => sofar += stage)
410
+ end
411
+ if @run.style[:checked]
412
+ @status.replace "Working on a .run for Linux."
413
+ Shoes::Pack.linux(@path, inc_linux_text, &blk)
414
+ @prog.style(:width => sofar += stage)
415
+ end
416
+ if @shy_path and not @shy.style[:checked]
417
+ FileUtils.rm_rf(@shy_path)
418
+ end
419
+
420
+ every do
421
+ if @prog.style[:width] == 1.0
422
+ @page2.hide
423
+ @page3.show
424
+ @path3.replace File.basename(@path)
425
+ end
426
+ end
427
+ rescue => e
428
+ @packErrMsg = e
429
+ # weirdness begins
430
+ @page2.hide
431
+ @path3.style :font => 'italic', :size => 12
432
+ @page3.show
433
+ @path3.replace @packErrMsg
434
+ end
435
+ end
436
+ end
437
+
438
+ inscription "Using the latest Shoes build (0.r#{Shoes::REVISION})", :margin => 0
439
+ flow :margin_top => 10, :margin_left => 310 do
440
+ button "OK", :margin_right => 4 do
441
+ @page1.hide; @bb.hide; @bf.hide
442
+ @packErrMsg = nil
443
+ build_thread
444
+ end
445
+ button "Cancel" do
446
+ close
447
+ end
448
+ end
449
+ end
450
+ end
451
+
452
+ @page_shy = stack :hidden => true do
453
+ stack do
454
+ background white
455
+ border "#DDD", :height => 2, :bottom => 0
456
+ stack :margin => 20 do
457
+ para "Details for:", :margin => 4
458
+ @shy_para = para "", :size => 20, :margin => 4
459
+ flow do
460
+ stack :margin => 10, :width => 0.4 do
461
+ para "Name of app:"
462
+ @shy_name = edit_line :width => 1.0
463
+ end
464
+ stack :margin => 10, :width => 0.4 do
465
+ para "Version:"
466
+ @shy_version = edit_line :width => 120
467
+ end
468
+ stack :margin => 10, :width => 0.4 do
469
+ para "Creator"
470
+ @shy_creator = edit_line :width => 1.0
471
+ end
472
+ stack :margin => 10, :width => 0.5 do
473
+ para "Launch"
474
+ @shy_launch = list_box :height => 30
475
+ end
476
+ end
477
+ end
478
+ end
479
+
480
+ stack :margin => 20 do
481
+ flow :margin_top => 10, :margin_left => 310 do
482
+ button "OK", :margin_right => 4 do
483
+ @shy_meta = Shy.new
484
+ @shy_meta.name = @shy_name.text
485
+ @shy_meta.creator = @shy_creator.text
486
+ @shy_meta.version = @shy_version.text
487
+ @shy_meta.launch = @shy_launch.text
488
+ @page_shy.hide
489
+ build_thread
490
+ end
491
+ button "Cancel" do
492
+ close
493
+ end
494
+ end
495
+ end
496
+ end
497
+
498
+ @page2 = stack :hidden => true do
499
+ stack do
500
+ background white
501
+ border "#DDD", :height => 2, :bottom => 0
502
+ stack :margin => 20 do
503
+ para "Packaging:", :margin => 4
504
+ @path2 = para "", :size => 20, :margin => 4
505
+ @status = para "", :margin => 4
506
+ end
507
+ end
508
+
509
+ stack :margin => 20 do
510
+ stack :width => -20, :height => 24 do
511
+ @prog = background "#{DIR}/static/stripe.png", :curve => 7
512
+ background "rgb(0, 0, 0, 100)".."rgb(120, 120, 120, 0)", :curve => 6, :height => 16
513
+ background "rgb(120, 120, 120, 0)".."rgb(0, 0, 0, 100)", :curve => 6,
514
+ :height => 16, :top => 8
515
+ border "rgb(60, 60, 60, 80)", :curve => 7, :strokewidth => 2
516
+ end
517
+ end
518
+ end
519
+
520
+ @page3 = stack :hidden => true do
521
+ stack do
522
+ background white
523
+ border "#DDD", :height => 2, :bottom => 0
524
+ stack :margin => 20 do
525
+ para "Completed:", :margin => 4
526
+ @path3 = para "", :size => 20, :margin => 4
527
+ para "Your files are done, you may close this window.", :margin => 4
528
+ button "Quit" do
529
+ exit
530
+ end
531
+ end
532
+ end
533
+ end
534
+
535
+ start do
536
+ @exe.checked = false
537
+ @dmg.checked = false
538
+ @run.checked = false
539
+ @shy.checked = true
540
+ #@inc.choose( ::RUBY_PLATFORM =~ /mswin|mingw/ ? Shoes::I_NET : Shoes::I_NOV )
541
+ end
542
+ end
543
+ end