GTK3 message dialog created with gtk_message_dialog_new shows no icon on Fedora?

I have this very simple code demonstrating a GTK3 message dialog:


#include <gtk/gtk.h>
int main (int argc, char *argv[]) {
	gtk_init (&argc, &argv);
    GtkWidget *hello = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Hello world!");
	gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (hello), "This is an example dialog.");
    gtk_dialog_run(GTK_DIALOG (hello));
    return 0;

When I compile the above code on my Fedora Linux 35 desktop:

gcc -o test $(pkg-config --cflags --libs gtk+-3.0) test.c  -g

And run the binary,

Screenshot 2022-01-11 121238

I don’t get an icon in the message dialog? I expect to see the system icon associated with GTK_MESSAGE_INFO in the message dialog.

If I perform the exact same steps on Ubuntu 20.04.3, I do get an icon:

Screenshot 2022-01-11 121448

The icon is added by an Ubuntu-specific patch: message-dialog-restore-traditional-look-on-unity.patch\patches\debian - ubuntu/+source/gtk+3.0 - [no description]

1 Like

GTK does not use icons in message dialogs.

If you want to show an icon, you’ll have to create your own GtkDialog and pack widgets inside its content area yourself.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.