has no way of exiting except to be killed by using the shell.</para>
<programlisting role="C">
-/* example-start base base.c */
+<!-- example-start base base.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>You can compile the above program with gcc using:</para>
hello world a la GTK.</para>
<programlisting role="C">
-/* example-start helloworld helloworld.c */
+<!-- example-start helloworld helloworld.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
topic, packing widgets.</para>
<programlisting role="C">
-/* example-start helloworld2 helloworld2.c */
+<!-- example-start helloworld2 helloworld2.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>Compile this program using the same linking arguments as our first
<title>Packing Demonstration Program</title>
<programlisting role="C">
-/* example-start packbox packbox.c */
+<!-- example-start packbox packbox.c -->
#include <stdio.h>
#include <stdlib.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>Here's the source code:</para>
<programlisting role="C">
-/* example-start table table.c */
+<!-- example-start table table.c -->
#include <gtk/gtk.h>
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
examples of using pixmaps later in the tutorial.</para>
<programlisting role="C">
-/* example-start buttons buttons.c */
+<!-- example-start buttons buttons.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>The xpm_label_box function could be used to pack xpm's and labels into
<para>The following example creates a radio button group with three buttons.</para>
<programlisting role="C">
-/* example-start radiobuttons radiobuttons.c */
+<!-- example-start radiobuttons radiobuttons.c -->
#include <gtk/gtk.h>
#include <glib.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<!-- TODO: check out gtk_radio_button_new_from_widget function - TRG -->
these widgets work for the user.</para>
<programlisting role="C">
-/* example-start rangewidgets rangewidgets.c */
+<!-- example-start rangewidgets rangewidgets.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>You will notice that the program does not call <literal>gtk_signal_connect</literal>
styles. You can ignore this for now as the <link linkend="sec-Frames">Frame</link> widget is explained later on.</para>
<programlisting role="C">
-/* example-start label label.c */
+<!-- example-start label label.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>Here's a brief example to illustrate their use.</para>
<programlisting role="C">
-/* example-start arrow arrow.c */
+<!-- example-start arrow arrow.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
code also shows you how to reset the Progress Bar.</para>
<programlisting role="C">
-/* example-start progressbar progressbar.c */
+<!-- example-start progressbar progressbar.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>The following is an example of using a pixmap in a button.</para>
<programlisting role="C">
-/* example-start pixmap pixmap.c */
+<!-- example-start pixmap pixmap.c -->
#include <gtk/gtk.h>
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>To load a file from an XPM data file called icon0.xpm in the current
desktop.</para>
<programlisting role="C">
-/* example-start wheelbarrow wheelbarrow.c */
+<!-- example-start wheelbarrow wheelbarrow.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>To make the wheelbarrow image sensitive, we could attach the button
Placement of the drawing area and the rulers is done using a table.</para>
<programlisting role="C">
-/* example-start rulers rulers.c */
+<!-- example-start rulers rulers.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
back off.</para>
<programlisting role="C">
-/* example-start statusbar statusbar.c */
+<!-- example-start statusbar statusbar.c -->
#include <gtk/gtk.h>
#include <glib.h>
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>The following code is an example of using an Entry widget.</para>
<programlisting role="C">
-/* example-start entry entry.c */
+<!-- example-start entry entry.c -->
#include <stdio.h>
#include <gtk/gtk.h>
gtk_main();
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>It's example time again.</para>
<programlisting role="C">
-/* example-start spinbutton spinbutton.c */
+<!-- example-start spinbutton spinbutton.c -->
#include <stdio.h>
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
example code.</para>
<programlisting role="C">
-/* example-start calendar calendar.c */
+<!-- example-start calendar calendar.c -->
/*
* Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Grönlund
* Copyright (C) 2000 Tony Gale
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
background color.</para>
<programlisting role="C">
-/* example-start colorsel colorsel.c */
+<!-- example-start colorsel colorsel.c -->
#include <glib.h>
#include <gdk/gdk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
screen, it does nothing as there is not a signal attached to it.</para>
<programlisting role="C">
-/* example-start filesel filesel.c */
+<!-- example-start filesel filesel.c -->
#include <gtk/gtk.h>
gtk_main ();
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
window reveals varying amounts of the label.</para>
<programlisting role="C">
-/* example-start eventbox eventbox.c */
+<!-- example-start eventbox eventbox.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>The following example illustrates how to use the Fixed Container.</para>
<programlisting role="C">
-/* example-start fixed fixed.c */
+<!-- example-start fixed fixed.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>The following code example illustrates the use of the Frame widget.</para>
<programlisting role="C">
-/* example-start frame frame.c */
+<!-- example-start frame frame.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
user resizes the top-level window.</para>
<programlisting role="C">
-/* example-start aspectframe aspectframe.c */
+<!-- example-start aspectframe aspectframe.c -->
#include <gtk/gtk.h>
gtk_main ();
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
window.</para>
<programlisting role="C">
-/* example-start paned paned.c */
+<!-- example-start paned paned.c -->
#define GTK_ENABLE_BROKEN
#include <stdio.h>
gtk_main ();
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
new to you.</para>
<programlisting role="C">
-/* example-start scrolledwin scrolledwin.c */
+<!-- example-start scrolledwin scrolledwin.c -->
#include <stdio.h>
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>Try playing with resizing the window. You'll notice how the scrollbars
for Button Boxes.</para>
<programlisting role="C">
-/* example-start buttonbox buttonbox.c */
+<!-- example-start buttonbox buttonbox.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
backward manner, and exit the program.</para>
<programlisting role="C">
-/* example-start notebook notebook.c */
+<!-- example-start notebook notebook.c -->
#include <stdio.h>
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>I hope this helps you on your way with creating notebooks for your
<title>A CList example</title>
<programlisting role="C">
-/* example-start clist clist.c */
+<!-- example-start clist clist.c -->
#include <gtk/gtk.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
can see when they are emitted.</para>
<programlisting role="C">
-/* example-start tree tree.c */
+<!-- example-start tree tree.c -->
#define GTK_ENABLE_BROKEN
#include <gtk/gtk.h>
gtk_main();
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<para>That should about do it. Let's take a look at an example to help clarify.</para>
<programlisting role="C">
-/* example-start menu menu.c */
+<!-- example-start menu menu.c -->
#include <stdio.h>
#include <gtk/gtk.h>
{
printf ("%s\n", string);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>You may also set a menu item to be insensitive and, using an accelerator
<para>Here is an example using the GTK item factory.</para>
<programlisting role="C">
-/* example-start menu itemfactory.c */
+<!-- example-start menu itemfactory.c -->
#include <gtk/gtk.h>
#include <strings.h>
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
<para>For now, there's only this example. An explanation and lots 'o' comments
<title>A GtkText Example</title>
<programlisting role="C">
-/* example-start text text.c */
+<!-- example-start text text.c -->
/* text.c */
return(0);
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
converted.</para>
<programlisting role="C">
-/* example-start selection gettargets.c */
+<!-- example-start selection gettargets.c -->
#include <gtk/gtk.h>
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
string representation of the time is returned.</para>
<programlisting role="C">
-/* example-start selection setselection.c */
+<!-- example-start selection setselection.c -->
#include <gtk/gtk.h>
#include <time.h>
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>
<title>tictactoe.h</title>
<programlisting role="C">
-/* example-start tictactoe tictactoe.h */
+<!-- example-start tictactoe tictactoe.h -->
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
#endif /* __TICTACTOE_H__ */
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect2>
<title>tictactoe.c</title>
<programlisting role="C">
-/* example-start tictactoe tictactoe.c */
+<!-- example-start tictactoe tictactoe.c -->
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
}
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect2>
<title>ttt_test.c</title>
<programlisting role="C">
-/* example-start tictactoe ttt_test.c */
+<!-- example-start tictactoe ttt_test.c -->
#include <gtk/gtk.h>
#include "tictactoe.h"
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect2>
<title>gtkdial.h</title>
<programlisting role="C">
-/* example-start gtkdial gtkdial.h */
+<!-- example-start gtkdial gtkdial.h -->
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
#endif /* __GTK_DIAL_H__ */
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect2>
<title>gtkdial.c</title>
<programlisting role="C">
-/* example-start gtkdial gtkdial.c */
+<!-- example-start gtkdial gtkdial.c -->
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
dial->old_value = adjustment->value;
}
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect2>
<title>scribble-simple.c</title>
<programlisting role="C">
-/* example-start scribble-simple scribble-simple.c */
+<!-- example-start scribble-simple scribble-simple.c -->
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect2>
<title>scribble-xinput.c</title>
<programlisting role="C">
-/* example-start scribble-xinput scribble-xinput.c */
+<!-- example-start scribble-xinput scribble-xinput.c -->
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
{
x = event->x;
y = event->y;
- gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
+ gdk_event_get_axis ((GdkEvent *)event, GDK_AXIS_PRESSURE, &pressure);
state = event->state;
}
return 0;
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect2>
by selecting them with the rightmost mouse button.</para>
<programlisting role="C">
-/* example-start list list.c */
+<!-- example-start list list.c -->
/* Include the GTK header files
* Include stdio.h, we need that for the printf() function
}
g_print("\n");
}
-/* example-end */
+<!-- example-end -->
</programlisting>
</sect1>