Based on @serge_gubenko's answer, if you want to prevent vertical resizing only after the initial layout, you will need to set up a callback for the size-allocate .
Example:
static gint signal_connect_id_cb_dialog_size_allocate; static void cb_dialog_size_allocate (GtkWidget *window, GdkRectangle *allocation, gpointer user_data) { GdkGeometry hints; g_signal_handler_disconnect (G_OBJECT (dialog), signal_connect_id_cb_dialog_size_allocate); hints.min_width = 0; hints.max_width = G_MAXINT; hints.min_height = allocation->height; hints.max_height = allocation->height; gtk_window_set_geometry_hints (GTK_WINDOW (window), (GtkWidget *) NULL, &hints, (GdkWindowHints) (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE)); } int main(int argc, char * argv[]) { gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); signal_connect_id_cb_dialog_size_allocate = g_signal_connect (G_OBJECT (state->dialog), "size-allocate", G_CALLBACK (cb_dialog_size_allocate), (gpointer) NULL ); gtk_widget_show_all(window); gtk_main(); return 0; }
source share