From eac6a03790d684b076d40759363e9c3b6bddb5d4 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Mon, 29 Jul 2019 15:22:42 -0700 Subject: [PATCH] LinGui: gtk4 port, fix summary tab preview image scaling GTK4 added a new widgit GtkPicture that is almost identical to GtkImage. The main difference appears to be that GtkImage now scales down the size of the given pixbuf using some undocumented algorithm. It's filling some of the space available, but not all of it. But it isn't a hard size limit because making the window bigger continues to make the image bigger. GtkPicture shows the pixbuf unscaled as expected. So use GtkPicture for the preview image :*( --- gtk/src/callbacks.c | 9 ++++++++- gtk/src/ghb3.ui | 45 ++++++++++++++++++++++++--------------------- gtk/src/ghb4.ui | 38 +++++++++++++++++++++----------------- gtk/src/preview.c | 7 ++++--- 4 files changed, 57 insertions(+), 42 deletions(-) diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 13c3373e9..1c5ebae68 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -2314,11 +2314,18 @@ ghb_update_summary_info(signal_user_data_t *ud) gtk_label_set_text(GTK_LABEL(widget), ""); widget = GHB_WIDGET(ud->builder, "dimensions_summary"); gtk_label_set_text(GTK_LABEL(widget), "--"); + widget = GHB_WIDGET(ud->builder, "summary_image"); + gtk_widget_show(widget); widget = GHB_WIDGET(ud->builder, "preview_button_image"); - ghb_image_set_from_icon_name(GTK_IMAGE(widget), "hb-icon", 128); + gtk_widget_hide(widget); return; } + widget = GHB_WIDGET(ud->builder, "summary_image"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "preview_button_image"); + gtk_widget_show(widget); + // Video Track const hb_encoder_t * video_encoder; const hb_rate_t * fps; diff --git a/gtk/src/ghb3.ui b/gtk/src/ghb3.ui index 1c175be0a..e7d1b8d95 100644 --- a/gtk/src/ghb3.ui +++ b/gtk/src/ghb3.ui @@ -3106,35 +3106,38 @@ sync for broken players that do not honor MP4 edit lists. - - vertical + True False + 4 + 4 + 4 + True + fill True - 12 - 0 - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - False - 4 - 4 - 4 - True - 128 - hb-icon - - - - 0 - - + 128 + hb-icon 1 + + + True + False + 4 + 4 + 4 + True + 128 + hb-icon + + + + 2 + + 0 diff --git a/gtk/src/ghb4.ui b/gtk/src/ghb4.ui index 5bc690b31..d90ac98df 100644 --- a/gtk/src/ghb4.ui +++ b/gtk/src/ghb4.ui @@ -2674,26 +2674,30 @@ sync for broken players that do not honor MP4 edit lists. - - vertical + True False + 4 + 4 + 4 + True + fill True - 12 - 0 - - - True - False - 4 - 4 - 4 - True - 128 - hb-icon - - - + 128 + hb-icon + + + + + False + False + 4 + 4 + 4 + True + fill + True + diff --git a/gtk/src/preview.c b/gtk/src/preview.c index 6721b3284..3272d4787 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -861,7 +861,11 @@ static void set_mini_preview_image(signal_user_data_t *ud, GdkPixbuf * pix) GtkWidget * widget; widget = GHB_WIDGET (ud->builder, "preview_button_image"); +#if GTK_CHECK_VERSION(3, 90, 0) + gtk_picture_set_pixbuf(GTK_PICTURE(widget), scaled_preview); +#else gtk_image_set_from_pixbuf(GTK_IMAGE(widget), scaled_preview); +#endif g_object_unref(scaled_preview); } } @@ -932,7 +936,6 @@ init_preview_image(signal_user_data_t *ud) GtkWidget *widget; gint width, height; - g_debug("set_preview_button_image ()"); gint title_id, titleindex; const hb_title_t *title; @@ -1094,8 +1097,6 @@ preview_button_size_allocate_cb( g_debug("nothing to do"); return; } - g_debug("prev allocate %d x %d", ud->preview->button_width, - ud->preview->button_height); ud->preview->button_width = width; ud->preview->button_height = height; set_mini_preview_image(ud, ud->preview->pix); -- 2.40.0