[gnome-sudoku/qqwing-version] Display QQwing version on about dialog



commit d405a2a391f52df8c4eb76b806d31d484140e1f8
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Wed Aug 6 18:57:22 2014 -0500

    Display QQwing version on about dialog

 lib/qqwing-wrapper.cpp    |   13 +++++++++++++
 lib/qqwing-wrapper.h      |    1 +
 lib/qqwing.vapi           |    1 +
 lib/sudoku-generator.vala |    5 +++++
 src/gnome-sudoku.vala     |    3 ++-
 5 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/lib/qqwing-wrapper.cpp b/lib/qqwing-wrapper.cpp
index 8fba300..7118521 100644
--- a/lib/qqwing-wrapper.cpp
+++ b/lib/qqwing-wrapper.cpp
@@ -12,6 +12,7 @@
 #include "qqwing-wrapper.h"
 
 #include <algorithm>
+#include <cstring>
 #include <iostream>
 
 #include <glib.h>
@@ -75,3 +76,15 @@ void qqwing_print_stats(int* puzzle)
     cout << "Number of Backtracks: " << board.getBacktrackCount() << endl;
     cout << "Difficulty: " << board.getDifficultyAsString() << endl;
 }
+
+/*
+ * Returns the version of qqwing in use.
+ * Free with g_free() or free()
+ */
+char* qqwing_get_version()
+{
+    string version = getVersion();
+    char* copy = static_cast<char*>(g_malloc(version.length() + 1)); // +1 for the trailing nullptr
+    strcpy(copy, version.c_str());
+    return copy;
+}
diff --git a/lib/qqwing-wrapper.h b/lib/qqwing-wrapper.h
index 42c683a..aafea5c 100644
--- a/lib/qqwing-wrapper.h
+++ b/lib/qqwing-wrapper.h
@@ -18,6 +18,7 @@ G_BEGIN_DECLS
 
 int *qqwing_generate_puzzle(int difficulty);
 void qqwing_print_stats(int *puzzle);
+char *qqwing_get_version(void);
 
 G_END_DECLS
 
diff --git a/lib/qqwing.vapi b/lib/qqwing.vapi
index 27d4888..6f48ef8 100644
--- a/lib/qqwing.vapi
+++ b/lib/qqwing.vapi
@@ -3,4 +3,5 @@ namespace QQwing {
     [CCode (array_length=false)]
     int[] generate_puzzle (int difficulty);
     void print_stats ([CCode (array_length = false)] int[] puzzle);
+    string get_version ();
 }
diff --git a/lib/sudoku-generator.vala b/lib/sudoku-generator.vala
index bde2107..c53a406 100644
--- a/lib/sudoku-generator.vala
+++ b/lib/sudoku-generator.vala
@@ -33,4 +33,9 @@ public class SudokuGenerator : Object
 
         QQwing.print_stats (puzzle);
     }
+
+    public static string qqwing_version ()
+    {
+        return QQwing.get_version ();
+    }
 }
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index 2b639f6..4ea4a35 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -341,7 +341,8 @@ public class Sudoku : Gtk.Application
                                "program-name", _("Sudoku"),
                                "logo-icon-name", "gnome-sudoku",
                                "version", VERSION,
-                               "comments", _("The popular Japanese logic puzzle\n\nGNOME Sudoku is a part of 
GNOME Games."),
+                               /* Appears on the About dialog. %s is the version of the QQwing puzzle 
generator in use. */
+                               "comments", _("The popular Japanese logic puzzle\n\nPuzzles by QQwing 
%s".printf (SudokuGenerator.qqwing_version ())),
                                "copyright", "Copyright © 2005–2008 Thomas M. Hinkle\nCopyright © 2010–2011 
Robert Ancell\nCopyright © 2014 Parin Porecha",
                                "license-type", License.GPL_2_0,
                                "authors", authors,


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