- g_signal_connect(G_OBJECT(mw.notebook), "switch-page",
- G_CALLBACK(mainwindow_title_before), NULL);
-}
-
-void
-mainwindow_title_before(GtkNotebook *nb, GtkWidget *p, guint idx, gpointer data)
-{
- mainwindow_title(idx);
-}
-
-/* XXX I'd like to avoid traversing the widget hierarchy. Find a better
- * way. */
-void
-mainwindow_title(gint idx)
-{
- GtkWidget *child, *tabbox, *evbox, *label;
- GList *tabbox_children, *last;
- const gchar *text;
-
- if (idx == -1)
- {
- idx = gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook));
- if (idx == -1)
- return;
- }
-
- child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(mw.notebook), idx);
- if (child == NULL)
- return;
-
- evbox = gtk_notebook_get_tab_label(GTK_NOTEBOOK(mw.notebook), child);
- tabbox = gtk_bin_get_child(GTK_BIN(evbox));
- tabbox_children = gtk_container_get_children(GTK_CONTAINER(tabbox));
- last = g_list_last(tabbox_children);
- label = last->data;
- text = gtk_label_get_text(GTK_LABEL(label));
- gtk_window_set_title(GTK_WINDOW(mw.win), text);
- g_list_free(tabbox_children);