[gnome-calculator] build: implement devel mode



commit 8e17e5d6c1f5bb755e47f6fbfcbf3d63e55fef32
Author: oscfdezdz <oscfdezdz tuta io>
Date:   Wed Dec 8 10:44:14 2021 +0100

    build: implement devel mode

 .gitlab-ci.yml                                     |  4 +-
 data/meson.build                                   | 58 +++++++++++++++-------
 data/org.gnome.Calculator.desktop.in               |  2 +-
 meson.build                                        | 16 +++++-
 meson_options.txt                                  |  1 +
 ...culator.json => org.gnome.Calculator.Devel.json |  8 +--
 src/gnome-calculator.vala                          |  8 +--
 src/math-preferences.vala                          |  4 ++
 src/math-window.vala                               |  5 ++
 vapi/config.vapi                                   |  3 ++
 10 files changed, 80 insertions(+), 29 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a151b117..bb867fc8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,9 +3,9 @@ include: 'https://gitlab.gnome.org/GNOME/citemplates/raw/master/flatpak/flatpak_
 flatpak:
   image: 'registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master'
   variables:
-    MANIFEST_PATH: "org.gnome.Calculator.json"
+    MANIFEST_PATH: "org.gnome.Calculator.Devel.json"
     FLATPAK_MODULE: "gnome-calculator"
-    APP_ID: "org.gnome.Calculator"
+    APP_ID: "org.gnome.Calculator.Devel"
     RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo";
     BUNDLE: "gnome-calculator-dev.flatpak"
   extends: '.flatpak'
diff --git a/data/meson.build b/data/meson.build
index 0f85acd3..ffc73f26 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,31 +1,55 @@
 # Icons
-install_subdir('icons',
-  install_dir: join_paths(get_option('datadir')),
+scalable_iconsdir = join_paths('icons', 'hicolor', 'scalable', 'apps')
+install_data(
+  join_paths(scalable_iconsdir, '@0@.svg'.format(app_id)),
+  install_dir: join_paths(get_option('datadir'), scalable_iconsdir)
+)
+
+symbolic_iconsdir = join_paths('icons', 'hicolor', 'symbolic', 'apps')
+install_data(
+  join_paths(symbolic_iconsdir, 'org.gnome.Calculator-symbolic.svg'),
+  install_dir: join_paths(get_option('datadir'), symbolic_iconsdir),
+  rename: '@0 -symbolic svg'.format(app_id)
 )
 
 # Desktop file
-i18n.merge_file(
-  input: 'org.gnome.Calculator.desktop.in',
-  output: 'org.gnome.Calculator.desktop',
-  type: 'desktop',
-  po_dir: po_dir,
-  install: true,
-  install_dir: join_paths(get_option('datadir'), 'applications'),
+desktop_file_in_config = configuration_data()
+desktop_file_in_config.set('app_id', app_id)
+desktop_file_in = configure_file(
+          input: 'org.gnome.Calculator.desktop.in',
+         output: '@0  desktop in'.format(app_id),
+  configuration: desktop_file_in_config,
+)
+
+desktop_file = i18n.merge_file(
+        input: desktop_file_in,
+       output: '@0@.desktop'.format(app_id),
+         type: 'desktop',
+       po_dir: po_dir,
+      install: true,
+  install_dir: join_paths(get_option('datadir'), 'applications')
 )
 
 # Appdata
-i18n.merge_file(
-  input: 'org.gnome.Calculator.appdata.xml.in',
-  output: 'org.gnome.Calculator.appdata.xml',
-  type: 'xml',
-  po_dir: po_dir,
-  install: true,
-  install_dir: join_paths(get_option('datadir'), 'metainfo')
+appconf = configuration_data()
+appconf.set('app_id', app_id)
+appstream_file_in = configure_file(
+          input: 'org.gnome.Calculator.appdata.xml.in',
+         output: '@0  appdata xml in'.format(app_id),
+  configuration: appconf,
+)
+
+appstream_file = i18n.merge_file(
+          input: appstream_file_in,
+         output: '@0  appdata xml'.format(app_id),
+         po_dir: po_dir,
+        install: true,
+    install_dir: join_paths(get_option('datadir'), 'metainfo')
 )
 
 # Gschema
 install_data('org.gnome.calculator.gschema.xml',
-  install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas'),
+  install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas'),
 )
 
 # Manpage
diff --git a/data/org.gnome.Calculator.desktop.in b/data/org.gnome.Calculator.desktop.in
index 96e283b9..f7c0a5e4 100644
--- a/data/org.gnome.Calculator.desktop.in
+++ b/data/org.gnome.Calculator.desktop.in
@@ -5,7 +5,7 @@ Comment=Perform arithmetic, scientific or financial calculations
 Keywords=calculation;arithmetic;scientific;financial;
 Exec=gnome-calculator
 # Translators: Do NOT translate or transliterate this text (this is an icon file name)!
-Icon=org.gnome.Calculator
+Icon=@app_id@
 Terminal=false
 Type=Application
 StartupNotify=true
diff --git a/meson.build b/meson.build
index 431b91dd..7d2d71e1 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,17 @@ inc_rooth_dep = declare_dependency (include_directories : inc_rooth)
 gnome = import('gnome')
 i18n = import('i18n')
 
+if get_option('development')
+  app_id = 'org.gnome.Calculator.Devel'
+  name_prefix = '(Nightly) '
+  vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
+  version_suffix = '-@0@'.format (vcs_tag)
+else
+  app_id = 'org.gnome.Calculator'
+  name_prefix = ''
+  version_suffix = ''
+endif
+
 # Some variables
 libexec_dir = join_paths(get_option('prefix'), get_option('libexecdir'))
 locale_dir = join_paths(get_option('prefix'), get_option('localedir'))
@@ -53,9 +64,12 @@ posix = valac.find_library('posix')
 # Configuration
 conf = configuration_data()
 
+conf.set_quoted('APP_ID', app_id)
+conf.set_quoted('NAME_PREFIX', name_prefix)
 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
 conf.set_quoted('LOCALE_DIR', locale_dir)
-conf.set_quoted('VERSION', meson.project_version())
+conf.set_quoted('VERSION', meson.project_version() + version_suffix)
+conf.set10('DEVELOPMENT_BUILD', get_option('development'))
 
 configure_file(output: 'config.h', configuration: conf)
 config_h_dir = include_directories('.')
diff --git a/meson_options.txt b/meson_options.txt
index 5b239427..2fb0b591 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -3,3 +3,4 @@ option('vala-version', type: 'string', value : '', description : 'Use another ve
 option('disable-introspection', type : 'boolean', value : false, description : 'Disable GObject 
Introspection Typelib generation')
 option('ui-tests', type : 'boolean', value : false, description : 'Execute UI tests: requires 
X/Wayland/Broadway/Windows server')
 option('libpath', type: 'string', value : '', description : 'Used to add search path for libraries like mpc')
+option('development', type: 'boolean', value: false, description: 'If this is a development build')
diff --git a/org.gnome.Calculator.json b/org.gnome.Calculator.Devel.json
similarity index 94%
rename from org.gnome.Calculator.json
rename to org.gnome.Calculator.Devel.json
index 0393ddb4..43cdbbda 100644
--- a/org.gnome.Calculator.json
+++ b/org.gnome.Calculator.Devel.json
@@ -1,5 +1,5 @@
 {
-    "app-id" : "org.gnome.Calculator",
+    "app-id" : "org.gnome.Calculator.Devel",
     "runtime" : "org.gnome.Sdk",
     "runtime-version" : "master",
     "sdk" : "org.gnome.Sdk",
@@ -59,7 +59,7 @@
         },
         {
             "name" : "gtksourceview",
-            "buildsystem": "meson",
+            "buildsystem" : "meson",
             "sources" : [
                 {
                     "type" : "git",
@@ -68,7 +68,6 @@
                 }
             ]
         },
-
         {
             "name" : "gee",
             "config-opts" : [
@@ -86,7 +85,8 @@
             "name" : "gnome-calculator",
             "buildsystem" : "meson",
             "config-opts" : [
-                "-Ddisable-introspection=true"
+                "-Ddisable-introspection=true",
+                "-Ddevelopment=true"
             ],
             "sources" : [
                 {
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index 537782b8..86d8fb30 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -40,7 +40,7 @@ public class Calculator : Gtk.Application
 
     public Calculator ()
     {
-        Object (flags : ApplicationFlags.NON_UNIQUE, application_id : "org.gnome.Calculator");
+        Object (flags : ApplicationFlags.NON_UNIQUE, application_id : APP_ID);
 
         add_main_option_entries (option_entries);
     }
@@ -321,7 +321,7 @@ public class Calculator : Gtk.Application
         Gtk.show_about_dialog (get_active_window (),
                                "program-name",
                                /* Program name in the about dialog */
-                               _("Calculator"),
+                               NAME_PREFIX + _("Calculator"),
                                "title", _("About Calculator"),
                                "version", VERSION,
                                "website", "https://wiki.gnome.org/Apps/Calculator";,
@@ -335,7 +335,7 @@ public class Calculator : Gtk.Application
                                "authors", authors,
                                "documenters", documenters,
                                "translator_credits", translator_credits,
-                               "logo-icon-name", "org.gnome.Calculator");
+                               "logo-icon-name", APP_ID);
     }
 
     private void quit_cb ()
@@ -378,7 +378,7 @@ public class Calculator : Gtk.Application
 
         program_name = Path.get_basename (args [0]);
 
-        Gtk.Window.set_default_icon_name ("org.gnome.Calculator-symbolic");
+        Gtk.Window.set_default_icon_name (APP_ID + "-symbolic");
 
         var app = new Calculator ();
 
diff --git a/src/math-preferences.vala b/src/math-preferences.vala
index b1654bd0..af6ffc2a 100644
--- a/src/math-preferences.vala
+++ b/src/math-preferences.vala
@@ -98,6 +98,10 @@ public class MathPreferencesDialog : Adw.PreferencesWindow
         equation.notify["angle-units"].connect ((pspec) => { set_combo_row_from_int (row_angle_units, 
equation.angle_units); });
 
         set_combo_row_from_int (row_refresh_interval, settings.get_int ("refresh-interval"));
+
+        if (DEVELOPMENT_BUILD) {
+            add_css_class ("devel");
+        }
     }
 
     private static string angle_units_name (Adw.EnumListItem item) {
diff --git a/src/math-window.vala b/src/math-window.vala
index 05e4dec3..4df796dd 100644
--- a/src/math-window.vala
+++ b/src/math-window.vala
@@ -87,6 +87,11 @@ public class MathWindow : Adw.ApplicationWindow
         var provider = new Gtk.CssProvider ();
         provider.load_from_resource ("/org/gnome/calculator/calculator.css");
         Gtk.StyleContext.add_provider_for_display (display, provider, 
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+        if (DEVELOPMENT_BUILD) {
+            add_css_class ("devel");
+        }
+
     }
 
     private void clear_cb ()
diff --git a/vapi/config.vapi b/vapi/config.vapi
index a1bb094d..192beb51 100644
--- a/vapi/config.vapi
+++ b/vapi/config.vapi
@@ -1,3 +1,6 @@
+public const string APP_ID;
+public const string NAME_PREFIX;
 public const string VERSION;
 public const string GETTEXT_PACKAGE;
 public const string LOCALE_DIR;
+public const bool DEVELOPMENT_BUILD;


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