Re: change value of an adjustment
- From: Suleyman <sgulsuner hekim net>
- To: gtk listesi <gtk-app-devel-list gnome org>
- Subject: Re: change value of an adjustment
- Date: Thu, 01 Mar 2001 16:04:27 +0200
Try setting the value after creating the adjustment and widget:
GtkAdjustment *adj1;
adj1 = (GtkAdjustment *)gtk_adjustment_new(87, 87, 109, 0.1, 0.05,
0.05);
hscale2 = gtk_hscale_new(adj1);
gtk_pack_to_something(somewhere, hscale2);
gtk_widget_show(hscale2);
/* Later on... */
adj1 = gtk_range_get_adjustment(GTK_RANGE(hscale2));
gtk_adjustment_set_value(adj1, 50); /* Set value. */
gtk_adjustment_value_changed(adj1); /* Realize changes. */
hi, I'm trying this with that code, But it doesn't work. May be I can't
explain my problem first message.
this code may be more open?
any idea?
#include <gtk/gtk.h>
void change_adj (GtkScale *hscale, GtkAdjustment *set,
GtkAdjustment *adj ) {
adj = gtk_range_get_adjustment(GTK_RANGE(hscale));
gtk_adjustment_set_value(adj, 50); /* Set value. */
gtk_adjustment_value_changed(adj);
}
int main( int argc, char *argv[] )
{
GtkWidget *hscale;
GtkObject *adj;
GtkWidget *window;
GtkWidget *table;
GtkWidget *button;
gtk_init( &argc, &argv );
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_object_set_data (GTK_OBJECT (window), "window", window);
gtk_widget_set_uposition (window, 250, 250);
gtk_widget_set_usize (window, 400, 120);
table = gtk_table_new (2, 2, FALSE);
gtk_widget_show (table);
gtk_container_add (GTK_CONTAINER (window), table);
adj= gtk_adjustment_new(87, 87, 109, 0.1, 0.05, 0.05);
hscale = gtk_hscale_new(GTK_ADJUSTMENT (adj));
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale),
GTK_UPDATE_CONTINUOUS);
gtk_table_attach (GTK_TABLE (table), hscale, 0,2 , 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
gtk_widget_show (hscale);
button = gtk_button_new_with_label ("100");
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (table), button, 0, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (change_adj),
NULL);
gtk_widget_show_all(window);
gtk_main();
return(0);
}
--
Suleyman Gulsuner
Dokuz Eylul Universitesi
TIp Fakultesi
Inciralti/IZMIR
Love& Respect& Linux
}\/\/{
| |
(.)(.)
| C |)
(___ |
)__|
/ \\
/ \\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]