summaryrefslogtreecommitdiff
path: root/examples/gtkdial
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gtkdial')
-rw-r--r--examples/gtkdial/Makefile10
-rw-r--r--examples/gtkdial/dial_test.c28
-rw-r--r--examples/gtkdial/gtkdial.c68
-rw-r--r--examples/gtkdial/gtkdial.h4
4 files changed, 61 insertions, 49 deletions
diff --git a/examples/gtkdial/Makefile b/examples/gtkdial/Makefile
index 1c388104e..0f83a9df0 100644
--- a/examples/gtkdial/Makefile
+++ b/examples/gtkdial/Makefile
@@ -1,14 +1,20 @@
CC = gcc
+CFLAGS = -Wall \
+ -DG_DISABLE_DEPRECATED \
+ -DGDK_DISABLE_DEPRECATED \
+ -DGDK_PIXBUF_DISABLE_DEPRECATED \
+ -DGTK_DISABLE_DEPRECATED
+
dial_test: gtkdial.o dial_test.o
$(CC) dial_test.o gtkdial.o -o dial_test `pkg-config --libs gtk+-2.0`
dial_test.o: dial_test.c gtkdial.h
- $(CC) `pkg-config --cflags gtk+-2.0` -c dial_test.c -o dial_test.o
+ $(CC) -c dial_test.c -o dial_test.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags`
gtkdial.o: gtkdial.c gtkdial.h
- $(CC) `pkg-config --cflags gtk+-2.0` -c gtkdial.c -o gtkdial.o
+ $(CC) -c gtkdial.c -o gtkdial.o $(CFLAGS) `pkg-config gtk+-2.0 --cflags`
clean:
rm -f *.o dial_test
diff --git a/examples/gtkdial/dial_test.c b/examples/gtkdial/dial_test.c
index ebcea0c7d..e753cc198 100644
--- a/examples/gtkdial/dial_test.c
+++ b/examples/gtkdial/dial_test.c
@@ -1,17 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
#include <gtk/gtk.h>
#include "gtkdial.h"
-void
-value_changed (GtkAdjustment *adjustment, GtkWidget *label)
+void value_changed( GtkAdjustment *adjustment,
+ GtkWidget *label )
{
char buffer[16];
sprintf(buffer,"%4.2f",adjustment->value);
- gtk_label_set (GTK_LABEL (label), buffer);
+ gtk_label_set_text (GTK_LABEL (label), buffer);
}
-int
-main (int argc, char *argv[])
+int main( int argc,
+ char *argv[])
{
GtkWidget *window;
GtkAdjustment *adjustment;
@@ -26,10 +28,10 @@ main (int argc, char *argv[])
gtk_window_set_title (GTK_WINDOW (window), "Dial");
- gtk_signal_connect (GTK_OBJECT (window), "destroy",
- GTK_SIGNAL_FUNC (gtk_exit), NULL);
+ g_signal_connect (GTK_OBJECT (window), "destroy",
+ GTK_SIGNAL_FUNC (exit), NULL);
- gtk_container_border_width (GTK_CONTAINER (window), 10);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 10);
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -37,23 +39,23 @@ main (int argc, char *argv[])
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
- gtk_box_pack_start (GTK_BOX(vbox), frame, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (vbox), frame);
gtk_widget_show (frame);
- adjustment = GTK_ADJUSTMENT(gtk_adjustment_new (0, -1.0, 1.0, 0.01, 0.1, 0));
+ adjustment = GTK_ADJUSTMENT(gtk_adjustment_new (0, 0, 100, 0.01, 0.1, 0));
dial = gtk_dial_new(adjustment);
gtk_dial_set_update_policy (GTK_DIAL(dial), GTK_UPDATE_DELAYED);
- /* gtk_widget_set_usize (dial, 100, 100); */
+ /* gtk_widget_set_size_request (dial, 100, 100); */
gtk_container_add (GTK_CONTAINER (frame), dial);
gtk_widget_show (dial);
label = gtk_label_new("0.00");
- gtk_box_pack_start (GTK_BOX(vbox), label, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX(vbox), label, 0, 0, 0);
gtk_widget_show (label);
- gtk_signal_connect (GTK_OBJECT(adjustment), "value_changed",
+ g_signal_connect (GTK_OBJECT(adjustment), "value_changed",
GTK_SIGNAL_FUNC (value_changed), label);
gtk_widget_show (window);
diff --git a/examples/gtkdial/gtkdial.c b/examples/gtkdial/gtkdial.c
index 51e70d2d6..0bd89fd13 100644
--- a/examples/gtkdial/gtkdial.c
+++ b/examples/gtkdial/gtkdial.c
@@ -1,4 +1,3 @@
-/* example-start gtkdial gtkdial.c */
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
@@ -59,25 +58,27 @@ static void gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment,
static GtkWidgetClass *parent_class = NULL;
-guint
+GType
gtk_dial_get_type ()
{
- static guint dial_type = 0;
+ static GType dial_type = 0;
if (!dial_type)
{
- GtkTypeInfo dial_info =
+ static const GTypeInfo dial_info =
{
- "GtkDial",
- sizeof (GtkDial),
sizeof (GtkDialClass),
- (GtkClassInitFunc) gtk_dial_class_init,
- (GtkObjectInitFunc) gtk_dial_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
+ NULL,
+ NULL,
+ (GClassInitFunc) gtk_dial_class_init,
+ NULL,
+ NULL,
+ sizeof (GtkDial),
+ 0,
+ (GInstanceInitFunc) gtk_dial_init,
};
- dial_type = gtk_type_unique (gtk_widget_get_type (), &dial_info);
+ dial_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkDial", &dial_info, 0);
}
return dial_type;
@@ -125,7 +126,7 @@ gtk_dial_new (GtkAdjustment *adjustment)
{
GtkDial *dial;
- dial = gtk_type_new (gtk_dial_get_type ());
+ dial = g_object_new (gtk_dial_get_type (), NULL);
if (!adjustment)
adjustment = (GtkAdjustment*) gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
@@ -146,7 +147,7 @@ gtk_dial_destroy (GtkObject *object)
dial = GTK_DIAL (object);
if (dial->adjustment)
- gtk_object_unref (GTK_OBJECT (dial->adjustment));
+ g_object_unref (GTK_OBJECT (dial->adjustment));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@@ -180,18 +181,18 @@ gtk_dial_set_adjustment (GtkDial *dial,
if (dial->adjustment)
{
- gtk_signal_disconnect_by_data (GTK_OBJECT (dial->adjustment), (gpointer) dial);
- gtk_object_unref (GTK_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;
- gtk_object_ref (GTK_OBJECT (dial->adjustment));
+ g_object_ref (GTK_OBJECT (dial->adjustment));
- gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
- (GtkSignalFunc) gtk_dial_adjustment_changed,
+ g_signal_connect (GTK_OBJECT (adjustment), "changed",
+ GTK_SIGNAL_FUNC (gtk_dial_adjustment_changed),
(gpointer) dial);
- gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
- (GtkSignalFunc) gtk_dial_adjustment_value_changed,
+ g_signal_connect (GTK_OBJECT (adjustment), "value_changed",
+ GTK_SIGNAL_FUNC (gtk_dial_adjustment_value_changed),
(gpointer) dial);
dial->old_value = adjustment->value;
@@ -331,20 +332,23 @@ gtk_dial_expose (GtkWidget *widget,
blankstyle->black_gc =
widget->style->bg_gc[GTK_STATE_NORMAL];
- gtk_draw_polygon (blankstyle,
+ gtk_paint_polygon (blankstyle,
widget->window,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
+ NULL,
+ widget,
+ NULL,
points, 5,
FALSE);
- gtk_style_unref(blankstyle);
+ g_object_unref(blankstyle);
/* Draw ticks */
if ((upper - lower) == 0)
- return;
+ return FALSE;
increment = (100*M_PI)/(dial->radius*dial->radius);
@@ -393,10 +397,13 @@ gtk_dial_expose (GtkWidget *widget,
points[4].y = points[0].y;
- gtk_draw_polygon (widget->style,
+ gtk_paint_polygon (widget->style,
widget->window,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
+ NULL,
+ widget,
+ NULL,
points, 5,
TRUE);
@@ -470,7 +477,7 @@ gtk_dial_button_release (GtkWidget *widget,
if ((dial->policy != GTK_UPDATE_CONTINUOUS) &&
(dial->old_value != dial->adjustment->value))
- gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
+ g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
}
return FALSE;
@@ -528,7 +535,7 @@ gtk_dial_timer (GtkDial *dial)
g_return_val_if_fail (GTK_IS_DIAL (dial), FALSE);
if (dial->policy == GTK_UPDATE_DELAYED)
- gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
+ g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
return FALSE;
}
@@ -564,11 +571,11 @@ gtk_dial_update_mouse (GtkDial *dial, gint x, gint y)
{
if (dial->policy == GTK_UPDATE_CONTINUOUS)
{
- gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
+ g_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
}
else
{
- gtk_widget_draw (GTK_WIDGET(dial), NULL);
+ gtk_widget_queue_draw (GTK_WIDGET (dial));
if (dial->policy == GTK_UPDATE_DELAYED)
{
@@ -602,13 +609,13 @@ gtk_dial_update (GtkDial *dial)
if (new_value != dial->adjustment->value)
{
dial->adjustment->value = new_value;
- gtk_signal_emit_by_name (GTK_OBJECT (dial->adjustment), "value_changed");
+ 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. /
(dial->adjustment->upper - dial->adjustment->lower);
- gtk_widget_draw (GTK_WIDGET(dial), NULL);
+ gtk_widget_queue_draw (GTK_WIDGET (dial));
}
static void
@@ -652,4 +659,3 @@ gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment,
dial->old_value = adjustment->value;
}
}
-/* example-end */
diff --git a/examples/gtkdial/gtkdial.h b/examples/gtkdial/gtkdial.h
index 781943548..850d7ea1e 100644
--- a/examples/gtkdial/gtkdial.h
+++ b/examples/gtkdial/gtkdial.h
@@ -1,4 +1,3 @@
-/* example-start gtkdial gtkdial.h */
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
@@ -77,7 +76,7 @@ struct _GtkDialClass
GtkWidget* gtk_dial_new (GtkAdjustment *adjustment);
-guint gtk_dial_get_type (void);
+GtkType gtk_dial_get_type (void);
GtkAdjustment* gtk_dial_get_adjustment (GtkDial *dial);
void gtk_dial_set_update_policy (GtkDial *dial,
GtkUpdateType policy);
@@ -90,4 +89,3 @@ void gtk_dial_set_adjustment (GtkDial *dial,
#endif /* __GTK_DIAL_H__ */
-/* example-end */