#if GTK_MAJOR_VERSION >= 4
GtkWidget* embedded_image_create(GdkPixbuf *pix) {
+ GtkWidget *grid = gtk_grid_new();
+ gtk_widget_add_css_class(grid, "ui_test"); // TODO: replace with new class
+
GdkTexture *texture = gdk_texture_new_for_pixbuf(pix);
- GtkWidget *image = gtk_image_new_from_paintable(GDK_PAINTABLE(texture));
+ GtkWidget *picture = gtk_picture_new_for_paintable(GDK_PAINTABLE(texture));
- int width = gdk_texture_get_width(texture);
- int height = gdk_texture_get_height(texture);
- gtk_widget_set_size_request(image, width, height);
+ double width = gdk_texture_get_width(texture);
+ double height = gdk_texture_get_height(texture);
- return image;
+ if(width > EDITOR_IMAGE_MAX_WIDTH) {
+ height = height * (EDITOR_IMAGE_MAX_WIDTH / width);
+ width = EDITOR_IMAGE_MAX_WIDTH;
+ }
+
+ gtk_widget_set_size_request(picture, width, height);
+
+ gtk_grid_attach(GTK_GRID(grid), picture, 0, 0, 1, 1);
+
+
+ return grid;
}
#else