Beep when a GtkDialog with a non-editable GtkTextView is first displayed



Hello,

I have a button in my main window that, when clicked, pops up a modal GtkDialog that has a non-editable GtkTextView. When this dialog is first shown after the application launches, the computer beeps once. If I dismiss it and click the button again, there is no beep. The key here seems to be that the GtkTextView is non-editable. If I do not use gtk_text_view_set_editable to make it non-editable, there is no beep at all.

I was wondering if anyone had any ideas as to what may be going on. I'm including sample source that reproduces the problem on my machine (Ubuntu 8.04, running gtk 2.12.9).

Thanks,

Ray

The compilation command line is "gcc `pkg-config --cflags --libs gtk +-2.0` test.c -o test"

#include <gtk/gtk.h>

static void showDialogCB( GtkWidget *w,
                          gpointer data )
/***************************************/
{
    GtkWidget * dlog = NULL;
    GtkWidget * txtbox = NULL;

    dlog = gtk_dialog_new_with_buttons( "",
                                        GTK_WINDOW( data ),
                                        GTK_DIALOG_MODAL,
                                        GTK_STOCK_OK,
                                        GTK_RESPONSE_ACCEPT,
                                        NULL );

    txtbox = gtk_text_view_new();

    gtk_text_view_set_editable( GTK_TEXT_VIEW( txtbox ), FALSE );
gtk_container_add( GTK_CONTAINER( GTK_DIALOG( dlog )->vbox ), txtbox );

    gtk_widget_show_all( dlog );
    gtk_dialog_run( GTK_DIALOG( dlog ) );

    gtk_widget_destroy( dlog );
}

int main( int argc, char *argv[] )
/********************************/
{
    GtkWidget * topWindow;
    GtkWidget * dlgButton;
    GtkWidget * buttonBox;

    gtk_init( &argc, &argv );

    topWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    g_signal_connect( G_OBJECT( topWindow ), "delete_event",
                        G_CALLBACK( gtk_main_quit ), NULL );
    g_signal_connect( G_OBJECT( topWindow ), "destroy",
                        G_CALLBACK( gtk_main_quit ), NULL );

    buttonBox = gtk_hbutton_box_new();
    dlgButton = gtk_button_new_with_label( "Show dialog" );
    gtk_container_add( GTK_CONTAINER( buttonBox ), dlgButton );

    g_signal_connect( G_OBJECT( dlgButton ), "clicked",
                      G_CALLBACK( showDialogCB ), topWindow );

    gtk_container_add( GTK_CONTAINER( topWindow ), buttonBox );
    gtk_widget_show_all( topWindow );

    gtk_main();

    return 0;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]