[d-spy] build: adjust versioning for release



commit bc45230d821fe55146fae722aa1a5046f6674303
Author: Christian Hergert <chergert redhat com>
Date:   Fri Sep 17 16:55:31 2021 -0700

    build: adjust versioning for release
    
    We really want to follow semantic internally so that we can be used as a
    library in a sane manner. But we also want GNOME version information to
    be released with the application.
    
    This does that (and adds an about dialog) for things.

 lib/dspy-version-macros.h | 37 ++++++------------
 lib/meson.build           | 22 +++--------
 meson.build               | 14 ++++++-
 src/build-ident.h.in      | 36 ++++++++++++++++++
 src/dspy-window.c         | 10 +++++
 src/dspy-window.ui        | 13 +++++++
 src/main.c                | 95 +++++++++++++++++++++++++++++++++++++----------
 src/meson.build           |  8 +++-
 8 files changed, 170 insertions(+), 65 deletions(-)
---
diff --git a/lib/dspy-version-macros.h b/lib/dspy-version-macros.h
index 77f5023..76d229a 100644
--- a/lib/dspy-version-macros.h
+++ b/lib/dspy-version-macros.h
@@ -38,8 +38,7 @@
 # define DSPY_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _DSPY_EXTERN
 #endif
 
-#define DSPY_VERSION_41_0 (G_ENCODE_VERSION (41, 0))
-#define DSPY_VERSION_42_0 (G_ENCODE_VERSION (42, 0))
+#define DSPY_VERSION_1_0 (G_ENCODE_VERSION (1, 0))
 
 #if (DSPY_MINOR_VERSION == 99)
 # define DSPY_VERSION_CUR_STABLE (G_ENCODE_VERSION (DSPY_MAJOR_VERSION + 1, 0))
@@ -102,36 +101,22 @@
 #if DSPY_VERSION_MAX_ALLOWED < DSPY_VERSION_MIN_REQUIRED
 #error "DSPY_VERSION_MAX_ALLOWED must be >= DSPY_VERSION_MIN_REQUIRED"
 #endif
-#if DSPY_VERSION_MIN_REQUIRED < DSPY_VERSION_41_0
-#error "DSPY_VERSION_MIN_REQUIRED must be >= DSPY_VERSION_41_0"
+#if DSPY_VERSION_MIN_REQUIRED < DSPY_VERSION_1_0
+#error "DSPY_VERSION_MIN_REQUIRED must be >= DSPY_VERSION_1_0"
 #endif
 
 #define DSPY_AVAILABLE_IN_ALL                  _DSPY_EXTERN
 
-#if DSPY_VERSION_MIN_REQUIRED >= DSPY_VERSION_41_0
-# define DSPY_DEPRECATED_IN_41_0                DSPY_DEPRECATED
-# define DSPY_DEPRECATED_IN_41_0_FOR(f)         DSPY_DEPRECATED_FOR(f)
+#if DSPY_VERSION_MIN_REQUIRED >= DSPY_VERSION_1_0
+# define DSPY_DEPRECATED_IN_1_0                DSPY_DEPRECATED
+# define DSPY_DEPRECATED_IN_1_0_FOR(f)         DSPY_DEPRECATED_FOR(f)
 #else
-# define DSPY_DEPRECATED_IN_41_0                _DSPY_EXTERN
-# define DSPY_DEPRECATED_IN_41_0_FOR(f)         _DSPY_EXTERN
+# define DSPY_DEPRECATED_IN_1_0                _DSPY_EXTERN
+# define DSPY_DEPRECATED_IN_1_0_FOR(f)         _DSPY_EXTERN
 #endif
 
-#if DSPY_VERSION_MAX_ALLOWED < DSPY_VERSION_41_0
-# define DSPY_AVAILABLE_IN_41_0                 DSPY_UNAVAILABLE(41, 0)
+#if DSPY_VERSION_MAX_ALLOWED < DSPY_VERSION_1_0
+# define DSPY_AVAILABLE_IN_1_0                 DSPY_UNAVAILABLE(1, 0)
 #else
-# define DSPY_AVAILABLE_IN_41_0                 _DSPY_EXTERN
-#endif
-
-#if DSPY_VERSION_MIN_REQUIRED >= DSPY_VERSION_42_0
-# define DSPY_DEPRECATED_IN_42_0                DSPY_DEPRECATED
-# define DSPY_DEPRECATED_IN_42_0_FOR(f)         DSPY_DEPRECATED_FOR(f)
-#else
-# define DSPY_DEPRECATED_IN_42_0                _DSPY_EXTERN
-# define DSPY_DEPRECATED_IN_42_0_FOR(f)         _DSPY_EXTERN
-#endif
-
-#if DSPY_VERSION_MAX_ALLOWED < DSPY_VERSION_42_0
-# define DSPY_AVAILABLE_IN_42_0                 DSPY_UNAVAILABLE(42, 0)
-#else
-# define DSPY_AVAILABLE_IN_42_0                 _DSPY_EXTERN
+# define DSPY_AVAILABLE_IN_1_0                 _DSPY_EXTERN
 #endif
diff --git a/lib/meson.build b/lib/meson.build
index aaf5cf8..0f3ce9c 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -1,16 +1,4 @@
-ABI_MAJOR = '0'
-
-lib_header_dir = join_paths(get_option('includedir'), 'dspy-@0@'.format(ABI_MAJOR))
-
-version_split = meson.project_version().split('.')
-version_major = version_split[0]
-if version_split[1].startswith('beta') or version_split[1].startswith('alpha')
-  version_minor = 0
-  version_micro = 0
-else
-  version_minor = version_split[1]
-  version_micro = version_split[2]
-endif
+lib_header_dir = join_paths(get_option('includedir'), 'dspy-@0@'.format(version_major))
 
 version_data = configuration_data()
 version_data.set('VERSION_MAJOR', version_major)
@@ -72,13 +60,13 @@ libdspy_sources += gnome.compile_resources('libdspy-resources', 'libdspy.gresour
   c_name: 'libdspy'
 )
 
-libdspy = library('dspy-@0@'.format(ABI_MAJOR), libdspy_sources,
+libdspy = library('dspy-@0@'.format(version_major), libdspy_sources,
            dependencies: libdspy_deps,
     include_directories: [ root_include_directory ],
                 install: true,
   gnu_symbol_visibility: 'hidden',
-                version: '@0@.0.0'.format(ABI_MAJOR),
-        darwin_versions: '@0@.0'.format(ABI_MAJOR.to_int() + 1),
+                version: '@0@.0.0'.format(version_major),
+        darwin_versions: '@0@.0'.format(version_major.to_int() + 1),
               link_args: release_link_args,
 )
 
@@ -89,4 +77,4 @@ libdspy_dep = declare_dependency(
 )
 
 install_headers(libdspy_headers,
-                subdir: 'dspy-@0@'.format(ABI_MAJOR))
+                subdir: 'dspy-@0@'.format(version_major))
diff --git a/meson.build b/meson.build
index c3825ab..9a40721 100644
--- a/meson.build
+++ b/meson.build
@@ -1,8 +1,15 @@
 project('dspy', 'c',
-        version: '41.beta1',
+        version: '0.99.0',
   meson_version: '>= 0.56.0',
 )
 
+symbolic_version = '41.rc1'
+
+version_split = meson.project_version().split('.')
+version_major = version_split[0]
+version_minor = version_split[1]
+version_micro = version_split[2]
+
 gnome = import('gnome')
 i18n = import('i18n')
 cc = meson.get_compiler('c')
@@ -15,10 +22,13 @@ else
 endif
 
 config_h = configuration_data()
+config_h.set_quoted('SYMBOLIC_VERSION', symbolic_version)
 config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
-config_h.set_quoted('GETTEXT_PACKAGE', 'dspy')
+config_h.set_quoted('PACKAGE_ICON_NAME', app_id)
+config_h.set_quoted('GETTEXT_PACKAGE', 'd-spy')
 config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
 config_h.set_quoted('APP_ID', app_id)
+config_h.set_quoted('PACKAGE_WEBSITE', 'https://gitlab.gnome.org/GNOME/d-spy')
 config_h.set10('DEVELOPMENT_BUILD', get_option('development'))
 
 glib_req_version = '2.68'
diff --git a/src/build-ident.h.in b/src/build-ident.h.in
new file mode 100644
index 0000000..3b76e33
--- /dev/null
+++ b/src/build-ident.h.in
@@ -0,0 +1,36 @@
+/* build-ident.h.in
+ *
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 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/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/**
+ * DSPY_BUILD_IDENTIFIER:
+ *
+ * A string containing a tag that defines the version that was built.
+ * Generally, this will be a small version tag plus some information to
+ * identify the git commit hash when applicable.
+ */
+#define DSPY_BUILD_IDENTIFIER "@VCS_TAG@"
+
+G_END_DECLS
diff --git a/src/dspy-window.c b/src/dspy-window.c
index 8bad7aa..328950f 100644
--- a/src/dspy-window.c
+++ b/src/dspy-window.c
@@ -26,6 +26,8 @@ struct _DspyWindow
 {
   AdwApplicationWindow  parent_instance;
   DspyView             *view;
+  GtkMenuButton        *primary_menu_button;
+  GMenu                *primary_menu;
 };
 
 G_DEFINE_TYPE (DspyWindow, dspy_window, ADW_TYPE_APPLICATION_WINDOW)
@@ -37,6 +39,8 @@ dspy_window_class_init (DspyWindowClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/dspy/dspy-window.ui");
   gtk_widget_class_bind_template_child (widget_class, DspyWindow, view);
+  gtk_widget_class_bind_template_child (widget_class, DspyWindow, primary_menu);
+  gtk_widget_class_bind_template_child (widget_class, DspyWindow, primary_menu_button);
 
   g_type_ensure (DSPY_TYPE_VIEW);
 }
@@ -46,6 +50,12 @@ dspy_window_init (DspyWindow *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  gtk_menu_button_set_menu_model (self->primary_menu_button, G_MENU_MODEL (self->primary_menu));
+
+#if GTK_CHECK_VERSION(4,4,0)
+  gtk_menu_button_set_primary (self->primary_menu_button, TRUE);
+#endif
+
 #if DEVELOPMENT_BUILD
   gtk_widget_add_css_class (GTK_WIDGET (self), "devel");
 #endif
diff --git a/src/dspy-window.ui b/src/dspy-window.ui
index 28d2558..66f4c0e 100644
--- a/src/dspy-window.ui
+++ b/src/dspy-window.ui
@@ -12,6 +12,11 @@
         <child>
           <object class="GtkHeaderBar" id="header_bar">
             <property name="show_title_buttons">True</property>
+            <child type="end">
+              <object class="GtkMenuButton" id="primary_menu_button">
+                <property name="icon-name">open-menu-symbolic</property>
+              </object>
+            </child>
           </object>
         </child>
         <child>
@@ -22,4 +27,12 @@
       </object>
     </child>
   </template>
+  <menu id="primary_menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_About D-Spy</attribute>
+        <attribute name="action">app.about</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>
diff --git a/src/main.c b/src/main.c
index cb90261..f07c63b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,44 +21,101 @@
 #include <adwaita.h>
 #include <glib/gi18n.h>
 
+#include "build-ident.h"
 #include "dspy-window.h"
 
+static const gchar *authors[] = {
+  "Christian Hergert",
+  NULL
+};
+
+static const gchar *artists[] = {
+  "Jakub Steiner",
+  NULL
+};
+
 static void
 on_activate (GtkApplication *app)
 {
-       GtkWindow *window;
+  GtkWindow *window;
+
+  g_assert (GTK_IS_APPLICATION (app));
+
+  window = gtk_application_get_active_window (app);
+  if (window == NULL)
+    window = g_object_new (DSPY_TYPE_WINDOW,
+                           "application", app,
+                           "default-width", 1000,
+                           "default-height", 700,
+                           NULL);
+
+  gtk_window_present (window);
+}
+
+static void
+about_action_cb (GSimpleAction *action,
+                 GVariant      *param,
+                 gpointer       user_data)
+{
+  GtkApplication *app = user_data;
+  g_autofree gchar *program_name = NULL;
+  GtkAboutDialog *dialog;
+  GtkWindow *window;
 
-       g_assert (GTK_IS_APPLICATION (app));
+  g_assert (GTK_IS_APPLICATION (app));
 
-       window = gtk_application_get_active_window (app);
-       if (window == NULL)
-               window = g_object_new (DSPY_TYPE_WINDOW,
-                                      "application", app,
-                                      "default-width", 1000,
-                                      "default-height", 700,
-                                      NULL);
+#ifdef DEVELOPMENT_BUILD
+  program_name = g_strdup_printf ("%s (Development)", _("D-Spy"));
+#else
+  program_name = g_strdup (_("D-Spy"));
+#endif
 
-       gtk_window_present (window);
+  dialog = GTK_ABOUT_DIALOG (gtk_about_dialog_new ());
+  gtk_about_dialog_set_program_name (dialog, program_name);
+  gtk_about_dialog_set_logo_icon_name (dialog, PACKAGE_ICON_NAME);
+  gtk_about_dialog_set_authors (dialog, authors);
+  gtk_about_dialog_set_artists (dialog, artists);
+#if DEVELOPMENT_BUILD
+  gtk_about_dialog_set_version (dialog, SYMBOLIC_VERSION " (" DSPY_BUILD_IDENTIFIER ")");
+#else
+  gtk_about_dialog_set_version (dialog, SYMBOLIC_VERSION);
+#endif
+  gtk_about_dialog_set_copyright (dialog, "© 2019-2021 Christian Hergert");
+  gtk_about_dialog_set_license_type (dialog, GTK_LICENSE_GPL_3_0);
+  gtk_about_dialog_set_website (dialog, PACKAGE_WEBSITE);
+  gtk_about_dialog_set_website_label (dialog, _("D-Spy Website"));
+  gtk_about_dialog_set_comments (dialog, _("Explore the D-Bus"));
+
+  window = gtk_application_get_active_window (app);
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+  gtk_window_present (GTK_WINDOW (dialog));
 }
 
+static const GActionEntry actions[] = {
+  { "about", about_action_cb },
+};
+
 int
 main (int   argc,
       char *argv[])
 {
-       g_autoptr(GtkApplication) app = NULL;
-       int ret;
+  g_autoptr(GtkApplication) app = NULL;
+  int ret;
 
-       bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-       bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-       textdomain (GETTEXT_PACKAGE);
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
 
-       app = g_object_new (ADW_TYPE_APPLICATION,
+  app = g_object_new (ADW_TYPE_APPLICATION,
                       "application-id", APP_ID,
                       "flags", G_APPLICATION_FLAGS_NONE,
                       "resource-base-path", "/org/gnome/dspy",
                       NULL);
-       g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
-       ret = g_application_run (G_APPLICATION (app), argc, argv);
+  g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
+  g_action_map_add_action_entries (G_ACTION_MAP (app), actions, G_N_ELEMENTS (actions), app);
+  ret = g_application_run (G_APPLICATION (app), argc, argv);
 
-       return ret;
+  return ret;
 }
diff --git a/src/meson.build b/src/meson.build
index a9fdfc3..be5d6ab 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -14,7 +14,13 @@ dspy_sources += gnome.compile_resources('dspy-resources', 'dspy.gresource.xml',
   c_name: 'dspy'
 )
 
-dspy = executable('d-spy', dspy_sources,
+build_ident_h = vcs_tag(
+     fallback: meson.project_version(),
+        input: 'build-ident.h.in',
+       output: 'build-ident.h',
+)
+
+dspy = executable('d-spy', dspy_sources + [build_ident_h],
          dependencies: dspy_deps,
               install: true,
   include_directories: root_include_directory,


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