likern
likern

Reputation: 3954

Handle "add child to Gtk.Box" event

As I am aware, I can subscribe to Gtk.Box signal "add child":

box.connect("add", self.__add_to_switch_list)

which will be called when I add child by box.add(child), and it's working.

But how I would do the same with box.pack_start() method?

Upvotes: 0

Views: 1120

Answers (2)

liberforce
liberforce

Reputation: 11454

In that very same bug report, @ebassi tells you that you can connect to the child widget's parent-set signal. If you can't know when a parent has a new child, you can know when a child has a new parent which is roughly the same thing.

Upvotes: 0

Alexander Dmitriev
Alexander Dmitriev

Reputation: 2525

There is no way.


"add" is only emitted when you call GtkContainer.add(). The first handler of this signal is subclass' method. For example, GtkBox does this :

/* gtk_box_class init: */
container_class->add = gtk_box_add;
...

static void
gtk_box_add (GtkContainer *container,
         GtkWidget    *widget)
{
  GtkBoxPrivate *priv = GTK_BOX (container)->priv;

  gtk_box_pack_start (GTK_BOX (container), widget,
                      priv->default_expand,
                      TRUE,
                      0);
}

Upvotes: 1

Related Questions