35 |
35 |
36 UIWIDGET ui_imageviewer_create(UiObject *obj, UiImageViewerArgs args) { |
36 UIWIDGET ui_imageviewer_create(UiObject *obj, UiImageViewerArgs args) { |
37 UiObject *current = uic_current_obj(obj); |
37 UiObject *current = uic_current_obj(obj); |
38 |
38 |
39 GtkWidget *scrolledwindow = SCROLLEDWINDOW_NEW(); |
39 GtkWidget *scrolledwindow = SCROLLEDWINDOW_NEW(); |
|
40 #if GTK_CHECK_VERSION(4, 0, 0) |
|
41 GtkWidget *image = gtk_picture_new(); |
|
42 #else |
40 GtkWidget *image = gtk_image_new(); |
43 GtkWidget *image = gtk_image_new(); |
|
44 #endif |
|
45 |
|
46 ui_set_name_and_style(image, args.name, args.style_class); |
41 |
47 |
42 #if GTK_MAJOR_VERSION < 4 |
48 #if GTK_MAJOR_VERSION < 4 |
43 GtkWidget *eventbox = gtk_event_box_new(); |
49 GtkWidget *eventbox = gtk_event_box_new(); |
44 SCROLLEDWINDOW_SET_CHILD(scrolledwindow, event_box); |
50 SCROLLEDWINDOW_SET_CHILD(scrolledwindow, eventbox); |
45 gtk_container_add(GTK_CONTAINER(eventbox), image); |
51 gtk_container_add(GTK_CONTAINER(eventbox), image); |
46 #else |
52 #else |
47 SCROLLEDWINDOW_SET_CHILD(scrolledwindow, image); |
53 SCROLLEDWINDOW_SET_CHILD(scrolledwindow, image); |
48 #endif |
54 #endif |
49 |
55 |
85 g->value = value; |
91 g->value = value; |
86 g->type = type; |
92 g->type = type; |
87 GdkPixbuf *pixbuf = value; |
93 GdkPixbuf *pixbuf = value; |
88 |
94 |
89 if(pixbuf) { |
95 if(pixbuf) { |
|
96 int width, height; |
90 #if GTK_CHECK_VERSION(4, 12, 0) |
97 #if GTK_CHECK_VERSION(4, 12, 0) |
91 GdkTexture *texture = gdk_texture_new_for_pixbuf(pixbuf); |
98 GdkTexture *texture = gdk_texture_new_for_pixbuf(pixbuf); |
92 gtk_image_set_from_paintable(GTK_IMAGE(g->obj), GDK_PAINTABLE(texture)); |
99 gtk_picture_set_paintable(GTK_PICTURE(g->obj), GDK_PAINTABLE(texture)); |
|
100 width = gdk_texture_get_width(texture); |
|
101 height = gdk_texture_get_height(texture); |
93 #else |
102 #else |
94 gtk_image_set_from_pixbuf(GTK_IMAGE(g->obj), pixbuf); |
103 gtk_image_set_from_pixbuf(GTK_IMAGE(g->obj), pixbuf); |
95 #endif |
104 #endif |
|
105 gtk_widget_set_size_request(g->obj, width, height); |
96 } |
106 } |
97 |
107 |
98 |
108 |
99 return 0; |
109 return 0; |
100 } |
110 } |