[latexila/wip/build-tools-revamp] LatexilaSynctex (not finished)



commit e5aa5f255c9f9d356994744049feb7a492a4a582
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat May 17 01:25:32 2014 +0200

    LatexilaSynctex (not finished)
    
    It is needed for the build tools for opening a PDF file with synctex
    support with evince. Since I don't want to use the Vala code in C, a
    rewrite of synctex.vala in C was needed.
    
    synctex.vala uses the synchronous API, which is bad. The rewrite in C
    uses the asynchronous API (it's better).

 configure.ac                       |    2 +
 src/Makefile.am                    |    2 +-
 src/evince/Makefile.am             |   31 ++++++++++++++++++++
 src/evince/evince-daemon-gdbus.xml |   19 ++++++++++++
 src/evince/evince-gdbus.xml        |   32 ++++++++++++++++++++
 src/liblatexila/Makefile.am        |   28 ++++++++++++------
 src/liblatexila/latexila-synctex.c |   56 ++++++++++++++++++++++++++++++++++++
 src/liblatexila/latexila-synctex.h |   54 ++++++++++++++++++++++++++++++++++
 src/liblatexila/latexila.h         |    1 +
 9 files changed, 215 insertions(+), 10 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 07a1342..d420cc9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,7 @@ AC_PROG_INSTALL
 AM_PROG_CC_C_O
 AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
 AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
+AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen])
 AM_PROG_VALAC([${VALA_REQUIRED_VERSION}],
               [found_vala=true]
              [found_vala=false])
@@ -168,6 +169,7 @@ AC_CONFIG_FILES([Makefile
                 man/Makefile
                 po/Makefile.in
                  src/Makefile
+                src/evince/Makefile
                 src/gedit/Makefile
                 src/liblatexila/Makefile
                 src/ui/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 508fd87..92f905e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = gedit liblatexila ui
+SUBDIRS = evince gedit liblatexila ui
 
 bin_PROGRAMS = latexila
 
diff --git a/src/evince/Makefile.am b/src/evince/Makefile.am
new file mode 100644
index 0000000..ced8b18
--- /dev/null
+++ b/src/evince/Makefile.am
@@ -0,0 +1,31 @@
+noinst_LTLIBRARIES = libevince.la
+
+libevince_la_CFLAGS = $(WARN_CFLAGS)
+
+libevince_built_sources =              \
+       evince-daemon-gdbus-generated.c \
+       evince-daemon-gdbus-generated.h \
+       evince-gdbus-generated.c        \
+       evince-gdbus-generated.h
+
+nodist_libevince_la_SOURCES = $(libevince_built_sources)
+
+BUILT_SOURCES = $(libevince_built_sources)
+
+evince-gdbus-generated.c evince-gdbus-generated.h: evince-gdbus.xml Makefile
+       $(AM_V_GEN) $(GDBUS_CODEGEN) \
+                       --c-namespace=Evince \
+                       --generate-c-code evince-gdbus-generated \
+                       evince-gdbus.xml
+
+evince-daemon-gdbus-generated.c evince-daemon-gdbus-generated.h: evince-daemon-gdbus.xml Makefile
+       $(AM_V_GEN) $(GDBUS_CODEGEN) \
+                       --c-namespace=Evince \
+                       --generate-c-code evince-daemon-gdbus-generated \
+                       evince-daemon-gdbus.xml
+
+EXTRA_DIST =                   \
+       evince-gdbus.xml        \
+       evince-daemon-gdbus.xml
+
+-include $(top_srcdir)/git.mk
diff --git a/src/evince/evince-daemon-gdbus.xml b/src/evince/evince-daemon-gdbus.xml
new file mode 100644
index 0000000..6b4f9d1
--- /dev/null
+++ b/src/evince/evince-daemon-gdbus.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Introspection 0.1//EN"
+                      "http://www.freedesktop.org/software/dbus/introspection.dtd";>
+<node>
+  <interface name="org.gnome.evince.Daemon">
+    <method name="RegisterDocument">
+      <arg type="s" name="uri" direction="in"/>
+      <arg type="s" name="owner" direction="out"/>
+    </method>
+    <method name="UnregisterDocument">
+      <arg type="s" name="uri" direction="in"/>
+    </method>
+    <method name="FindDocument">
+      <arg type="s" name="uri" direction="in"/>
+      <arg type="b" name="spawn" direction="in"/>
+      <arg type="s" name="owner" direction="out"/>
+    </method>
+  </interface>
+</node>
diff --git a/src/evince/evince-gdbus.xml b/src/evince/evince-gdbus.xml
new file mode 100644
index 0000000..b6b50d1
--- /dev/null
+++ b/src/evince/evince-gdbus.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Introspection 0.1//EN"
+                      "http://www.freedesktop.org/software/dbus/introspection.dtd";>
+<node>
+  <interface name='org.gnome.evince.Application'>
+    <annotation name="org.gtk.GDBus.C.Name" value="EvinceApplication" />
+    <method name='Reload'>
+      <arg type='a{sv}' name='args' direction='in'/>
+      <arg type='u' name='timestamp' direction='in'/>
+    </method>
+    <method name='GetWindowList'>
+      <arg type='ao' name='window_list' direction='out'/>
+    </method>
+  </interface>
+  <interface name='org.gnome.evince.Window'>
+    <annotation name="org.gtk.GDBus.C.Name" value="EvinceWindow" />
+    <method name='SyncView'>
+      <arg type='s' name='source_file' direction='in'/>
+      <arg type='(ii)' name='source_point' direction='in'/>
+      <arg type='u' name='timestamp' direction='in'/>
+    </method>
+    <signal name='SyncSource'>
+      <arg type='s' name='source_file' direction='out'/>
+      <arg type='(ii)' name='source_point' direction='out'/>
+      <arg type='u' name='timestamp' direction='out'/>
+    </signal>
+    <signal name='Closed'/>
+    <signal name='DocumentLoaded'>
+      <arg type='s' name='uri' direction='out'/>
+    </signal>
+  </interface>
+</node>
diff --git a/src/liblatexila/Makefile.am b/src/liblatexila/Makefile.am
index 538c4e5..f971b79 100644
--- a/src/liblatexila/Makefile.am
+++ b/src/liblatexila/Makefile.am
@@ -4,8 +4,10 @@ noinst_LTLIBRARIES = liblatexila.la
 
 liblatexila_la_CFLAGS = $(WARN_CFLAGS) $(CODE_COVERAGE_CFLAGS)
 liblatexila_la_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
+liblatexila_la_LIBADD = ../evince/libevince.la
 
 liblatexila_headers =                          \
+       latexila.h                              \
        latexila-build-job.h                    \
        latexila-build-tool.h                   \
        latexila-build-tools.h                  \
@@ -14,14 +16,11 @@ liblatexila_headers =                               \
        latexila-build-view.h                   \
        latexila-post-processor.h               \
        latexila-post-processor-all-output.h    \
+       latexila-synctex.h                      \
        latexila-types.h                        \
        latexila-utils.h
 
-BUILT_SOURCES =                        \
-       latexila-enum-types.c   \
-       latexila-enum-types.h
-
-liblatexila_la_SOURCES =                       \
+liblatexila_sources =                          \
        latexila-build-job.c                    \
        latexila-build-tool.c                   \
        latexila-build-tools.c                  \
@@ -30,9 +29,20 @@ liblatexila_la_SOURCES =                     \
        latexila-build-view.c                   \
        latexila-post-processor.c               \
        latexila-post-processor-all-output.c    \
-       latexila-utils.c                        \
-       $(liblatexila_headers)                  \
-       $(BUILT_SOURCES)
+       latexila-synctex.c                      \
+       latexila-utils.c
+
+liblatexila_built_sources =    \
+       latexila-enum-types.c   \
+       latexila-enum-types.h
+
+liblatexila_la_SOURCES =               \
+       $(liblatexila_headers)          \
+       $(liblatexila_sources)
+
+nodist_liblatexila_la_SOURCES = $(liblatexila_built_sources)
+
+BUILT_SOURCES = $(liblatexila_built_sources)
 
 ENUM_TYPES = $(liblatexila_headers)
 
@@ -64,7 +74,7 @@ Latexila.gir: liblatexila.la
 Latexila_gir_NAMESPACE = Latexila
 Latexila_gir_INCLUDES = Gtk-3.0
 Latexila_gir_LIBS = liblatexila.la
-Latexila_gir_FILES = $(liblatexila_la_SOURCES)
+Latexila_gir_FILES = $(liblatexila_la_SOURCES) $(nodist_liblatexila_la_SOURCES)
 
 noinst_DATA += Latexila.gir Latexila.typelib
 CLEANFILES += Latexila.gir Latexila.typelib
diff --git a/src/liblatexila/latexila-synctex.c b/src/liblatexila/latexila-synctex.c
new file mode 100644
index 0000000..540b69b
--- /dev/null
+++ b/src/liblatexila/latexila-synctex.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of LaTeXila.
+ *
+ * Copyright (C) 2014 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * LaTeXila is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LaTeXila is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "latexila-synctex.h"
+
+struct _LatexilaSynctexPrivate
+{
+  gint something;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (LatexilaSynctex, latexila_synctex, G_TYPE_OBJECT)
+
+static void
+latexila_synctex_dispose (GObject *object)
+{
+
+  G_OBJECT_CLASS (latexila_synctex_parent_class)->dispose (object);
+}
+
+static void
+latexila_synctex_finalize (GObject *object)
+{
+
+  G_OBJECT_CLASS (latexila_synctex_parent_class)->finalize (object);
+}
+
+static void
+latexila_synctex_class_init (LatexilaSynctexClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->dispose = latexila_synctex_dispose;
+  object_class->finalize = latexila_synctex_finalize;
+}
+
+static void
+latexila_synctex_init (LatexilaSynctex *self)
+{
+  self->priv = latexila_synctex_get_instance_private (self);
+}
diff --git a/src/liblatexila/latexila-synctex.h b/src/liblatexila/latexila-synctex.h
new file mode 100644
index 0000000..e362856
--- /dev/null
+++ b/src/liblatexila/latexila-synctex.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of LaTeXila.
+ *
+ * Copyright (C) 2014 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * LaTeXila is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LaTeXila is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __LATEXILA_SYNCTEX_H__
+#define __LATEXILA_SYNCTEX_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define LATEXILA_TYPE_SYNCTEX             (latexila_synctex_get_type ())
+#define LATEXILA_SYNCTEX(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), LATEXILA_TYPE_SYNCTEX, 
LatexilaSynctex))
+#define LATEXILA_SYNCTEX_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), LATEXILA_TYPE_SYNCTEX, 
LatexilaSynctexClass))
+#define LATEXILA_IS_SYNCTEX(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LATEXILA_TYPE_SYNCTEX))
+#define LATEXILA_IS_SYNCTEX_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), LATEXILA_TYPE_SYNCTEX))
+#define LATEXILA_SYNCTEX_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), LATEXILA_TYPE_SYNCTEX, 
LatexilaSynctexClass))
+
+typedef struct _LatexilaSynctex        LatexilaSynctex;
+typedef struct _LatexilaSynctexClass   LatexilaSynctexClass;
+typedef struct _LatexilaSynctexPrivate LatexilaSynctexPrivate;
+
+struct _LatexilaSynctex
+{
+  GObject parent;
+
+  LatexilaSynctexPrivate *priv;
+};
+
+struct _LatexilaSynctexClass
+{
+  GObjectClass parent_class;
+};
+
+GType latexila_synctex_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __LATEXILA_SYNCTEX_H__ */
diff --git a/src/liblatexila/latexila.h b/src/liblatexila/latexila.h
index 0d799f0..a200ab9 100644
--- a/src/liblatexila/latexila.h
+++ b/src/liblatexila/latexila.h
@@ -31,6 +31,7 @@
 #include "latexila-build-view.h"
 #include "latexila-post-processor.h"
 #include "latexila-post-processor-all-output.h"
+#include "latexila-synctex.h"
 #include "latexila-utils.h"
 
 #endif /* __LATEXILA_H__ */


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