ADG Lua 

ADG Lua Commit Details

Date:2013-03-17 19:42:47 (6 years 8 months ago)
Author:Nicola Fontana
Branch:master
Commit:252caf51c835e77bc896d88af0fec3c49f061a72
Parents: e7fc702428a27ee6f6b752d694c2a30024fbc8c5
Message:Completed "Print" dialog

Changes:
Madg-demo.lua.in (2 diffs)

File differences

adg-demo.lua.in
133133
134134
135135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
136182
137183
138184
......
142188
143189
144190
191
145192
dialog:run()
end
-- Print dialog
do
local settings
ui.mainPrint.on_clicked = function ()
local operation = Gtk.PrintOperation.new()
operation:set_use_full_page(operation, false)
operation:set_unit(Gtk.Unit.POINTS)
if settings then
operation:set_print_settings(settings)
end
if Gtk.PrintOperation.set_embed_page_setup then
operation:set_embed_page_setup(true)
end
local page_setup = canvas:get_page_setup()
if page_setup then
operation:set_default_page_setup(page_setup)
end
operation.on_begin_print = function ()
operation:set_n_pages(1)
end
operation.on_draw_page = function (operation, context)
local cr = context:get_cairo_context()
local old_map = canvas:get_global_map()
canvas:set_global_map(Adg.matrix_identity())
canvas:render(cr)
canvas:set_global_map(old_map)
end
local result, err = operation:run(Gtk.PrintOperationAction.PRINT_DIALOG, window)
if result == Gtk.PrintOperationResult.APPLY then
settings = operation:get_print_settings()
end
end
end
-- Quit command
ui.mainQuit.on_clicked = Gtk.main_quit
window.on_delete_event = Gtk.main_quit
window:show_all()
Gtk.main()

Archive Download the corresponding diff file

Branches

Tags