summaryrefslogtreecommitdiff
path: root/examples/rangewidgets
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2002-02-19 01:25:26 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2002-02-19 01:25:26 +0000
commitbd73a312f06ad6d1a448cab873f309264ee24b46 (patch)
tree62afa03ae970e3260e0677d02a2391e1d0350a1d /examples/rangewidgets
parentc3940d4a07a6855998e1d991afeb92f3253bef56 (diff)
downloadgtk+-bd73a312f06ad6d1a448cab873f309264ee24b46.tar.gz
Trivial formatting fixes to all examples, simple functional fixes to
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting fixes to all examples, simple functional fixes to rangewidgets example.
Diffstat (limited to 'examples/rangewidgets')
-rw-r--r--examples/rangewidgets/rangewidgets.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/examples/rangewidgets/rangewidgets.c b/examples/rangewidgets/rangewidgets.c
index 4c38e8c305..5f0450bd4b 100644
--- a/examples/rangewidgets/rangewidgets.c
+++ b/examples/rangewidgets/rangewidgets.c
@@ -33,6 +33,11 @@ void cb_page_size( GtkAdjustment *get,
* adjustment to the value specified by the "Page Size" scale */
set->page_size = get->value;
set->page_increment = get->value;
+
+ gtk_adjustment_set_value (set, CLAMP (set->value,
+ set->lower,
+ (set->upper - set->page_size)));
+
/* Now emit the "changed" signal to reconfigure all the widgets that
* are attached to this adjustment */
g_signal_emit_by_name (GTK_OBJECT (set), "changed");
@@ -56,7 +61,7 @@ GtkWidget *make_menu_item( gchar *name,
item = gtk_menu_item_new_with_label (name);
g_signal_connect (GTK_OBJECT (item), "activate",
- callback, data);
+ callback, data);
gtk_widget_show (item);
return item;
@@ -88,8 +93,8 @@ void create_range_controls( void )
/* Standard window-creating stuff */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (GTK_OBJECT (window), "destroy",
- GTK_SIGNAL_FUNC(gtk_main_quit),
- NULL);
+ GTK_SIGNAL_FUNC (gtk_main_quit),
+ NULL);
gtk_window_set_title (GTK_WINDOW (window), "range controls");
box1 = gtk_vbox_new (FALSE, 0);
@@ -118,7 +123,7 @@ void create_range_controls( void )
/* Reuse the same adjustment */
hscale = gtk_hscale_new (GTK_ADJUSTMENT (adj1));
- gtk_widget_set_size_request (GTK_WIDGET (hscale), 200, 30);
+ gtk_widget_set_size_request (GTK_WIDGET (hscale), 200, -1);
scale_set_default_values (GTK_SCALE (hscale));
gtk_box_pack_start (GTK_BOX (box3), hscale, TRUE, TRUE, 0);
gtk_widget_show (hscale);
@@ -141,7 +146,7 @@ void create_range_controls( void )
button = gtk_check_button_new_with_label("Display value on scale widgets");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_signal_connect (GTK_OBJECT (button), "toggled",
- GTK_SIGNAL_FUNC(cb_draw_value), NULL);
+ GTK_SIGNAL_FUNC (cb_draw_value), NULL);
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
gtk_widget_show (button);
@@ -153,11 +158,11 @@ void create_range_controls( void )
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
gtk_widget_show (label);
- opt = gtk_option_menu_new();
- menu = gtk_menu_new();
+ opt = gtk_option_menu_new ();
+ menu = gtk_menu_new ();
item = make_menu_item ("Top",
- GTK_SIGNAL_FUNC(cb_pos_menu_select),
+ GTK_SIGNAL_FUNC (cb_pos_menu_select),
GINT_TO_POINTER (GTK_POS_TOP));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -170,7 +175,7 @@ void create_range_controls( void )
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
item = make_menu_item ("Right", GTK_SIGNAL_FUNC (cb_pos_menu_select),
- GINT_TO_POINTER (GTK_POS_RIGHT));
+ GINT_TO_POINTER (GTK_POS_RIGHT));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_option_menu_set_menu (GTK_OPTION_MENU (opt), menu);
@@ -189,8 +194,8 @@ void create_range_controls( void )
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, FALSE, 0);
gtk_widget_show (label);
- opt = gtk_option_menu_new();
- menu = gtk_menu_new();
+ opt = gtk_option_menu_new ();
+ menu = gtk_menu_new ();
item = make_menu_item ("Continuous",
GTK_SIGNAL_FUNC (cb_update_menu_select),
@@ -198,8 +203,8 @@ void create_range_controls( void )
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
item = make_menu_item ("Discontinuous",
- GTK_SIGNAL_FUNC (cb_update_menu_select),
- GINT_TO_POINTER (GTK_UPDATE_DISCONTINUOUS));
+ GTK_SIGNAL_FUNC (cb_update_menu_select),
+ GINT_TO_POINTER (GTK_UPDATE_DISCONTINUOUS));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
item = make_menu_item ("Delayed",
@@ -225,7 +230,7 @@ void create_range_controls( void )
adj2 = gtk_adjustment_new (1.0, 0.0, 5.0, 1.0, 1.0, 0.0);
g_signal_connect (GTK_OBJECT (adj2), "value_changed",
- GTK_SIGNAL_FUNC (cb_digits_scale), NULL);
+ GTK_SIGNAL_FUNC (cb_digits_scale), NULL);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adj2));
gtk_scale_set_digits (GTK_SCALE (scale), 0);
gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0);
@@ -245,7 +250,7 @@ void create_range_controls( void )
adj2 = gtk_adjustment_new (1.0, 1.0, 101.0, 1.0, 1.0, 0.0);
g_signal_connect (GTK_OBJECT (adj2), "value_changed",
- GTK_SIGNAL_FUNC (cb_page_size), adj1);
+ GTK_SIGNAL_FUNC (cb_page_size), adj1);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adj2));
gtk_scale_set_digits (GTK_SCALE (scale), 0);
gtk_box_pack_start (GTK_BOX (box2), scale, TRUE, TRUE, 0);
@@ -265,8 +270,8 @@ void create_range_controls( void )
button = gtk_button_new_with_label ("Quit");
g_signal_connect_swapped (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC(gtk_main_quit),
- NULL);
+ GTK_SIGNAL_FUNC (gtk_main_quit),
+ NULL);
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
@@ -278,11 +283,11 @@ void create_range_controls( void )
int main( int argc,
char *argv[] )
{
- gtk_init(&argc, &argv);
+ gtk_init (&argc, &argv);
- create_range_controls();
+ create_range_controls ();
- gtk_main();
+ gtk_main ();
return 0;
}