[atomix/wip/gtk3-port] Make sure we are single-instance



commit a5f6c95f214a904e8a519d5b0f6d0486ca1eef4c
Author: Robert Roth <robert roth off gmail com>
Date:   Sat Dec 26 04:10:58 2015 +0200

    Make sure we are single-instance

 src/main.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index a0a313c..b788de6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -657,15 +657,20 @@ static AtomixApp *create_gui (void)
 static void
 app_activate (GApplication *app_instance, gpointer user_data)
 {
-  /* make a few initalisations here */
-  app = create_gui ();
 
-  game_init ();
+  if (app == NULL) {
+    /* make a few initalisations here */
+    app = create_gui ();
 
-  gtk_widget_set_size_request (GTK_WIDGET (app->mainwin), 678, 520);
-  //gtk_window_set_resizable (GTK_WINDOW (app->mainwin), FALSE);
-  gtk_widget_show (app->mainwin);
-  gtk_application_add_window (GTK_APPLICATION (app_instance), GTK_WINDOW (app->mainwin));
+    game_init ();
+
+    gtk_widget_set_size_request (GTK_WIDGET (app->mainwin), 678, 520);
+    //gtk_window_set_resizable (GTK_WINDOW (app->mainwin), FALSE);
+    gtk_widget_show (app->mainwin);
+    gtk_application_add_window (GTK_APPLICATION (app_instance), GTK_WINDOW (app->mainwin));
+  } else {
+    gtk_window_present (GTK_WINDOW (app->mainwin));
+  }
 }
 
 int main (int argc, char *argv[])


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