Some differences between Gtk and Gtk2


I finally got around to having a look at the new Gtk2 port, which
I have been looking forward to for a long time. First of all, thanks
a lot to everyone involved!

While playing around with the new Gtk2 port, I'm hitting stuck on
several differences compared to the Gtk port, that I thought that
I would list here. 

Here are a list of what I have found so far:

1. Creation of new widgets and setting of their properties. In Gtk
   you can create a widget and set their properties in one call.


    $mw = Gtk::Widget->new("Gtk::Window",
                           type                 => -toplevel,
                           title                =>      "puzzle",
                           allow_grow           =>      0,
                           allow_shrink         =>      0,


    $mw = Gtk2::Window->new("toplevel");
    $mw->set(title                =>      "Traffic Jam",
             allow_grow           =>      0,
             allow_shrink         =>      0,

   Since Gtk2::Widget->new isn't implemented at all, this would be
   an easy wrapper function to write.

2. The signal::event property:

   One family of the properties that may be set in Gtk is the signal::*
   properties. The Gtk way is more concise. It is not clear to me 
   though if this was caught on the gtk+ level or if Gtk::Perl did
   the necessary connection.


     $button = Gtk::Widget->new("Gtk::Button",
                                label => "Press me",
                                "signal::clicked" => sub { 
                                     print "Hello dude!\n\n"; 


     $mw = Gtk::Button->new("Press me");
     Gtk2::GSignal->connect(button, "clicked", sub { print "Hello dude!\n"; });

3. The event->type names

   This should probably be considered a bug. The type names in Gtk are
   with underlines and in Gtk2 with minus characters. Btw, I liked having
   base types as hashes, as it meant you could easily print its "keys" to 
   see what properties were set... Also emacs doesn't make the syntax
   parsing mistake of coloring $event->{y} which it does with $event->y . ;-)

       $event->{type} eq "motion_notify"


       if ($event->type eq "motion-notify") ...

I'll be happy provide patches for all of these issues if it is desirable.
I don't know when I'll get around to looking at them though. 


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