Re: Gtk::perl documentation?



Oh no need to apologize; I wasn't clear, and thanks for the hints. I map
C to perl OK (with occasional screwups :-) but I find a lot of things
don't map, or the transformations aren't obvious to me, eg.
gtk_button_new_with_mnemonic() maps to... what? not
'Gtk::Button_with_mnemonic-> new' or other variations I've tried.

as a general rule :
Gtk::Class->new_function
where Gtk is always there. where class is the type of object you want to
deal with, i.e. Button, HBox, ButtonBox, Frame, ... and new_function is
one of the listed new functions you can find in the api reference on
gtk.org.

so the function mapping rule is gtk_objec_name_new_function(...) ->
Gtk::ObjectName->new_function(...) 

after that you just use the object returned as follows.

button = gtk_button_new();
gtk_button_signal_connect( GTK_BUTTON(button), ...);

becomes

$button = Gtk::Button->new("Hello");
$button->signal_connect(...);

i.e. you drop the gtk and the object name and do
$var->operation_on_object.

once you get the hang of those general rules of thumb they should get
you through 95% of the code. beyond that it's looking at the source and
doc and/or trial and error.

But that's only part of it; for example I coded my menus explicitly,
then later stumble upon GtkItemFactory, which appears like it might be
some higher-level (and smarter) way to assemble menus. I found
references to *_STOCK_* items the same way; those look easy to
implement, the reference may be adequate here, but the mere existence of
these things is the mystery. Obviously knowing available structural
models up front would beat reading a reference in alpha order.

can't help you there, i've never tried using item factory.

I don't mean to complain; the code is great. I was mainly wondering

 * Does everyone have this problem, or just me?

yeah, when people start out doing gui development (in general not with
gtk) it takes a while to get your head around things, but once you do
you can get pretty quick at it. the same general idea applies when you
go to try more complex things like item factory. takes a while to figure
it out, but once you do you're good to go. i would venture a guess that
the gnome/gtk programming book(s) touch on such things (in c) enough to
get you going pretty fast.

I did just order 'Linux GNOME/GTK+ bible'. I'll RTFM and see what
happens next. It seems awfully thick... (eg. "I would have written you a
shorter letter, but I did not have the time -- BLAISE PASCAL")

you might want to post a review of the book to somewhere like
slashdot.org if you read through it enough to do so. i guess that you
might want to pass on what you think of it to this list, which is
archived so when people search for books they ought to see it.

-rm




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