# PrintOperation on windows

**URL:** <https://www.ruby-forum.com/t/printoperation-on-windows/144757>\
**Category:** Ruby-Gnome 2\
**Created:** [August 1, 2008, 8:53pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757 "2008-08-01T20:53:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 1, 2008, 8:53pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/1 "2008-08-01T20:53:40Z")

</div>

hi,

ruby -e “require ‘gtk2’;p “gtk:#{Gtk::VERSION.inspect},  
binding:#{Gtk::BINDING\_VERSION.inspect}””  
on a gentoo(ruby 1.8.6 (2008-03-03 patchlevel 114) [x86\_64-linux]):  
“gtk:[2, 12, 11], binding:[0, 16, 0]”  
on the XP(ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]):  
“gtk:[2, 10, 6], binding:[0, 15, 0]” (strange it was installed by  
ruby-gnome2-0.16.0-1-i386-mswin32.exe)

anyways, my problem is with printing on windows:  
on the gentoo the following presents the dialog, but on the XP it just  
stops responding, and hangs forever, no output.  
ruby -e “require  
‘gtk2’;Gtk::PrintOperation.new.run(Gtk::PrintOperation::ACTION\_PRINT\_DIALOG)”

do i miss something?  
is it supported?  
is there something i could do to make it work?

thanks in advice,  
balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 1, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/2 "2008-08-01T21:28:54Z")

</div>

ruby -e “require ‘gtk2’;Gtk::PrintOperation.run\_page\_setup\_dialog”  
also does not work.  
but  
ruby -e “require ‘gtk2’;p Gtk::PrintOperation.new.status”  
#\<Gtk::PrintOperation::Status initial\>  
and  
ruby -e “require ‘gtk2’;p Gtk::PrintOperation.new.job\_name”  
“-e job #1”  
works. is it just the dialog?

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 2, 2008, 2:40pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/3 "2008-08-02T14:40:00Z")

</div>

Kou, can you please confirm this situation? is it not implemented, or am  
i doing something wrong?  
thanks in advice

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 4, 2008, 9:12pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/4 "2008-08-04T21:12:36Z")

</div>

hi,  
i tested the dialog, it’s the same ☹  
is there anything else i should try?  
thanks  
balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 3, 2008, 2:27am UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/5 "2008-08-03T02:27:29Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] PrintOperation on windows” on Sat, 02 Aug  
2008 15:39:17 +0300,  
Dobai-Pataky Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Kou, can you please confirm this situation? is it not implemented, or am i  
> doing something wrong?

I’m sorry but I don’t have a Windows environment…

Could you try with the current GTK+?

- Download the current GTK+:  
[http://www.gtk.org/download-windows.html:](http://www.gtk.org/download-windows.html:)  
[http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.12/gtk+-bundle-2.12.11.zip](http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.12/gtk+-bundle-2.12.11.zip)

- Move the GTK+ bundled with Ruby-GNOME2:  
C:\ruby\lib\GTK → C:\ruby\lib\GTK-Ruby-GNOME2

- Extract the current GTK+ to C:\ruby\lib\GTK

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 5, 2008, 2:10pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/6 "2008-08-05T14:10:57Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] PrintOperation on windows” on Mon, 04 Aug  
2008 22:11:36 +0300,  
Dobai-Pataky Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i tested the dialog, it’s the same ☹  
> is there anything else i should try?

If you have a GTK+ build environment (and you can write C)  
on Windows, please try the same code in C. If you can  
reproduce the problem in C, it’s a GTK+ problem. Otherwise,  
it’s a Ruby/GTK+ (or Ruby/GLib) problem. Can you do it? If  
you can’t write C, I will be able to write it.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 5, 2008, 2:12pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/7 "2008-08-05T14:12:43Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] PrintOperation on windows” on Tue, 05 Aug  
2008 21:10:38 +0900 (JST),  
Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > i tested the dialog, it’s the same ☹  
> > is there anything else i should try?
> 
> If you have a GTK+ build environment (and you can write C)  
> on Windows, please try the same code in C. If you can  
> reproduce the problem in C, it’s a GTK+ problem. Otherwise,  
> it’s a Ruby/GTK+ (or Ruby/GLib) problem. Can you do it? If  
> you can’t write C, I will be able to write it.

Or I will be able to build a test program binary on  
my Debian GNU/Linux environment. (cross compile)

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 7, 2008, 12:22pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/8 "2008-08-07T12:22:43Z")

</div>

Kouhei S. wrote:

> > If you have a GTK+ build environment (and you can write C)  
> > on Windows, please try the same code in C. If you can  
> > reproduce the problem in C, it’s a GTK+ problem. Otherwise,  
> > it’s a Ruby/GTK+ (or Ruby/GLib) problem. Can you do it? If  
> > you can’t write C, I will be able to write it.
> 
> Or I will be able to build a test program binary on  
> my Debian GNU/Linux environment. (cross compile)

please do so, i tried MSvisualC2008, but with no luck, yet.

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 7, 2008, 1:22pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/9 "2008-08-07T13:22:34Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] PrintOperation on windows” on Thu, 07 Aug  
2008 13:21:54 +0300,  
Dobai-Pataky Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> Or I will be able to build a test program binary on
> my Debian GNU/Linux environment. (cross compile)
> 
> ```
> 
> please do so, i tried MSvisualC2008, but with no luck, yet.

Here is a test program built from the following code:  
[http://ruby-gnome2.sourceforge.jp/gtk-print.exe](http://ruby-gnome2.sourceforge.jp/gtk-print.exe)

#include \<gtk/gtk.h\>

int  
main(int argc, char \*\*argv)  
{  
GtkPrintOperation \*operation;  
GtkPrintOperationResult result;  
GError \*error = NULL;

```
gtk_init(&argc, &argv);

operation = gtk_print_operation_new();
result = gtk_print_operation_run(operation,
                                 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                 NULL,
                                 &error);
if (error) {
    g_warning("%d:%s", error->code, error->message);
    g_error_free(error);
} else {
    g_print("RESULT: %d\n", result);
}

return 0;

```

}

Thanks,  
kou

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 7, 2008, 1:31pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/10 "2008-08-07T13:31:21Z")

</div>

Hi,

2008/8/7 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > ```
> > Or I will be able to build a test program binary on
> > my Debian GNU/Linux environment. (cross compile)
> > 
> > ```
> > 
> > please do so, i tried MSvisualC2008, but with no luck, yet.
> 
> Here is a test program built from the following code:  
> [http://ruby-gnome2.sourceforge.jp/gtk-print.exe](http://ruby-gnome2.sourceforge.jp/gtk-print.exe)

BTW, did you run a “Printing” sample from gtk-demo.exe?

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 7, 2008, 8:26pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/11 "2008-08-07T20:26:17Z")

</div>

Kouhei S. wrote:

> > Here is a test program built from the following code:  
> > [http://ruby-gnome2.sourceforge.jp/gtk-print.exe](http://ruby-gnome2.sourceforge.jp/gtk-print.exe)
> 
> BTW, did you run a “Printing” sample from gtk-demo.exe?

yes, it presents the printer chooser, i did not go further.  
now i tried, and was able to setup a new printer from it, and was able  
to print to file from it. so i think that works as your gtk-print.exe  
in the ruby-gtk2-demo there is no printing.

thank you

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 7, 2008, 8:22pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/12 "2008-08-07T20:22:11Z")

</div>

Kouhei S. wrote:

> > please do so, i tried MSvisualC2008, but with no luck, yet.  
> > GtkPrintOperation \*operation;  
> > if (error) {  
> > Thanks,  
> > kou

this is the error:

but i have c:\ruby\lib\GTK\bin\libglib-2.0-0.dll

ops, it runs if i copied it to c:\ruby\lib\GTK\bin  
it presents the nice printer chooser.  
thanks

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 10, 2008, 10:32am UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/13 "2008-08-10T10:32:05Z")

</div>

Kouhei S. wrote:

> > now i tried, and was able to setup a new printer from it, and was able to print  
> > kou

“not a Gtk::MessageDialog::ButtonType” error i get in line 26  
i tried replacing the buttons parameter with  
Gtk::MessageDialog::ButtonsType::CLOSE, and with 2, but no luck, same  
error.  
so i replaced the dialog part with a “p $!.message”  
and if i press the print button now i see: “not a Gtk::PaperSize::Unit”

this line generates the error, around line number 60  
operation.unit = :points

so i removed that line, i wanna see any printings now, don’t care if  
it’s not calculated correctly.

but than:  
“not a Gtk::PrintOperation::Action” in line 63  
by the line: operation.run(:print\_dialog,self)

so i replace :print\_dialog with 0  
and we get to the begining of the problem. it hangs, and does not  
present the dialog.

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 13, 2008, 2:10pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/14 "2008-08-13T14:10:53Z")

</div>

Dobai-Pataky BÃ¡lint wrote:

> “not a Gtk::MessageDialog::ButtonType” error i get in line 26  
> i tried replacing the buttons parameter with  
> Gtk::MessageDialog::ButtonsType::CLOSE, and with 2, but no luck, same  
> error.  
> so i replaced the dialog part with a “p $!.message”  
> and if i press the print button now i see: “not a Gtk::PaperSize::Unit”

There was a patch applied by Kou in latest trunk. Can you check if this  
works?

Best Regards,  
Joachim G.

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 9, 2008, 8:06am UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/15 "2008-08-09T08:06:01Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] PrintOperation on windows” on Thu, 07 Aug  
2008 21:25:37 +0300,  
Dobai-Pataky Bálint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> BTW, did you run a "Printing" sample from gtk-demo.exe?
> 
> ```
> 
> yes, it presents the printer chooser, i did not go further.  
> now i tried, and was able to setup a new printer from it, and was able to print  
> to file from it. so i think that works as your gtk-print.exe  
> in the ruby-gtk2-demo there is no printing.

Here is a “Printing” sample in Ruby. Please put it to  
gtk/sample/gtk-demo/ directory, run main.rb and try  
“Printing” sample.

## Thanks,

kou

–

# Copyright (c) 2008 Ruby-GNOME2 Project Team

# This program is licenced under the same licence as Ruby-GNOME2.

=begin  
= Printing

Gtk::PrintOperation offers a simple API to support printing  
in a cross-platform way.  
=end

require ‘common’

module Demo  
class Printing \< BasicWindow  
Data = Struct.new(:font\_size, :lines\_per\_page, :lines, :n\_pages)  
HEADER\_HEIGHT = 10 \* 72 / 25.4  
HEADER\_GAP = 3 \* 72 / 25.4

```
def initialize
  super('Printing')

  button = Gtk::Button.new("Print...")
  button.signal_connect("clicked") do
    begin
      run_print_operation
    rescue
      dialog = Gtk::MessageDialog.new(self, :destroy_with_parent, 

```

:error,  
:close, $!.message)  
dialog.signal\_connect(“response”) do  
dialog.destroy  
true  
end  
dialog.show  
end  
true  
end  
add(button)  
end

```
private
def run_print_operation
  operation = Gtk::PrintOperation.new

  data = Data.new
  data.font_size = 12.0
  operation.signal_connect("begin-print") do |_operation, context|
    on_begin_print(_operation, context, data)
  end
  operation.signal_connect("draw-page") do |_operation, context, 

```

page\_number|  
on\_draw\_page(\_operation, context, page\_number, data)  
end  
operation.signal\_connect(“end-print”) do |\_operation, context|  
on\_end\_print(\_operation, context, data)  
end

```
  operation.use_full_page = false
  operation.unit = :points

  operation.run(:print_dialog, self)
end

def on_begin_print(operation, context, data)
  height = context.height - HEADER_HEIGHT - HEADER_GAP
  data.lines_per_page = (height / data.font_size).floor
  data.lines = File.readlines( __FILE__ )
  data.n_pages = (data.lines.size - 1) / data.lines_per_page + 1
  operation.set_n_pages(data.n_pages)
end

def on_draw_page(operation, context, page_number, data)
  cr = context.cairo_context
  width = context.width

  cr.rectangle(0, 0, width, HEADER_HEIGHT)
  cr.set_source_rgb(0.8, 0.8, 0.8)
  cr.fill_preserve

  cr.set_source_rgb(0, 0, 0)
  cr.line_width = 1
  cr.stroke

  layout = context.create_pango_layout
  layout.font_description = Pango::FontDescription.new("sans 14")

  layout.text = File.basename( __FILE__ )
  text_width, text_height = layout.pixel_size

  if (text_width > width)
    layout.width = width
    layout.ellipsize = :start
    text_width, text_height = layout.pixel_size
  end

  cr.move_to((width - text_width) / 2, (HEADER_HEIGHT - text_height) 

```

/ 2)  
cr.show\_pango\_layout(layout)

```
  layout.text = "#{page_number + 1}/#{data.n_pages}"
  layout.width = -1
  text_width, text_height = layout.pixel_size
  cr.move_to(width - text_width - 4, (HEADER_HEIGHT - text_height) / 

```

1. cr.show\_pango\_layout(layout)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 13, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/16 "2008-08-13T17:13:55Z")

</div>

Joachim G. wrote:

> There was a patch applied by Kou in latest trunk. Can you check if this  
> works?
> 
> Best Regards,  
> Joachim G.

no, i did not.  
i can currently compile it on linux.  
if you guide me in compiling it on windows, i’ll do it.

thanks,  
balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 16, 2008, 11:10am UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/17 "2008-08-16T11:10:35Z")

</div>

Joachim G. wrote:

> If you use MinGW this should work at least on the machine on which it is  
> compiled.

i followed th link.  
built everything up to ruby-glib2, which failed with  
rbglib\_maincontext.c:166: error: syntax error before “rb\_thread\_t”  
rbglib\_maincontext.c: In function `source_prepare_add_poll': rbglib_maincontext.c:168: error: `thread’ undeclared (first use in this  
function )  
rbglib\_maincontext.c:168: error: (Each undeclared identifier is reported  
only on ce  
rbglib\_maincontext.c:168: error: for each function it appears in.)  
rbglib\_maincontext.c:170: error: `source' undeclared (first use in this function ) rbglib_maincontext.c: In function `source\_prepare\_setup\_poll\_fd’:  
rbglib\_maincontext.c:199: error: `rb_thread_t' undeclared (first use in this fun ction) rbglib_maincontext.c:199: error: syntax error before "thread" rbglib_maincontext.c:207: error: `thread’ undeclared (first use in this  
function )  
rbglib\_maincontext.c:207: error: `rb_curr_thread' undeclared (first use in this function) rbglib_maincontext.c:211: error: `THREAD\_RUNNABLE’ undeclared (first use  
in this function)  
rbglib\_maincontext.c:214: error: `THREAD_KILLED' undeclared (first use in this f unction) make[1]: *** [rbglib_maincontext.o] Error 1 make[1]: Leaving directory `/home/balint/rg2/glib/src’  
make: \*\*\* [all] Error 2

should i try other version than ruby-1.8.5?  
thanks

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 14, 2008, 12:52pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/18 "2008-08-14T12:52:49Z")

</div>

Dobai-Pataky BÃ¡lint wrote:

> no, i did not.  
> i can currently compile it on linux.  
> if you guide me in compiling it on windows, i’ll do it.

This wiki entry can help you:  
[http://ruby-gnome2.sourceforge.jp/hiki.cgi?cmd=view&p=compile\_mingw&key=win32](http://ruby-gnome2.sourceforge.jp/hiki.cgi?cmd=view&p=compile_mingw&key=win32)

If you use MinGW this should work at least on the machine on which it is  
compiled.

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 16, 2008, 1:11pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/19 "2008-08-16T13:11:44Z")

</div>

Dobai-Pataky BÃ¡lint wrote:

> > This wiki entry can help you:  
> > this function )  
> > this function )  
> > should i try other version than ruby-1.8.5?  
> > thanks

built with 1.8.7-p71

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [August 16, 2008, 3:22pm UTC](https://www.ruby-forum.com/t/printoperation-on-windows/144757/20 "2008-08-16T15:22:20Z")

</div>

someone please update the rg2 wiki on installing on windows:  
i ran into rcairo not configuring:

~/rcairo-1.6.3  
$ ruby extconf.rb && make && make install  
checking for GCC… yes  
checking for cairo version (\>= 1.2.0)… \*\*\* extconf.rb failed \*\*\*  
Could not create Makefile due to some reason, probably lack of  
necessary libraries and/or headers. Check the mkmf.log file for more  
details. You may need configuration options.

~/rcairo-1.6.3  
$pkg-config.exe --cflags gtk±2.0  
Package pixman-1 was not found in the pkg-config search path.  
Perhaps you should add the directory containing `pixman-1.pc’  
to the PKG\_CONFIG\_PATH environment variable  
Package ‘pixman-1’, required by ‘cairo’, not found

this link helped me out:  
[http://www.nabble.com/pixman-1-was-not-found-in-the-pkg-config-td16842574.html](http://www.nabble.com/pixman-1-was-not-found-in-the-pkg-config-td16842574.html)  
i’ve built [http://cairographics.org/releases/pixman-0.10.0.tar.gz](http://cairographics.org/releases/pixman-0.10.0.tar.gz) with  
the following:  
./configure --prefix=/MinGW && make && make install

then in the rcairo source:  
export PKG\_CONFIG\_PATH=“$PKG\_CONFIG\_PATH:/C/MinGW/lib/pkgconfig/”

$ pkg-config.exe --cflags gtk±2.0  
-mms-bitfields -Ic:/GTK/include/gtk-2.0 -Ic:/GTK/lib/gtk-2.0/include  
-Ic:/GTK/include/atk-1.0 -Ic:/GTK/include/cairo  
-Ic:/GTK/include/pango-1.0 -Ic:/GTK/include/glib-2.0  
-Ic:/GTK/lib/glib-2.0/include -Ic:/GTK/include/freetype2

but than i ran into:  
~/rcairo-1.6.3  
$ make  
gcc -I. -I. -Ic:/MinGW/lib/ruby/1.8/i386-mingw32 -I.  
-DRUBY\_CAIRO\_PLATFORM\_WIN32 -DRB\_CAIRO\_COMPILATION -g -O2 -Wall  
-I/target/include/cairo -I/target/include/freetype2 -I/target/include  
-I/target/include/libpng12 -I/MinGW/include/pixman-1 -mms-bitfields -c  
C:/msys/1.0/home/balint/rcairo-1.6.3/src/rb\_cairo\_context.c  
-osrc/rb\_cairo\_context.o  
In file included from  
C:/msys/1.0/home/balint/rcairo-1.6.3/src/rb\_cairo\_context.c:15:  
C:/msys/1.0/home/balint/rcairo-1.6.3/src/rb\_cairo.h:19:19: cairo.h: No  
such file or directory  
In file included from  
C:/msys/1.0/home/balint/rcairo-1.6.3/src/rb\_cairo\_context.c:15:  
C:/msys/1.0/home/balint/rcairo-1.6.3/src/rb\_cairo.h:162: error: syntax  
error before ‘\*’ token  
C:/msys/1.0/home/balint/rcairo-1.6.3/src/rb\_cairo.h:162: warning: type  
defaults to `int' in declaration of `rb\_cairo\_context\_from\_ruby\_object’

so i extracted include/cairo/\*h from cairo-dev-1.6.4-2.zip into  
MinGW/include/  
and make of rcairo finished  
make install succeeded

for making rg2 modules(like pango,gdkpixbuf, and finally gtk and atk) i  
have to export 2 variables:  
export PKG\_CONFIG\_PATH=“$PKG\_CONFIG\_PATH:/C/MinGW/lib/pkgconfig/”  
export CAIRO\_PATH=/home/balint/rcairo-1.6.3/

testing:  
require ‘gtk2’  
Gtk::PrintOperation.run\_page\_setup\_dialog

presents the dialog. 🙂

so my question: how do i deploy this mess onto other windows machines?  
zip/unzip everything?  
or should i wait for a windows release of rg2, which includes the  
working PrintOperation?

thanks for your help

[Next page](https://www.ruby-forum.com/t/printoperation-on-windows/144757.md?page=2)
