[buoh/vala: 2/2] Port main.c to Vala



commit 0c13ec2f1bb2fbb5af7cbf1200e9b8c49c200f1b
Author: Jan Tojnar <jtojnar gmail com>
Date:   Sun Feb 3 02:41:08 2019 +0100

    Port main.c to Vala

 default.nix     |  2 +-
 meson.build     |  2 ++
 src/buoh.vapi   |  7 +++++++
 src/main.c      | 45 --------------------------------------------
 src/main.vala   | 13 +++++++++++++
 src/meson.build | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 6 files changed, 78 insertions(+), 49 deletions(-)
---
diff --git a/default.nix b/default.nix
index 9f37898..9b8d2e6 100644
--- a/default.nix
+++ b/default.nix
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
   name = "buoh";
 
   nativeBuildInputs = [
-    meson ninja pkgconfig gettext python3 xvfb_run libxslt wrapGAppsHook
+    meson ninja gobject-introspection vala pkgconfig gettext python3 xvfb_run libxslt wrapGAppsHook
   ];
 
   buildInputs = [
diff --git a/meson.build b/meson.build
index 518c0d3..6d58356 100644
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,7 @@
 project(
   'buoh',
   'c',
+  'vala',
   license: 'GPL2+',
   version: '0.8.3',
   default_options: [
@@ -11,6 +12,7 @@ project(
 gnome = import('gnome')
 i18n = import('i18n')
 python3 = import('python3')
+valac = meson.get_compiler('vala')
 data_dir = join_paths(meson.source_root(), 'data')
 po_dir = join_paths(meson.source_root(), 'po')
 
diff --git a/src/buoh.vapi b/src/buoh.vapi
new file mode 100644
index 0000000..f06137a
--- /dev/null
+++ b/src/buoh.vapi
@@ -0,0 +1,7 @@
+[CCode (cprefix = "", lower_case_cprefix = "")]
+namespace Config {
+    public const string COMICS_DIR;
+    public const string GETTEXT_PACKAGE;
+    public const string VERSION;
+    public const string LOCALE_DIR;
+}
diff --git a/src/main.vala b/src/main.vala
new file mode 100644
index 0000000..abf5508
--- /dev/null
+++ b/src/main.vala
@@ -0,0 +1,13 @@
+using Config;
+
+namespace Buoh {
+    public static int main(string [] argv) {
+        Intl.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALE_DIR);
+        Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE, "UTF-8");
+        Intl.textdomain(Config.GETTEXT_PACKAGE);
+
+        Buoh.Application buoh = new Buoh.Application();
+
+        return buoh.run(argv);
+    }
+}
diff --git a/src/meson.build b/src/meson.build
index bb6a4b8..5525bc6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -19,7 +19,23 @@ sources = files(
   'buoh-view-message.c',
   'buoh-view.c',
   'buoh-window.c',
-  'main.c',
+)
+
+headers = settings_headers + files(
+  'buoh-add-comic-dialog.h',
+  'buoh-application.h',
+  'buoh-comic-cache.h',
+  'buoh-comic-list.h',
+  'buoh-comic-loader.h',
+  'buoh-comic-manager-date.h',
+  'buoh-comic-manager.h',
+  'buoh-comic.h',
+  'buoh-properties-dialog.h',
+  'buoh-settings.h',
+  'buoh-view-comic.h',
+  'buoh-view-message.h',
+  'buoh-view.h',
+  'buoh-window.h',
 )
 
 sources += gnome.compile_resources(
@@ -44,10 +60,46 @@ cflags = [
   '-DLOCALE_DIR="@0@"'.format(localedir),
 ]
 
+libbuoh = static_library(
+  'buoh',
+  sources + headers,
+  dependencies: buoh_deps,
+  c_args: cflags,
+  install: false,
+)
+
+gir = gnome.generate_gir(
+  libbuoh,
+  sources: sources + headers,
+  includes: ['Gio-2.0', 'GLib-2.0', 'GdkPixbuf-2.0', 'Gtk-3.0'],
+  nsversion: '1.0',
+  namespace: 'Buoh',
+  identifier_prefix: 'Buoh',
+  header: 'buoh.h',
+  dependencies: buoh_deps,
+  extra_args: [
+    '--warn-all',
+  ],
+  symbol_prefix: 'buoh',
+  install: false,
+)
+
+vala_flags = ['--gresourcesdir=' + join_paths(meson.current_source_dir(), '..', 'data')]
+
+buoh_deps += gnome.generate_vapi(
+  'buoh',
+  sources: gir[0],
+  packages: ['gio-2.0', 'glib-2.0', 'gdk-pixbuf-2.0', 'gtk+-3.0'],
+)
+
+libbuoh_dep = declare_dependency(link_with: libbuoh, dependencies: buoh_deps)
+
 buoh = executable(
   meson.project_name(),
-  sources,
-  dependencies: buoh_deps,
+  'main.vala',
+  'buoh.vapi',
+  dependencies: libbuoh_dep,
   c_args: cflags,
+  vala_args: vala_flags,
   install: true,
 )


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