[gnome-nibbles] Port to meson



commit 844d78ea2cbe23ba66d06413bc8b72b8eb4ac6d9
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Tue May 7 21:57:00 2019 +0000

    Port to meson

 .gitignore                                         |   1 +
 Makefile.am                                        |   9 -
 autogen.sh                                         |  47 ---
 data/icons/Makefile.am                             |   3 -
 .../{gnome-nibbles.png => org.gnome.Nibbles.png}   | Bin
 .../{gnome-nibbles.png => org.gnome.Nibbles.png}   | Bin
 .../{gnome-nibbles.png => org.gnome.Nibbles.png}   | Bin
 .../{gnome-nibbles.png => org.gnome.Nibbles.png}   | Bin
 .../{gnome-nibbles.png => org.gnome.Nibbles.png}   | Bin
 data/icons/hicolor/Makefile.am                     |  17 --
 .../{gnome-nibbles.svg => org.gnome.Nibbles.svg}   |   0
 ...symbolic.svg => org.gnome.Nibbles-symbolic.svg} |   0
 data/levels/Makefile.am                            |  30 --
 data/levels/meson.build                            |  30 ++
 data/meson.build                                   |  91 ++++++
 data/nibbles.ui                                    |   2 +-
 data/org.gnome.Nibbles.appdata.xml.in              |  16 +-
 data/org.gnome.Nibbles.desktop.in                  |  10 +-
 data/pix/Makefile.am                               |  45 ---
 data/pix/meson.build                               |  42 +++
 git.mk                                             | 332 ---------------------
 help/LINGUAS                                       |   9 +
 help/meson.build                                   |  32 ++
 meson.build                                        |  58 ++++
 meson_post_install.py                              |  21 ++
 po/POTFILES.in                                     |  10 +-
 po/meson.build                                     |   3 +
 src/Makefile.am                                    |  50 ----
 src/gnome-nibbles.vala                             |   4 +-
 src/meson.build                                    |  36 +++
 src/{ => vapi}/config.vapi                         |   0
 src/vapi/libcanberra-gtk3.vapi                     |  37 +++
 32 files changed, 382 insertions(+), 553 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..378eac2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/data/icons/hicolor/16x16/gnome-nibbles.png b/data/icons/hicolor/16x16/org.gnome.Nibbles.png
similarity index 100%
rename from data/icons/hicolor/16x16/gnome-nibbles.png
rename to data/icons/hicolor/16x16/org.gnome.Nibbles.png
diff --git a/data/icons/hicolor/22x22/gnome-nibbles.png b/data/icons/hicolor/22x22/org.gnome.Nibbles.png
similarity index 100%
rename from data/icons/hicolor/22x22/gnome-nibbles.png
rename to data/icons/hicolor/22x22/org.gnome.Nibbles.png
diff --git a/data/icons/hicolor/24x24/gnome-nibbles.png b/data/icons/hicolor/24x24/org.gnome.Nibbles.png
similarity index 100%
rename from data/icons/hicolor/24x24/gnome-nibbles.png
rename to data/icons/hicolor/24x24/org.gnome.Nibbles.png
diff --git a/data/icons/hicolor/32x32/gnome-nibbles.png b/data/icons/hicolor/32x32/org.gnome.Nibbles.png
similarity index 100%
rename from data/icons/hicolor/32x32/gnome-nibbles.png
rename to data/icons/hicolor/32x32/org.gnome.Nibbles.png
diff --git a/data/icons/hicolor/48x48/gnome-nibbles.png b/data/icons/hicolor/48x48/org.gnome.Nibbles.png
similarity index 100%
rename from data/icons/hicolor/48x48/gnome-nibbles.png
rename to data/icons/hicolor/48x48/org.gnome.Nibbles.png
diff --git a/data/icons/hicolor/scalable/gnome-nibbles.svg b/data/icons/hicolor/scalable/org.gnome.Nibbles.svg
similarity index 100%
rename from data/icons/hicolor/scalable/gnome-nibbles.svg
rename to data/icons/hicolor/scalable/org.gnome.Nibbles.svg
diff --git a/data/icons/hicolor/symbolic/gnome-nibbles-symbolic.svg 
b/data/icons/hicolor/symbolic/org.gnome.Nibbles-symbolic.svg
similarity index 100%
rename from data/icons/hicolor/symbolic/gnome-nibbles-symbolic.svg
rename to data/icons/hicolor/symbolic/org.gnome.Nibbles-symbolic.svg
diff --git a/data/levels/meson.build b/data/levels/meson.build
new file mode 100644
index 0000000..55f3229
--- /dev/null
+++ b/data/levels/meson.build
@@ -0,0 +1,30 @@
+levels = [
+    'level001.gnl',
+    'level002.gnl',
+    'level003.gnl',
+    'level004.gnl',
+    'level005.gnl',
+    'level006.gnl',
+    'level007.gnl',
+    'level008.gnl',
+    'level009.gnl',
+    'level010.gnl',
+    'level011.gnl',
+    'level012.gnl',
+    'level013.gnl',
+    'level014.gnl',
+    'level015.gnl',
+    'level016.gnl',
+    'level017.gnl',
+    'level018.gnl',
+    'level019.gnl',
+    'level020.gnl',
+    'level021.gnl',
+    'level022.gnl',
+    'level023.gnl',
+    'level024.gnl',
+    'level025.gnl',
+    'level026.gnl',
+]
+
+install_data(levels, install_dir: join_paths(pkgdatadir, 'levels'))
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..d56caa9
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,91 @@
+# Desktop file
+desktop_file = i18n.merge_file(
+    input: 'org.gnome.Nibbles.desktop.in',
+    output: 'org.gnome.Nibbles.desktop',
+    type: 'desktop',
+    po_dir: podir,
+    install: true,
+    install_dir: join_paths(datadir, 'applications')
+)
+
+# Validate desktop file
+desktop_file_validate = find_program('desktop-file-validate', required: false)
+if desktop_file_validate.found()
+  test(
+    'validate-desktop',
+    desktop_file_validate,
+    args: [
+      desktop_file.full_path()
+    ]
+  )
+endif
+
+# Sound
+install_data([
+    'appear.ogg',
+    'bonus.ogg',
+    'crash.ogg',
+    'gameover.ogg',
+    'gobble.ogg',
+    'life.ogg',
+    'reverse.ogg',
+    'teleport.ogg'
+], install_dir: sounddir)
+
+# UI files
+install_data([
+    'nibbles.ui',
+    'nibbles.css',
+    'scoreboard.ui',
+    'player-score-box.ui',
+    'controls-grid.ui',
+    'preferences-dialog.ui'
+], install_dir: pkgdatadir)
+
+# Icons
+foreach size: [ '16x16', '22x22', '24x24', '32x32', '48x48' ]
+    install_data(join_paths('icons', 'hicolor', size, 'org.gnome.Nibbles.png'),
+                 install_dir: join_paths (datadir, 'icons', 'hicolor', size, 'apps')
+    )
+endforeach
+
+install_data(join_paths('icons', 'hicolor', 'scalable', 'org.gnome.Nibbles.svg'),
+             install_dir: join_paths (datadir, 'icons', 'hicolor', 'scalable', 'apps'))
+install_data(join_paths('icons', 'hicolor', 'symbolic', 'org.gnome.Nibbles-symbolic.svg'),
+             install_dir: join_paths (datadir, 'icons', 'hicolor', 'symbolic', 'apps'))
+
+# Appdata
+appdata_file = i18n.merge_file(
+    input: 'org.gnome.Nibbles.appdata.xml.in',
+    output: 'org.gnome.Nibbles.appdata.xml',
+    type: 'xml',
+    po_dir: podir,
+    install: true,
+    install_dir: join_paths(datadir, 'metainfo'),
+)
+
+# Validate AppData file
+appstream_util = find_program('appstream-util', required: false)
+if appstream_util.found()
+  test(
+    'validate-appdata', appstream_util,
+    args: [
+      'validate-relax', appdata_file.full_path()
+    ]
+  )
+endif
+
+# Gschema
+install_data('org.gnome.nibbles.gschema.xml',
+    install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
+)
+
+# Gresource
+resources = gnome.compile_resources('gnome-nibbles', 'gnome-nibbles.gresource.xml')
+
+# Manpage
+install_man('gnome-nibbles.6')
+
+# Subdirs
+subdir('levels')
+subdir('pix')
diff --git a/data/nibbles.ui b/data/nibbles.ui
index ffe5c32..9c05a42 100644
--- a/data/nibbles.ui
+++ b/data/nibbles.ui
@@ -122,7 +122,7 @@
                                                 <child>
                                                     <object class="GtkImage">
                                                         <property name="visible">True</property>
-                                                        <property name="icon-name">gnome-nibbles</property>
+                                                        <property 
name="icon-name">org.gnome.Nibbles</property>
                                                         <property name="icon-size">6</property> <!-- DIALOG 
-->
                                                         <property name="pixel-size">96</property>
                                                     </object>
diff --git a/data/org.gnome.Nibbles.appdata.xml.in b/data/org.gnome.Nibbles.appdata.xml.in
index 26f67ad..f16bcd9 100644
--- a/data/org.gnome.Nibbles.appdata.xml.in
+++ b/data/org.gnome.Nibbles.appdata.xml.in
@@ -4,25 +4,25 @@
   <id>org.gnome.Nibbles.desktop</id>
   <metadata_license>CC0-1.0</metadata_license>
   <project_license>GPL-3.0+</project_license>
-  <_name>GNOME Nibbles</_name>
+  <name>GNOME Nibbles</name>
   <_summary>Guide a worm around a maze</_summary>
   <description>
-    <_p>
+    <p>
       Control a worm in its quest to eat bonuses and become longer. Outmaneuver
       enemy worms while eating doughnuts and ice cream to increase your length.
       Each worm has ten lives and loses one by running into a wall, another worm,
       or itself. The enemy worms are after the same bonuses that you are, so be
       careful: if they become too large, you won’t have much room for movement.
-    </_p>
-    <_p>
+    </p>
+    <p>
       The adventure progresses through 26 maps of increasing difficulty. The early
       levels are mostly open with a few walls, but later on, cramped spaces and
       teleporters make things more interesting.
-    </_p>
-    <_p>
+    </p>
+    <p>
       Play on your own against up to five enemy worms, or share your keyboard to
       play with a friend.
-    </_p>
+    </p>
   </description>
   <screenshots>
     <screenshot height="608" width="972" type="default">
@@ -43,5 +43,5 @@
     <kudo>UserDocs</kudo>
   </kudos>
   <translation type="gettext">gnome-nibbles</translation>
-  <_developer_name>The GNOME Project</_developer_name>
+  <developer_name>The GNOME Project</developer_name>
 </component>
diff --git a/data/org.gnome.Nibbles.desktop.in b/data/org.gnome.Nibbles.desktop.in
index 24e84d9..c6c2d16 100644
--- a/data/org.gnome.Nibbles.desktop.in
+++ b/data/org.gnome.Nibbles.desktop.in
@@ -1,9 +1,11 @@
 [Desktop Entry]
-_Name=Nibbles
-_Comment=Guide a worm around a maze
-_Keywords=game;snake;board;
+Name=Nibbles
+Comment=Guide a worm around a maze
+# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list 
MUST also end with a semicolon!
+Keywords=game;snake;board;
 Exec=gnome-nibbles
-Icon=gnome-nibbles
+# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
+Icon=org.gnome.Nibbles
 Terminal=false
 Type=Application
 Categories=GNOME;GTK;Game;ArcadeGame;
diff --git a/data/pix/meson.build b/data/pix/meson.build
new file mode 100644
index 0000000..e70792e
--- /dev/null
+++ b/data/pix/meson.build
@@ -0,0 +1,42 @@
+bonus_pix = [
+    'bonus1.svg',
+    'bonus2.svg',
+    'bonus3.svg',
+    'bonus4.svg',
+    'bonus5.svg',
+    'diamond.svg',
+    'life.svg',
+    'questionmark.svg',
+]
+
+small_pix = [
+    'snake-blue.svg',
+    'snake-cyan.svg',
+    'snake-green.svg',
+    'snake-magenta.svg',
+    'snake-red.svg',
+    'snake-yellow.svg',
+    'wall-corner-bottom-left.svg',
+    'wall-corner-bottom-right.svg',
+    'wall-corner-top-left.svg',
+    'wall-corner-top-right.svg',
+    'wall-cross.svg',
+    'wall-straight-side.svg',
+    'wall-straight-up.svg',
+    'wall-tee-down.svg',
+    'wall-tee-left.svg',
+    'wall-tee-right.svg',
+    'wall-tee-up.svg',
+]
+
+scoreboard_pix = [
+    'scoreboard-life.svg',
+]
+
+controls_pix = [
+    'arrow.svg',
+    'arrow-key.svg',
+]
+
+install_data(bonus_pix + small_pix + scoreboard_pix + controls_pix,
+    install_dir: join_paths(pkgdatadir, 'pixmaps'))
diff --git a/help/LINGUAS b/help/LINGUAS
new file mode 100644
index 0000000..68254be
--- /dev/null
+++ b/help/LINGUAS
@@ -0,0 +1,9 @@
+cs
+de
+el
+es
+fr
+hu
+pl
+sv
+tr
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..d75dce7
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,32 @@
+gnome_nibbles_help_pages = [
+    'basics.page',
+    'controls-change.page',
+    'controls-default.page',
+    'fake-bonus.page',
+    'index.page',
+    'multi-player.page',
+    'preferences.page',
+    'scores.page',
+    'legal.xml',
+]
+
+gnome_nibbles_help_media = [
+    'figures/cherry.svg',
+    'figures/diamond.svg',
+    'figures/donut.svg',
+    'figures/ice-cream.svg',
+    'figures/life.svg',
+    'figures/nibbles.png',
+    'figures/snake-blue.svg',
+    'figures/snake-cyan.svg',
+    'figures/snake-green.svg',
+    'figures/snake-grey.svg',
+    'figures/snake-magenta.svg',
+    'figures/snake-red.svg',
+    'figures/snake-yellow.svg',
+]
+
+gnome.yelp(meson.project_name(),
+    sources: gnome_nibbles_help_pages,
+    media: gnome_nibbles_help_media
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..6d49218
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,58 @@
+project('gnome-nibbles', ['c', 'vala'],
+  license: 'GPL3+',
+  meson_version: '>= 0.44.1',
+  version: '3.23.92'
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+prefix = get_option('prefix')
+datadir = join_paths(prefix, get_option('datadir'))
+pkgdatadir = join_paths(datadir, meson.project_name())
+sounddir = join_paths(pkgdatadir, 'sounds')
+localedir = join_paths(prefix, get_option('localedir'))
+podir = join_paths(meson.source_root(), 'po')
+
+# Dependencies
+glib_version = '2.40.0'
+
+gee_dep = dependency('gee-0.8')
+gio_dep = dependency('gio-2.0', version: '>= @0@'.format(glib_version))
+glib_dep = dependency('glib-2.0', version: '>= @0@'.format(glib_version))
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.18.0')
+clutter_dep = dependency('clutter-1.0', version: '>= 1.22.0')
+clutter_gtk_dep = dependency('clutter-gtk-1.0', version: '>= 1.4.0')
+canberra_dep = dependency('libcanberra', version: '>= 0.30')
+canberra_gtk3_dep = dependency('libcanberra-gtk3', version: '>= 0.30')
+libgnome_games_support_dep = dependency('libgnome-games-support-1')
+
+valac = meson.get_compiler('vala')
+posix_dep = valac.find_library('posix')
+
+# Configuration
+conf = configuration_data()
+
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('PKGDATADIR', pkgdatadir)
+conf.set_quoted('SOUND_DIRECTORY', sounddir)
+conf.set_quoted('LOCALEDIR', join_paths(prefix, localedir))
+conf.set_quoted('VERSION', meson.project_version())
+
+configure_file(output: 'config.h', configuration: conf)
+config_h_dir = include_directories('.')
+
+add_project_arguments([
+    '-include', 'config.h'
+  ],
+  language: 'c'
+)
+
+# Extra scripts
+meson.add_install_script('meson_post_install.py')
+
+# Subdirs
+subdir('data')
+subdir('help')
+subdir('po')
+subdir('src')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..f6e9d54
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = os.path.join(prefix, 'share')
+
+# Packaging tools define DESTDIR and this isn't needed for them
+if 'DESTDIR' not in os.environ:
+    print('Compiling gsettings schemas...')
+    subprocess.call(['glib-compile-schemas',
+                    os.path.join(datadir, 'glib-2.0', 'schemas')])
+
+    print('Updating icon cache...')
+    subprocess.call(['gtk-update-icon-cache', '-qtf',
+                    os.path.join(datadir, 'icons', 'hicolor')])
+
+    print("Updating desktop database")
+    subprocess.call(["update-desktop-database",
+                    os.path.join(datadir, 'applications')])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d32a36e..a9a5d73 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,13 +1,13 @@
 # List of source files containing translatable strings.
 # Please keep this file in alphabetical order.
-[encoding: UTF-8]
-[type: gettext/glade]data/controls-grid.ui
-[type: gettext/glade]data/nibbles.ui
+data/controls-grid.ui
+data/nibbles-menus.ui
+data/nibbles.ui
 data/org.gnome.Nibbles.appdata.xml.in
 data/org.gnome.Nibbles.desktop.in
 data/org.gnome.nibbles.gschema.xml
-[type: gettext/glade]data/player-score-box.ui
-[type: gettext/glade]data/preferences-dialog.ui
+data/player-score-box.ui
+data/preferences-dialog.ui
 src/gnome-nibbles.vala
 src/nibbles-view.vala
 src/preferences-dialog.vala
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..554ceaf
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+i18n.gettext(meson.project_name(),
+    preset: 'glib'
+)
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 4b7260c..18302c1 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -136,7 +136,7 @@ public class Nibbles : Gtk.Application
         Environment.set_prgname ("org.gnome.Nibbles");
         Environment.set_application_name (_("Nibbles"));
 
-        Gtk.Window.set_default_icon_name ("gnome-nibbles");
+        Gtk.Window.set_default_icon_name ("org.gnome.Nibbles");
 
         Gtk.Settings.get_default ().set ("gtk-application-prefer-dark-theme", true);
 
@@ -1050,7 +1050,7 @@ public class Nibbles : Gtk.Application
 
         Gtk.show_about_dialog (window,
                                "program-name", _("Nibbles"),
-                               "logo-icon-name", "gnome-nibbles",
+                               "logo-icon-name", "org.gnome.Nibbles",
                                "version", VERSION,
                                "comments", _("A worm game for GNOME"),
                                "copyright",
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..688fc58
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,36 @@
+# gnome-nibbles executable
+
+gnome_nibbles_sources = [
+    'vapi/config.vapi',
+    'boni.vala',
+    'gnome-nibbles.vala',
+    'nibbles-game.vala',
+    'nibbles-view.vala',
+    'preferences-dialog.vala',
+    'warp.vala',
+    'worm.vala',
+    resources,
+]
+
+gnome_nibbles_deps = [
+    gee_dep,
+    gio_dep,
+    glib_dep,
+    gtk_dep,
+    clutter_dep,
+    clutter_gtk_dep,
+    canberra_dep,
+    canberra_gtk3_dep,
+    libgnome_games_support_dep,
+    posix_dep,
+]
+
+gnome_nibbles_vala_args = [
+    '--vapidir', join_paths(meson.current_source_dir(), 'vapi')
+]
+
+executable(meson.project_name(), gnome_nibbles_sources,
+    dependencies: gnome_nibbles_deps,
+    vala_args: gnome_nibbles_vala_args,
+    install: true
+)
diff --git a/src/config.vapi b/src/vapi/config.vapi
similarity index 100%
rename from src/config.vapi
rename to src/vapi/config.vapi
diff --git a/src/vapi/libcanberra-gtk3.vapi b/src/vapi/libcanberra-gtk3.vapi
new file mode 100644
index 0000000..f788f8e
--- /dev/null
+++ b/src/vapi/libcanberra-gtk3.vapi
@@ -0,0 +1,37 @@
+/***
+  This file is part of libcanberra.
+
+  Copyright 2009 Lennart Poettering
+
+  libcanberra is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation, either version 2.1 of the
+  License, or (at your option) any later version.
+
+  libcanberra 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
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with libcanberra. If not, see
+  <http://www.gnu.org/licenses/>.
+***/
+
+using Canberra;
+using Gdk;
+using Gtk;
+
+[CCode (cprefix = "CA_GTK_", lower_case_cprefix = "ca_gtk_", cheader_filename = "canberra-gtk.h")]
+namespace CanberraGtk {
+
+        public unowned Context? context_get();
+        public unowned Context? context_get_for_screen(Gdk.Screen? screen);
+
+        public int proplist_set_for_widget(Proplist p, Gtk.Widget w);
+        public int play_for_widget(Gtk.Widget w, uint32 id, ...);
+        public int proplist_set_for_event(Proplist p, Gdk.Event e);
+        public int play_for_event(Gdk.Event e, uint32 id, ...);
+
+        public void widget_disable_sounds(Gtk.Widget w, bool enable = false);
+}


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