diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index ecc6bea..1bd3a67 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -479,6 +479,12 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
 
               if (button)
                 {
+                  char *name;
+
+                  name = g_strdup_printf ("gtk-titlebutton-%s", t[j]);
+                  gtk_widget_set_name (button, name);
+                  g_free (name);
+
                   gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
                   n_children ++;
                 }
