
#include <gio/gio.h>

static void
activate (GApplication *app)
{
  GNotification *notification;

  notification = g_notification_new ("alarm");
  g_notification_set_title (notification, "Alarm");
  g_notification_set_default_action (notification, "app.snooze", "i", 5);
  g_notification_add_button (notification, "Dismiss", "app.dismiss", NULL);
  g_notification_add_button (notification, "Snooze", "app.snooze", "i", 5);

  g_application_send_notification (app, notification);
  g_application_hold (app);

  g_object_unref (notification);
}

static void
snooze (GSimpleAction *action,
        GVariant      *parameter,
        gpointer       user_data)
{
  GApplication *app = user_data;

  g_message ("snoozed for %d minutes", g_variant_get_int32 (parameter));
  g_application_release (app);
}

static void
dismiss (GSimpleAction *action,
         GVariant      *parameter,
         gpointer       user_data)
{
  GApplication *app = user_data;

  g_message ("dismissed");
  g_application_release (app);
}

const GActionEntry actions[] =
{
    { "snooze", snooze, "i" },
    { "dismiss", dismiss }
};

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

  app = g_application_new ("org.gtk.Example", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  g_action_map_add_action_entries (G_ACTION_MAP (app), actions, G_N_ELEMENTS (actions), app);

  status = g_application_run (app, 0, NULL);

  g_object_unref (app);
  return status;
}
