summaryrefslogtreecommitdiffstats
path: root/gtk/src/preview.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2018-04-19 12:16:18 -0700
committerJohn Stebbins <[email protected]>2018-04-19 12:16:18 -0700
commit3932f559303edd80fb7be32ac0b6b128b2137458 (patch)
tree8002cc01fbaadd5c99dd75a9703c162192cd17ed /gtk/src/preview.c
parent2967fbd87cecaccdc6ddfe7b2995c2a652fc4dff (diff)
LinGui: start adding Gtk4 support
Gtk4 drops support for a number of widget properties and APIs. Fortunately these were all pretty much duplicate functionality that could be replaced by other existing properties and APIs. Building with Gtk4 is currently disabled due to several bugs in libgtk4.
Diffstat (limited to 'gtk/src/preview.c')
-rw-r--r--gtk/src/preview.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/gtk/src/preview.c b/gtk/src/preview.c
index 35517fc1d..3a28aa4bd 100644
--- a/gtk/src/preview.c
+++ b/gtk/src/preview.c
@@ -123,6 +123,7 @@ preview_set_render_size(signal_user_data_t *ud, int width, int height)
{
GtkWidget * widget;
GtkWindow * window;
+ GdkWindow * w;
GdkGeometry geo;
widget = GHB_WIDGET (ud->builder, "preview_image");
@@ -130,11 +131,15 @@ preview_set_render_size(signal_user_data_t *ud, int width, int height)
window = GTK_WINDOW(GHB_WIDGET(ud->builder, "preview_window"));
gtk_window_unmaximize(window);
gtk_window_resize(window, width, height);
- geo.min_aspect = (double)(width - 4) / height;
- geo.max_aspect = (double)(width + 4) / height;
- geo.width_inc = geo.height_inc = 2;
- gtk_window_set_geometry_hints(window, NULL, &geo,
- GDK_HINT_ASPECT|GDK_HINT_RESIZE_INC);
+ w = gtk_widget_get_window(GTK_WIDGET(window));
+ if (w != NULL)
+ {
+ geo.min_aspect = (double)(width - 4) / height;
+ geo.max_aspect = (double)(width + 4) / height;
+ geo.width_inc = geo.height_inc = 2;
+ gdk_window_set_geometry_hints(w, &geo,
+ GDK_HINT_ASPECT|GDK_HINT_RESIZE_INC);
+ }
ud->preview->render_width = width;
ud->preview->render_height = height;
@@ -1050,7 +1055,7 @@ preview_draw_cb(
}
G_MODULE_EXPORT void
-preview_button_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, signal_user_data_t *ud)
+preview_button_size_allocate_cb(GtkWidget *widget, GdkRectangle *allocation, signal_user_data_t *ud)
{
g_debug("allocate %d x %d", allocation->width, allocation->height);
if (ud->preview->button_width == allocation->width &&
@@ -1305,16 +1310,23 @@ preview_state_cb(
GdkEvent *event,
signal_user_data_t *ud)
{
- GdkEventWindowState * wse = (GdkEventWindowState*)event;
- if (wse->type == GDK_WINDOW_STATE)
+ GdkEventType type = ghb_event_get_event_type(event);
+ if (type == GDK_WINDOW_STATE)
{
// Look for transition to iconified state.
// Toggle "Show Preview" button when iconified.
// I only do this because there seems to be no
// way to reliably disable the iconfy button without
// also disabling the maximize button.
+#if GTK_CHECK_VERSION(3, 90, 0)
+ GdkWindow * window = gdk_event_get_window(event);
+ GdkWindowState state = gdk_window_get_state(window);
+ if (state & GDK_WINDOW_STATE_ICONIFIED)
+#else
+ GdkEventWindowState * wse = (GdkEventWindowState*)event;
if (wse->changed_mask & wse->new_window_state &
GDK_WINDOW_STATE_ICONIFIED)
+#endif
{
live_preview_stop(ud);
GtkWidget *widget = GHB_WIDGET(ud->builder, "show_preview");