create_doc 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 737411ab1670a9bc54995be1eaec6f7f24ebf712
4
+ data.tar.gz: 87d49fa974cc381910ebb3a2519b8bef3327d87d
5
+ SHA512:
6
+ metadata.gz: 469f534c6c4284c90b3462084bfff4a0390ac0445a2ed87f3dfe25bbaef7e773eb4ea2a6b43f4586177294c0158b53f8166dbb7b13df2f361b4b35bd0a89fc9d
7
+ data.tar.gz: c68d5020ac580b3cf01637e534b816a084feb9511bb1f31ce216bd134078c0e91ef7f55ebe4092fbd68ba5097780de6b39ea4ef3f3843bc8735b551df99ce0b3
data/bin/MainApp.rb ADDED
@@ -0,0 +1,53 @@
1
+
2
+ class MainApp #(change name)
3
+
4
+ include GladeGUI
5
+
6
+ # make $ENV global object available everywhere
7
+ def before_show()
8
+ $ENV = VR::load_yaml(SavableSettings, "settings.yaml")
9
+ @builder[:window1].resize $ENV.width, $ENV.height
10
+ refresh()
11
+ end
12
+
13
+ def refresh()
14
+ @builder[:filename].text = $ENV.filename
15
+ @builder[:title].text = $ENV.title
16
+ @builder[:smalltitle].text = $ENV.smalltitle
17
+ @builder[:foot].text = $ENV.foot
18
+ end
19
+
20
+ def buttonEdit__clicked(*a)
21
+ $ENV.show_glade(self)
22
+ refresh()
23
+ end
24
+
25
+ # delete_event signal occurs before the window actually closes
26
+ # It gives us time to save the height and width of the widow before
27
+ #closing it. Returns: true = don't close window, false = close window.
28
+ def window1__delete_event(*)
29
+ $ENV.width, $ENV.height = @builder[:window1].size()
30
+ VR::save_yaml($ENV)
31
+ return false #ok to close
32
+ end
33
+
34
+ def buttonCancel__clicked(*a)
35
+ window1__delete_event
36
+ @builder[:window1].destroy
37
+ end
38
+
39
+ def CreateDocButton__clicked(*a)
40
+ $ENV = VR::load_yaml(SavableSettings, "settings.yaml")
41
+
42
+ Caracal::Document.save $ENV.filename+'.docx' do |docx|
43
+ # page 1
44
+ docx.p $ENV.title, color: 'FF0000', size: 56, bold: true, align: :center
45
+ docx.p $ENV.smalltitle, size: 30, align: :center
46
+ docx.hr
47
+ docx.p $ENV.filename, align: :center
48
+ docx.p $ENV.foot
49
+ end
50
+ end
51
+
52
+ end
53
+
@@ -0,0 +1,35 @@
1
+
2
+ class SavableSettings
3
+
4
+ include GladeGUI
5
+
6
+ attr_accessor :filename, :title, :smalltitle, :foot, :height, :width
7
+
8
+ def initialize()
9
+ defaults()
10
+ end
11
+
12
+ # defaults are set on new and loaded objects. You can add to this list
13
+ # and it will not cause errors. New variables will be added
14
+ # and loaded objects will function flawlessly. When you load a yaml
15
+ # file using VR::load_yaml, it will look for a method named "defaults"
16
+ # and execute it, so use the name "defaults, and it will automatically run.
17
+
18
+ def defaults()
19
+ @height ||= 200
20
+ @width ||= 350
21
+ @filename ||= "文件名"
22
+ @title ||= "文章标题"
23
+ @smalltitle ||= "文章小标题"
24
+ @foot ||= "页脚"
25
+ end
26
+
27
+ def buttonSave__clicked(*a)
28
+ get_glade_variables
29
+ VR::save_yaml(self)
30
+ @builder[:window1].destroy
31
+ end
32
+
33
+
34
+ end
35
+
@@ -0,0 +1,145 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generated with glade 3.18.3 -->
3
+ <interface>
4
+ <requires lib="gtk+" version="3.0"/>
5
+ <object class="GtkWindow" id="window1">
6
+ <property name="can_focus">False</property>
7
+ <property name="window_position">center</property>
8
+ <child>
9
+ <object class="GtkBox" id="box1">
10
+ <property name="visible">True</property>
11
+ <property name="can_focus">False</property>
12
+ <property name="margin_left">20</property>
13
+ <property name="margin_right">20</property>
14
+ <property name="margin_top">20</property>
15
+ <property name="margin_bottom">20</property>
16
+ <property name="orientation">vertical</property>
17
+ <child>
18
+ <object class="GtkLabel" id="label1">
19
+ <property name="visible">True</property>
20
+ <property name="can_focus">False</property>
21
+ <property name="label" translatable="yes">&lt;big&gt;文档内容&lt;/big&gt;</property>
22
+ <property name="use_markup">True</property>
23
+ </object>
24
+ <packing>
25
+ <property name="expand">False</property>
26
+ <property name="fill">True</property>
27
+ <property name="position">0</property>
28
+ </packing>
29
+ </child>
30
+ <child>
31
+ <object class="GtkLabel" id="filename">
32
+ <property name="visible">True</property>
33
+ <property name="can_focus">False</property>
34
+ <property name="vexpand">True</property>
35
+ <property name="ypad">1</property>
36
+ <property name="label" translatable="yes">label</property>
37
+ <property name="wrap">True</property>
38
+ </object>
39
+ <packing>
40
+ <property name="expand">False</property>
41
+ <property name="fill">False</property>
42
+ <property name="position">1</property>
43
+ </packing>
44
+ </child>
45
+ <child>
46
+ <object class="GtkLabel" id="title">
47
+ <property name="visible">True</property>
48
+ <property name="can_focus">False</property>
49
+ <property name="vexpand">True</property>
50
+ <property name="ypad">1</property>
51
+ <property name="label" translatable="yes">label</property>
52
+ <property name="wrap">True</property>
53
+ </object>
54
+ <packing>
55
+ <property name="expand">False</property>
56
+ <property name="fill">False</property>
57
+ <property name="position">2</property>
58
+ </packing>
59
+ </child>
60
+ <child>
61
+ <object class="GtkLabel" id="smalltitle">
62
+ <property name="visible">True</property>
63
+ <property name="can_focus">False</property>
64
+ <property name="vexpand">True</property>
65
+ <property name="ypad">1</property>
66
+ <property name="label" translatable="yes">label</property>
67
+ <property name="wrap">True</property>
68
+ </object>
69
+ <packing>
70
+ <property name="expand">False</property>
71
+ <property name="fill">False</property>
72
+ <property name="position">3</property>
73
+ </packing>
74
+ </child>
75
+ <child>
76
+ <object class="GtkLabel" id="foot">
77
+ <property name="visible">True</property>
78
+ <property name="can_focus">False</property>
79
+ <property name="vexpand">True</property>
80
+ <property name="ypad">1</property>
81
+ <property name="label" translatable="yes">label</property>
82
+ <property name="wrap">True</property>
83
+ </object>
84
+ <packing>
85
+ <property name="expand">False</property>
86
+ <property name="fill">False</property>
87
+ <property name="position">4</property>
88
+ </packing>
89
+ </child>
90
+ <child>
91
+ <object class="GtkButtonBox" id="buttonbox1">
92
+ <property name="visible">True</property>
93
+ <property name="can_focus">False</property>
94
+ <property name="spacing">10</property>
95
+ <property name="layout_style">end</property>
96
+ <child>
97
+ <object class="GtkButton" id="CreateDocButton">
98
+ <property name="label" translatable="yes">生成</property>
99
+ <property name="visible">True</property>
100
+ <property name="can_focus">True</property>
101
+ <property name="receives_default">True</property>
102
+ </object>
103
+ <packing>
104
+ <property name="expand">True</property>
105
+ <property name="fill">True</property>
106
+ <property name="position">0</property>
107
+ </packing>
108
+ </child>
109
+ <child>
110
+ <object class="GtkButton" id="buttonEdit">
111
+ <property name="label" translatable="yes">编辑</property>
112
+ <property name="visible">True</property>
113
+ <property name="can_focus">True</property>
114
+ <property name="receives_default">True</property>
115
+ </object>
116
+ <packing>
117
+ <property name="expand">True</property>
118
+ <property name="fill">True</property>
119
+ <property name="position">1</property>
120
+ </packing>
121
+ </child>
122
+ <child>
123
+ <object class="GtkButton" id="buttonCancel">
124
+ <property name="label" translatable="yes">退出</property>
125
+ <property name="visible">True</property>
126
+ <property name="can_focus">True</property>
127
+ <property name="receives_default">True</property>
128
+ </object>
129
+ <packing>
130
+ <property name="expand">True</property>
131
+ <property name="fill">True</property>
132
+ <property name="position">2</property>
133
+ </packing>
134
+ </child>
135
+ </object>
136
+ <packing>
137
+ <property name="expand">False</property>
138
+ <property name="fill">True</property>
139
+ <property name="position">5</property>
140
+ </packing>
141
+ </child>
142
+ </object>
143
+ </child>
144
+ </object>
145
+ </interface>
@@ -0,0 +1,266 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generated with glade 3.18.3 -->
3
+ <interface>
4
+ <requires lib="gtk+" version="3.0"/>
5
+ <object class="GtkWindow" id="window1">
6
+ <property name="visible">True</property>
7
+ <property name="can_focus">False</property>
8
+ <property name="title" translatable="yes">Edit Settings</property>
9
+ <property name="modal">True</property>
10
+ <property name="window_position">center</property>
11
+ <property name="default_width">400</property>
12
+ <property name="default_height">400</property>
13
+ <child>
14
+ <object class="GtkBox" id="box1">
15
+ <property name="visible">True</property>
16
+ <property name="can_focus">False</property>
17
+ <property name="margin_left">20</property>
18
+ <property name="margin_right">20</property>
19
+ <property name="margin_top">20</property>
20
+ <property name="margin_bottom">20</property>
21
+ <property name="orientation">vertical</property>
22
+ <property name="spacing">10</property>
23
+ <child>
24
+ <object class="GtkLabel" id="label1">
25
+ <property name="visible">True</property>
26
+ <property name="can_focus">False</property>
27
+ <property name="label" translatable="yes">&lt;big&gt;设置&lt;/big&gt;</property>
28
+ <property name="use_markup">True</property>
29
+ </object>
30
+ <packing>
31
+ <property name="expand">False</property>
32
+ <property name="fill">True</property>
33
+ <property name="position">0</property>
34
+ </packing>
35
+ </child>
36
+ <child>
37
+ <object class="GtkFrame" id="frame1">
38
+ <property name="visible">True</property>
39
+ <property name="can_focus">False</property>
40
+ <property name="label_xalign">0</property>
41
+ <property name="shadow_type">in</property>
42
+ <child>
43
+ <object class="GtkAlignment" id="alignment1">
44
+ <property name="visible">True</property>
45
+ <property name="can_focus">False</property>
46
+ <property name="left_padding">12</property>
47
+ <child>
48
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
49
+ <property name="visible">True</property>
50
+ <property name="can_focus">True</property>
51
+ <property name="margin_right">10</property>
52
+ <property name="margin_bottom">10</property>
53
+ <property name="hexpand">True</property>
54
+ <property name="vexpand">True</property>
55
+ <property name="shadow_type">in</property>
56
+ <child>
57
+ <object class="GtkTextView" id="filename">
58
+ <property name="visible">True</property>
59
+ <property name="can_focus">True</property>
60
+ <property name="margin_left">10</property>
61
+ <property name="margin_right">10</property>
62
+ <property name="margin_top">1</property>
63
+ <property name="margin_bottom">1</property>
64
+ <property name="wrap_mode">word</property>
65
+ </object>
66
+ </child>
67
+ </object>
68
+ </child>
69
+ </object>
70
+ </child>
71
+ <child type="label">
72
+ <object class="GtkLabel" id="label3">
73
+ <property name="visible">True</property>
74
+ <property name="can_focus">False</property>
75
+ <property name="label" translatable="yes">文件名</property>
76
+ <property name="lines">1</property>
77
+ </object>
78
+ </child>
79
+ </object>
80
+ <packing>
81
+ <property name="expand">True</property>
82
+ <property name="fill">True</property>
83
+ <property name="position">1</property>
84
+ </packing>
85
+ </child>
86
+ <child>
87
+ <object class="GtkFrame" id="frame2">
88
+ <property name="visible">True</property>
89
+ <property name="can_focus">False</property>
90
+ <property name="label_xalign">0</property>
91
+ <property name="shadow_type">in</property>
92
+ <child>
93
+ <object class="GtkAlignment" id="alignment2">
94
+ <property name="visible">True</property>
95
+ <property name="can_focus">False</property>
96
+ <property name="left_padding">12</property>
97
+ <child>
98
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
99
+ <property name="visible">True</property>
100
+ <property name="can_focus">True</property>
101
+ <property name="margin_bottom">10</property>
102
+ <property name="hexpand">True</property>
103
+ <property name="vexpand">True</property>
104
+ <property name="shadow_type">in</property>
105
+ <child>
106
+ <object class="GtkTextView" id="title">
107
+ <property name="visible">True</property>
108
+ <property name="can_focus">True</property>
109
+ <property name="margin_top">1</property>
110
+ <property name="margin_bottom">1</property>
111
+ <property name="wrap_mode">word</property>
112
+ </object>
113
+ </child>
114
+ </object>
115
+ </child>
116
+ </object>
117
+ </child>
118
+ <child type="label">
119
+ <object class="GtkLabel" id="label4">
120
+ <property name="visible">True</property>
121
+ <property name="can_focus">False</property>
122
+ <property name="label" translatable="yes">标题</property>
123
+ </object>
124
+ </child>
125
+ </object>
126
+ <packing>
127
+ <property name="expand">True</property>
128
+ <property name="fill">True</property>
129
+ <property name="position">2</property>
130
+ </packing>
131
+ </child>
132
+ <child>
133
+ <object class="GtkFrame" id="frame3">
134
+ <property name="visible">True</property>
135
+ <property name="can_focus">False</property>
136
+ <property name="label_xalign">0</property>
137
+ <property name="shadow_type">in</property>
138
+ <child>
139
+ <object class="GtkAlignment" id="alignment3">
140
+ <property name="visible">True</property>
141
+ <property name="can_focus">False</property>
142
+ <property name="left_padding">12</property>
143
+ <child>
144
+ <object class="GtkScrolledWindow" id="scrolledwindow3">
145
+ <property name="visible">True</property>
146
+ <property name="can_focus">True</property>
147
+ <property name="margin_bottom">10</property>
148
+ <property name="hexpand">True</property>
149
+ <property name="vexpand">True</property>
150
+ <property name="shadow_type">in</property>
151
+ <child>
152
+ <object class="GtkTextView" id="smalltitle">
153
+ <property name="visible">True</property>
154
+ <property name="can_focus">True</property>
155
+ <property name="margin_top">1</property>
156
+ <property name="margin_bottom">1</property>
157
+ <property name="wrap_mode">word</property>
158
+ </object>
159
+ </child>
160
+ </object>
161
+ </child>
162
+ </object>
163
+ </child>
164
+ <child type="label">
165
+ <object class="GtkLabel" id="label5">
166
+ <property name="visible">True</property>
167
+ <property name="can_focus">False</property>
168
+ <property name="label" translatable="yes">小标题</property>
169
+ </object>
170
+ </child>
171
+ </object>
172
+ <packing>
173
+ <property name="expand">True</property>
174
+ <property name="fill">True</property>
175
+ <property name="position">3</property>
176
+ </packing>
177
+ </child>
178
+ <child>
179
+ <object class="GtkFrame" id="frame4">
180
+ <property name="visible">True</property>
181
+ <property name="can_focus">False</property>
182
+ <property name="label_xalign">0</property>
183
+ <property name="shadow_type">in</property>
184
+ <child>
185
+ <object class="GtkAlignment" id="alignment4">
186
+ <property name="visible">True</property>
187
+ <property name="can_focus">False</property>
188
+ <property name="left_padding">12</property>
189
+ <child>
190
+ <object class="GtkScrolledWindow" id="scrolledwindow4">
191
+ <property name="visible">True</property>
192
+ <property name="can_focus">True</property>
193
+ <property name="margin_bottom">10</property>
194
+ <property name="hexpand">True</property>
195
+ <property name="vexpand">True</property>
196
+ <property name="shadow_type">in</property>
197
+ <child>
198
+ <object class="GtkTextView" id="foot">
199
+ <property name="visible">True</property>
200
+ <property name="can_focus">True</property>
201
+ <property name="margin_top">1</property>
202
+ <property name="margin_bottom">1</property>
203
+ <property name="wrap_mode">word</property>
204
+ </object>
205
+ </child>
206
+ </object>
207
+ </child>
208
+ </object>
209
+ </child>
210
+ <child type="label">
211
+ <object class="GtkLabel" id="label2">
212
+ <property name="visible">True</property>
213
+ <property name="can_focus">False</property>
214
+ <property name="label" translatable="yes">页脚</property>
215
+ </object>
216
+ </child>
217
+ </object>
218
+ <packing>
219
+ <property name="expand">True</property>
220
+ <property name="fill">True</property>
221
+ <property name="position">4</property>
222
+ </packing>
223
+ </child>
224
+ <child>
225
+ <object class="GtkButtonBox" id="buttonbox1">
226
+ <property name="visible">True</property>
227
+ <property name="can_focus">False</property>
228
+ <property name="spacing">10</property>
229
+ <property name="layout_style">end</property>
230
+ <child>
231
+ <object class="GtkButton" id="buttonCancel">
232
+ <property name="label" translatable="yes">退出</property>
233
+ <property name="visible">True</property>
234
+ <property name="can_focus">True</property>
235
+ <property name="receives_default">True</property>
236
+ </object>
237
+ <packing>
238
+ <property name="expand">True</property>
239
+ <property name="fill">True</property>
240
+ <property name="position">0</property>
241
+ </packing>
242
+ </child>
243
+ <child>
244
+ <object class="GtkButton" id="buttonSave">
245
+ <property name="label" translatable="yes">保存</property>
246
+ <property name="visible">True</property>
247
+ <property name="can_focus">True</property>
248
+ <property name="receives_default">True</property>
249
+ </object>
250
+ <packing>
251
+ <property name="expand">True</property>
252
+ <property name="fill">True</property>
253
+ <property name="position">1</property>
254
+ </packing>
255
+ </child>
256
+ </object>
257
+ <packing>
258
+ <property name="expand">False</property>
259
+ <property name="fill">True</property>
260
+ <property name="position">5</property>
261
+ </packing>
262
+ </child>
263
+ </object>
264
+ </child>
265
+ </object>
266
+ </interface>
data/main.rb ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # ignore -- this is for development, same as require 'vrlib'
4
+ require File.exists?("./../../lib/vrlib.rb") ? "./../../lib/vrlib.rb" : "vrlib"
5
+
6
+ begin
7
+ require 'caracal'
8
+ rescue LoadError
9
+ alert "You must install activerecord gem to use this example. " +
10
+ "Just enter at command prompt:\n\n<b>gem install caracal</b>"
11
+ exit
12
+ end
13
+
14
+ # from require_all gem:
15
+ require_rel 'bin/'
16
+
17
+ MainApp.new.show_glade()
18
+
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: create_doc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chen Liang
8
+ autorequire:
9
+ bindir:
10
+ - "."
11
+ cert_chain: []
12
+ date: 2018-07-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: visualruby
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 3.0.18
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 3.0.18
28
+ - !ruby/object:Gem::Dependency
29
+ name: require_all
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.2.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.2.0
42
+ description: Full description here
43
+ email: holdstock@yeah.net
44
+ executables:
45
+ - main.rb
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - "./main.rb"
50
+ - bin/MainApp.rb
51
+ - bin/SavableSettings.rb
52
+ - bin/glade/MainApp.glade
53
+ - bin/glade/SavableSettings.glade
54
+ - main.rb
55
+ homepage: http://www.yoursite.org/
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project: nowarning
74
+ rubygems_version: 2.6.14
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Short Description Here.
78
+ test_files: []