/**
 * Compiled with:
 * gcc -o example `pkg-config --cflags --libs glib-2.0 gio-2.0 gobject-2.0` example.c
 */

#include <stdlib.h>

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>

static gint
on_command_line (GApplication *self,
                 GApplicationCommandLine *cmdline)
{
  g_return_val_if_fail(G_IS_APPLICATION(self), EXIT_FAILURE);
  g_return_val_if_fail(G_IS_APPLICATION_COMMAND_LINE(cmdline), EXIT_FAILURE);

  g_print("***********\n");
  g_print("This is a normal print statement\n");
  g_print("***********\n");

  g_print("***********\n");
  g_application_command_line_print(cmdline,
    "This is a local GApplicationCommandLine print statement\n");
  g_print("***********\n");

  return EXIT_SUCCESS;
}

int main (int argc, char **argv)
{
  GApplication *app; gint status;

  g_type_init();

  app = g_application_new("org.gtk.TestApplication",
          G_APPLICATION_HANDLES_COMMAND_LINE);
  g_signal_connect(app, "command-line", G_CALLBACK(on_command_line), NULL);

  status = g_application_run(app, argc, argv);
  g_object_unref(app);

  return status;
}

