I'm new to GTK. I've created a ApplicationWindow with a Button in it. When the Button is pressed an AboutDialog is made visible by calling show().
I did try about.hide_on_delete(), about.connect_delete_event() and about.connect_close() to hide AboutDialog. All gives same error.
I'm not sure if program reaches about.connect_close().
Problem is when I reopen about dialog. Follow steps to see error:
- Click on "Click kro jara!" button and AboutDialog will be will be visible properly.
- Now close AboutDialog
- Again Click on "Click kro jara!" button and the problem will there. The dialog won't be visible properly. It will be blank(I've added an image below). Clicking over the blank space just prints same message again and again.
Source Code:
use gtk::prelude::*;
use gio::prelude::*;
use gtk::{Application, ApplicationWindow, Button, AboutDialog};
fn main() {
let application = Application::new(
Some("com.github.gtk-rs.examples.basic"),
Default::default(),
).expect("failed to initialize GTK application");
application.connect_activate(|app| {
let window = ApplicationWindow::new(app);
window.set_title("GTK wala Program");
window.set_default_size(350, 70);
let about = AboutDialog::new();
about.set_comments(Some("Test App ka Comment hai."));
// about.hide_on_delete();
// about.connect_close(|a| {
// println!("About ka Dialog kar rahe hai!");
// a.hide();
// });
about.connect_delete_event(|a, _| {
println!("About ka Dialog kar rahe hai!");
a.hide();
Inhibit(false)
});
let button = Button::with_label("Click kro jara!");
button.connect_clicked(move |_| {
println!("Clicked!");
about.show();
});
window.add(&button);
window.show_all();
});
application.run(&[]);
}
Log message:
Clicked!
About ka Dialog kar rahe hai!
Clicked!
(test_about:14579): Gtk-CRITICAL **: 18:49:37.111: gtk_widget_show: assertion 'GTK_IS_WIDGET (widget)' failed
(test_about:14579): Gtk-CRITICAL **: 18:49:37.111: gtk_widget_hide: assertion 'GTK_IS_WIDGET (widget)' failed
(test_about:14579): Gtk-CRITICAL **: 18:49:37.115: gtk_container_foreach: assertion 'GTK_IS_CONTAINER (container)' failed
Image of Dialog on reopen:
