Re: Trouble setting the value of a GtkAdjustment
- From: cecashon aol com
- To: richard rshann plus com, gtk-app-devel-list gnome org
- Subject: Re: Trouble setting the value of a GtkAdjustment
- Date: Mon, 24 Apr 2017 14:48:07 -0400
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.
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]