summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2017-01-03 17:03:13 -0700
committerJohn Stebbins <[email protected]>2017-01-03 17:03:56 -0700
commitac5efd889aea96f72000fd6848000c7a6afeffc3 (patch)
treefef2e3e6d65f5963fe59998879fa67eb1cda9b0d /gtk/src
parent0d1fec639aee17804285fdf7e7d99f8e92769e6e (diff)
LinGui: fix use of gtk 3.22 deprecated functions
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/ghbcompat.h36
-rw-r--r--gtk/src/hb-backend.c13
-rw-r--r--gtk/src/preview.c27
3 files changed, 58 insertions, 18 deletions
diff --git a/gtk/src/ghbcompat.h b/gtk/src/ghbcompat.h
index 1641d36c0..cb27f307b 100644
--- a/gtk/src/ghbcompat.h
+++ b/gtk/src/ghbcompat.h
@@ -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"
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index fa6a8a6a2..eacc73cb5 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -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;
diff --git a/gtk/src/preview.c b/gtk/src/preview.c
index d242fd705..81f278e9b 100644
--- a/gtk/src/preview.c
+++ b/gtk/src/preview.c
@@ -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);
+ }
}
}
}