#include <gtk/gtk.h>

/*
  Usage: main /path/to/a/scalable/icon.svg

  Tested with /usr/share/icons/hicolor/scalable/apps/openshot.svg and
              /usr/share/icons/hicolor/scalable/apps/gnome-color-manager.svg
*/

static gboolean
run (gpointer user_data)
{
  GtkWidget *widget;
  GtkWidget *window;
  GIcon     *icon;
  gchar     *icon_filename = (gchar *) user_data;

  icon = g_icon_new_for_string (icon_filename, NULL);

  widget = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "delete-event", gtk_main_quit, NULL);

  gtk_container_add (GTK_CONTAINER (window), widget);

  gtk_widget_show_all (window);

  return G_SOURCE_REMOVE;
}

int
main (int argc, char **argv)
{
  gtk_init (&argc, &argv);

  if (argc == 2)
    {
      g_idle_add (run, argv[1]);
      gtk_main ();
    }

  return 0;
}
