Commit 9f136301 authored by Matthias Clasen's avatar Matthias Clasen

More GTK+ 2.0 updates.

	* docs/tutorial/gtk-tut.sgml, docs/tutorial/images/*, examples/*: More
	 GTK+ 2.0 updates.

	* docs/tutorial/Makefile.am: build and dist the new tutorial, not
	the old Linuxdoc one.
parent 4d06c9d0
TUTORIAL_FR_FILES=html/gtk_tut_fr-1.html \
html/gtk_tut_fr-2.html \
html/gtk_tut_fr-3.html \
html/gtk_tut_fr-4.html \
html/gtk_tut_fr-5.html \
html/gtk_tut_fr-6.html \
html/gtk_tut_fr-7.html \
html/gtk_tut_fr-8.html \
html/gtk_tut_fr-9.html \
html/gtk_tut_fr-10.html \
html/gtk_tut_fr-11.html \
html/gtk_tut_fr-12.html \
html/gtk_tut_fr-13.html \
html/gtk_tut_fr-14.html \
html/gtk_tut_fr-15.html \
html/gtk_tut_fr-16.html \
html/gtk_tut_fr-17.html \
html/gtk_tut_fr-18.html \
html/gtk_tut_fr-19.html \
html/gtk_tut_fr-20.html \
html/gtk_tut_fr-21.html \
html/gtk_tut_fr-22.html \
html/gtk_tut_fr-23.html \
html/gtk_tut_fr-24.html \
html/gtk_tut_fr.html text/gtk_tut_fr.txt
.PHONY: html pdf
TUTORIAL_FILES=text/gtk_tut.txt html/gtk_tut.html \
html/gtk_tut.html \
html/gtk_tut-1.html \
html/gtk_tut-2.html \
html/gtk_tut-3.html \
html/gtk_tut-4.html \
html/gtk_tut-5.html \
html/gtk_tut-6.html \
html/gtk_tut-7.html \
html/gtk_tut-8.html \
html/gtk_tut-9.html \
html/gtk_tut-10.html \
html/gtk_tut-11.html \
html/gtk_tut-12.html \
html/gtk_tut-13.html \
html/gtk_tut-14.html \
html/gtk_tut-15.html \
html/gtk_tut-16.html \
html/gtk_tut-17.html \
html/gtk_tut-18.html \
html/gtk_tut-19.html \
html/gtk_tut-20.html \
html/gtk_tut-21.html \
html/gtk_tut-22.html \
html/gtk_tut-23.html \
html/gtk_tut-24.html \
html/gtk_tut-25.html \
html/gtk_tut-26.html \
html/gtk_tut-27.html \
html/gtk_tut-28.html \
html/gtk_tut-29.html \
html/gtk_tut-30.html \
html/gtk_tut-31.html
TUTORIAL_IT_FILES= html/gtk_tut_it.html \
html/gtk_tut_it-1.html \
html/gtk_tut_it-2.html \
html/gtk_tut_it-3.html \
html/gtk_tut_it-4.html \
html/gtk_tut_it-5.html \
html/gtk_tut_it-6.html \
html/gtk_tut_it-7.html \
html/gtk_tut_it-8.html \
html/gtk_tut_it-9.html \
html/gtk_tut_it-10.html \
html/gtk_tut_it-11.html \
html/gtk_tut_it-12.html \
html/gtk_tut_it-13.html \
html/gtk_tut_it-14.html \
html/gtk_tut_it-15.html \
html/gtk_tut_it-16.html \
html/gtk_tut_it-17.html \
html/gtk_tut_it-18.html \
html/gtk_tut_it-19.html \
html/gtk_tut_it-20.html \
html/gtk_tut_it-21.html \
html/gtk_tut_it-22.html \
html/gtk_tut_it-23.html \
html/gtk_tut_it-24.html \
text/gtk_tut_it.txt
GTKDOCS_FIX=$(srcdir)/../gtkdocs_fix
.PHONY: htmldir textdir tutorial tutorial_it tutorial_fr
htmldir:
(cd $(srcdir); mkdir -p html; cp gtk_tut*gif html)
textdir:
mkdir -p $(srcdir)/text
$(TUTORIAL_FILES): tutorial
$(TUTORIAL_FR_FILES): tutorial_fr
$(TUTORIAL_IT_FILES): tutorial_it
tutorial: htmldir textdir
(cd $(srcdir); sgml2html gtk_tut.sgml; \
perl $(GTKDOCS_FIX) gtk_tut*html; \
mv gtk_tut*html html/; \
sgml2txt gtk_tut.sgml; \
mv gtk_tut.txt text/)
EXTRA_DIST = \
gtk-tut.sgml \
images/arrow.png \
images/aspectframe.png \
images/base.png \
images/buttonbox.png \
images/buttons.png \
images/calendar.png \
images/colorsel.png \
images/entry.png \
images/eventbox.png \
images/filesel.png \
images/fixed.png \
images/frame.png \
images/gtkdial.png \
images/helloworld.png \
images/helloworld2.png \
images/label.png \
images/menu.png \
images/notebook.png \
images/packbox1.png \
images/packbox2.png \
images/paned.png \
images/progressbar.png \
images/radiobuttons.png \
images/rangewidgets.png \
images/rulers.png \
images/scribble.png \
images/scrolledwin.png \
images/spinbutton.png \
images/statusbar.png \
images/table.png \
images/tictactoe.png
tutorial_it: htmldir textdir
(cd $(srcdir); sgml2html --language=it gtk_tut_it.sgml; \
perl $(GTKDOCS_FIX) gtk_tut_it*html; \
mv gtk_tut_it*html html/; \
sgml2txt --language=it gtk_tut_it.sgml; \
mv gtk_tut_it.txt text/)
if HAVE_DOCBOOK
html:
(cd $(srcdir); \
db2html gtk-tut.sgml; \
mv gtk-tut html; \
mkdir html/images; \
cp images/*.png html/images)
tutorial_fr: htmldir textdir
(cd $(srcdir); sgml2html --language=fr gtk_tut_fr.sgml; \
perl $(GTKDOCS_FIX) gtk_tut_fr*html; \
mv gtk_tut_fr*html html/; \
sgml2txt --language=fr gtk_tut_fr.sgml; \
mv gtk_tut_fr.txt text/)
pdf:
(cd $(srcdir); db2pdf gtk-tut.sgml)
dist-hook: html pdf
cp -Rp $(srcdir)/html $(distdir)
cp -p $(srcdir)/gtk-tut.pdf $(distdir)
else
html:
echo "***"
echo "*** Warning: Tutorial not built"
echo "***"
EXTRA_DIST = \
gtk_tut.sgml \
gtk_tut_12.es.sgml \
gtk_tut_it.sgml \
gtk_tut_fr.sgml \
gtk_tut_packbox1.gif \
gtk_tut_packbox1.eps \
gtk_tut_packbox1.jpg \
gtk_tut_packbox2.gif \
gtk_tut_packbox2.eps \
gtk_tut_packbox2.jpg \
gtk_tut_table.gif \
gtk_tut_table.eps \
gtk_tut_table.jpg \
package_tutorial.sh \
package-db-tutorial.sh
pdf:
echo "***"
echo "*** Warning: Tutorial not built"
echo "***"
if HAVE_SGML2HTML
dist-hook: tutorial tutorial_it tutorial_fr
mkdir $(distdir)/html
cp -p $(srcdir)/html/*.html $(distdir)/html
cp -p $(srcdir)/html/*.gif $(distdir)/html
mkdir $(distdir)/text
cp -p $(srcdir)/text/*.txt $(distdir)/text
else
dist-hook:
echo "***"
echo "*** Warning: Tutorial not built"
echo "*** DISTRIBUTION IS INCOMPLETE"
echo "***"
endif
This diff is collapsed.
docs/tutorial/images/buttons.png

5.15 KB | W: | H:

docs/tutorial/images/buttons.png

3.97 KB | W: | H:

docs/tutorial/images/buttons.png
docs/tutorial/images/buttons.png
docs/tutorial/images/buttons.png
docs/tutorial/images/buttons.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -9,7 +9,7 @@ int main( int argc,
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_widget_show (window);
gtk_main ();
......
CC = gcc
CFLAGS = -Wall \
CFLAGS = -Wall -Wunused \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED \
......
......@@ -5,44 +5,31 @@
/* Create a new hbox with an image and a label packed into it
* and return the box. */
GtkWidget *xpm_label_box( GtkWidget *parent,
gchar *xpm_filename,
GtkWidget *xpm_label_box( gchar *xpm_filename,
gchar *label_text )
{
GtkWidget *box1;
GtkWidget *box;
GtkWidget *label;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
GtkWidget *image;
/* Create box for xpm and label */
box1 = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box1), 2);
/* Create box for image and label */
box = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box), 2);
/* Get the style of the button to get the
* background color. */
style = gtk_widget_get_style (parent);
/* Now on to the xpm stuff */
pixmap = gdk_pixmap_create_from_xpm (parent->window, &mask,
&style->bg[GTK_STATE_NORMAL],
xpm_filename);
pixmapwid = gtk_image_new_from_file (xpm_filename);
/* Now on to the image stuff */
image = gtk_image_new_from_file (xpm_filename);
/* Create a label for the button */
label = gtk_label_new (label_text);
/* Pack the pixmap and label into the box */
gtk_box_pack_start (GTK_BOX (box1),
pixmapwid, FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 3);
/* Pack the image and label into the box */
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3);
gtk_widget_show (pixmapwid);
gtk_widget_show (image);
gtk_widget_show (label);
return box1;
return box;
}
/* Our usual callback function */
......@@ -58,7 +45,7 @@ int main( int argc,
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *button;
GtkWidget *box1;
GtkWidget *box;
gtk_init (&argc, &argv);
......@@ -76,7 +63,6 @@ int main( int argc,
/* Sets the border width of the window. */
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
gtk_widget_realize (window);
/* Create a new button */
button = gtk_button_new ();
......@@ -86,12 +72,12 @@ int main( int argc,
G_CALLBACK (callback), (gpointer) "cool button");
/* This calls our box creating function */
box1 = xpm_label_box(window, "info.xpm", "cool button");
box = xpm_label_box ("info.xpm", "cool button");
/* Pack and show all our widgets */
gtk_widget_show (box1);
gtk_widget_show (box);
gtk_container_add (GTK_CONTAINER (button), box1);
gtk_container_add (GTK_CONTAINER (button), box);
gtk_widget_show (button);
......
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
......
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
......@@ -28,30 +29,30 @@
/* Forward declarations */
static void gtk_dial_class_init (GtkDialClass *klass);
static void gtk_dial_init (GtkDial *dial);
static void gtk_dial_destroy (GtkObject *object);
static void gtk_dial_realize (GtkWidget *widget);
static void gtk_dial_class_init (GtkDialClass *klass);
static void gtk_dial_init (GtkDial *dial);
static void gtk_dial_destroy (GtkObject *object);
static void gtk_dial_realize (GtkWidget *widget);
static void gtk_dial_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_dial_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_dial_expose (GtkWidget *widget,
GdkEventExpose *event);
static gint gtk_dial_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_dial_button_release (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_dial_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gint gtk_dial_timer (GtkDial *dial);
static void gtk_dial_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_dial_expose (GtkWidget *widget,
GdkEventExpose *event);
static gint gtk_dial_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_dial_button_release (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_dial_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gint gtk_dial_timer (GtkDial *dial);
static void gtk_dial_update_mouse (GtkDial *dial, gint x, gint y);
static void gtk_dial_update (GtkDial *dial);
static void gtk_dial_adjustment_changed (GtkAdjustment *adjustment,
gpointer data);
static void gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data);
static void gtk_dial_adjustment_changed (GtkAdjustment *adjustment,
gpointer data);
static void gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data);
/* Local data */
......@@ -140,12 +141,13 @@ gtk_dial_destroy (GtkObject *object)
{
GtkDial *dial;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_DIAL (object));
dial = GTK_DIAL (object);
if (dial->adjustment)
g_object_unref (G_OBJECT (dial->adjustment));
g_object_unref (GTK_OBJECT (dial->adjustment));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
......@@ -154,6 +156,7 @@ gtk_dial_destroy (GtkObject *object)
GtkAdjustment*
gtk_dial_get_adjustment (GtkDial *dial)
{
g_return_val_if_fail (dial != NULL, NULL);
g_return_val_if_fail (GTK_IS_DIAL (dial), NULL);
return dial->adjustment;
......@@ -163,6 +166,7 @@ void
gtk_dial_set_update_policy (GtkDial *dial,
GtkUpdateType policy)
{
g_return_if_fail (dial != NULL);
g_return_if_fail (GTK_IS_DIAL (dial));
dial->policy = policy;
......@@ -172,23 +176,24 @@ void
gtk_dial_set_adjustment (GtkDial *dial,
GtkAdjustment *adjustment)
{
g_return_if_fail (dial != NULL);
g_return_if_fail (GTK_IS_DIAL (dial));
if (dial->adjustment)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (dial->adjustment), NULL, (gpointer) dial);
g_object_unref (G_OBJECT (dial->adjustment));
g_signal_handlers_disconnect_by_func (GTK_OBJECT (dial->adjustment), NULL, (gpointer) dial);
g_object_unref (GTK_OBJECT (dial->adjustment));
}
dial->adjustment = adjustment;
g_object_ref (G_OBJECT (dial->adjustment));
g_object_ref (GTK_OBJECT (dial->adjustment));
g_signal_connect (G_OBJECT (adjustment), "changed",
G_CALLBACK (gtk_dial_adjustment_changed),
dial);
g_signal_connect (G_OBJECT (adjustment), "value_changed",
G_CALLBACK (gtk_dial_adjustment_value_changed),
dial);
g_signal_connect (GTK_OBJECT (adjustment), "changed",
GTK_SIGNAL_FUNC (gtk_dial_adjustment_changed),
(gpointer) dial);
g_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (gtk_dial_adjustment_value_changed),
(gpointer) dial);
dial->old_value = adjustment->value;
dial->old_lower = adjustment->lower;
......@@ -204,6 +209,7 @@ gtk_dial_realize (GtkWidget *widget)
GdkWindowAttr attributes;
gint attributes_mask;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_DIAL (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
......@@ -246,6 +252,7 @@ gtk_dial_size_allocate (GtkWidget *widget,
{
GtkDial *dial;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_DIAL (widget));
g_return_if_fail (allocation != NULL);
......@@ -278,6 +285,7 @@ gtk_dial_expose (GtkWidget *widget,
gint tick_length;
gint i, inc;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
......@@ -352,7 +360,7 @@ gtk_dial_expose (GtkWidget *widget,
for (i = 0; i <= inc; i++)
{
theta = ((gdouble)i*M_PI / (18*inc/24.) - M_PI/6.);
theta = ((gfloat)i*M_PI / (18*inc/24.) - M_PI/6.);
if ((theta - last) < (increment))
continue;
......@@ -412,6 +420,7 @@ gtk_dial_button_press (GtkWidget *widget,
double d_parallel;
double d_perpendicular;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
......@@ -451,6 +460,7 @@ gtk_dial_button_release (GtkWidget *widget,
{
GtkDial *dial;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
......@@ -467,7 +477,7 @@ gtk_dial_button_release (GtkWidget *widget,
if ((dial->policy != GTK_UPDATE_CONTINUOUS) &&
(dial->old_value != dial->adjustment->value))
gtk_adjustment_value_changed (dial->adjustment);
g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
}
return FALSE;
......@@ -481,6 +491,7 @@ gtk_dial_motion_notify (GtkWidget *widget,
GdkModifierType mods;
gint x, y, mask;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_DIAL (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
......@@ -520,10 +531,11 @@ gtk_dial_motion_notify (GtkWidget *widget,
static gint
gtk_dial_timer (GtkDial *dial)
{
g_return_val_if_fail (dial != NULL, FALSE);
g_return_val_if_fail (GTK_IS_DIAL (dial), FALSE);
if (dial->policy == GTK_UPDATE_DELAYED)
gtk_adjustment_value_changed (dial->adjustment);
g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
return FALSE;
}
......@@ -532,8 +544,9 @@ static void
gtk_dial_update_mouse (GtkDial *dial, gint x, gint y)
{
gint xc, yc;
gdouble old_value;
gfloat old_value;
g_return_if_fail (dial != NULL);
g_return_if_fail (GTK_IS_DIAL (dial));
xc = GTK_WIDGET(dial)->allocation.width / 2;
......@@ -558,7 +571,7 @@ gtk_dial_update_mouse (GtkDial *dial, gint x, gint y)
{
if (dial->policy == GTK_UPDATE_CONTINUOUS)
{
gtk_adjustment_value_changed (dial->adjustment);
g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
}
else
{
......@@ -580,8 +593,9 @@ gtk_dial_update_mouse (GtkDial *dial, gint x, gint y)
static void
gtk_dial_update (GtkDial *dial)
{
gdouble new_value;
gfloat new_value;
g_return_if_fail (dial != NULL);
g_return_if_fail (GTK_IS_DIAL (dial));
new_value = dial->adjustment->value;
......@@ -594,7 +608,8 @@ gtk_dial_update (GtkDial *dial)
if (new_value != dial->adjustment->value)
{
gtk_adjustment_set_value (dial->adjustment, new_value);
dial->adjustment->value = new_value;
g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
}
dial->angle = 7.*M_PI/6. - (new_value - dial->adjustment->lower) * 4.*M_PI/3. /
......@@ -605,12 +620,12 @@ gtk_dial_update (GtkDial *dial)
static void
gtk_dial_adjustment_changed (GtkAdjustment *adjustment,
gpointer data)
gpointer data)
{
GtkDial *dial;
g_return_if_fail (adjustment != NULL);
g_return_if_fail (GTK_IS_DIAL (data));
g_return_if_fail (data != NULL);
dial = GTK_DIAL (data);
......@@ -633,7 +648,7 @@ gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment,
GtkDial *dial;
g_return_if_fail (adjustment != NULL);
g_return_if_fail (GTK_IS_DIAL (data));
g_return_if_fail (data != NULL);
dial = GTK_DIAL (data);
......
/* Include the GTK header files
* Include stdio.h, we need that for the printf() function
*/
#include <gtk/gtk.h>
#include <stdio.h>
......
......@@ -14,11 +14,11 @@ gint delete_event( GtkWidget *widget,
/* Make a new hbox filled with button-labels. Arguments for the
* variables we're interested are passed in to this function.
* We do not show the box, but do show everything inside. */
GtkWidget *make_box( gint homogeneous,
gint spacing,
gint expand,
gint fill,
gint padding )
GtkWidget *make_box( gboolean homogeneous,
gint spacing,
gboolean expand,
gboolean fill,
guint padding )
{
GtkWidget *box;
GtkWidget *button;
......@@ -285,7 +285,7 @@ int main( int argc,
gtk_main ();
/* Control returns here when gtk_main_quit() is called, but not when
* gtk_exit is used. */
* exit() is used. */
return 0;
}
......@@ -57,8 +57,8 @@ int main( int argc,
the application */
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (close_application), NULL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (close_application), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
gtk_widget_show (window);
......
......@@ -20,7 +20,7 @@ int main( int argc,
GtkWidget *separator;
GSList *group;
gtk_init (&argc,&argv);
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
......@@ -50,9 +50,8 @@ int main( int argc,
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
gtk_widget_show (button);
button = gtk_radio_button_new_with_label(
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
"button3");
button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button),
"button3");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
gtk_widget_show (button);
......
......@@ -217,3 +217,4 @@ int main( int argc,
return 0;
}
/* text.c */
#define GTK_ENABLE_BROKEN
#include <stdio.h>
#include <gtk/gtk.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment