Bonjour,

j'ai un petit soucis j'arrive a charger puis afficher mon image de fond, mais elle s'affiche en tout petit, alors qu'elle est bien au dimension de ma fenêtre.

J'aimerais donc qu'elle s'affiche correctement et remplisse bien tout l'arrière plan.

Voici le code, je précise que je découvre gtk4, donc soyez indulgent, merci.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
static void activate(GtkApplication* app, gpointer user_data)
{
    GtkWidget *window;
    GtkWidget *background;
    GtkWidget *browse_button[3];
    GtkWidget *convert_button[3];
    GtkWidget *frame[3] = {NULL};
    GtkWidget *box;
 
    GtkWidget *video_entry = NULL;
    GtkWidget *image_entry = NULL;
    GtkWidget *audio_entry = NULL;
 
    GtkWidget *zone = NULL;
    GtkWidget *grid = NULL;
 
    GtkWidget *videos_files_label = NULL;
    gchar *utf8_videos_files;
 
    GtkWidget *images_files_label = NULL;
    gchar *utf8_images_files;
 
    GtkWidget *audio_files_label = NULL;
    gchar *utf8_audio_files;
 
    size_t i = 0;
 
    window = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (window), "FilesConverter");
    gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
 
    zone = gtk_fixed_new();
 
    box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
    gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
    gtk_window_set_child (GTK_WINDOW(window), zone);
 
    background = gtk_image_new_from_file("images/BG.jpeg");
    gtk_fixed_put(GTK_FIXED(zone), background, 100, 150);
 
    videos_files_label = gtk_label_new(NULL);
 
    utf8_videos_files = g_locale_to_utf8("<span foreground=\"#000000\">Videos Files</span>\n", -1, NULL, NULL, NULL);
    gtk_label_set_markup(GTK_LABEL(videos_files_label), utf8_videos_files);
    gtk_fixed_put(GTK_FIXED(zone), videos_files_label, 20, 20);
 
    frame[0] = gtk_frame_new(NULL);
    gtk_widget_set_size_request(frame[0], 780, 160);
    gtk_fixed_put(GTK_FIXED(zone), frame[0], 10, 10);
 
    images_files_label = gtk_label_new(NULL);
 
    utf8_images_files = g_locale_to_utf8("<span foreground=\"#000000\">Images Files</span>\n", -1, NULL, NULL, NULL);
    gtk_label_set_markup(GTK_LABEL(images_files_label), utf8_images_files);
    gtk_fixed_put(GTK_FIXED(zone), images_files_label, 20, 230);
 
    frame[1] = gtk_frame_new(NULL);
    gtk_widget_set_size_request(frame[1], 780, 160);
    gtk_fixed_put(GTK_FIXED(zone), frame[1], 10, 220);
 
 
    audio_files_label = gtk_label_new(NULL);
 
    utf8_audio_files = g_locale_to_utf8("<span foreground=\"#000000\">Audio Files</span>\n", -1, NULL, NULL, NULL);
    gtk_label_set_markup(GTK_LABEL(audio_files_label), utf8_audio_files);
    gtk_fixed_put(GTK_FIXED(zone), audio_files_label, 20, 430);
 
    frame[2] = gtk_frame_new(NULL);
    gtk_widget_set_size_request(frame[2], 780, 160);
    gtk_fixed_put(GTK_FIXED(zone), frame[2], 10, 420);
 
 
    for(i = 0; i < 3; i++)
    {
        browse_button[i] = gtk_button_new_with_label ("Browse");
        convert_button[i] = gtk_button_new_with_label("Convert");
    }
 
    gtk_fixed_put(GTK_FIXED(zone), browse_button[0], 450, 60);
    gtk_fixed_put(GTK_FIXED(zone), browse_button[1], 450, 270);
    gtk_fixed_put(GTK_FIXED(zone), browse_button[2], 450, 470);
 
    gtk_fixed_put(GTK_FIXED(zone), convert_button[0], 550, 60);
    gtk_fixed_put(GTK_FIXED(zone), convert_button[1], 550, 270);
    gtk_fixed_put(GTK_FIXED(zone), convert_button[2], 550, 470);
 
    g_signal_connect (browse_button[0], "clicked", G_CALLBACK(print_hello), NULL);
    g_signal_connect_swapped (browse_button[0], "clicked", G_CALLBACK(gtk_window_destroy), window);
 
    video_entry = gtk_entry_new();
    gtk_widget_set_size_request(video_entry, 400, 30);
    gtk_fixed_put(GTK_FIXED(zone), video_entry, 20, 60);
 
    image_entry = gtk_entry_new();
    gtk_widget_set_size_request(image_entry, 400, 10);
    gtk_fixed_put(GTK_FIXED(zone), image_entry, 20, 270);
 
    audio_entry= gtk_entry_new();
    gtk_widget_set_size_request(audio_entry, 400, 10);
    gtk_fixed_put(GTK_FIXED(zone), audio_entry, 20, 470);
 
    gtk_window_present(GTK_WINDOW (window));
 
}
 
 
int main (int argc, char *argv[])
{
    GtkApplication *app;
    int status;
 
    app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
    g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
    status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);
 
  return status;
}
Et voici une capture d'écran avec mon background en tout petit :

Nom : Capture d’écran du 2024-10-11 18-25-08.png
Affichages : 25
Taille : 21,7 Ko

Bien à vous.