On Mon, 2017-04-24 at 14:48 -0400, cecas...@aol.com wrote:
> 
> Hi Richard,
> 
> It looks like how you add containers makes a difference in this case.
> Also the window placement might have to be adjusted after the window
> is shown. Here is a try at it.

Thank you very much - it seems you are right, by moving the
gtk_container_add() calls until just before the gtk_show_all() the
GtkAdjustment widget becomes controllable. The values it has are no
longer what were set when it was created however, so I set it with this
code after the gtk_show_all() call:

    gdouble lower, upper, page;
    lower = gtk_adjustment_get_lower (hadj);
    upper = gtk_adjustment_get_upper (hadj);
    page = gtk_adjustment_get_page_size (hadj);
    //g_print ("Lower ... %f %f %f\n", lower, upper, page);
    gtk_adjustment_set_value (hadj, (upper-page - lower)/2);

which gets the horizontal slider in the middle.

The values when printed out are:

Lower ... 0.000000 1901.000000 800.000000

where those values come from is a mystery. And, I suppose the way it
changes depending on the order of placing the widgets inside each other
will have to remain a mystery too.

Thanks once again,

Richard


> 
> Eric
> 
> 
> //gcc -Wall adj1.c -o adj1 `pkg-config --cflags --libs gtk+-3.0`
> //Tested on Ubuntu16.04 and GTK3.18
> 
> #include<gtk/gtk.h>
> 
> int main(int argc, char **argv)
>  {
>    gtk_init(&argc, &argv);
> 
>    GtkWidget *keyboard_window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
>    gtk_window_set_title(GTK_WINDOW(keyboard_window), "Keyboard
> Window");
>    gtk_window_set_default_size(GTK_WINDOW(keyboard_window), 200, 200);
>    gtk_window_set_position(GTK_WINDOW(keyboard_window),
> GTK_WIN_POS_CENTER);
>    g_signal_connect(keyboard_window, "destroy",
> G_CALLBACK(gtk_main_quit), NULL);
> 
>    GtkWidget *label=gtk_label_new("Label");
>    gtk_widget_set_size_request(label, 400, 400);
> 
>    //GtkAdjustment *ADJ = gtk_adjustment_new (1.5, 0.0, 2.0, 0.01,
> 0.01, 0.01);
>    //GtkWidget *sw = gtk_scrolled_window_new (ADJ , gtk_adjustment_new
> (1.5, 0.0, 2.0, 0.01, 0.01, 0.01));
>    GtkAdjustment *ADJ = gtk_adjustment_new (100.0, 0.0, 400.0, 0.0,
> 0.0, 0.0);
>    GtkWidget *sw = gtk_scrolled_window_new (ADJ , ADJ);
> 
>    //gtk_adjustment_set_value (ADJ, 1.22222);
>    g_print ("value %p is %f\n", ADJ, gtk_adjustment_get_value (ADJ));
> 
>    GtkWidget *keyboard=gtk_grid_new();
>    gtk_grid_attach(GTK_GRID(keyboard), label, 0, 0, 1, 1);
>    gtk_container_add(GTK_CONTAINER(sw), keyboard);  
>    gtk_container_add(GTK_CONTAINER(keyboard_window), sw);
> 
>    //gtk_container_add(GTK_CONTAINER(keyboard_window), sw);
>    //GtkWidget *keyboard=gtk_grid_new();
>    //gtk_grid_attach(GTK_GRID(keyboard), label, 0, 0, 1, 1);  
>    //gtk_container_add(GTK_CONTAINER(sw), keyboard);
> 
>    gtk_widget_show_all(keyboard_window);
> 
>    gtk_adjustment_set_value (ADJ, 100.0);
> 
>    gtk_main();
> 
>    return 0;  
>  }
> 
> 


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to