Mailinglist Archive: opensuse-programming-de (94 mails)
| < Previous | Next > |
Re: Gtk-perl kam ohne Doku?
- From: Bernhard Walle <Bernhard.Walle@xxxxxx>
- Date: Sun, 29 Dec 2002 21:39:21 +0100
- Message-id: <20021229203921.GA787@xxxxxxxxxxxxxxx>
Hi,
On Sun, 29 Dec 2002 at 21:14 (+0100), Ratti wrote:
> Jörg Roßdeutscher:
> > >ich versuche mich gerade an Gtk-perl. Schöne Sache!
> > >
> > >Leider finde ich keine Doku.
>
> David Haller:
> >
> > perldoc Gtk
> > man -k Gtk::
>
> Ja. Nein. :-)
>
> Also, ich finde auch die manpages. Aber mal so als Beispiel:
>
> man Gtk:
>
> [...]
> The Perl binding tries to follow the C interface as much as possible
> [...]
>
> Wie jetzt - "tries ... as possible"? "Geht so ähnlich wie in C" ist eine
> Hoffnung, ein Wunsch, eine Drohung wohlmöglich aber keine Doku.
Perl ist halt kein C. Ich denke das "tries ... as possible" bezieht
sich mehr auf das Interface und nicht auf die Funktionalität. Die
Perl-Bindings rufen ja auch nur die C-Funktionen auf -- warum sollten
sie also was an der Funktionalität verändert.
> Nehmen wir beispielsweise mal einen Befehl, der mir gerade Kummer macht:
>
> $window->set_policy
>
> Laut man Gtk::reference ergibt sich:
>
> $window->set_policy ($allow_shrink, $allow_grow, $auto_shrink)
>
> · $allow_shrink (integer)
> · $allow_grow (integer)
> · $auto_shrink (integer)
>
> Das ist, wie der Name der manpage schon androht, eine Referenz - aber
> keine Erklärung. was _bedeutet_ $auto_shrink?
Geh halt einfach davon aus, _dass_ die Funktionalität gleich mit der
von C ist und schau in der Gtk+-Doku nach:
=========================================================================
gtk_window_set_policy ()
void gtk_window_set_policy (GtkWindow *window,
gint allow_shrink,
gint allow_grow,
gint auto_shrink);
Warning
gtk_window_set_policy is deprecated and should not be used in
newly-written code. Use gtk_window_set_resizable() instead.
Changes how a toplevel window deals with its size request and user
resize attempts. There are really only two reasonable ways to call
this function:
1. gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE)
means that the window is user-resizable.
2. gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE)
means that the window's size is program-controlled, and should
simply match the current size request of the window's children.
The first policy is the default, that is, by default windows are
designed to be resized by users.
The basic ugly truth of this function is that it should be simply:
void gtk_window_set_resizable (GtkWindow* window, gboolean setting);
...which is why GTK+ 2.0 introduces gtk_window_set_resizable(), which
you should use instead of gtk_window_set_policy().
If set to TRUE, the allow_grow parameter allows the user to expand the
window beyond the size request of its child widgets. If allow_grow is
TRUE, be sure to check that your child widgets work properly as the
window is resized.
A toplevel window will always change size to ensure its child widgets
receive their requested size. This means that if you add child
widgets, the toplevel window will expand to contain them. However,
normally the toplevel will not shrink to fit the size request of its
children if it's too large; the auto_shrink parameter causes the
window to shrink when child widgets have too much space. auto_shrink
is normally used with the second of the two window policies mentioned
above. That is, set auto_shrink to TRUE if you want the window to have
a fixed, always-optimal size determined by your program.
Note that auto_shrink doesn't do anything if allow_shrink and
allow_grow are both set to FALSE.
Neither of the two suggested window policies set the allow_shrink
parameter to TRUE. If allow_shrink is TRUE, the user can shrink the
window so that its children do not receive their full size request;
this is basically a bad thing, because most widgets will look wrong if
this happens. Furthermore GTK+ has a tendency to re-expand the window
if size is recalculated for any reason. The upshot is that
allow_shrink should always be set to FALSE.
Sometimes when you think you want to use allow_shrink, the real
problem is that some specific child widget is requesting too much
space, so the user can't shrink the window sufficiently. Perhaps you
are calling gtk_widget_set_size_request() on a child widget, and
forcing its size request to be too large. Instead of setting the
child's usize, consider using gtk_window_set_default_size() so that
the child gets a larger allocation than it requests.
window : the window
allow_shrink : whether the user can shrink the window below its
size request
allow_grow : whether the user can grow the window larger than
its size request
auto_shrink : whether the window automatically snaps back to its
size request if it's larger
=========================================================================
BTW: Die beannte Doku ist bei Gtk+ 2.x dabei. Ich weiß nicht, ob sich
die Perl-Bindings auf das alte oder das neue Gtk+ beziehen. Zu
Gtk+ 1.x gibt's IIRC keine vollständige Doku.
> P.S.:
> ratti@ratti:~> man -k set_policy
> set_policy: nichts passendes.
>
> Wieso eigentlich? Zumindest in zwei Seiten wird es ja erwähnt?
Aus man(1)¹:
man -k printf
Sucht die Kurzbeschreibungen und die Namen der Manual
seiten zum Schlüsselwort printf und gibt alle Treffer
aus.
HTH. BTW: Nicht dass hier der falsche Eindruck erweckt wird: ich habe
von Gtk+ nicht viel Ahnung. Mir gefällt's auch nicht
besonders².
Ich finde es sowieso irgendwie Unsinn, in einer nicht
OO-Programmiersprache objektorientiert zu programmieren,
zumal man deswegen viele Typ"konvertierungen" von Hand
machen muss. Die Bindungen zu anderen Programmiersprachen
(also nicht C) hinken prinzipiell hinterher. Perl ist auch
nicht die Programmiersprache, die ich mir für größere
Programme wünsche. Und die Art, in Perl OO zu programmieren
finde ich auch nicht unbedingt toll.
Java finde ich da um einiges besser.
Gruß,
Bernhard
¹ das ist die Manualseite zu "man", aufzurufen mit "man man"
² ich meine nicht das Aussehen der Programme sondern die Art, in Gtk+
zu programmieren, siehe nachfolgende Sätze
--
"In dieser Welt gibt es nichts Sicheres als den Tod und die
Steuern."
-- Benjamin Franklin
On Sun, 29 Dec 2002 at 21:14 (+0100), Ratti wrote:
> Jörg Roßdeutscher:
> > >ich versuche mich gerade an Gtk-perl. Schöne Sache!
> > >
> > >Leider finde ich keine Doku.
>
> David Haller:
> >
> > perldoc Gtk
> > man -k Gtk::
>
> Ja. Nein. :-)
>
> Also, ich finde auch die manpages. Aber mal so als Beispiel:
>
> man Gtk:
>
> [...]
> The Perl binding tries to follow the C interface as much as possible
> [...]
>
> Wie jetzt - "tries ... as possible"? "Geht so ähnlich wie in C" ist eine
> Hoffnung, ein Wunsch, eine Drohung wohlmöglich aber keine Doku.
Perl ist halt kein C. Ich denke das "tries ... as possible" bezieht
sich mehr auf das Interface und nicht auf die Funktionalität. Die
Perl-Bindings rufen ja auch nur die C-Funktionen auf -- warum sollten
sie also was an der Funktionalität verändert.
> Nehmen wir beispielsweise mal einen Befehl, der mir gerade Kummer macht:
>
> $window->set_policy
>
> Laut man Gtk::reference ergibt sich:
>
> $window->set_policy ($allow_shrink, $allow_grow, $auto_shrink)
>
> · $allow_shrink (integer)
> · $allow_grow (integer)
> · $auto_shrink (integer)
>
> Das ist, wie der Name der manpage schon androht, eine Referenz - aber
> keine Erklärung. was _bedeutet_ $auto_shrink?
Geh halt einfach davon aus, _dass_ die Funktionalität gleich mit der
von C ist und schau in der Gtk+-Doku nach:
=========================================================================
gtk_window_set_policy ()
void gtk_window_set_policy (GtkWindow *window,
gint allow_shrink,
gint allow_grow,
gint auto_shrink);
Warning
gtk_window_set_policy is deprecated and should not be used in
newly-written code. Use gtk_window_set_resizable() instead.
Changes how a toplevel window deals with its size request and user
resize attempts. There are really only two reasonable ways to call
this function:
1. gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE)
means that the window is user-resizable.
2. gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE)
means that the window's size is program-controlled, and should
simply match the current size request of the window's children.
The first policy is the default, that is, by default windows are
designed to be resized by users.
The basic ugly truth of this function is that it should be simply:
void gtk_window_set_resizable (GtkWindow* window, gboolean setting);
...which is why GTK+ 2.0 introduces gtk_window_set_resizable(), which
you should use instead of gtk_window_set_policy().
If set to TRUE, the allow_grow parameter allows the user to expand the
window beyond the size request of its child widgets. If allow_grow is
TRUE, be sure to check that your child widgets work properly as the
window is resized.
A toplevel window will always change size to ensure its child widgets
receive their requested size. This means that if you add child
widgets, the toplevel window will expand to contain them. However,
normally the toplevel will not shrink to fit the size request of its
children if it's too large; the auto_shrink parameter causes the
window to shrink when child widgets have too much space. auto_shrink
is normally used with the second of the two window policies mentioned
above. That is, set auto_shrink to TRUE if you want the window to have
a fixed, always-optimal size determined by your program.
Note that auto_shrink doesn't do anything if allow_shrink and
allow_grow are both set to FALSE.
Neither of the two suggested window policies set the allow_shrink
parameter to TRUE. If allow_shrink is TRUE, the user can shrink the
window so that its children do not receive their full size request;
this is basically a bad thing, because most widgets will look wrong if
this happens. Furthermore GTK+ has a tendency to re-expand the window
if size is recalculated for any reason. The upshot is that
allow_shrink should always be set to FALSE.
Sometimes when you think you want to use allow_shrink, the real
problem is that some specific child widget is requesting too much
space, so the user can't shrink the window sufficiently. Perhaps you
are calling gtk_widget_set_size_request() on a child widget, and
forcing its size request to be too large. Instead of setting the
child's usize, consider using gtk_window_set_default_size() so that
the child gets a larger allocation than it requests.
window : the window
allow_shrink : whether the user can shrink the window below its
size request
allow_grow : whether the user can grow the window larger than
its size request
auto_shrink : whether the window automatically snaps back to its
size request if it's larger
=========================================================================
BTW: Die beannte Doku ist bei Gtk+ 2.x dabei. Ich weiß nicht, ob sich
die Perl-Bindings auf das alte oder das neue Gtk+ beziehen. Zu
Gtk+ 1.x gibt's IIRC keine vollständige Doku.
> P.S.:
> ratti@ratti:~> man -k set_policy
> set_policy: nichts passendes.
>
> Wieso eigentlich? Zumindest in zwei Seiten wird es ja erwähnt?
Aus man(1)¹:
man -k printf
Sucht die Kurzbeschreibungen und die Namen der Manual
seiten zum Schlüsselwort printf und gibt alle Treffer
aus.
HTH. BTW: Nicht dass hier der falsche Eindruck erweckt wird: ich habe
von Gtk+ nicht viel Ahnung. Mir gefällt's auch nicht
besonders².
Ich finde es sowieso irgendwie Unsinn, in einer nicht
OO-Programmiersprache objektorientiert zu programmieren,
zumal man deswegen viele Typ"konvertierungen" von Hand
machen muss. Die Bindungen zu anderen Programmiersprachen
(also nicht C) hinken prinzipiell hinterher. Perl ist auch
nicht die Programmiersprache, die ich mir für größere
Programme wünsche. Und die Art, in Perl OO zu programmieren
finde ich auch nicht unbedingt toll.
Java finde ich da um einiges besser.
Gruß,
Bernhard
¹ das ist die Manualseite zu "man", aufzurufen mit "man man"
² ich meine nicht das Aussehen der Programme sondern die Art, in Gtk+
zu programmieren, siehe nachfolgende Sätze
--
"In dieser Welt gibt es nichts Sicheres als den Tod und die
Steuern."
-- Benjamin Franklin
| < Previous | Next > |