diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2023-03-07 21:37:42 +0100 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2023-03-08 20:23:11 +0100 |
commit | 08684d332a072bfd0c8cd8e466a788b1dba604be (patch) | |
tree | 2974aa5ab6dc00afd0858cdd6b2e3b7a81267486 | |
parent | 18a3213d94b7d806e8461d151031484344fcbbf8 (diff) |
Do not use vala.
Vala is great, but it is hard to debug, and maintaining an API is
impossible.
-rw-r--r-- | Makefile.am | 44 | ||||
-rw-r--r-- | bootstrap.conf | 2 | ||||
-rw-r--r-- | cfg.mk | 2 | ||||
-rw-r--r-- | include/disfluid/adwaita.h | 58 | ||||
-rw-r--r-- | po/POTFILES.in | 7 | ||||
-rw-r--r-- | src/about.ui | 12 | ||||
-rw-r--r-- | src/adwaita/disfluid-application.c | 76 | ||||
-rw-r--r-- | src/disfluid-cache-request.h | 122 | ||||
-rw-r--r-- | src/disfluid-header-iterator.h | 85 | ||||
-rw-r--r-- | src/disfluid.gresource.xml | 8 | ||||
-rw-r--r-- | src/disfluid.ui | 73 | ||||
-rw-r--r-- | src/disfluid/main.c | 25 | ||||
-rw-r--r-- | src/main-relocate.h | 10 | ||||
-rw-r--r-- | src/unit_tests_report.ui | 89 | ||||
-rw-r--r-- | src/vala/about.vala | 20 | ||||
-rw-r--r-- | src/vala/application-window.vala | 18 | ||||
-rw-r--r-- | src/vala/config.vala | 21 | ||||
-rw-r--r-- | src/vala/libdisfluid.vala | 7 | ||||
-rw-r--r-- | src/vala/main.vala | 58 | ||||
-rw-r--r-- | src/vala/unit-tests-report.vala | 98 |
20 files changed, 186 insertions, 649 deletions
diff --git a/Makefile.am b/Makefile.am index 3c13f25..7c9ef4c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,28 +2,18 @@ SUBDIRS = lib libprog . po tests bin_PROGRAMS = disfluid -lib_LTLIBRARIES = libdisfluid.la +lib_LTLIBRARIES = \ + libdisfluid.la \ + libdisfluid-adwaita.la include_HEADERS = include/disfluid.h +pkginclude_HEADERS = include/disfluid/adwaita.h -AM_VALAFLAGS = --pkg gtk4 --pkg libadwaita-1 \ - --gresources $(srcdir)/src/disfluid.gresource.xml --gresourcesdir $(srcdir) ACLOCAL_AMFLAGS = -I m4 -I m4prog -EXTRA_DIST = m4/gnulib-cache.m4 m4prog/gnulib-cache.m4 \ - src/disfluid.gresource.xml \ - src/about.ui \ - src/disfluid.ui \ - src/unit_tests_report.ui +EXTRA_DIST = m4/gnulib-cache.m4 m4prog/gnulib-cache.m4 disfluid_SOURCES = \ - src/vala/config.vala \ - src/vala/libdisfluid.vala \ - src/vala/application-window.vala \ - src/vala/unit-tests-report.vala \ - src/vala/about.vala \ - src/vala/main.vala \ - src/main-relocate.h \ - src/disfluid.gresource.c + src/disfluid/main.c disfluid_CPPFLAGS = \ -I libprog -I $(srcdir)/libprog \ @@ -35,6 +25,7 @@ disfluid_CPPFLAGS = \ disfluid_LDADD = \ libprog/libgnu.la \ libdisfluid.la \ + libdisfluid-adwaita.la \ $(LIBTHREAD) \ $(LTLIBINTL) \ $(SETLOCALE_LIB) \ @@ -64,12 +55,25 @@ libdisfluid_la_LDFLAGS = \ $(SETLOCALE_NULL_LIB) \ @INTL_MACOSX_LIBS@ -SUFFIXES = .gresource.xml .gresource.c +libdisfluid_adwaita_la_SOURCES = \ + src/adwaita/disfluid-application.c -.gresource.xml.gresource.c: - $(AM_V_GEN) (cd $(srcdir) && $(GLIB_COMPILE_RESOURCES) --generate-source --target=$@-t $(srcdir)/$< && (echo "#include <config.h>" ; cat $@-t) > $@-fixed && rm -f $@-t && mv $@-fixed $(srcdir)/$@) +libdisfluid_adwaita_la_CPPFLAGS = \ + -I lib -I $(srcdir)/lib \ + -DBUILDING_LIBDISFLUID_ADWAITA \ + -I include -I $(srcdir)/include \ + -DLOCALEDIR=\"$(localedir)\" \ + -DINSTALLDIR=\"$(bindir)\" -src/disfluid.gresource.c: src/disfluid.ui src/about.ui src/unit_tests_report.ui +libdisfluid_adwaita_la_CFLAGS = $(CFLAG_VISIBILITY) +libdisfluid_adwaita_la_LIBADD = \ + lib/libgnu.la +libdisfluid_adwaita_la_LDFLAGS = \ + $(LIBTHREAD) \ + $(LTLIBINTL) \ + $(SETLOCALE_LIB) \ + $(SETLOCALE_NULL_LIB) \ + @INTL_MACOSX_LIBS@ TESTS = run-unit-tests check_PROGRAMS = run-unit-tests diff --git a/bootstrap.conf b/bootstrap.conf index abac2b8..bbb6345 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -57,5 +57,5 @@ bootstrap_post_import_hook () --aux-dir=build-aux \ --libtool \ --macro-prefix=glprog \ - relocatable-prog gettext-h locale setlocale stdbool + relocatable-prog gettext-h locale setlocale stdbool attribute } @@ -1,7 +1,7 @@ old_NEWS_hash = d41d8cd98f00b204e9800998ecf8427e _makefile_at_at_check_exceptions = ' && !/INTL_MACOSX_LIBS/' -generated_files = $(srcdir)/lib/*.[ch] src/vala/*.c src/disfluid.gresource.c +generated_files = $(srcdir)/lib/*.[ch] _gl_translatable_string_re ?= \b(N?_|gettext) *\([^)"]*("|$$)|translatable="yes" .PHONY: push-updated-translations diff --git a/include/disfluid/adwaita.h b/include/disfluid/adwaita.h new file mode 100644 index 0000000..35b42ec --- /dev/null +++ b/include/disfluid/adwaita.h @@ -0,0 +1,58 @@ +#ifndef H_DISFLUID_ADWAITA_INCLUDED +# define H_DISFLUID_ADWAITA_INCLUDED + +# include <stdlib.h> +# include <glib-object.h> + +# if defined _WIN32 && !defined __CYGWIN__ +# define LIBDISFLUID_ADWAITA_DLL_MADNESS 1 +# else +# define LIBDISFLUID_ADWAITA_DLL_MADNESS 0 +# endif + +# if BUILDING_LIBDISFLUID_ADWAITA && HAVE_VISIBILITY +# define LIBDISFLUID_ADWAITA_DLL_EXPORTED __attribute__((__visibility__("default"))) +# elif BUILDING_LIBDISFLUID_ADWAITA && LIBDISFLUID_ADWAITA_DLL_MADNESS +# define LIBDISFLUID_ADWAITA_DLL_EXPORTED __declspec(dllexport) +# elif LIBDISFLUID_ADWAITA_DLL_MADNESS +# define LIBDISFLUID_ADWAITA_DLL_EXPORTED __declspec(dllimport) +# else +# define LIBDISFLUID_ADWAITA_DLL_EXPORTED +# endif + +# define LIBDISFLUID_ADWAITA_API \ + LIBDISFLUID_ADWAITA_DLL_EXPORTED + +# ifdef ATTRIBUTE_DEALLOC +# define LIBDISFLUID_ADWAITA_DEALLOC_WITH ATTRIBUTE_DEALLOC +# else +# define LIBDISFLUID_ADWAITA_DEALLOC_WITH(f, i) +# endif + +# ifdef ATTRIBUTE_CONST +# define LIBDISFLUID_ADWAITA_CONST ATTRIBUTE_CONST +# else +# define LIBDISFLUID_ADWAITA_CONST +# endif + +# ifdef __cplusplus +extern "C" +{ +# endif /* __cplusplus */ + + struct DisfluidApplication; + + LIBDISFLUID_ADWAITA_CONST LIBDISFLUID_ADWAITA_API extern GType + disfluid_application_get_type (void); + + LIBDISFLUID_ADWAITA_API extern struct DisfluidApplication + *disfluid_application_new (void); + + LIBDISFLUID_ADWAITA_API extern struct DisfluidApplication + *disfluid_application_construct (GType object_type); + +# ifdef __cplusplus +} +# endif /* __cplusplus */ + +#endif /* not H_DISFLUID_ADWAITA_INCLUDED */ diff --git a/po/POTFILES.in b/po/POTFILES.in index f5793f9..2febfdd 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,8 +1,3 @@ # List of source files which contain translatable strings. -src/about.ui -src/disfluid.ui +src/adwaita/disfluid-application.c src/libdisfluid/disfluid-tests.h -src/unit_tests_report.ui -src/vala/about.c -src/vala/application-window.c -src/vala/unit-tests-report.c diff --git a/src/about.ui b/src/about.ui deleted file mode 100644 index 1ac2c6c..0000000 --- a/src/about.ui +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.40.0 --> -<interface> - <object class="AdwAboutWindow" id="window"> - <property name="application-icon">disfluid</property> - <property name="application-name" translatable="yes">Disfluid</property> - <property name="developer-name">Vivien Kraus</property> - <property name="website">https://disfluid.planete-kraus.eu</property> - <property name="copyright" translatable="yes">Copyright © 2023 Vivien Kraus</property> - <property name="license-type">agpl-3-0</property> - </object> -</interface> diff --git a/src/adwaita/disfluid-application.c b/src/adwaita/disfluid-application.c new file mode 100644 index 0000000..6bf3956 --- /dev/null +++ b/src/adwaita/disfluid-application.c @@ -0,0 +1,76 @@ +#include <config.h> + +#include "attribute.h" +#include <disfluid/adwaita.h> + +#define STREQ(a, b) (strcmp ((a), (b)) == 0) +#define STRNEQ(a, b) (! (STREQ (a, b))) + +#include <locale.h> +#include <stdio.h> +#include <unistd.h> +#include "gettext.h" +#include "relocatable.h" + +#define _(String) dgettext (PACKAGE, (String)) +#define N_(String) (String) + +#include <glib-object.h> +#include <adwaita.h> +#include <gtk/gtk.h> + +#define DISFLUID_TYPE_APPLICATION \ + disfluid_application_get_type () + +struct DisfluidApplication +{ + AdwApplication parent_instance; +}; + +struct DisfluidApplicationClass +{ + AdwApplicationClass parent_instance; +}; + +typedef struct DisfluidApplication DisfluidApplication; +typedef struct DisfluidApplicationClass DisfluidApplicationClass; + +/* *INDENT-OFF* */ +G_DEFINE_TYPE (DisfluidApplication, disfluid_application, ADW_TYPE_APPLICATION) +/* *INDENT-ON* */ + +static void +disfluid_application_class_init (DisfluidApplicationClass * klass) +{ + (void) klass; +} + +static void +disfluid_application_init (DisfluidApplication * self) +{ + (void) self; + /* Perform default initialization of self. */ +} + +static void +activated (GtkApplication * app) +{ + GtkWidget *window = gtk_application_window_new (app); + GtkWidget *label = gtk_label_new (_("Hello, world!")); + gtk_window_set_title (GTK_WINDOW (window), _("Hello")); + gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); + gtk_window_set_child (GTK_WINDOW (window), label); + gtk_window_present (GTK_WINDOW (window)); +} + +DisfluidApplication * +disfluid_application_new (void) +{ + DisfluidApplication *self = NULL; + self = (DisfluidApplication *) g_object_new (DISFLUID_TYPE_APPLICATION, + "application-id", + "eu.planete-kraus.Disfluid", + NULL); + g_signal_connect (self, "activate", G_CALLBACK (activated), NULL); + return self; +} diff --git a/src/disfluid-cache-request.h b/src/disfluid-cache-request.h deleted file mode 100644 index 8d6310c..0000000 --- a/src/disfluid-cache-request.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef DISFLUID_CACHE_REQUEST_INCLUDED -# define DISFLUID_CACHE_REQUEST_INCLUDED - -struct disfluid_cache_request; - -static inline int cache_request_init (struct disfluid_cache_request *request); - -static inline - void cache_request_clear (struct disfluid_cache_request *request); - -static inline - int cache_request_prepare (struct disfluid_cache_request *request, - const char *method, const char *host, - const char *path, const char *version); - -static inline - const char *cache_request_method (const struct disfluid_cache_request - *request); - -static inline - const char *cache_request_path (const struct disfluid_cache_request - *request); - -static inline - const char *cache_request_host (const struct disfluid_cache_request - *request); - -static inline - const char *cache_request_version (const struct disfluid_cache_request - *request); - -struct disfluid_cache_request -{ - char *method; - char *host; - char *path; - char *version; -}; - -static inline int -cache_request_init (struct disfluid_cache_request *request) -{ - request->method = NULL; - request->host = NULL; - request->path = NULL; - request->version = NULL; - return 0; -} - -static inline void -cache_request_clear (struct disfluid_cache_request *request) -{ - free (request->method); - free (request->host); - free (request->path); - free (request->version); - request->method = NULL; - request->host = NULL; - request->path = NULL; - request->version = NULL; -} - -static inline int -cache_request_prepare (struct disfluid_cache_request *request, - const char *method, const char *host, const char *path, - const char *version) -{ - char *my_method = malloc (strlen (method) + 1); - char *my_host = malloc (strlen (host) + 1); - char *my_path = malloc (strlen (path) + 1); - char *my_version = malloc (strlen (version) + 1); - if (my_method && my_host && my_path && my_version) - { - strcpy (my_method, method); - strcpy (my_host, host); - strcpy (my_path, path); - strcpy (my_version, version); - free (request->method); - free (request->host); - free (request->path); - free (request->version); - request->method = my_method; - request->host = my_host; - request->path = my_path; - request->version = my_version; - return 0; - } - else - { - free (my_method); - free (my_host); - free (my_path); - free (my_version); - return 1; - } -} - -static inline const char * -cache_request_method (const struct disfluid_cache_request *request) -{ - return request->method; -} - -static inline const char * -cache_request_path (const struct disfluid_cache_request *request) -{ - return request->path; -} - -static inline const char * -cache_request_host (const struct disfluid_cache_request *request) -{ - return request->host; -} - -static inline const char * -cache_request_version (const struct disfluid_cache_request *request) -{ - return request->version; -} - -#endif /* DISFLUID_CACHE_REQUEST_INCLUDED */ diff --git a/src/disfluid-header-iterator.h b/src/disfluid-header-iterator.h deleted file mode 100644 index db3ff75..0000000 --- a/src/disfluid-header-iterator.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef DISFLUID_HEADER_ITERATOR_INCLUDED -# define DISFLUID_HEADER_ITERATOR_INCLUDED - -struct disfluid_header_iterator; - -static inline - int header_iterator_init_request (struct disfluid_header_iterator *iterator, - const struct disfluid_cache_request - *request); - -static inline - void header_iterator_clear (struct disfluid_header_iterator *iterator); - -static inline - const char *header_iterator_get_name (const struct disfluid_header_iterator - *iterator); - -static inline - const char *header_iterator_get_value (const struct disfluid_header_iterator - *iterator); - -static inline - bool header_iterator_next (struct disfluid_header_iterator *iterator); - -# include "disfluid-cache-request.h" - -struct disfluid_header_iterator -{ - const struct disfluid_cache_request *request; - size_t i; -}; - -static inline int -header_iterator_init (struct disfluid_header_iterator *iterator, - const struct disfluid_cache_request *request) -{ - iterator->request = request; - iterator->i = 0; -} - -static inline void -header_iterator_clear (struct disfluid_header_iterator *iterator) -{ - iterator->request = NULL; -} - -/* Before iterating over the other headers, the request produces 1 - header: Host. */ - -static inline const char * -header_iterator_get_name (const struct disfluid_header_iterator *iterator) -{ - switch (iterator->i) - { - case 0: - return "Host"; - default: - return NULL; - } -} - -static inline const char * -header_iterator_get_value (const struct disfluid_header_iterator *iterator) -{ - switch (iterator->i) - { - case 0: - return iterator->request->host; - default: - return NULL; - } -} - -static inline bool -header_iterator_next (struct disfluid_header_iterator *iterator) -{ - if (iterator->i < 1) - { - iterator->i += 1; - return true; - } - return false; -} - -#endif /* DISFLUID_HEADER_ITERATOR_INCLUDED */ diff --git a/src/disfluid.gresource.xml b/src/disfluid.gresource.xml deleted file mode 100644 index 8410b7d..0000000 --- a/src/disfluid.gresource.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<gresources> - <gresource prefix="/eu/planete_kraus/Disfluid"> - <file>src/disfluid.ui</file> - <file>src/about.ui</file> - <file>src/unit_tests_report.ui</file> - </gresource> -</gresources> diff --git a/src/disfluid.ui b/src/disfluid.ui deleted file mode 100644 index 8d24cad..0000000 --- a/src/disfluid.ui +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.40.0 --> -<interface> - <template class="DisfluidWindow" parent="AdwApplicationWindow"> - <property name="content"> - <object class="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="AdwHeaderBar"> - <property name="centering-policy">strict</property> - <property name="title-widget"> - <object class="AdwViewSwitcherTitle" id="title"> - <property name="stack">stack</property> - <property name="title" translatable="yes">Disfluid</property> - </object> - </property> - <child> - <object class="GtkMenuButton" id="window_menu"> - <property name="icon-name">open-menu</property> - </object> - </child> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="AdwViewStack" id="stack"> - <child> - <object class="AdwViewStackPage"> - <property name="name">home</property> - <property name="title" translatable="yes" context="home-page">Home</property> - <property name="icon-name">go-home</property> - <property name="child"> - <object class="AdwStatusPage"> - <property name="title" translatable="yes">Nothing to see here.</property> - <property name="description" translatable="yes">Disfluid is not ready yet. Please come back later.</property> - <property name="icon-name">computer-fail</property> - </object> - </property> - </object> - </child> - <child> - <object class="AdwViewStackPage"> - <property name="name">settings</property> - <property name="title" translatable="yes" context="home-page">Settings</property> - <property name="icon-name">emblem-system</property> - <property name="child"> - <object class="GtkListBox"> - <property name="selection-mode">none</property> - <style> - <class name="boxed-list"/> - </style> - </object> - </property> - </object> - </child> - </object> - </child> - <child> - <object class="AdwViewSwitcherBar"> - <property name="stack">stack</property> - <binding name="reveal"> - <lookup name="title-visible">title</lookup> - </binding> - </object> - </child> - </object> - </child> - </object> - </property> - </template> -</interface> diff --git a/src/disfluid/main.c b/src/disfluid/main.c new file mode 100644 index 0000000..f671301 --- /dev/null +++ b/src/disfluid/main.c @@ -0,0 +1,25 @@ +#include <config.h> +#include "attribute.h" +#include <disfluid.h> + +#include <locale.h> +#include "gettext.h" +#include "progname.h" +#include "relocatable.h" + +#include <disfluid/adwaita.h> +#include <glib.h> +#include <adwaita.h> + +int +main (int argc, char *argv[]) +{ + set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); + textdomain (PACKAGE); + struct DisfluidApplication *app = disfluid_application_new (); + int status = g_application_run ((GApplication *) app, argc, argv); + g_object_unref (app); + return status; +} diff --git a/src/main-relocate.h b/src/main-relocate.h deleted file mode 100644 index 0957d0d..0000000 --- a/src/main-relocate.h +++ /dev/null @@ -1,10 +0,0 @@ -#include <config.h> -#include "relocatable.h" - -/* relocate is a function-like macro. This greatly confuses vala. */ - -inline const char * -_disfluid_relocate (const char *arg) -{ - return relocate (arg); -} diff --git a/src/unit_tests_report.ui b/src/unit_tests_report.ui deleted file mode 100644 index 62c74d7..0000000 --- a/src/unit_tests_report.ui +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.40.0 --> -<interface> - <template class="DisfluidUnitTestsReportDialog" parent="AdwApplicationWindow"> - <property name="content"> - <object class="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="AdwHeaderBar"> - <property name="centering-policy">strict</property> - <property name="title-widget"> - <object class="AdwWindowTitle" id="title"> - <property name="title" translatable="yes">Disfluid</property> - <property name="subtitle" translatable="yes">Checking the Disfluid implementation</property> - </object> - </property> - </object> - </child> - <child> - <object class="AdwClamp"> - <property name="orientation">horizontal</property> - <property name="maximum-size">480</property> - <property name="tightening-threshold">320</property> - <property name="child"> - <object class="GtkStack" id="stack"> - <property name="valign">center</property> - <property name="vhomogeneous">true</property> - <property name="vexpand">true</property> - <property name="vexpand-set">true</property> - <property name="transition-type">slide-left</property> - <property name="interpolate-size">true</property> - <child> - <object class="AdwStatusPage" id="page_wait"> - <property name="title" translatable="yes">Running disfluid unit tests…</property> - <property name="description" translatable="yes">Please wait while disfluid is running the unit tests.</property> - </object> - </child> - <child> - <object class="AdwStatusPage" id="page_failure"> - <property name="title" translatable="yes">The unit tests failed.</property> - <property name="description" translatable="yes">Disfluid unit tests failed. Sorry for the inconvenience.</property> - <property name="icon-name">dialog-error</property> - <child> - <object class="GtkBox"> - <property name="orientation">vertical</property> - <child> - <object class="GtkTextView" id="debug_info"> - <property name="editable">false</property> - <property name="cursor-visible">false</property> - <property name="monospace">true</property> - </object> - </child> - <child> - <object class="GtkButton"> - <property name="label" translatable="yes">Retry</property> - <property name="action-name">win.rerun-unit-tests</property> - </object> - </child> - <child> - <object class="GtkLinkButton" id="report_button"> - <property name="label" translatable="yes">Report</property> - <property name="visited">false</property> - </object> - </child> - </object> - </child> - </object> - </child> - <child> - <object class="AdwStatusPage" id="page_success"> - <property name="title" translatable="yes">The unit tests passed.</property> - <property name="description" translatable="yes">Disfluid unit tests passed. The application is functioning as expected.</property> - <property name="icon-name">dialog-information</property> - <child> - <object class="GtkButton"> - <property name="label" translatable="yes">Retry</property> - <property name="action-name">win.rerun-unit-tests</property> - </object> - </child> - </object> - </child> - </object> - </property> - </object> - </child> - </object> - </property> - </template> -</interface> diff --git a/src/vala/about.vala b/src/vala/about.vala deleted file mode 100644 index 2c6e7c8..0000000 --- a/src/vala/about.vala +++ /dev/null @@ -1,20 +0,0 @@ -[CCode (cheader_filename = "config.h")] -extern const string ABOUT_VALA; - -namespace Disfluid { - namespace About { - public Adw.AboutWindow create () { - var builder = new Gtk.Builder.from_resource ("/eu/planete_kraus/Disfluid/src/about.ui"); - var window = (Adw.AboutWindow) builder.get_object ("window"); - window.version = Disfluid.Config.VERSION; - window.release_notes = _("<p>Disfluid is very early in its conception.</p>"); - window.add_link (_ ("Send feedback and bug reports!"), "mailto:vivien@planete-kraus.eu"); - window.support_url = "mailto:vivien@planete-kraus.eu"; - const string devs[] = { - "Vivien Kraus <vivien@planete-kraus.eu>" - }; - window.developers = devs; - return window; - } - } -} diff --git a/src/vala/application-window.vala b/src/vala/application-window.vala deleted file mode 100644 index 3255d72..0000000 --- a/src/vala/application-window.vala +++ /dev/null @@ -1,18 +0,0 @@ -[CCode (cheader_filename = "config.h")] -extern const string APPLICATION_WINDOW_VALA; - -namespace Disfluid { - [GtkTemplate (ui = "/eu/planete_kraus/Disfluid/src/disfluid.ui")] - public class Window: Adw.ApplicationWindow { - [GtkChild] - private unowned Gtk.MenuButton window_menu; - - public Window (Adw.Application app) { - this.application = app; - var menu_model = new GLib.Menu (); - menu_model.append(_ ("About disfluid"), "app.about"); - menu_model.append(_ ("Run disfluid unit tests"), "app.run-unit-tests"); - window_menu.menu_model = menu_model; - } - } -} diff --git a/src/vala/config.vala b/src/vala/config.vala deleted file mode 100644 index a3b97d6..0000000 --- a/src/vala/config.vala +++ /dev/null @@ -1,21 +0,0 @@ -[CCode (cheader_filename = "config.h")] -extern const string CONFIG_VALA; - -namespace Disfluid { - namespace Config { - [CCode (cname = "PACKAGE")] - extern const string PACKAGE; - - [CCode (cname = "VERSION")] - extern const string VERSION; - - [CCode (cname = "LOCALEDIR")] - extern const string LOCALEDIR; - } - - [CCode (cheader_filename = "progname.h", cname = "set_program_name")] - extern void set_program_name (string arg0); - - [CCode (cheader_filename = "src/main-relocate.h", cname = "_disfluid_relocate")] - extern unowned string relocate(string arg); -} diff --git a/src/vala/libdisfluid.vala b/src/vala/libdisfluid.vala deleted file mode 100644 index cd076c3..0000000 --- a/src/vala/libdisfluid.vala +++ /dev/null @@ -1,7 +0,0 @@ -[CCode (cheader_filename = "config.h")] -extern const string LIBDISFLUID_VALA; - -namespace Disfluid { - [CCode (cheader_filename = "disfluid.h", cname = "disfluid_run_tests")] - extern string? run_tests(out size_t n_tests, out size_t n_errors); -} diff --git a/src/vala/main.vala b/src/vala/main.vala deleted file mode 100644 index 8b24cd7..0000000 --- a/src/vala/main.vala +++ /dev/null @@ -1,58 +0,0 @@ -[CCode (cheader_filename = "config.h")] -extern const string MAIN_VALA; - -namespace Disfluid { - - public class Application: Adw.Application { - - private string debug_info = ""; - - public signal void new_debug_info (string debug_info); - - public Application () { - Object (application_id: "eu.planete_kraus.Disfluid", flags: 0); - - GLib.SimpleAction show_about_dialog = - new GLib.SimpleAction ("about", null); - show_about_dialog.activate.connect (() => { - this.hold (); - var window = Disfluid.About.create (); - window.application = this; - window.debug_info = this.debug_info; - this.new_debug_info.connect ((app, di) => { - window.debug_info = di; - }); - window.present (); - this.release (); - }); - this.add_action (show_about_dialog); - GLib.SimpleAction run_unit_tests = - new GLib.SimpleAction ("run-unit-tests", null); - run_unit_tests.activate.connect (() => { - this.hold (); - var dialog = new Disfluid.UnitTestsReportDialog (this); - dialog.new_debug_info.connect ((app, di) => { - this.new_debug_info (di); - }); - dialog.present (); - this.release (); - }); - this.add_action (run_unit_tests); - this.activate.connect (() => { - var main_window = new Disfluid.Window (this); - main_window.present (); - }); - } - } -} - -int -main (string[] argv) -{ - Disfluid.set_program_name (argv[0]); - Intl.setlocale (LocaleCategory.ALL, ""); - Intl.bindtextdomain (Disfluid.Config.PACKAGE, Disfluid.relocate (Disfluid.Config.LOCALEDIR)); - Intl.textdomain (Disfluid.Config.PACKAGE); - var app = new Disfluid.Application (); - return app.run (argv); -} diff --git a/src/vala/unit-tests-report.vala b/src/vala/unit-tests-report.vala deleted file mode 100644 index 6442e48..0000000 --- a/src/vala/unit-tests-report.vala +++ /dev/null @@ -1,98 +0,0 @@ -[CCode (cheader_filename = "config.h")] -extern const string UNIT_TESTS_REPORT_VALA; - -namespace Disfluid { - - class UnitTestsReport: GLib.Object { - public string output; - public size_t n_tests; - public size_t n_errors; - - public UnitTestsReport (string output, size_t n_tests, size_t n_errors) { - this.output = output; - this.n_tests = n_tests; - this.n_errors = n_errors; - } - } - - async UnitTestsReport do_run_tests_in_bg () throws GLib.ThreadError { - GLib.SourceFunc callback = do_run_tests_in_bg.callback; - UnitTestsReport[] output = new UnitTestsReport[1]; - ThreadFunc<bool> run = () => { - size_t n_tests, n_errors; - var o = Disfluid.run_tests (out n_tests, out n_errors); - if (o == null) { - o = _ ("The tests did not produce any output."); - } - output[0] = new UnitTestsReport (o, n_tests, n_errors); - Idle.add ((owned) callback); - return true; - }; - new Thread<bool> ("unit-tests-thread", run); - yield; - return output[0]; - } - - [GtkTemplate (ui = "/eu/planete_kraus/Disfluid/src/unit_tests_report.ui")] - public class UnitTestsReportDialog: Adw.ApplicationWindow { - - [GtkChild] - private unowned Gtk.Stack stack; - - [GtkChild] - private unowned Adw.StatusPage page_wait; - - [GtkChild] - private unowned Adw.StatusPage page_success; - - [GtkChild] - private unowned Adw.StatusPage page_failure; - - [GtkChild] - private unowned Gtk.TextView debug_info; - - [GtkChild] - private unowned Gtk.LinkButton report_button; - - public signal void new_debug_info (string debug_info); - - public void start () { - this.stack.visible_child = this.page_wait; - do_run_tests_in_bg.begin ((obj, res) => { - try { - var results = do_run_tests_in_bg.end (res); - if (results.n_errors == 0) { - this.stack.visible_child = this.page_success; - } - else { - this.stack.visible_child = this.page_failure; - this.debug_info.buffer.text = results.output; - // Do not translate the subject - var subject = "[Disfluid unit tests failure] " + _ ("*** Your subject line here, in English ***") ; - var body = _ ("*** Please give as much information as possible, in English, as best as you can. Following your message is the debug information, check if there is no sensitive personal information. ***") + "\n\n" + results.output; - var query = "subject=" + GLib.Uri.escape_string (subject) + "&body=" + GLib.Uri.escape_string (body); - this.report_button.uri = "mailto:vivien@planete-kraus.eu?" + query; - this.new_debug_info (results.output); - } - } - catch (ThreadError e) { - this.stack.visible_child = this.page_failure; - } - }); - } - - public UnitTestsReportDialog (Gtk.Application app) { - this.application = app; - var s = new Gtk.Spinner (); - s.spinning = true; - var spinner = new Gtk.WidgetPaintable (s); - this.page_wait.paintable = spinner; - this.start (); - GLib.SimpleAction rerun = new GLib.SimpleAction ("rerun-unit-tests", null); - rerun.activate.connect (() => { - this.start (); - }); - this.add_action (rerun); - } - } -} |