Re: [gtk-list] YATU - Yet Another Tutorial Update
- From: Tim Janik <timj psynet net>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] YATU - Yet Another Tutorial Update
- Date: Thu, 31 Jul 1997 14:40:00 +0200 (CEST)
On Wed, 30 Jul 1997, Ian Main wrote:
> There is also a third component called glib which contains a few
> replacements for printf, malloc etc. These are used to increase gtk's
> portability, as some of the functions implemented here are not available on
> all unicies. Some also contain enhancements to the libc versions (such as
> g_malloc), and others (such as g_strerror) will even pop up windows for you
> printing your error string.
hup? nope, for the moment there are no functions that will pop up a window
for you, but that could easily be implemented by consequent use of these
functions.
g_strerror and g_strsignal will only provide you with an explanatory string
for the given errno-state.
[snip]
> The last line enters the GTK main processing loop.
>
> gtk_main ();
>
> gtk_main() is another call you will see in every gtk application. When
> control reaches this point, gtk will sleep waiting for X events (such as
> button or keypresses) to occur.
> In our simple example however, no events will be registered.
not fully correct ;)
there are a few events that will occour from the X-server, like the first
expose event after the windows creation. also there will be a few events,
that are mostly gtk-internal like SHOW, MAP, REALIZE, DRAW, SIZE_ALLOCATE...
also if you move the mouse across your empty window, you will genereate
ENTER_NOTIFY_EVENT and LEAVE_NOTIFY_EVENT. you can even click into the
window generting a BUTTON_PRESS_EVENT, there is just no function bound
to it.
[hm, taht was a little excessive... ;) ]
[snip]
> /* and the window */
> gtk_widget_show (window);
>
> /* all gtk applications must have a gtk_main(). Control ends here
> * and waits for an event to occur (like a key press or mouse event). */
> gtk_main ();
>
> return 0;
> }
you might want to explain also, that gtk_exit(0) will be called, if the program
finishes, as well as gdk_exit(). these functions free some previously allocated
memory and do some else clean up like closing the XDisplay.
[snip]
>
> 4) pack the widget into a container using gtk_container_add() or
> gtk_box_pack_start() (are there others ?).
yep there are a lot others, but besides GtkNotebook, the gtk_container_add()
function will always call the corresponding gtk_widget_add() function with
apropriate defaults. like gtk_container_add() for boxes will just call
gtk_box_pack_start_defaults(,) with it's arguments, which in turn calls
gtk_box_pack_start(,, TRUE, TRUE, 0).
[snip]
>
> PACKING
>
[snip]
> void gtk_box_pack_start (GtkBox *box,
> GtkWidget *child,
> gint expand,
> gint fill,
> gint padding);
>
[snip]
> The fill argument to the gtk_box_pack functions control whether the extra
> space is allocated to the objects themselves (TRUE), or as extra padding
> in the box around these objects (FALSE). It only has an effect if the
> expand argument is also TRUE.
>
> [does the above sound right to you ?]
if the box is homogenous, all expand arguments of widgets that will be put
into it are implicitly set to TRUE. that means if you call
gtk_box_pack_start() with expand and fill set to FALSE, you might still
get a smaller allocation width for your widget if the box is homogenous.
>
> When creating a new box, the function looks like this:
>
> GtkWidget * gtk_hbox_new (gint homogeneous,
> gint spacing);
>
> The homogeneous argument to gtk_hbox_new (and the same for gtk_vbox_new)
> controls whether each object in the box has the same size (i.e. the same
> width in an hbox, or the same height in a vbox). If it is set, the expand
> argument to the gtk_box_pack routines is always turned on.
ups - sorry, you mentioned it here ;)
[snip]
> TIMEOUTS, IO, AND IDLE FUNCTIONS
>
> TIMEOUTS
>
> You may be wondering how you make gtk do useful work when in gtk_main.
> Well, you have several options. Using the following functions you can
> create a timeout function.
>
> gint gtk_timeout_add (guint32 interval,
> GtkFunction function,
> gpointer data);
>
> The first arguement is the number of milliseconds [doublecheck this]
^^^^^^^^^^^^ correct! ;)
[snip]
> This tutorial is written and maintained by Ian Main <slow@intergate.bc.ca>
> This is free software, you may use any of these examples in any of your
> code without including any disclaimer or copyright notice.
>
> Many thanks to the contributors
>
> Bawer Dagdeviren <chamele0n@geocities.com> (tutorial on menus)
>
> And to the following from whom I stole^H^H^H^H^H borrowed some material
>
> Raph Levien <raph@acm.org> (widget packing code and examples)
> Peter Mattis <petm@xcf.berkeley.edu>
>
> And to all of you who commented and helped refine this document.
>
> Thanks.
wow, that's quite a bunch of information so far - i'm impressed!
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]