]> granicus.if.org Git - handbrake/commitdiff
LinGui: gtk4 port, fix summary tab preview image scaling
authorJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 29 Jul 2019 22:22:42 +0000 (15:22 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 29 Jul 2019 22:22:42 +0000 (15:22 -0700)
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
gtk/src/ghb3.ui
gtk/src/ghb4.ui
gtk/src/preview.c

index 13c3373e9c5fbae0a7dfb44a6c3bd1c48a0f9ff0..1c5ebae684a60b079adf4fae8e995d969204cc14 100644 (file)
@@ -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;
index 1c175be0a29ac5226764c9e7a0ae34b1311129fc..e7d1b8d958757735abacf344a86c50f119b4ea12 100644 (file)
@@ -3106,35 +3106,38 @@ sync for broken players that do not honor MP4 edit lists.</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox9">
-                        <property name="orientation">vertical</property>
+                      <object class="GtkImage" id="summary_image">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <property name="margin-bottom">4</property>
+                        <property name="margin-start">4</property>
+                        <property name="margin-end">4</property>
+                        <property name="vexpand">True</property>
+                        <property name="valign">fill</property>
                         <property name="expand">True</property>
-                        <property name="margin-top">12</property>
-                        <property name="margin-end">0</property>
-                        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <child>
-                          <object class="GtkImage" id="preview_button_image">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="margin-bottom">4</property>
-                            <property name="margin-start">4</property>
-                            <property name="margin-end">4</property>
-                            <property name="expand">True</property>
-                            <property name="pixel_size">128</property>
-                            <property name="icon_name">hb-icon</property>
-                            <signal name="size-allocate" handler="preview_button_size_allocate_cb" swapped="no"/>
-                          </object>
-                          <packing>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
+                        <property name="pixel_size">128</property>
+                        <property name="icon_name">hb-icon</property>
                       </object>
                       <packing>
                         <property name="position">1</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkImage" id="preview_button_image">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin-bottom">4</property>
+                        <property name="margin-start">4</property>
+                        <property name="margin-end">4</property>
+                        <property name="expand">True</property>
+                        <property name="pixel_size">128</property>
+                        <property name="icon_name">hb-icon</property>
+                        <signal name="size-allocate" handler="preview_button_size_allocate_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="position">0</property>
index 5bc690b313d8a93b3dd9175b20129d84423cff12..d90ac98dfe2d68dbe0bc1bf4b899d418c4510a85 100644 (file)
@@ -2674,26 +2674,30 @@ sync for broken players that do not honor MP4 edit lists.</property>
                           </object>
                         </child>
                         <child>
-                          <object class="GtkBox" id="vbox9">
-                            <property name="orientation">vertical</property>
+                          <object class="GtkImage" id="summary_image">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
+                            <property name="margin-bottom">4</property>
+                            <property name="margin-start">4</property>
+                            <property name="margin-end">4</property>
+                            <property name="vexpand">True</property>
+                            <property name="valign">fill</property>
                             <property name="expand">True</property>
-                            <property name="margin-top">12</property>
-                            <property name="margin-end">0</property>
-                            <child>
-                              <object class="GtkImage" id="preview_button_image">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="margin-bottom">4</property>
-                                <property name="margin-start">4</property>
-                                <property name="margin-end">4</property>
-                                <property name="expand">True</property>
-                                <property name="pixel_size">128</property>
-                                <property name="icon_name">hb-icon</property>
-                                <signal name="size-allocate" handler="preview_button_size_allocate_cb" swapped="no"/>
-                              </object>
-                            </child>
+                            <property name="pixel_size">128</property>
+                            <property name="icon_name">hb-icon</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkPicture" id="preview_button_image">
+                            <property name="visible">False</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin-bottom">4</property>
+                            <property name="margin-start">4</property>
+                            <property name="margin-end">4</property>
+                            <property name="vexpand">True</property>
+                            <property name="valign">fill</property>
+                            <property name="expand">True</property>
+                            <signal name="size-allocate" handler="preview_button_size_allocate_cb" swapped="no"/>
                           </object>
                         </child>
                       </object>
index 6721b328424fe40c1966370d2450805ccb88be70..3272d478795902d03211faae9a9530943d36dd09 100644 (file)
@@ -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);