etti 0.3.1 → 0.5.0
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 +4 -4
- data/bin/etti +2 -0
- data/lib/data/locale/de/LC_MESSAGES/etti.mo +0 -0
- data/lib/etti/elements/data.rb +14 -0
- data/lib/etti/elements/text.rb +11 -0
- data/lib/etti/page-datas.rb +25 -13
- data/lib/etti/ui/data-page.rb +22 -0
- data/lib/etti/ui/label-elements.rb +1 -0
- data/lib/etti/ui/label-layout-page.rb +87 -49
- data/lib/etti/ui/label-layout.rb +5 -0
- data/lib/etti/ui/label-selection-page.rb +18 -20
- data/lib/etti/ui/page-layout.rb +74 -6
- data/lib/etti/ui/window.rb +194 -13
- data/lib/etti/version.rb +1 -1
- data/lib/etti.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01d2ab51124b22c47e91b53f203896608f6864ba
|
4
|
+
data.tar.gz: 751753191c55665d7765dd7e16b84a701ce172d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf955706b9dac4c9ddd464c4732a848853b807bd56ed6016e835748c392827ca61b51f3cfc4e979d51aa378cbbd1e57fbb290f38bfc7984ccda574f0e11cace
|
7
|
+
data.tar.gz: 6ad7f544fd18741f19094ff9410bba699002f475697ebbcf7945abb321035dc90ec905ffed8f8bd19c3db60e663a48db1cf8cf308cf34e44c5da372f7a7ccc52
|
data/bin/etti
CHANGED
Binary file
|
data/lib/etti/elements/data.rb
CHANGED
@@ -42,6 +42,20 @@ module Etti
|
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
|
+
def to_h
|
46
|
+
hs = {}
|
47
|
+
if @showAs == SHOW_AS_TEXT
|
48
|
+
hs['showAs'] = 'text'
|
49
|
+
else
|
50
|
+
hs['showAs'] = 'qr'
|
51
|
+
['qrWidth', 'qrHeight', 'qrVersion', 'qrErrorCorrection', 'qrEncoding'].each do |name|
|
52
|
+
hs[name] = get_by_name name
|
53
|
+
end
|
54
|
+
end
|
55
|
+
hs.merge super()
|
56
|
+
end
|
57
|
+
|
58
|
+
|
45
59
|
def draw_selection view
|
46
60
|
if @showAs == SHOW_AS_TEXT
|
47
61
|
super
|
data/lib/etti/elements/text.rb
CHANGED
@@ -9,6 +9,7 @@ module Etti
|
|
9
9
|
@size = size || 4.0
|
10
10
|
end
|
11
11
|
|
12
|
+
# x, y, rotation, color have to be moved to the Etti::Element::Base class
|
12
13
|
def set_by_name name, val
|
13
14
|
if name == 'text' then @text = val; return; end
|
14
15
|
if name == 'pos_x' then @x = val.to_f; return; end
|
@@ -29,6 +30,16 @@ module Etti
|
|
29
30
|
end
|
30
31
|
|
31
32
|
|
33
|
+
def to_h
|
34
|
+
hs = {}
|
35
|
+
['text', 'pos_x', 'pos_y', 'size', 'rotation', 'color'].each do |name|
|
36
|
+
hs[name] = get_by_name name
|
37
|
+
end
|
38
|
+
hs
|
39
|
+
# hs.merge super
|
40
|
+
end
|
41
|
+
|
42
|
+
|
32
43
|
def redraw
|
33
44
|
|
34
45
|
end
|
data/lib/etti/page-datas.rb
CHANGED
@@ -15,6 +15,8 @@ module Etti
|
|
15
15
|
def initialize
|
16
16
|
super()
|
17
17
|
|
18
|
+
@pageDimensions = {'a4' => [297.0, 210.0]}
|
19
|
+
|
18
20
|
@pageDatas = {}
|
19
21
|
@dataFiles = [DATA_PATH + 'page-data.json',
|
20
22
|
File.expand_path('~') + '/.local/share/etti/page-data.json']
|
@@ -58,13 +60,18 @@ module Etti
|
|
58
60
|
end
|
59
61
|
|
60
62
|
|
61
|
-
def
|
63
|
+
def get_page_dimensions size
|
64
|
+
@pageDimensions[size]
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def save_page_data page, savePage, &callback
|
62
69
|
FileUtils.mkdir_p File.dirname(@dataFiles.last)
|
63
|
-
if @pageDatas.key? page[:name]
|
70
|
+
if savePage and @pageDatas.key? page[:name]
|
64
71
|
message = _("The page description\n\"%s\"\nalready exist.\n\nSould it be replaced?") % page[:name]
|
65
72
|
|
66
73
|
ret = callback.call :warning, :yes_no, message
|
67
|
-
return unless ret == 'yes'
|
74
|
+
return nil unless ret == 'yes'
|
68
75
|
end
|
69
76
|
# header
|
70
77
|
json = {'Etti' => 'page data file',
|
@@ -76,30 +83,35 @@ module Etti
|
|
76
83
|
json['Data'][key] = val if val[:source] == 1
|
77
84
|
end
|
78
85
|
|
79
|
-
|
86
|
+
pageHash = nil
|
80
87
|
newPage = !@pageDatas.key?(page[:name])
|
81
88
|
|
82
89
|
# fill the current or new page with the page data from the UI
|
83
90
|
if newPage
|
84
|
-
|
91
|
+
pageHash = {}
|
85
92
|
else
|
86
|
-
|
93
|
+
pageHash = @pageDatas[page[:name]]
|
87
94
|
end
|
88
95
|
FIELDS.each do |key|
|
89
|
-
|
96
|
+
pageHash[key.to_s] = page[key]
|
90
97
|
end
|
91
98
|
|
92
|
-
json['Data'][page[:name]] =
|
99
|
+
json['Data'][page[:name]] = pageHash
|
93
100
|
|
94
|
-
if newPage
|
95
|
-
|
96
|
-
@pageDatas[page[:name]] =
|
97
|
-
signal_emit :new_page, [page[:name],
|
101
|
+
if savePage and newPage
|
102
|
+
pageHash['source'] = 1
|
103
|
+
@pageDatas[page[:name]] = pageHash
|
104
|
+
signal_emit :new_page, [page[:name], pageHash]
|
98
105
|
end
|
99
106
|
|
107
|
+
return pageHash unless savePage
|
100
108
|
fd = File.new @dataFiles.last, File::CREAT|File::TRUNC|File::RDWR, 0644
|
101
|
-
|
109
|
+
fileData = $etti_developement_version ? JSON.pretty_generate(json) : JSON.fast_generate(json)
|
110
|
+
fd.write fileData
|
102
111
|
fd.flush
|
112
|
+
|
113
|
+
# we need pageHash also in saving the complete document
|
114
|
+
pageHash
|
103
115
|
end
|
104
116
|
|
105
117
|
private
|
data/lib/etti/ui/data-page.rb
CHANGED
@@ -34,6 +34,28 @@ module Etti
|
|
34
34
|
end
|
35
35
|
|
36
36
|
|
37
|
+
def get_user_settings
|
38
|
+
settings = {}
|
39
|
+
section = @radioRevealer.active
|
40
|
+
if section == 0
|
41
|
+
settings['section'] = 'enumeration'
|
42
|
+
settings['prefix'] = @dataEntries[0].text
|
43
|
+
settings['string'] = @dataEntries[1].text
|
44
|
+
settings['postfix'] = @dataEntries[2].text
|
45
|
+
elsif section == 1
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
settings
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def set_user_settings
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
37
59
|
def update_data_preview idx
|
38
60
|
# data from enumeration
|
39
61
|
if idx == 0
|
@@ -65,6 +65,7 @@ module Etti
|
|
65
65
|
cc.font_size = 16.0
|
66
66
|
cc.show_text text
|
67
67
|
cc.stroke
|
68
|
+
# remove this, if we switch to a newer ruby-gtk version dependency, and keep the from_surface call
|
68
69
|
pixbuf = nil
|
69
70
|
if ([2, 2, 2] <=> Gtk::BINDING_VERSION) < 1
|
70
71
|
pixbuf = Gdk::Pixbuf.from_surface surface, 0, 0, ext.width, ext.height * 1.5
|
@@ -6,24 +6,23 @@ module Etti
|
|
6
6
|
GetText.bindtextdomain 'etti', :path => Etti::LOCALE_PATH
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
super :vertical
|
10
|
-
@printPageSetup = nil
|
9
|
+
super :vertical #:orientation => :vertical
|
11
10
|
|
12
|
-
create_toolbar
|
13
|
-
self.pack_start @toolbar, :expand => false, :fill => false, :padding => 6
|
14
|
-
|
15
11
|
hbox = Gtk::Box.new :horizontal
|
16
12
|
self.pack_start hbox, :expand => true, :fill => true
|
17
|
-
|
13
|
+
|
18
14
|
create_property_view
|
19
|
-
hbox.pack_start @propertyView, :expand => false, :fill => false
|
20
|
-
|
15
|
+
hbox.pack_start @propertyView, :expand => false, :fill => false, :padding => 6
|
16
|
+
|
21
17
|
paned = Gtk::Paned.new :horizontal
|
22
18
|
hbox.pack_start paned, :expand => true, :fill => true
|
23
19
|
|
24
20
|
@layoutPreview = Etti::LabelLayout.new @propertyViews
|
25
21
|
paned.pack1 @layoutPreview, :resize => true, :shrink => true
|
26
|
-
|
22
|
+
# @layoutPreview.signal_connect(:element_count_changed) do |widget, count|
|
23
|
+
# @saveButton.sensitive = (count > 0 and @saveButtonActivated)
|
24
|
+
# @saveAsButton.sensitive = count > 0
|
25
|
+
# end
|
27
26
|
|
28
27
|
ebox = Gtk::Box.new :horizontal
|
29
28
|
|
@@ -36,8 +35,30 @@ module Etti
|
|
36
35
|
@labelElements = Etti::LabelElements.new
|
37
36
|
ebox.pack_start @labelElements, :expand => true, :fill => true
|
38
37
|
end
|
38
|
+
attr_reader :layoutPreview
|
39
|
+
|
40
|
+
def get_user_settings
|
41
|
+
settings = {}
|
42
|
+
settings['scale'] = @layoutPreview.scale
|
43
|
+
settings['centerX'] = @layoutPreview.centerX
|
44
|
+
settings['centerY'] = @layoutPreview.centerY
|
45
|
+
elementData = []
|
46
|
+
@layoutPreview.elements.each {|element| elementData << element.to_h}
|
47
|
+
settings['elements'] = elementData
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_user_settings
|
51
|
+
|
52
|
+
end
|
39
53
|
|
40
54
|
|
55
|
+
=begin
|
56
|
+
def activate_save state
|
57
|
+
@saveButtonActivate = state
|
58
|
+
@saveButton.sensitive = (state and @layoutPreview.elements.length() > 0)
|
59
|
+
end
|
60
|
+
=end
|
61
|
+
|
41
62
|
def update_page_data pageData
|
42
63
|
@pageData = pageData
|
43
64
|
@layoutPreview.update_page_data pageData
|
@@ -83,46 +104,62 @@ module Etti
|
|
83
104
|
end
|
84
105
|
end
|
85
106
|
|
86
|
-
|
87
|
-
def create_toolbar
|
88
|
-
@toolbar = Gtk::Box.new :horizontal
|
89
107
|
=begin
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
108
|
+
def create_toolbar
|
109
|
+
toolbar = Gtk::Box.new :horizontal
|
110
|
+
toolbarData = [{:stock => Gtk::Stock::OPEN,
|
111
|
+
:method => proc{on_open},
|
112
|
+
:tooltip => _('open a new document')},
|
113
|
+
{:stock => Gtk::Stock::SAVE,
|
114
|
+
:method => proc{on_save true},
|
115
|
+
:tooltip => _('save the document')},
|
116
|
+
{:stock => Gtk::Stock::SAVE_AS,
|
117
|
+
:method => proc{on_save false},
|
118
|
+
:tooltip => _('save the document under a new name')},
|
119
|
+
{:stock => Gtk::Stock::PRINT,
|
120
|
+
:method => proc{on_print},
|
121
|
+
:tooltip => _('print the labels')},
|
122
|
+
:separator,
|
123
|
+
{:stock => Gtk::Stock::ZOOM_IN,
|
124
|
+
:method => proc{@layoutPreview.zoom_in},
|
125
|
+
:tooltip => _('zoom in')},
|
126
|
+
{:stock => Gtk::Stock::ZOOM_OUT,
|
127
|
+
:method => proc{@layoutPreview.zoom_out},
|
128
|
+
:tooltip => _('zoom out')},
|
129
|
+
{:stock => Gtk::Stock::ZOOM_FIT,
|
130
|
+
:method => proc{@layoutPreview.zoom_fit},
|
131
|
+
:tooltip => _('zoom that all is displayed')}]
|
132
|
+
toolbarData.each_with_index do |buttonData, idx|
|
133
|
+
if buttonData.is_a? Hash
|
134
|
+
button = Gtk::Button.new
|
135
|
+
if idx == 1
|
136
|
+
@saveButton = button
|
137
|
+
button.sensitive = false
|
138
|
+
elsif idx == 2
|
139
|
+
@saveAsButton = button
|
140
|
+
button.sensitive = false
|
141
|
+
end
|
142
|
+
button.tooltip_text = buttonData[:tooltip]
|
143
|
+
button.signal_connect(:clicked) {buttonData[:method].call}
|
144
|
+
img = Gtk::Image.new :stock => buttonData[:stock], :size => :large_toolbar
|
145
|
+
button << img
|
146
|
+
toolbar.pack_start button, :expand => false, :fill => false, :padding => 0
|
147
|
+
elsif buttonData.is_a? Symbol
|
148
|
+
sep = Gtk::Separator.new :vertical
|
149
|
+
toolbar.pack_start sep, :expand => false, :fill => false, :padding => 8
|
150
|
+
end
|
151
|
+
end
|
152
|
+
toolbar
|
153
|
+
end
|
99
154
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
img = Gtk::Image.new :stock => Gtk::Stock::ZOOM_OUT, :size => :small_toolbar
|
109
|
-
button << img
|
110
|
-
@toolbar.pack_start button, :expand => false, :fill => false, :padding => 0
|
111
|
-
|
112
|
-
button = Gtk::Button.new
|
113
|
-
button.signal_connect(:clicked) {@layoutPreview.zoom_fit}
|
114
|
-
img = Gtk::Image.new :stock => Gtk::Stock::ZOOM_FIT, :size => :small_toolbar
|
115
|
-
button << img
|
116
|
-
@toolbar.pack_start button, :expand => false, :fill => false, :padding => 0
|
117
|
-
|
118
|
-
sep = Gtk::Separator.new :vertical
|
119
|
-
@toolbar.pack_start sep, :expand => false, :fill => false, :padding => 8
|
120
|
-
|
121
|
-
button = Gtk::Button.new
|
122
|
-
button.signal_connect(:clicked) {on_print}
|
123
|
-
img = Gtk::Image.new :stock => Gtk::Stock::PRINT, :size => :small_toolbar
|
124
|
-
button << img
|
125
|
-
@toolbar.pack_start button, :expand => false, :fill => false, :padding => 0
|
155
|
+
|
156
|
+
def on_open
|
157
|
+
p 'open file'
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def on_save same
|
162
|
+
signal_emit :save_document, same
|
126
163
|
end
|
127
164
|
|
128
165
|
|
@@ -148,7 +185,7 @@ module Etti
|
|
148
185
|
|
149
186
|
ret = printOperation.run :print_dialog, self.toplevel
|
150
187
|
|
151
|
-
|
188
|
+
#=begin
|
152
189
|
# only for debugging purpose
|
153
190
|
printOperation.signal_connect('end-print') {print "-=== printing ended\n"}
|
154
191
|
|
@@ -187,7 +224,8 @@ module Etti
|
|
187
224
|
else
|
188
225
|
print "unknown result: ",printr.inspect,"\n"
|
189
226
|
end
|
190
|
-
|
227
|
+
#=end
|
191
228
|
end
|
229
|
+
=end
|
192
230
|
end
|
193
231
|
end
|
data/lib/etti/ui/label-layout.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Etti
|
4
4
|
class LabelLayout < Gtk::EventBox
|
5
|
+
self.type_register
|
6
|
+
self.signal_new :element_count_changed, GLib::Signal::RUN_FIRST, nil, GLib::Type['void'], Integer
|
7
|
+
def signal_do_element_count_changed bla; end
|
8
|
+
|
5
9
|
include GetText
|
6
10
|
GetText.bindtextdomain 'etti', :path => Etti::LOCALE_PATH
|
7
11
|
|
@@ -68,6 +72,7 @@ module Etti
|
|
68
72
|
@elements << Etti::Element::Text.new(data, cx, cy)
|
69
73
|
end
|
70
74
|
queue_draw
|
75
|
+
signal_emit :element_count_changed, @elements.length
|
71
76
|
end
|
72
77
|
|
73
78
|
|
@@ -27,7 +27,7 @@ module Etti
|
|
27
27
|
self.position = 300
|
28
28
|
end
|
29
29
|
|
30
|
-
attr_reader :labelList, :pageData
|
30
|
+
attr_reader :labelList, :pageData, :pageDatas
|
31
31
|
|
32
32
|
def create_label_list
|
33
33
|
@labelListStore = Gtk::ListStore.new String
|
@@ -51,26 +51,24 @@ module Etti
|
|
51
51
|
|
52
52
|
|
53
53
|
def on_label_list_cursor_changed
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
54
|
+
name = @labelListStore.get_iter(@labelList.cursor[0]).get_value 0
|
55
|
+
if @previewArea.entryChanged and @pageData[:name] != name
|
56
|
+
message = _("The page was changed. Should it be saved?")
|
57
|
+
dialog = Etti::MessageDialog.new self.toplevel, :buttons => [:yes, :no, :cancel],
|
58
|
+
:type => :info, :message => message, :title => _('Page was changed')
|
59
|
+
ret = dialog.run
|
60
|
+
case ret
|
61
|
+
when 'cancel'
|
62
|
+
idx = @pageDatas.get_page_names.index @pageData[:name]
|
63
|
+
@labelList.selection.select_path Gtk::TreePath.new(idx.to_s)
|
64
|
+
return
|
65
|
+
when 'yes'
|
66
|
+
@previewArea.save
|
68
67
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@previewArea.update_page_data @pageData
|
68
|
+
end
|
69
|
+
@pageData = @pageDatas.get_page_data name
|
70
|
+
signal_emit :page_changed, @pageData
|
71
|
+
@previewArea.update_page_data @pageData
|
74
72
|
end
|
75
73
|
|
76
74
|
|
data/lib/etti/ui/page-layout.rb
CHANGED
@@ -65,6 +65,19 @@ module Etti
|
|
65
65
|
:tooltip => _('The size of the sheet, i.e. "a4"')}
|
66
66
|
}
|
67
67
|
|
68
|
+
@sheetData = {:cols =>
|
69
|
+
{:pos => 0,
|
70
|
+
:label => _('columns'),
|
71
|
+
:tooltip => _('The number of labels horizontal'),
|
72
|
+
:range => 1..100},
|
73
|
+
:rows =>
|
74
|
+
{:pos => 1,
|
75
|
+
:label => _('rows'),
|
76
|
+
:tooltip => _('The number of labels vertical'),
|
77
|
+
:range => 1..100}
|
78
|
+
}
|
79
|
+
|
80
|
+
|
68
81
|
|
69
82
|
@sizeGroup = Gtk::SizeGroup.new :both
|
70
83
|
widget = make_entry :name, _('Name'), _("The name of the label\nIt has to be unique")
|
@@ -91,6 +104,11 @@ module Etti
|
|
91
104
|
box.pack_start Gtk::Label.new(val[:label]), :expand => false, :fill => false
|
92
105
|
|
93
106
|
entry = Rgw::RestrictedEntry.new
|
107
|
+
if key == :width or key == :height
|
108
|
+
entry.editable = false
|
109
|
+
entry.sensitive = false
|
110
|
+
end
|
111
|
+
|
94
112
|
entry.restriction = :float
|
95
113
|
entry.range = val[:range]
|
96
114
|
@entries[key] = entry
|
@@ -101,17 +119,23 @@ module Etti
|
|
101
119
|
entry.width_chars = 8
|
102
120
|
|
103
121
|
entry.tooltip_text = val[:tooltip]
|
104
|
-
entry.editable = true
|
105
122
|
|
106
123
|
entry.signal_connect(:changed) {|entry| on_entry_changed entry}
|
107
124
|
end
|
108
125
|
|
126
|
+
# the box below the sheet preview
|
127
|
+
bottomBox = Gtk::Box.new :horizontal
|
128
|
+
self.pack_start bottomBox, :expand => false, :fill => false
|
129
|
+
bottomLeft = Gtk::Box.new :vertical
|
130
|
+
bottomBox.pack_start bottomLeft, :expand => false, :fill => false
|
131
|
+
bottomRight = Gtk::Box.new :vertical
|
132
|
+
bottomBox.pack_start bottomRight, :expand => false, :fill => false, :padding => 64
|
109
133
|
|
110
134
|
# create the page size combo box
|
111
135
|
val = @descriptionData[:pageSize]
|
112
136
|
cbox = Gtk::Box.new :horizontal
|
113
|
-
|
114
|
-
label = Gtk::Label.new.set_markup(
|
137
|
+
bottomLeft.pack_start cbox, :expand => false, :fill => false
|
138
|
+
label = Gtk::Label.new.set_markup("<b>%s</b>: " % val[:label])
|
115
139
|
label.xalign = 0.0
|
116
140
|
cbox.pack_start label, :expand => false, :fill => false, :padding => 6
|
117
141
|
@sizeGroup.add_widget label
|
@@ -128,8 +152,32 @@ module Etti
|
|
128
152
|
[:manufacture, :orderNr, :description].each do |key|
|
129
153
|
val = @descriptionData[key]
|
130
154
|
widget = make_entry key, val[:label], val[:tooltip]
|
131
|
-
|
155
|
+
bottomLeft.pack_start widget, :expand => false, :fill => false, :padding => 4
|
132
156
|
end
|
157
|
+
|
158
|
+
# create the column and row count display
|
159
|
+
rcTable = Gtk::Table.new 3, 2, false
|
160
|
+
bottomRight.pack_start rcTable, :expand => false, :fill => false
|
161
|
+
@sheetData.each_pair do |key, val|
|
162
|
+
label = Gtk::Label.new.set_markup("<b>%s: </b>" % val[:label])
|
163
|
+
label.xalign = 0.0
|
164
|
+
rcTable.attach_defaults label, 0, 1, val[:pos], val[:pos] + 1
|
165
|
+
|
166
|
+
entry = Rgw::RestrictedEntry.new
|
167
|
+
entry.restriction = :integer
|
168
|
+
entry.range = val[:range]
|
169
|
+
@entries[key] = entry
|
170
|
+
entry.name = key
|
171
|
+
rcTable.attach_defaults entry, 1, 2, val[:pos], val[:pos] + 1
|
172
|
+
|
173
|
+
entry.set_max_length 3
|
174
|
+
entry.width_chars = 8
|
175
|
+
|
176
|
+
entry.tooltip_text = val[:tooltip]
|
177
|
+
|
178
|
+
entry.signal_connect(:changed) {|entry| on_entry_changed entry}
|
179
|
+
end
|
180
|
+
|
133
181
|
signal_connect(:map) {on_map}
|
134
182
|
signal_connect(:draw) do |widget|
|
135
183
|
draw_bg
|
@@ -159,6 +207,10 @@ module Etti
|
|
159
207
|
w, h = *@pageData[key]
|
160
208
|
@entries[:width].text = @lcNumeric.to_s w
|
161
209
|
@entries[:height].text = @lcNumeric.to_s h
|
210
|
+
when :cols
|
211
|
+
@entries[:cols].text = @lcNumeric.to_s @pageData[key]
|
212
|
+
when :rows
|
213
|
+
@entries[:rows].text = @lcNumeric.to_s @pageData[key]
|
162
214
|
when :pageSize
|
163
215
|
@pageSizeCombo.active = @pageSizes.index @pageData[:pageSize]
|
164
216
|
end
|
@@ -195,6 +247,7 @@ private
|
|
195
247
|
def on_entry_changed entry
|
196
248
|
return if @pageData.nil?
|
197
249
|
key = entry.name.to_sym
|
250
|
+
return if key == :width or key == :height
|
198
251
|
text = @entries[key].text
|
199
252
|
return if text.nil?
|
200
253
|
@entryChanged = true
|
@@ -216,10 +269,25 @@ private
|
|
216
269
|
@pageData[:size][0] = val
|
217
270
|
when :height
|
218
271
|
@pageData[:size][1] = val
|
272
|
+
when :cols
|
273
|
+
@pageData[:cols] = val
|
274
|
+
when :rows
|
275
|
+
@pageData[:rows] = val
|
219
276
|
end
|
277
|
+
recalculate_page_layout
|
220
278
|
end
|
221
279
|
|
222
280
|
|
281
|
+
def recalculate_page_layout
|
282
|
+
pw, ph = *@pageDatas.get_page_dimensions(@pageData[:pageSize])
|
283
|
+
labelsWidth = (pw - @pageData[:borders][0] * 2 + @pageData[:padding][0] * 2) / @pageData[:cols]
|
284
|
+
labelsHeight = (pw - @pageData[:borders][1] * 2 + @pageData[:padding][1] * 2) / @pageData[:rows]
|
285
|
+
@entries[:width].text = @lcNumeric.to_s labelsWidth
|
286
|
+
@entries[:height].text = @lcNumeric.to_s labelsHeight
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
|
223
291
|
def on_save
|
224
292
|
@entries.each do |entry|
|
225
293
|
if entry[1].text.nil?
|
@@ -228,10 +296,10 @@ private
|
|
228
296
|
:type => :info, :message => message,
|
229
297
|
:title => _('Invalid Entries')
|
230
298
|
dialog.run
|
231
|
-
return
|
299
|
+
return nil
|
232
300
|
end
|
233
301
|
end
|
234
|
-
@pageDatas.save_page_data(@pageData) do |type, answers, message|
|
302
|
+
return @pageDatas.save_page_data(@pageData, true) do |type, answers, message|
|
235
303
|
if answers == :yes_no
|
236
304
|
dialog = Etti::MessageDialog.new self.toplevel, :buttons => [:yes, :no],
|
237
305
|
:type => :info, :message => message
|
data/lib/etti/ui/window.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#encoding: UTF-8
|
2
2
|
|
3
3
|
module Etti
|
4
|
+
DOCUMENT_SUFFIX = 'ettidoc'
|
4
5
|
class Window < Gtk::Window
|
5
6
|
include GetText
|
6
7
|
GetText.bindtextdomain 'etti', :path => Etti::LOCALE_PATH
|
@@ -9,14 +10,20 @@ module Etti
|
|
9
10
|
super()
|
10
11
|
signal_connect(:delete_event) {on_quit false}
|
11
12
|
signal_connect(:destroy) {on_quit true}
|
12
|
-
signal_connect_after(:draw) {paint_logo}
|
13
13
|
self.border_width = 3
|
14
14
|
self.title = 'Etti'
|
15
15
|
set_default_size 1200, 900
|
16
16
|
self.icon = Etti::PIXMAP_PATH + 'win-logo.png'
|
17
|
-
|
18
17
|
@logoPixbuf = Gdk::Pixbuf.new Etti::PIXMAP_PATH + 'logo.png'
|
19
18
|
|
19
|
+
# the current document, if is read from a file or already saved
|
20
|
+
@document = nil
|
21
|
+
@documentFileFilter = Gtk::FileFilter.new
|
22
|
+
@documentFileFilter.add_pattern '*\.' + DOCUMENT_SUFFIX
|
23
|
+
|
24
|
+
@printPageSetup = nil
|
25
|
+
@saveButtonActivated = false
|
26
|
+
|
20
27
|
@accelGroup = Gtk::AccelGroup.new
|
21
28
|
add_accel_group @accelGroup
|
22
29
|
|
@@ -28,15 +35,24 @@ module Etti
|
|
28
35
|
@labelSelectionPage.signal_connect(:page_changed) do |widget, pageData|
|
29
36
|
@labelLayoutPage.update_page_data pageData
|
30
37
|
end
|
38
|
+
|
39
|
+
@labelLayoutPage.layoutPreview.signal_connect(:element_count_changed) do |widget, count|
|
40
|
+
@saveButton.sensitive = (count > 0 and @saveButtonActivated)
|
41
|
+
@saveAsButton.sensitive = count > 0
|
42
|
+
end
|
43
|
+
|
31
44
|
@labelLayoutPage.update_page_data @labelSelectionPage.pageData
|
32
45
|
|
46
|
+
pile = Rgw::Pile.new
|
47
|
+
self.add pile
|
33
48
|
@notebook = Gtk::Notebook.new
|
34
|
-
|
49
|
+
pile.set_child @notebook
|
50
|
+
pile.set_pile_child create_toolbar, -24, 6
|
51
|
+
|
35
52
|
notebook_append_page @dataPage, _("<b> Data \n Input </b>")
|
36
53
|
notebook_append_page @labelSelectionPage, _("<b> Label \n Selection </b>")
|
37
54
|
notebook_append_page @labelLayoutPage, _("<b> Label \n Formatting </b>")
|
38
55
|
notebook_append_page @aboutPage, _("<b> About Etti </b>")
|
39
|
-
|
40
56
|
end
|
41
57
|
attr_reader :dataPage, :labelLayoutPage, :labelSelectionPage
|
42
58
|
|
@@ -99,19 +115,184 @@ module Etti
|
|
99
115
|
end
|
100
116
|
|
101
117
|
|
102
|
-
def
|
103
|
-
|
104
|
-
Gtk.
|
118
|
+
def create_toolbar
|
119
|
+
vbox = Gtk::Box.new :vertical
|
120
|
+
toolbar = Gtk::Box.new :horizontal
|
121
|
+
|
122
|
+
logo = Gtk::Image.new :pixbuf => @logoPixbuf # Etti::PIXMAP_PATH + 'logo.png'
|
123
|
+
toolbar.pack_end logo, :expand => false, :fill => false, :padding => 32
|
124
|
+
|
125
|
+
|
126
|
+
vbox.pack_start toolbar, :expand => false, :fill => false, :padding => 6
|
127
|
+
toolbarData = [{:stock => Gtk::Stock::OPEN,
|
128
|
+
:method => proc{on_open},
|
129
|
+
:tooltip => _('open a new document')},
|
130
|
+
{:stock => Gtk::Stock::SAVE,
|
131
|
+
:method => proc{on_save true},
|
132
|
+
:tooltip => _('save the document')},
|
133
|
+
{:stock => Gtk::Stock::SAVE_AS,
|
134
|
+
:method => proc{on_save false},
|
135
|
+
:tooltip => _('save the document under a new name')},
|
136
|
+
{:stock => Gtk::Stock::PRINT,
|
137
|
+
:method => proc{on_print},
|
138
|
+
:tooltip => _('print the labels')},
|
139
|
+
:separator,
|
140
|
+
{:stock => Gtk::Stock::ZOOM_IN,
|
141
|
+
:method => proc{@labelLayoutPage.layoutPreview.zoom_in},
|
142
|
+
:tooltip => _('zoom in')},
|
143
|
+
{:stock => Gtk::Stock::ZOOM_OUT,
|
144
|
+
:method => proc{@labelLayoutPage.layoutPreview.zoom_out},
|
145
|
+
:tooltip => _('zoom out')},
|
146
|
+
{:stock => Gtk::Stock::ZOOM_FIT,
|
147
|
+
:method => proc{@labelLayoutPage.layoutPreview.zoom_fit},
|
148
|
+
:tooltip => _('zoom that all is displayed')}]
|
149
|
+
toolbarData.each_with_index do |buttonData, idx|
|
150
|
+
if buttonData.is_a? Hash
|
151
|
+
button = Gtk::Button.new
|
152
|
+
if idx == 1
|
153
|
+
@saveButton = button
|
154
|
+
button.sensitive = false
|
155
|
+
elsif idx == 2
|
156
|
+
@saveAsButton = button
|
157
|
+
button.sensitive = false
|
158
|
+
end
|
159
|
+
button.tooltip_text = buttonData[:tooltip]
|
160
|
+
button.signal_connect(:clicked) {buttonData[:method].call}
|
161
|
+
img = Gtk::Image.new :stock => buttonData[:stock], :size => :large_toolbar
|
162
|
+
button << img
|
163
|
+
toolbar.pack_start button, :expand => false, :fill => false, :padding => 0
|
164
|
+
elsif buttonData.is_a? Symbol
|
165
|
+
sep = Gtk::Separator.new :vertical
|
166
|
+
toolbar.pack_start sep, :expand => false, :fill => false, :padding => 8
|
167
|
+
end
|
168
|
+
end
|
169
|
+
vbox
|
105
170
|
end
|
106
171
|
|
107
172
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
173
|
+
def on_open
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
def on_save same
|
179
|
+
path = @document
|
180
|
+
unless same
|
181
|
+
fileChooser = Gtk::FileChooserDialog.new :title => _('Select File'),
|
182
|
+
:parent => self.toplevel,
|
183
|
+
:action => :save,
|
184
|
+
:buttons => [[:cancel, :cancel],
|
185
|
+
[:ok, :ok]]
|
186
|
+
|
187
|
+
fileChooser.filter = @documentFileFilter
|
188
|
+
ret = fileChooser.run
|
189
|
+
path = fileChooser.filename.clone
|
190
|
+
fileChooser.destroy
|
191
|
+
|
192
|
+
return if ret == Gtk::ResponseType::CANCEL
|
193
|
+
return if path.nil?
|
194
|
+
|
195
|
+
path += '.' + DOCUMENT_SUFFIX unless path.end_with? '.' + DOCUMENT_SUFFIX
|
196
|
+
|
197
|
+
if File.exist? path
|
198
|
+
message = _("Shall the document\n\"%s\"\nbe replaced?") % File.basename(path)
|
199
|
+
dialog = Etti::MessageDialog.new self.toplevel, :buttons => [:yes, :cancel],
|
200
|
+
:type => :info, :message => message
|
201
|
+
ret = dialog.run
|
202
|
+
return unless ret == 'yes'
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
@document = path
|
207
|
+
activate_save true
|
208
|
+
|
209
|
+
json = {'Etti' => 'document file', 'Version' => [1, 0]}
|
210
|
+
json['UserData'] = @dataPage.get_user_settings
|
211
|
+
json['PageData'] = @labelSelectionPage.pageDatas.save_page_data(@labelSelectionPage.pageData, false){}
|
212
|
+
json['LabelLayout'] = @labelLayoutPage.get_user_settings
|
114
213
|
|
214
|
+
fd = File.new path, File::CREAT|File::TRUNC|File::RDWR, 0644
|
215
|
+
fd.write JSON.pretty_generate(json)
|
216
|
+
fd.flush
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
def activate_save state
|
221
|
+
@saveButtonActivate = state
|
222
|
+
@saveButton.sensitive = (state and @labelLayoutPage.layoutPreview.elements.length() > 0)
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
def on_print
|
227
|
+
# set the borders from the selected label sheet
|
228
|
+
pd = @labelSelectionPage.pageData
|
229
|
+
lp = @labelLayoutPage.layoutPreview
|
230
|
+
pageSetup = Gtk::PageSetup.new
|
231
|
+
pageSetup.set_left_margin pd[:borders][0], :mm
|
232
|
+
pageSetup.set_top_margin pd[:borders][1], :mm
|
233
|
+
pageSetup.set_right_margin pd[:borders][0], :mm
|
234
|
+
pageSetup.set_bottom_margin pd[:borders][1], :mm
|
235
|
+
|
236
|
+
|
237
|
+
printOperation = Gtk::PrintOperation.new
|
238
|
+
printOperation.show_progress = true
|
239
|
+
printOperation.default_page_setup = pageSetup
|
240
|
+
printOperation.n_pages = (lp.elementDataData.length().to_f /
|
241
|
+
(pd[:cols] * pd[:rows]).to_f).ceil
|
242
|
+
|
243
|
+
printOperation.signal_connect('draw-page') do |widget, printContext, pageNumber|
|
244
|
+
cc = printContext.cairo_context
|
245
|
+
lp.print_labels cc, pageNumber
|
246
|
+
end
|
247
|
+
|
248
|
+
ret = printOperation.run :print_dialog, self.toplevel
|
249
|
+
|
250
|
+
=begin
|
251
|
+
# only for debugging purpose
|
252
|
+
printOperation.signal_connect('end-print') {print "-=== printing ended\n"}
|
253
|
+
|
254
|
+
printOperation.signal_connect('status-changed') do
|
255
|
+
case printOperation.status
|
256
|
+
when Gtk::PrintOperation::Status::INITIAL
|
257
|
+
p 'initial'
|
258
|
+
when Gtk::PrintOperation::Status::PREPARING
|
259
|
+
p 'preparing'
|
260
|
+
when Gtk::PrintOperation::Status::GENERATING_DATA
|
261
|
+
p 'GENERATING_DATA'
|
262
|
+
when Gtk::PrintOperation::Status::SENDING_DATA
|
263
|
+
p 'SENDING_DATA'
|
264
|
+
when Gtk::PrintOperation::Status::PENDING
|
265
|
+
p 'PENDING'
|
266
|
+
when Gtk::PrintOperation::Status::PRINTING
|
267
|
+
p 'PRINTING'
|
268
|
+
when Gtk::PrintOperation::Status::FINISHED
|
269
|
+
p 'FINISHED'
|
270
|
+
when Gtk::PrintOperation::Status::FINISHED_ABORTED
|
271
|
+
p 'FINISHED_ABORTED'
|
272
|
+
else
|
273
|
+
'p unknown'
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
case ret
|
278
|
+
when Gtk::PrintOperation::Result::ERROR
|
279
|
+
print "error\n"
|
280
|
+
when Gtk::PrintOperation::Result::CANCEL
|
281
|
+
print "cancelled\n"
|
282
|
+
when Gtk::PrintOperation::Result::APPLY
|
283
|
+
print "applied\n"
|
284
|
+
when Gtk::PrintOperation::Result::IN_PROGRESS
|
285
|
+
print "in progress\n"
|
286
|
+
else
|
287
|
+
print "unknown result: ",printr.inspect,"\n"
|
288
|
+
end
|
289
|
+
=end
|
290
|
+
end
|
291
|
+
|
292
|
+
|
293
|
+
def on_quit destroy
|
294
|
+
# @project.save_project
|
295
|
+
Gtk.main_quit
|
115
296
|
end
|
116
297
|
end
|
117
298
|
end
|
data/lib/etti/version.rb
CHANGED
data/lib/etti.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Detlef Reichl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n-toolbox
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gettext
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- COPYING
|
128
128
|
- README.md
|
129
129
|
- bin/etti
|
130
|
+
- lib/data/locale/de/LC_MESSAGES/etti.mo
|
130
131
|
- lib/data/page-data.json
|
131
132
|
- lib/data/pixmaps/logo.png
|
132
133
|
- lib/data/pixmaps/logo.svg
|