[gtk+/wip/gapplication-2-22: 25/25] Port to latest GApplication API



commit 26265c62683c24328d305211831a8eb9fb80474e
Author: Colin Walters <walters verbum org>
Date:   Fri May 28 16:45:53 2010 -0400

    Port to latest GApplication API

 gtk/gtkapplication.c    |   23 ++++++++++++++++++++++-
 tests/testapplication.c |   14 ++++++++++++++
 2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index 36cc76d..62f8491 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -82,6 +82,12 @@ gtk_application_default_action (GApplication *application, const char *action, g
   g_list_free (actions);
 }
 
+static void
+_gtk_application_format_activation_data (GVariantBuilder *builder)
+{
+  /* TODO - append startup notification stuff here */
+}
+
 /**
  * gtk_application_new:
  * @argc: (allow-none) (inout): System argument count
@@ -102,9 +108,24 @@ gtk_application_new (int                  *argc,
                      char               ***argv,
                      const char           *appid)
 {  
+  int argc_for_app;
+  char **argv_for_app;
+  GApplicationPlugin gtk_app_plugin;
+
   gtk_init (argc, argv);
 
-  return g_object_new (GTK_TYPE_APPLICATION, "appid", appid, NULL);
+  if (argc)
+    argc_for_app = *argc;
+  else
+    argc_for_app = 0;
+  if (argv)
+    argv_for_app = *argv;
+  else
+    argv_for_app = NULL;
+
+  gtk_app_plugin.format_activation_data = _gtk_application_format_activation_data;
+
+  return GTK_APPLICATION (g_application_new_subtype (argc_for_app, argv_for_app, appid, GTK_TYPE_APPLICATION, &gtk_app_plugin));
 }
 
 static void
diff --git a/tests/testapplication.c b/tests/testapplication.c
index 06c6db8..99da58a 100644
--- a/tests/testapplication.c
+++ b/tests/testapplication.c
@@ -47,6 +47,18 @@ about_activate (GtkAction *action,
   gtk_widget_hide (GTK_WIDGET (about_dialog));
 }
 
+static void
+on_app_activated (GApplication  *application,
+		  char         **args,
+		  GVariant      *platform_data)
+{
+  char **iter;
+  g_print ("got args: ");
+  for (iter = args; *iter; iter++)
+    g_print ("%s ", *iter);
+  g_print ("\n");
+}
+
 int
 main (int argc, char **argv)
 {
@@ -57,6 +69,8 @@ main (int argc, char **argv)
   GtkActionGroup *actions;
 
   app = gtk_application_new (&argc, &argv, "org.gtk.TestApp");
+  g_signal_connect (app, "activated", G_CALLBACK(on_app_activated), NULL);
+
   builder = gtk_builder_new ();
   if (!gtk_builder_add_from_string (builder, builder_data, -1, NULL))
     g_error ("failed to parse UI");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]