/* GTK - The GIMP Toolkit
 * testapplication.c: Using GtkApplication
 * Copyright (C) 2010, Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include "config.h"
#include <gtk/gtk.h>

static void
action_with_data_cb (GApplication *application,
		     gchar        *name,
		     GVariant     *platform_data,
		     gpointer      user_data)
{
	g_message ("received action '%s' with platform_data '%p'", name, platform_data);
}

int
main (int argc, char **argv)
{
  GtkApplication *app;
  GtkWindow *window;

  app = gtk_application_new ("org.gtk.TestApp", &argc, &argv);
  if (g_application_is_remote (G_APPLICATION (app))) {
    g_application_invoke_action (G_APPLICATION (app), "TOTEM_FOOBAR", NULL);
    return 0;
  }

  g_application_add_action (G_APPLICATION (app), "TOTEM_FOOBAR", "Foobar desc");
  g_signal_connect (app, "action-with-data",
		    G_CALLBACK (action_with_data_cb), NULL);

  window = gtk_application_get_window (app);
  gtk_container_add (GTK_CONTAINER (window), gtk_label_new ("Hello world"));
  gtk_widget_show_all (GTK_WIDGET (window));
  gtk_application_add_window (app, window);

  gtk_main ();

  return 0;
}
