From: Olaf Wintermann Date: Sat, 6 Dec 2025 16:34:04 +0000 (+0100) Subject: fix gtk3 build X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=3cd69a50b185ed40eebd3b5875b84cd836b73635;p=note.git fix gtk3 build --- diff --git a/application/gtk-image.c b/application/gtk-image.c index 3b09599..9f796b3 100644 --- a/application/gtk-image.c +++ b/application/gtk-image.c @@ -66,7 +66,7 @@ GtkWidget* embedded_image_create(EmbeddedWidget *em, GdkPixbuf *pix) { static void embedded_image_adjust_size(EmbeddedWidget *em, int max_width) { GtkWidget *image = em->wdata1; - GdkPixmap *pix = em->wdata2; + GdkPixbuf *pix = em->wdata2; double width = gdk_pixbuf_get_width(pix); double height = gdk_pixbuf_get_height(pix); @@ -76,7 +76,7 @@ static void embedded_image_adjust_size(EmbeddedWidget *em, int max_width) { width = max_width; } - gtk_widget_set_size_request(picture, width, height); + gtk_widget_set_size_request(em->widget, width, height); } GtkWidget* embedded_image_create(EmbeddedWidget *em, GdkPixbuf *pix) { diff --git a/application/gtk-text.c b/application/gtk-text.c index 67aab7c..dbc0ce7 100644 --- a/application/gtk-text.c +++ b/application/gtk-text.c @@ -1217,16 +1217,30 @@ static void draw_bulletlist( pango_cairo_show_layout(cr, layout); } -static void md_serialize_list(EmbeddedWidget *em, CxBuffer *out) { - cxBufferPutString(out, " - "); -} - static void destroy_listelm(gpointer data) { ListElmWidget *elm = data; free(elm->str); free(elm); } +#if GTK_MAJOR_VERSION < 4 +static gboolean draw_bulletlist_callback(GtkWidget *widget, cairo_t *cr, gpointer data) { + int width = gtk_widget_get_allocated_width (widget); + int height = gtk_widget_get_allocated_height (widget); + draw_bulletlist(GTK_DRAWING_AREA(widget), cr, width, height, data); + return FALSE; +} + +static void destroy_bulletlist_elm(GtkWidget *widget, gpointer data) { + destroy_listelm(data); +} +#endif + +static void md_serialize_list(EmbeddedWidget *em, CxBuffer *out) { + cxBufferPutString(out, " - "); +} + + void editor_insert_list_element(NoteEditor *editor, GtkTextIter *iter, const char *style, int num) { GtkTextView *textview = GTK_TEXT_VIEW(editor->textview); GtkTextBuffer *buffer = gtk_text_view_get_buffer(textview); @@ -1248,7 +1262,18 @@ void editor_insert_list_element(NoteEditor *editor, GtkTextIter *iter, const cha } GtkWidget *widget = gtk_drawing_area_new(); // • +#if GTK_CHECK_VERSION(4, 0, 0) gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(widget), draw_bulletlist, elm, destroy_listelm); +#else + g_signal_connect( + G_OBJECT(widget), "draw", + G_CALLBACK(draw_bulletlist_callback), + elm); + g_signal_connect( + G_OBJECT(widget), "destroy", + G_CALLBACK(destroy_bulletlist_elm), + elm); +#endif gtk_widget_set_size_request(widget, 40, height); //gtk_widget_add_css_class(widget, "ui_test"); gtk_widget_set_margin_bottom(widget, -descent);