update build system

This commit is contained in:
2019-01-05 00:28:18 -03:00
parent c37c341784
commit ed580cfe2a
34 changed files with 164 additions and 64 deletions

6
src/config.vala.in Normal file
View File

@@ -0,0 +1,6 @@
namespace Sernatur {
namespace Constants {
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
public const string VERSION = "@VERSION@";
}
}

View File

@@ -5,23 +5,31 @@ gtk_dep = dependency('gtk+-3.0', version: '>=3.0.0')
gmodule_dep = dependency('gmodule-2.0', version: '>=2.0')
pq_dep = dependency('libpq', version: '>=9.0')
config_data = configuration_data()
config_data.set('VERSION', meson.project_version())
config_data.set('GETTEXT_PACKAGE', meson.project_name())
config_data_file = configure_file(input: 'config.vala.in',
output: 'config.vala',
configuration: config_data)
vala_sources = files(
'sernatur.vala',
'sernatur-window.vala')
sources = vala_sources
c_sources = [sernatur_gresource_c]
sources += gresource
sources += config_data_file
sources = vala_sources
sources += c_sources
vala_args = ['--vapidir=' + join_paths(meson.source_root(), 'vapi')]
vala_args += ['--gresources=' + join_paths(meson.source_root(), 'data/ui/sernatur.gresource.xml')]
vala_args = ['--vapidir='+join_paths(meson.source_root(),'vapi')]
vala_args += ['--gresources='+join_paths(meson.source_root(),'data/ui/sernatur.gresource.xml')]
inc = include_directories('../lib', './')
sernatur_dep = declare_dependency(link_with: sernatur_lib, include_directories: include_directories('../lib'))
exe = executable('sernatur',
exe = executable(meson.project_name(),
sources,
vala_args: vala_args,
dependencies: [glib_dep, gobject_dep, gtk_dep, gmodule_dep, pq_dep, sernatur_dep],
include_directories : inc,
gui_app: true,
dependencies: [glib_dep, gobject_dep, gtk_dep, gmodule_dep, pq_dep, lib_dep],
install: true)

View File

@@ -16,14 +16,15 @@
* The main Sernatur namespace
*/
namespace Sernatur {
using DB;
using LibSernatur.Person;
using LibSernatur.DB;
/**
* The MainWindow class
*/
[GtkTemplate (ui = "/cl/cromer/ubb/sernatur/sernatur.window.ui")]
public class MainWindow : Gtk.ApplicationWindow {
Gtk.Grid content;
private Gtk.Grid content;
[GtkChild]
private Gtk.Box mainbox;
@@ -132,7 +133,7 @@ namespace Sernatur {
}
print (dgettext (null, "Postgresql server version:") + " %d\n", conn.get_server_version ());
/*var tour = Tour.get_all_tours (conn);
var tour = Tour.get_all_tours (conn);
print (tour[0].ciudad.region.nombre_region + "\n");
var tiene_enfermedad = TieneEnfermedad.get_all_tiene_enfermedades (conn);
print (tiene_enfermedad[0].turista.contacto_emergencia.nombre_emergencia + "\n");
@@ -150,18 +151,18 @@ namespace Sernatur {
var requerir_auto = RequerirAuto.get_all_requerir_autos (conn);
print (requerir_auto[0].vehiculo.marca + "\n");
try {
var rut = new Person.Rut ("23.660.457-8");
var rut = new Rut ("23.660.457-8");
print (rut.get_rut () + "\n");
if (rut.type () == Person.Rut.Type.RUN) {
if (rut.type () == Rut.Type.RUN) {
print ("person\n");
}
else {
print ("company\n");
}
}
catch (Person.InvalidRut e) {
catch (InvalidRut e) {
print ("Rut is invalid");
}*/
}
}
}
}

View File

@@ -16,8 +16,23 @@
* The main Sernatur namespace
*/
namespace Sernatur {
using Constants;
using Gtk;
private static bool version = false;
private const GLib.OptionEntry[] options = {
// --version
{ "version", 'v', 0, OptionArg.NONE, ref version, "Display version number", null },
// list terminator
{ null }
};
public unowned string MyTranslateFunc (string str) {
return dgettext (null, str);
}
/**
* The application class
*/
@@ -55,8 +70,6 @@ namespace Sernatur {
* Run when the application starts
*/
public override void startup () {
Intl.textdomain ("sernatur");
Intl.setlocale (LocaleCategory.ALL, "");
base.startup ();
}
}
@@ -67,7 +80,31 @@ namespace Sernatur {
* @return success of the application
*/
public static int main (string[] args) {
var application = new Application ();
return application.run (args);
Intl.setlocale (LocaleCategory.ALL, "");
Intl.bindtextdomain (GETTEXT_PACKAGE, "/usr/share/locale");
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (GETTEXT_PACKAGE);
try {
var opt_context = new OptionContext ("");
opt_context.set_translation_domain (GETTEXT_PACKAGE);
opt_context.set_translate_func (MyTranslateFunc, null);
opt_context.set_help_enabled (true);
opt_context.add_main_entries (options, null);
opt_context.parse (ref args);
}
catch (OptionError e) {
print (dgettext (null, "Error: %s\n"), e.message);
print (dgettext (null, "Run '%s --help' to see a full list of available command line options.\n"), args[0]);
return 1;
}
if (version) {
print (dgettext (null, "SERNATUR version: ") + VERSION + "\n");
return 0;
}
else {
var application = new Application ();
return application.run (args);
}
}
}