Search code examples
cgtkgtk3

No button click sound when application starts with startup applications


I'm writing GTK application with C. I wanted to add sound after clicking the button. I wanted to do it with as little effort as possible so i used the Bell sign from ascii (7), so it looks like this:

void infButtonClick()
{
    char d = (char)7;
    printf("%c\n", d);
    //Rest of the code
}

It's working fine except one situation. The application is added to Startup Applications and when it starts this way the bell sound doesn't work. Other sounds in the application (videos played with libvlc) works fine. So where is the problem here? What should I change to make a bell sign work after automatic start up?


Solution

  • As you are using GTK, the easiest way to produce a beep is with gtk_widget_error_bell(). See documentation