Printoperation

hi list,

i’m experimenting with printoperation, on a cvs version of Fri Nov 10
11:47:07 2006.
and i found a “[BUG] Segmentation fault”

p context.page_setup.paper_size.inspect
in line 23 aborts the script.

i’m still experimenting with this stuff, all hints will be welcomed.

thanks

this is my script:
$ cat printer2.rb
require ‘gtk2’

Gtk.init

@w = Gtk::Window.new
@w.signal_connect(‘destroy’){Gtk.main_quit}
@w.set_default_size(300, 100)

pbutton=Gtk::Button.new
pbutton.set_image(Gtk::Image.new(Gtk::Stock::PRINT,Gtk::IconSize::LARGE_TOOLBAR))
pbutton.set_label(“PrintTest”)
pbutton.signal_connect(“clicked”){|me|
printo=Gtk::PrintOperation.new
printo.set_n_pages(1).set_show_progress(true)
printo.signal_connect(‘draw-page’){|me,context,page_number|
me.set_unit(Gtk::PaperSize::Unit::MM)
height = context.height
width = context.width
p Gtk::PaperSize::Unit
p me.unit
print width,“x”,height,"\n"

p context.page_setup.paper_size.inspect

    p context.page_setup.orientation.inspect
    cr = context.cairo_context

cr.rectangle(0,0,width,20)

    cr.set_source_rgb(0, 0, 0)

cr.fill

    layout = context.create_pango_layout

    desc = Pango::FontDescription.new("sans 10")
    layout.set_font_description(desc)

    layout.set_text(@editor.buffer.get_text)
    layout.set_width(width)

    layout_width, layout_height = layout.size
    text_height = layout_height / Pango::SCALE

    cr.show_pango_layout(layout)

}
printo.signal_connect(‘end-print’){|me,context|
print “-=== printing ended\n”
}
printo.signal_connect(‘status-changed’){|me|
print “- status changed: “,me.status_string,”\n”
}

printr=printo.run(Gtk::PrintOperation::ACTION_PRINT_DIALOG,@w)
case printr
when Gtk::PrintOperation::RESULT_ERROR
print “error\n”
when Gtk::PrintOperation::RESULT_CANCEL
print “cancelled\n”
when Gtk::PrintOperation::RESULT_APPLY
print “applied\n”
when Gtk::PrintOperation::RESULT_IN_PROGRESS
print “in progress\n”
else
print “unknown result: “,printr.inspect,”\n”
end

printo.destroy

}

@editor=Gtk::TextView.new()
@editor.set_width_request(200)

holder=Gtk::VBox.new()
holder.pack_start(@editor)
holder.pack_end(pbutton)
@w.add(holder)
@w.show_all

Gtk.main

Hi,

Fixed. Thanks.

On Mon, 13 Nov 2006 10:44:28 +0200
Dobai-Pataky B. [email protected] wrote:

@w.set_default_size(300, 100)
width = context.width

    text_height = layout_height / Pango::SCALE

printr=printo.run(Gtk::PrintOperation::ACTION_PRINT_DIALOG,@w)
print “unknown result: “,printr.inspect,”\n”
holder=Gtk::VBox.new()
holder.pack_start(@editor)
holder.pack_end(pbutton)
@w.add(holder)
@w.show_all

Gtk.main


Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Hi,

2006/11/15, Dobai-Pataky Bálint [email protected]:

and i think here is another one:

layout.set_text(layout.text+“\ncontext.page_setup.paper_height
= #{context.page_setup.paper_height}”)
gives
undefined method `paper_height’ for #<Gtk::PageSetup:0xb66ef0bc
ptr=0x83b4918>

not according to
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3APageSetup#paper_height

The documentation is wrong. I fixed.
Use #get_paper_height.

Thanks,

kou


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] printoperation” on Wed, 15 Nov 2006
11:14:21 +0200,
Dobai-Pataky Bálint [email protected] wrote:

undefined method `run_page_setup_dialog’ for #<Gtk::PrintOperation:0xb66e71a0
ptr=0x834e000>

run_page_setup_dialog is a class method of
Gtk::PrintOperation, not instance method.

Thanks,

kou


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Hi,

Fixed. Try CVS again.

Also API reference was wrong. I fixed it, too.

require ‘gtk2’
window = Gtk::Window.new
page_setup = Gtk::PageSetup.new
setting = Gtk::PrintSettings.new
p Gtk::PrintOperation.run_page_setup_dialog(window, page_setup, setting)

window, page_setup, setting are omittable.
So, you can write it as:

require ‘gtk2’
p Gtk::PrintOperation.run_page_setup_dialog


ruby 1.8.5 (2006-08-25) [i686-linux]

Aborted


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV