[buoh/vala] Port main.c to Vala



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

    Port main.c to Vala

 meson.build     |  2 ++
 src/buoh.vapi   |  7 +++++++
 src/main.c      | 45 ---------------------------------------------
 src/main.vala   | 13 +++++++++++++
 src/meson.build | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 67 insertions(+), 46 deletions(-)
---
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..130b520 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -19,7 +19,25 @@ sources = files(
   'buoh-view-message.c',
   'buoh-view.c',
   'buoh-window.c',
-  'main.c',
+  'buoh.vapi',
+  'main.vala',
+)
+
+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,6 +62,32 @@ cflags = [
   '-DLOCALE_DIR="@0@"'.format(localedir),
 ]
 
+noinst_lib = shared_library(
+  'noinst',
+  headers,
+  install: false,
+)
+
+gir = gnome.generate_gir(
+  noinst_lib,
+  sources: headers,
+  nsversion: '1.0',
+  namespace: 'Buoh',
+  identifier_prefix: 'Buoh',
+  dependencies: buoh_deps,
+  extra_args: [
+    '--header-only',
+  ],
+  symbol_prefix: 'buoh',
+)
+
+vapi = gnome.generate_vapi(
+  'buoh',
+  sources: gir[0],
+)
+
+buoh_deps += vapi
+
 buoh = executable(
   meson.project_name(),
   sources,


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