Re: [Vala] Genie error !



Hi,

I try to port simple pdf viewer from vala to genie.

But i have this error:

pdfview.gs:53.18-53.44: error: Too many arguments, method `PopplerSample.new' does not take 1 arguments
   var sample = new PopplerSample (args[1])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)

What's wrong in code ?

[indent=4]

/* Build with valac --pkg gtk+-2.0 --pkg poppler-glib yourfile.gs */

uses
   Gtk
   Poppler

class PopplerSample : Window
   document : Poppler.Document
   image : Image
   index:int = 0
   init
       title = "Simple PDF Viewer"
       default_height = 350
       default_width = 500
       window_position = WindowPosition.CENTER
       destroy += Gtk.main_quit
def PopplerSample (pdf_filename : string)
       try
this.document = new Poppler.Document.from_file (Filename.to_uri (pdf_filename), "");
       except e:OptionError
           print ("%s", e.message)
       // Create an image and render first page to image
var pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 800, 600);
       this.image = new Image.from_pixbuf (pixbuf);
       render_page ()
       add (this.image)
       this.key_press_event += on_key_pressed
       this.destroy += Gtk.main_quit

def private on_key_pressed (source : PopplerSample, key : Gdk.EventKey) : bool
       if (key.str is "q")
           Gtk.main_quit ()
       // Render the next page, or the first if we were at the last
       this.index++
       this.index %= this.document.get_n_pages ()
       render_page ()
       return false

   def private render_page ()
       var pixbuf = this.image.get_pixbuf ()
       var page = this.document.get_page (this.index)
       page.render_to_pixbuf (0, 0, 800, 600, 1.0, 0, pixbuf)
       this.image.set_from_pixbuf (pixbuf)


init
   if (args.length != 2)
       print ("Usage: %s /full/path/to/some.pdf\n", args[0])
   Gtk.init (ref args)
   var sample = new PopplerSample (args[1])
   sample.show_all ()
   Gtk.main ()

Thank you in advance,
Nicolas.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]