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




commit 237fe1636b7a4742ac7b16757df5ccfc6f7f9ffd
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.h      | 14 ++++++++++
 src/buoh.vapi   |  7 +++++
 src/main.c      | 45 ------------------------------
 src/main.vala   | 13 +++++++++
 src/meson.build | 85 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 7 files changed, 112 insertions(+), 56 deletions(-)
---
diff --git a/default.nix b/default.nix
index 13dc285..d55aa36 100644
--- a/default.nix
+++ b/default.nix
@@ -64,6 +64,8 @@ in pkgs.stdenv.mkDerivation rec {
     meson
     ninja
     pkg-config
+    gobject-introspection
+    vala
     gettext
     python3
     xvfb_run
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.h b/src/buoh.h
new file mode 100644
index 0000000..719845a
--- /dev/null
+++ b/src/buoh.h
@@ -0,0 +1,14 @@
+#include "buoh-add-comic-dialog.h"
+#include "buoh-application.h"
+#include "buoh-comic-cache.h"
+#include "buoh-comic-list.h"
+#include "buoh-comic-loader.h"
+#include "buoh-comic-manager-date.h"
+#include "buoh-comic-manager.h"
+#include "buoh-comic.h"
+#include "buoh-properties-dialog.h"
+#include "buoh-settings.h"
+#include "buoh-view-comic.h"
+#include "buoh-view-message.h"
+#include "buoh-view.h"
+#include "buoh-window.h"
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..c777660
--- /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);
+
+        Application buoh = new Application();
+
+        return buoh.run(argv);
+    }
+}
diff --git a/src/meson.build b/src/meson.build
index bb6a4b8..fbe6349 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -19,17 +19,23 @@ sources = files(
   'buoh-view-message.c',
   'buoh-view.c',
   'buoh-window.c',
-  'main.c',
 )
 
-sources += gnome.compile_resources(
-  'buoh-resources',
-  join_paths(data_dir, 'org.gnome.buoh.gresource.xml'),
-  source_dir: [
-    data_dir,
-  ],
-  c_name: 'buoh',
-  export: true,
+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.mkenums_simple(
@@ -44,10 +50,67 @@ cflags = [
   '-DLOCALE_DIR="@0@"'.format(localedir),
 ]
 
-buoh = executable(
-  meson.project_name(),
+libbuoh = static_library(
+  'buoh',
   sources,
   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,
+)
+
+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)
+
+exe_sources = [
+  'main.vala',
+  'buoh.vapi',
+]
+
+exe_sources += gnome.compile_resources(
+  'buoh-resources',
+  join_paths(data_dir, 'org.gnome.buoh.gresource.xml'),
+  source_dir: [
+    data_dir,
+  ],
+  c_name: 'buoh',
+  export: true,
+)
+
+buoh = executable(
+  meson.project_name(),
+  exe_sources,
+  dependencies: libbuoh_dep,
+  c_args: cflags,
   install: true,
 )


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