Commit efd2faa0 authored by Iñigo Martínez's avatar Iñigo Martínez

meson: Change config.h handling

The `config.h` file handling, which is done through the
`config.vapi` file, has been changed following Vala
recommendations[0].

To do this, the global variables in the `config.vapi` file has been
moved to the `Config` namespace.

The `DATADIR` and `LOCALEDIR` variables, although they still exist
in the `config.vapi` file, they are not set in the `config.h` file
because they will be set by the compiler's macro definitions when
using compiler flags.

https://bugzilla.gnome.org/show_bug.cgi?id=793340

[0] https://wiki.gnome.org/Projects/Vala/GameDevelopmentSeries/Setup
parent 1edfc7bb
......@@ -35,8 +35,6 @@ posix_dep = valac.find_library('posix')
conf = configuration_data()
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf.set_quoted('LOCALEDIR', localedir)
conf.set_quoted('DATADIR', pkgdatadir)
conf.set_quoted('VERSION', meson.project_version())
config_h_inc = include_directories('.')
......
......@@ -8,7 +8,10 @@
* license.
*/
public const string DATADIR;
public const string LOCALEDIR;
public const string GETTEXT_PACKAGE;
public const string VERSION;
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
namespace Config {
public const string DATADIR;
public const string GETTEXT_PACKAGE;
public const string LOCALEDIR;
public const string VERSION;
}
......@@ -15,6 +15,8 @@
* events.
*/
using Config;
public class GameView : Clutter.Group
{
private TileActor highlighted = null;
......@@ -358,12 +360,12 @@ public class Theme : Object
try
{
for (int i = 0; i < 4; i++) {
var pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (DATADIR, "themes", name, colors[i] + ".svg"));
var pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.DATADIR, "themes", name, colors[i] + ".svg"));
textures[i] = new Clutter.Image ();
textures[i].set_data (pixbuf.get_pixels (), Cogl.PixelFormat.RGBA_8888,
pixbuf.get_width (), pixbuf.get_height (), pixbuf.get_rowstride ());
}
var pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (DATADIR, "themes", name, "highlight.svg"));
var pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.DATADIR, "themes", name, "highlight.svg"));
cursor = new Clutter.Image ();
cursor.set_data (pixbuf.get_pixels (), Cogl.PixelFormat.RGBA_8888,
pixbuf.get_width (), pixbuf.get_height (), pixbuf.get_rowstride ());
......
......@@ -18,11 +18,10 @@ deps = [
clutter_gtk_dep,
]
c_flags = [
'-DVERSION="@0@"'.format (meson.project_version ()),
'-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()),
'-DLOCALEDIR="@0@"'.format (localedir),
'-DDATADIR="@0@"'.format (pkgdatadir),
c_flags = [
'-DDATADIR="@0@"'.format(pkgdatadir),
'-DLOCALEDIR="@0@"'.format(localedir),
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name())
]
executable('swell-foop', sources,
......
......@@ -8,6 +8,8 @@
* license.
*/
using Config;
public class SwellFoop : Gtk.Application
{
/* Application settings */
......@@ -56,7 +58,7 @@ public class SwellFoop : Gtk.Application
private void load_css ()
{
var css_provider = new Gtk.CssProvider ();
var css_path = Path.build_filename (DATADIR, "swell-foop.css");
var css_path = Path.build_filename (Config.DATADIR, "swell-foop.css");
try
{
css_provider.load_from_path (css_path);
......@@ -301,7 +303,7 @@ public class SwellFoop : Gtk.Application
var preferences_builder = new Gtk.Builder ();
try
{
preferences_builder.add_from_file (Path.build_filename (DATADIR, "preferences.ui", null));
preferences_builder.add_from_file (Path.build_filename (Config.DATADIR, "preferences.ui", null));
}
catch (Error e)
{
......@@ -453,7 +455,7 @@ public class SwellFoop : Gtk.Application
Gtk.show_about_dialog (window,
"program-name", _("Swell Foop"),
"version", VERSION,
"version", Config.VERSION,
"comments",
_("I want to play that game!\nYou know, they all light-up and you click on them and they vanish!"),
"copyright", _("Copyright \xc2\xa9 2009 Tim Horton"),
......@@ -508,9 +510,9 @@ public class SwellFoop : Gtk.Application
public static int main (string[] args)
{
Intl.setlocale (LocaleCategory.ALL, "");
Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (GETTEXT_PACKAGE);
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);
if (GtkClutter.init (ref args) != Clutter.InitError.SUCCESS)
{
......@@ -519,7 +521,7 @@ public class SwellFoop : Gtk.Application
}
var context = new OptionContext (null);
context.set_translation_domain (GETTEXT_PACKAGE);
context.set_translation_domain (Config.GETTEXT_PACKAGE);
context.add_group (Gtk.get_option_group (true));
context.add_group (Clutter.get_option_group_without_init ());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment