How to access to the buttons of a Gtk2::Dialog?



Dear list,

I want to add a simple search dialog to my application. The idea is to
grey out the "Search next" and "Search previous" buttons until the
user has written something to the search field.

Obviously, I'd use something like:

        my $dialog = Gtk2::Dialog->new_with_buttons
($gui_strings{help_title}, $win, 'destroy-with-parent',
                               $gui_strings{btn_search_prev}    => 'prev',
                               $gui_strings{btn_search_next}    => 'next',
                               $gui_strings{btn_search_close}   => 'ok');

        $dialog->set_default_response ('ok');
        $dialog->set_resizable(FALSE);

        my $search_hbox = Gtk2::HBox->new (0, 15);
        $dialog->vbox->pack_start($search_hbox, 0, 1, 0);
        
        my $search_label = Gtk2::Label->new($gui_strings{search_label});
        $search_label->set_alignment (1.0, 0.5);
        $search_hbox->pack_start($search_label, 0, 1, 0);               
        my $search_entry = Gtk2::Entry->new();
        $search_hbox->pack_start($search_entry, 0, 1, 0);               
        $search_entry->set_editable(TRUE);
        $search_entry->signal_connect (changed =>
                                                                                sub {
                                                                                        my $search_text = 
$search_entry->get_text();
                                                                                        
$prev_button->set_sensitive($search_text eq '');
                                                                                        
$next_button->set_sensitive($search_text eq '');
                                                                                }
                                                                  );

But how can I access the button widgets?

The C documentation mentions a certain
gtk-dialog-get-widget-for-response() function, which seems to be what
I look for.
(http://library.gnome.org/devel/gtk/2.22/GtkDialog.html#gtk-dialog-get-widget-for-response)
However, there seems to be no binding for this function in the
Gtk2-Perl docs (http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/Dialog.html).

Is there an other way, perhaps with $dialog->get_action_area?

Péter Juhász



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