From 9aa8c90399f482128c5cf8d8ec7338e552bd5a18 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 28 May 2023 04:32:42 +0300 Subject: [PATCH 35/35] gtk4: Fix science dialog ScrolledWindow / Viewport confusion See osdn #47445 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/repodlgs.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/client/gui-gtk-4.0/repodlgs.c b/client/gui-gtk-4.0/repodlgs.c index 79cdcd037b..ff0a482c5e 100644 --- a/client/gui-gtk-4.0/repodlgs.c +++ b/client/gui-gtk-4.0/repodlgs.c @@ -275,7 +275,7 @@ static void science_diagram_update(GtkDrawingArea *widget, cairo_t *cr, GtkAdjustment *vadjustment; gint hadjustment_value; gint vadjustment_value; - GtkScrolledWindow *sw; + GtkViewport *vp; if (!tileset_is_fully_loaded()) { return; @@ -284,9 +284,9 @@ static void science_diagram_update(GtkDrawingArea *widget, cairo_t *cr, get_reqtree_dimensions(reqtree, &rtwidth, &rtheight); gtk_widget_set_size_request(GTK_WIDGET(widget), rtwidth, rtheight); - sw = GTK_SCROLLED_WINDOW(gtk_widget_get_parent(GTK_WIDGET(widget))); - hadjustment = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(sw)); - vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(sw)); + vp = GTK_VIEWPORT(gtk_widget_get_parent(GTK_WIDGET(widget))); + hadjustment = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(vp)); + vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vp)); hadjustment_value = (gint)gtk_adjustment_get_value(hadjustment); vadjustment_value = (gint)gtk_adjustment_get_value(vadjustment); @@ -350,27 +350,23 @@ static void science_diagram_data(GtkWidget *widget, bool show_all) ****************************************************************************/ static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech) { - GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(gtk_widget_get_parent(diagram)); + GtkViewport *vp = GTK_VIEWPORT(gtk_widget_get_parent(diagram)); struct reqtree *reqtree; int x, y, width, height; - if (!GTK_IS_SCROLLED_WINDOW(sw)) { - return; - } - reqtree = g_object_get_data(G_OBJECT(diagram), "reqtree"); get_reqtree_dimensions(reqtree, &width, &height); if (find_tech_on_reqtree(reqtree, tech, &x, &y, NULL, NULL)) { GtkAdjustment *adjust = NULL; gdouble value; - adjust = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(sw)); + adjust = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(vp)); value = (gtk_adjustment_get_lower(adjust) + gtk_adjustment_get_upper(adjust) - gtk_adjustment_get_page_size(adjust)) / width * x; gtk_adjustment_set_value(adjust, value); - adjust = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw)); + adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vp)); value = (gtk_adjustment_get_lower(adjust) + gtk_adjustment_get_upper(adjust) - gtk_adjustment_get_page_size(adjust)) / height * y; -- 2.39.2