From 79dfe39edbeeea182d9b42bd6cfeb8b1f0b50aad Mon Sep 17 00:00:00 2001
From: Bruce Cowan <bruce@bcowan.eu>
Date: Wed, 21 Mar 2018 15:08:44 +0000
Subject: [PATCH] Remove RugbyApplication

---
 src/{rugby-application.c => main.c} | 48 ++++++++++-------------------
 src/meson.build                     |  3 +-
 src/rugby-app-window.c              |  7 +++--
 src/rugby-app-window.h              |  2 +-
 src/rugby-application.h             | 30 ------------------
 src/rugby.c                         | 32 -------------------
 6 files changed, 22 insertions(+), 100 deletions(-)
 rename src/{rugby-application.c => main.c} (75%)
 delete mode 100644 src/rugby-application.h
 delete mode 100644 src/rugby.c

diff --git a/src/rugby-application.c b/src/main.c
similarity index 75%
rename from src/rugby-application.c
rename to src/main.c
index 0081d9a..70d0266 100644
--- a/src/rugby-application.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
-/* rugby-application.c
+/* main.c
  *
- * Copyright © 2012, 2016, 2017 Bruce Cowan <bruce@bcowan.eu>
+ * Copyright © 2012, 2016-2018 Bruce Cowan <bruce@bcowan.eu>
  *
  * This file is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
@@ -18,20 +18,13 @@
 
 #include <gtk/gtk.h>
 
-#include "rugby-application.h"
 #include "rugby-app-window.h"
 
-struct _RugbyApplication
-{
-    GtkApplication parent;
-};
-
-G_DEFINE_TYPE (RugbyApplication, rugby_application, GTK_TYPE_APPLICATION)
-
 static void
-rugby_application_activate (GApplication *app)
+on_activate (GApplication *app,
+             gpointer      user_data)
 {
-    RugbyAppWindow *win = rugby_app_window_new (RUGBY_APPLICATION (app));
+    RugbyAppWindow *win = rugby_app_window_new (GTK_APPLICATION (app));
     gtk_window_present (GTK_WINDOW (win));
 }
 
@@ -69,7 +62,8 @@ quit_activated (GSimpleAction *simple,
 }
 
 static void
-rugby_application_startup (GApplication *app)
+on_startup (GApplication *app,
+            gpointer      user_data)
 {
     const GActionEntry app_entries[] =
     {
@@ -77,8 +71,6 @@ rugby_application_startup (GApplication *app)
         { "quit", quit_activated }
     };
 
-    G_APPLICATION_CLASS (rugby_application_parent_class)->startup (app);
-
     g_action_map_add_action_entries (G_ACTION_MAP (app),
                                      app_entries,
                                      G_N_ELEMENTS (app_entries),
@@ -97,24 +89,16 @@ rugby_application_startup (GApplication *app)
                                                GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
 
-static void
-rugby_application_class_init (RugbyApplicationClass *klass)
+int
+main (int    argc,
+      char **argv)
 {
-    GApplicationClass *app_class = G_APPLICATION_CLASS (klass);
+    GtkApplication *app = gtk_application_new ("uk.me.bcowan.rugby", G_APPLICATION_FLAGS_NONE);
 
-    app_class->activate = rugby_application_activate;
-    app_class->startup = rugby_application_startup;
-}
+    g_signal_connect (app, "startup",
+                      G_CALLBACK(on_startup), NULL);
+    g_signal_connect (app, "activate",
+                      G_CALLBACK (on_activate), NULL);
 
-static void
-rugby_application_init (RugbyApplication *self)
-{
-}
-
-RugbyApplication *
-rugby_application_new (void)
-{
-    return g_object_new (RUGBY_TYPE_APPLICATION,
-                         "application-id", "uk.me.bcowan.rugby",
-                         NULL);
+    return g_application_run (G_APPLICATION (app), argc, argv);
 }
diff --git a/src/meson.build b/src/meson.build
index 7fff179..fbe94bb 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -8,8 +8,7 @@ conf.set('KICK_POINTS', get_option('kick_points'))
 config_h = configure_file(configuration: conf, output: 'config.h')
 
 sources = files(
-    'rugby.c',
-    'rugby-application.c',
+    'main.c',
     'rugby-app-window.c',
     'rugby-list-store.c',
     'rugby-possibility.c',
diff --git a/src/rugby-app-window.c b/src/rugby-app-window.c
index 32af8db..89da100 100644
--- a/src/rugby-app-window.c
+++ b/src/rugby-app-window.c
@@ -19,7 +19,6 @@
 #include <gtk/gtk.h>
 
 #include "config.h"
-#include "rugby-application.h"
 #include "rugby-app-window.h"
 #include "rugby-list-store.h"
 #include "rugby-possibility.h"
@@ -134,7 +133,9 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass)
 }
 
 RugbyAppWindow *
-rugby_app_window_new (RugbyApplication *app)
+rugby_app_window_new (GtkApplication *app)
 {
-    return g_object_new (RUGBY_TYPE_APP_WINDOW, "application", app, NULL);
+    return g_object_new (RUGBY_TYPE_APP_WINDOW,
+                         "application", app,
+                         NULL);
 }
diff --git a/src/rugby-app-window.h b/src/rugby-app-window.h
index 70af6de..b9ac69c 100644
--- a/src/rugby-app-window.h
+++ b/src/rugby-app-window.h
@@ -26,6 +26,6 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (RugbyAppWindow, rugby_app_window, RUGBY, APP_WINDOW, GtkApplicationWindow);
 
-RugbyAppWindow *rugby_app_window_new (RugbyApplication *app);
+RugbyAppWindow *rugby_app_window_new (GtkApplication *app);
 
 G_END_DECLS
diff --git a/src/rugby-application.h b/src/rugby-application.h
deleted file mode 100644
index 2adb606..0000000
--- a/src/rugby-application.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* rugby-application.h
- *
- * Copyright © 2012, 2016 Bruce Cowan <bruce@bcowan.eu>
- *
- * This file 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 3 of the
- * License, or (at your option) any later version.
- *
- * This file 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 General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define RUGBY_TYPE_APPLICATION rugby_application_get_type ()
-G_DECLARE_FINAL_TYPE (RugbyApplication, rugby_application, RUGBY, APPLICATION, GtkApplication)
-
-RugbyApplication * rugby_application_new (void);
-
-G_END_DECLS
diff --git a/src/rugby.c b/src/rugby.c
deleted file mode 100644
index 0667898..0000000
--- a/src/rugby.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* rugby.c
- *
- * Copyright © 2012 Bruce Cowan <bruce@bcowan.eu>
- *
- * This file 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 3 of the
- * License, or (at your option) any later version.
- *
- * This file 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 General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "rugby-application.h"
-
-int
-main (int    argc,
-      char **argv)
-{
-    RugbyApplication *app;
-    gint retval;
-
-    app = rugby_application_new ();
-    retval = g_application_run (G_APPLICATION (app), argc, argv);
-
-    return retval;
-}
-- 
GitLab