2002-02-25 01:47:44 +00:00
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1998-03-23 06:36:09 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gtkdial.h"
|
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
void value_changed( GtkAdjustment *adjustment,
|
|
|
|
GtkWidget *label )
|
1998-03-23 06:36:09 +00:00
|
|
|
{
|
|
|
|
char buffer[16];
|
|
|
|
|
2011-01-05 21:15:42 +00:00
|
|
|
sprintf(buffer,"%4.2f",gtk_adjustment_get_value (adjustment));
|
2002-02-16 23:52:30 +00:00
|
|
|
gtk_label_set_text (GTK_LABEL (label), buffer);
|
1998-03-23 06:36:09 +00:00
|
|
|
}
|
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
int main( int argc,
|
|
|
|
char *argv[])
|
1998-03-23 06:36:09 +00:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
GtkWidget *dial;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-23 06:36:09 +00:00
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-23 06:36:09 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Dial");
|
2008-08-11 18:36:07 +00:00
|
|
|
|
|
|
|
g_signal_connect (window, "destroy",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (exit), NULL);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
1998-03-23 06:36:09 +00:00
|
|
|
|
2010-10-30 03:00:32 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 5);
|
1998-03-23 06:36:09 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_widget_show (vbox);
|
1998-03-23 06:36:09 +00:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2002-02-16 23:52:30 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), frame);
|
2008-08-11 18:36:07 +00:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2010-09-27 13:10:12 +00:00
|
|
|
adjustment = gtk_adjustment_new (0, 0, 100, 0.01, 0.1, 0);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
2002-02-19 01:25:26 +00:00
|
|
|
dial = gtk_dial_new (adjustment);
|
|
|
|
gtk_dial_set_update_policy (GTK_DIAL (dial), GTK_UPDATE_DELAYED);
|
2002-02-16 23:52:30 +00:00
|
|
|
/* gtk_widget_set_size_request (dial, 100, 100); */
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-23 06:36:09 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), dial);
|
|
|
|
gtk_widget_show (dial);
|
|
|
|
|
2002-02-19 01:25:26 +00:00
|
|
|
label = gtk_label_new ("0.00");
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), label, 0, 0, 0);
|
1998-03-23 06:36:09 +00:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2008-08-11 18:36:07 +00:00
|
|
|
g_signal_connect (adjustment, "value-changed",
|
|
|
|
G_CALLBACK (value_changed),
|
|
|
|
label);
|
|
|
|
|
1998-03-23 06:36:09 +00:00
|
|
|
gtk_widget_show (window);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-23 06:36:09 +00:00
|
|
|
gtk_main ();
|
2008-08-11 18:36:07 +00:00
|
|
|
|
1998-03-23 06:36:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|