signal_*_event and tab labels of Notebook
- From: Jakub Okoński <jakub okonski org>
- To: gtkmm-list gnome org
- Subject: signal_*_event and tab labels of Notebook
- Date: Mon, 3 Sep 2012 18:02:46 +0200
I'm trying to implement closing the tab of a Notebook by middle mouse button and I want to do that by creating a label and connecting to signal_press_button_event().
I have a class which loads contents from files and outputs it to TextView. There's a `Gtk::Label representational_` which is used for tab head.
Functionality for set_file(Gio::File) in that class involves this code:
// create representational widget if there's not
if (!representational_) {
auto new_rep = std::make_shared<Gtk::Label>();
std::swap(representational_, new_rep);
}
// assign text
representational_->set_text(file_->get_basename());
auto window = representational_->property_window().get_value();
if (window) {
window->set_events(window->get_events() | Gdk::EventMask::BUTTON_PRESS_MASK);
//representational_->property_selectable().set_value(true);
representational_->property_sensitive().set_value(true);
representational_->property_can_focus().set_value(true);
representational_->add_events(Gdk::BUTTON_PRESS_MASK);
representational_->signal_button_press_event().connect(sigc::ptr_fun(&the_event), false);
}
The way I use this class is to create it, set_file to it (notebook page does not exist yet, so window is a null pointer), then I Gtk::Notebook::append_page() using the representational_, and set_file() again (window exists this time).
But it works only if I uncomment the line which assigns selectable property to true. I've looked at the Gtk+ code and I know it ensures that Gdk::Window is created.
Obviously, selecting text in that label is unacceptable for me, but I need to trigger the Gtk::Widget::realize() method somehow.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]