#include <gtk/gtk.h>

gboolean update_tooltip(GtkWidget *widget) {
  gchar tooltip_text[1024];
  snprintf(tooltip_text, sizeof tooltip_text, "%lu", g_get_real_time());
  gtk_widget_set_tooltip_text(widget, tooltip_text);
  return TRUE;
}

int main(int argc, char *argv[]) {
  GtkWidget *window;
  GtkWidget *button;
  guint64 update_interval = argc < 2 ? 500 : g_ascii_strtoull(argv[1], NULL, 10);

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width(GTK_CONTAINER(window), 15);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

  button = gtk_button_new_with_label("Fluffy Button");
  gtk_container_add(GTK_CONTAINER(window), button);

  g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);

  g_timeout_add(update_interval, (GSourceFunc) update_tooltip, button);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}
