ui/gtk/graphics.c

changeset 431
bb7da585debc
parent 299
48763a9d19a7
--- a/ui/gtk/graphics.c	Sun May 23 09:44:43 2021 +0200
+++ b/ui/gtk/graphics.c	Sat Jan 04 16:38:48 2025 +0100
@@ -51,6 +51,7 @@
 }
 
 
+#if GTK_MAJOR_VERSION <= 3
 static gboolean widget_button_pressed(
         GtkWidget *widget,
         GdkEvent *event,
@@ -82,14 +83,18 @@
     }
     return TRUE;
 }
+#endif
 
 void ui_drawingarea_getsize(UIWIDGET drawingarea, int *width, int *height) {
-#ifdef UI_GTK3
-        *width = gtk_widget_get_allocated_width(drawingarea);
-        *height = gtk_widget_get_allocated_height(drawingarea);
+#if GTK_MAJOR_VERSION >= 4
+    *width = gtk_widget_get_width(drawingarea);
+    *height = gtk_widget_get_height(drawingarea);
+#elif GTK_MAJOR_VERSION == 3
+    *width = gtk_widget_get_allocated_width(drawingarea);
+    *height = gtk_widget_get_allocated_height(drawingarea);
 #else
-        *width = drawingarea->allocation.width;
-        *height = drawingarea->allocation.height;
+    *width = drawingarea->allocation.width;
+    *height = drawingarea->allocation.height;
 #endif
 }
 
@@ -98,12 +103,17 @@
 }
 
 void ui_drawingarea_mousehandler(UiObject *obj, UIWIDGET widget, ui_callback f, void *u) {
+#if GTK_MAJOR_VERSION >= 4
+    // TODO
+#else
     gtk_widget_set_events(widget, GDK_BUTTON_PRESS_MASK);
     if(f) {
         UiEventData *event = malloc(sizeof(UiEventData));
         event->obj = obj;
         event->callback = f;
         event->userdata = u;
+        event->customdata = NULL;
+        event->value = 0;
         
         g_signal_connect(G_OBJECT(widget),
                 "button-press-event",
@@ -112,6 +122,7 @@
     } else {
          // TODO: warning
     }
+#endif
 }
 
 

mercurial