]> granicus.if.org Git - handbrake/commitdiff
LinGui: fix use of gtk 3.22 deprecated functions
authorJohn Stebbins <jstebbins.hb@gmail.com>
Wed, 4 Jan 2017 00:03:13 +0000 (17:03 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Wed, 4 Jan 2017 00:03:56 +0000 (17:03 -0700)
gtk/src/ghbcompat.h
gtk/src/hb-backend.c
gtk/src/preview.c

index 1641d36c05830bf7edff75c0385f0921df262708..cb27f307bc456fcfe7b1a807dd6d7c5b1225bbca 100644 (file)
@@ -47,6 +47,42 @@ static inline PangoFontDescription* ghb_widget_get_font(GtkWidget *widget)
     return font;
 }
 
+static inline void ghb_monitor_get_size(GdkWindow *window, gint *w, gint *h)
+{
+    *w = *h = 0;
+
+#if GTK_CHECK_VERSION(3, 22, 0)
+    if (window != NULL)
+    {
+        GdkMonitor *mm;
+        GdkDisplay *dd;
+
+        dd = gdk_display_get_default();
+        if (dd != NULL)
+        {
+            mm = gdk_display_get_monitor_at_window(dd, window);
+            if (mm != NULL)
+            {
+                GdkRectangle rr;
+
+                gdk_monitor_get_geometry(mm, &rr);
+                *w = rr.width;
+                *h = rr.height;
+            }
+        }
+    }
+#else
+    GdkScreen *ss;
+
+    ss = gdk_screen_get_default();
+    if (ss != NULL)
+    {
+        *w = gdk_screen_get_width(ss);
+        *h = gdk_screen_get_height(ss);
+    }
+#endif
+}
+
 #if !GTK_CHECK_VERSION(3, 10, 0)
 #define gtk_image_set_from_icon_name gtk_image_set_from_stock
 #define GHB_PLAY_ICON "gtk-media-play"
index fa6a8a6a2a257dc5e4f9924c678f35c0fb6679f6..eacc73cb5e4643961cc7b86b53c16d2df7a45abd 100644 (file)
@@ -4406,15 +4406,16 @@ ghb_get_preview_image(
     {
         gint factor = 80;
 
-        GdkScreen *ss;
+        GdkWindow *window;
         gint s_w, s_h;
 
-        ss = gdk_screen_get_default();
-        s_w = gdk_screen_get_width(ss);
-        s_h = gdk_screen_get_height(ss);
+        window = gtk_widget_get_window(
+                    GHB_WIDGET(ud->builder, "hb_window"));
+        ghb_monitor_get_size(window, &s_w, &s_h);
 
-        if (previewWidth > s_w * factor / 100 ||
-            previewHeight > s_h * factor / 100)
+        if (s_w > 0 && s_h > 0 &&
+            (previewWidth  > s_w * factor / 100 ||
+             previewHeight > s_h * factor / 100))
         {
             GdkPixbuf *scaled_preview;
             int orig_w = previewWidth;
index d242fd70550e8920e7e8d0fa503bd028a7b788e4..81f278e9bd53ebdaaa6888583515cc3787616222 100644 (file)
@@ -327,22 +327,25 @@ caps_set(GstCaps *caps, signal_user_data_t *ud)
         preview_set_size(ud, width, height);
         if (ghb_dict_get_bool(ud->prefs, "reduce_hd_preview"))
         {
-            GdkScreen *ss;
+            GdkWindow *window;
             gint s_w, s_h;
 
-            ss = gdk_screen_get_default();
-            s_w = gdk_screen_get_width(ss);
-            s_h = gdk_screen_get_height(ss);
+            window = gtk_widget_get_window(
+                        GHB_WIDGET(ud->builder, "preview_window"));
+            ghb_monitor_get_size(window, &s_w, &s_h);
 
-            if (width > s_w * 80 / 100)
+            if (s_w > 0 && s_h > 0)
             {
-                width = s_w * 80 / 100;
-                height = gst_util_uint64_scale_int(width, den, num);
-            }
-            if (height > s_h * 80 / 100)
-            {
-                height = s_h * 80 / 100;
-                width = gst_util_uint64_scale_int(height, num, den);
+                if (width > s_w * 80 / 100)
+                {
+                    width = s_w * 80 / 100;
+                    height = gst_util_uint64_scale_int(width, den, num);
+                }
+                if (height > s_h * 80 / 100)
+                {
+                    height = s_h * 80 / 100;
+                    width = gst_util_uint64_scale_int(height, num, den);
+                }
             }
         }
     }