[recipes] Use the same version string in about dialog and --version



commit 4f5858e823af2595ede8b286d955b3e7aa68514f
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jun 6 17:52:44 2017 -0400

    Use the same version string in about dialog and --version
    
    We show either the `git describe` (for development
    versions, or the package version (for release builds).
    
    Split out the code that obtains this information into
    a helper function, and use it in both places.

 src/gr-about-dialog.c |   10 +---------
 src/gr-app.c          |    2 +-
 src/gr-utils.c        |   11 +++++++++++
 src/gr-utils.h        |    2 +-
 4 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/gr-about-dialog.c b/src/gr-about-dialog.c
index 1342037..784fa8c 100644
--- a/src/gr-about-dialog.c
+++ b/src/gr-about-dialog.c
@@ -895,8 +895,6 @@ gr_about_dialog_new (void)
         g_autofree char **recipe_authors = NULL;
         guint length;
         g_autoptr(GdkPixbuf) logo = NULL;
-        const char *p;
-        const char *version;
         GrRecipeStore *store;
 
         logo = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
@@ -905,15 +903,9 @@ gr_about_dialog_new (void)
                                          GTK_ICON_LOOKUP_FORCE_SIZE,
                                          NULL);
 
-        p = strrchr (PACKAGE_VERSION, '.');
-        if (p && (atoi (p + 1) % 2 == 1))
-                version = COMMIT_ID;
-        else
-                version = PACKAGE_VERSION;
-
         about = g_object_new (GR_TYPE_ABOUT_DIALOG,
                               "program-name", _("Recipes"),
-                              "version", version,
+                              "version", get_version (),
                               "copyright", "© 2016, 2017 Matthias Clasen",
                               "license-type", GTK_LICENSE_GPL_3_0,
                               "comments", _("GNOME loves to cook"),
diff --git a/src/gr-app.c b/src/gr-app.c
index e0fa852..09ed38b 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -456,7 +456,7 @@ gr_app_handle_local_options (GApplication *app,
         const char *category;
 
         if (g_variant_dict_lookup (options, "version", "b", &value)) {
-                g_print ("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
+                g_print ("%s %s\n", PACKAGE_NAME, get_version ());
                 return 0;
         }
 
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 9a23eb3..8c85b88 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -809,3 +809,14 @@ strv_remove (char       ***strv_in,
         g_free (*strv_in);
         *strv_in = strv;
 }
+
+const char *
+get_version (void)
+{
+        const char *p = strrchr (PACKAGE_VERSION, '.');
+
+        if (p && (atoi (p + 1) % 2 == 1))
+                return COMMIT_ID;
+        else
+                return PACKAGE_VERSION;
+}
diff --git a/src/gr-utils.h b/src/gr-utils.h
index 3e5977f..919d7d0 100644
--- a/src/gr-utils.h
+++ b/src/gr-utils.h
@@ -83,4 +83,4 @@ void strv_remove (char       ***strv_in,
 void strv_prepend (char       ***strv_in,
                    const char   *s);
 
-
+const char *get_version (void);


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