I've been trying to code a simple exit program with C on Arch Linux to shutdown/restart/etc. I'm using a grid and "embedding" images on all the buttons.
What's really strange is that randomly, one image on one of the buttons chooses not to appear at all. If I try to use other image objects, the images that appeared on other buttons won't appear on the apparently buggy button. If I create a new button, with the same image used on the non-working button, it works. If I remove the faulty button object from the code, then another random button decides that it doesn't want to have an image.
If the images simply didn't exist, then an "image missing" warning image is used, which I saw earlier when experimenting.

Here's the relevant code.
Code:
/*...*/
GtkWidget *window, *grid,
*restartbutton, *shutdownbutton,
*logoffbutton, *lockbutton,
*irestartbutton, *ishutdownbutton,
*ilogoffbutton, *ilockbutton;
/*...*/
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
/* Create buttons */
shutdownbutton = gtk_button_new_with_label("Shutdown");
restartbutton = gtk_button_new_with_label(" Restart ");
logoffbutton = gtk_button_new_with_label(" Log Off ");
lockbutton = gtk_button_new_with_label(" Lock ");
/* Define button images */
ishutdownbutton = gtk_image_new_from_icon_name("system-shutdown",bts);
irestartbutton = gtk_image_new_from_icon_name("reload",bts);
ilogoffbutton = gtk_image_new_from_icon_name("system-log-out",bts);
ilockbutton = gtk_image_new_from_icon_name("system-lock-screen",bts);
/* Connect buttons with their functions */
g_signal_connect(restartbutton, "clicked", G_CALLBACK(restart), NULL);
g_signal_connect(shutdownbutton, "clicked", G_CALLBACK(shutdown), NULL);
g_signal_connect(logoffbutton, "clicked", G_CALLBACK(logoff), NULL);
g_signal_connect(lockbutton, "clicked", G_CALLBACK(lock), NULL);
/* Connect images with their buttons */
gtk_button_set_image(GTK_BUTTON(logoffbutton),ilogoffbutton);
gtk_button_set_image(GTK_BUTTON(restartbutton),irestartbutton);
gtk_button_set_image(GTK_BUTTON(lockbutton),ilockbutton);
gtk_button_set_image(GTK_BUTTON(shutdownbutton),ishutdownbutton);
gtk_button_set_image_position(GTK_BUTTON(shutdownbutton),GTK_POS_TOP);
gtk_button_set_image_position(GTK_BUTTON(restartbutton),GTK_POS_TOP);
gtk_button_set_image_position(GTK_BUTTON(logoffbutton),GTK_POS_TOP);
gtk_button_set_image_position(GTK_BUTTON(lockbutton),GTK_POS_TOP);
gtk_widget_show(GTK_WIDGET(ishutdownbutton));
gtk_widget_show(GTK_WIDGET(irestartbutton));
gtk_widget_show(GTK_WIDGET(ilogoffbutton));
gtk_widget_show(GTK_WIDGET(ilockbutton));
/* attach grid to window, buttons to grid */
gtk_container_add(GTK_CONTAINER(window), grid);
gtk_grid_attach(GTK_GRID(grid), restartbutton, 1,1,1,1);
gtk_grid_attach(GTK_GRID(grid), lockbutton, 1,2,1,1);
gtk_grid_attach(GTK_GRID(grid), logoffbutton, 0,2,1,1);
gtk_grid_attach(GTK_GRID(grid), shutdownbutton, 0,1,1,1);
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_widget_show_all(window);
}
Maybe I'm using deprecated techniques or there would be a better way to do what I want?
Thanks in advance...
edit: I switched from using a grid to a table and from GTK3 to GTK2 and the exact same problem is present on the exact same button from the "original" source code. It's probably a bug in my code...