Commit d021724c authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Resolve "Use the GApplication / GtkApplication API more!"

parent dce1caa4
......@@ -71,18 +71,18 @@ cd $SOURCE_TOP || exit 1
rm -rf ../tarot-*.tar.gz ../tarot-*/ tarot-*.tar.gz
sh autogen.sh VALAFLAGS="--target-glib=2.50" || exit 1
./configure \
CFLAGS="-Wall -Wextra -Werror -g $CFLAGS" \
CFLAGS="-Wall -Wextra -g $CFLAGS" \
VALAFLAGS="--target-glib=2.50" \
--prefix="$SOURCE_TOP/dist" \
--enable-valgrind=yes \
--enable-silent-rules=yes \
|| (cat config.log ; exit 1) \
|| exit 1
(cd lib && make -j 16 CFLAGS="-Wno-error -g $CFLAGS") || exit 1
make -j 16 safe || exit 1
make -j 16 distcheck || exit 1
make -j 8 check || exit 1
make -j 16 install install-html || exit 1
(cd lib && make -j 16) || exit 1
make -j 16 CFLAGS="$CFLAGS -Werror" safe || exit 1
make -j 16 CFLAGS="$CFLAGS -Werror" distcheck || exit 1
make -j 8 CFLAGS="$CFLAGS -Werror" check || exit 1
make -j 16 CFLAGS="$CFLAGS -Werror" install install-html || exit 1
make indent || exit 1
rm -rf ../../tarot-*.tar.gz ../../tarot-*/
cp tarot-*.tar.gz ../../ || exit 1
......
......@@ -81,13 +81,9 @@ AS_IF([test "x$enable_program" != "xno"], [
PKG_CHECK_MODULES([CAIRO], [cairo cairo-png],, [
AC_MSG_ERROR([Cairo was not found.])
])
PKG_CHECK_MODULES([GTK], [gtk+-3.0], [
AM_CONDITIONAL([WITH_GTK], [true])
], [
AM_CONDITIONAL([WITH_GTK], [false])
PKG_CHECK_MODULES([GTK], [gtk+-3.0],, [
AC_MSG_ERROR([Gtk+ was not found.])
])
], [
AM_CONDITIONAL([WITH_GTK], [false])
])
AX_LIB_NETTLE([yes])
PKG_CHECK_MODULES([XML], [libxml-2.0])
......
# List of source files which contain translatable strings.
src/tarot-app/tarot_cli.vala
src/tarot-app/application.vala
src/tarot-app/pretty_status.vala
src/tarot-app/solo.vala
src/tarot-app/main.vala
src/tarot-app/gui/application.vala
src/tarot-app/gui/window.vala
src/tarot-app/gui/window.ui
src/tarot-app/gui/widget.vala
......
This diff is collapsed.
......@@ -89,6 +89,8 @@ tarot_player_to_string_c_alloc (TarotPlayer p)
{
size_t n = player_to_string_c (p, 0, NULL);
char *ret = xmalloc (n + 1);
// GCC warns that we should not use strncpy since we don't truncate
// anyway. This is true, but we don't care.
size_t check = player_to_string_c (p, n + 1, ret);
assert (check == n);
assert (ret[n] == '\0');
......
......@@ -3,8 +3,10 @@
rm -rf bus-name
mkfifo bus-name || exit 1
>&2 echo "Starting the server..."
(tarot --dbus-server --anonymous-dbus > bus-name) &
>&2 echo "Starting the server, in case it is not running yet..."
(tarot --gapplication-service --hold > bus-name) &
echo "Reading the bus name..."
BUS_NAME=$(head -n 1 bus-name)
......@@ -24,7 +26,7 @@ mkfifo final-score || exit 1
for i in 0 $(seq 4)
do
>&2 echo "Starting player $i"
(tarot --dbus-mcts="/eu/planete_kraus/Tarot/Server/Games/$GAME_ID/seat/$i" --dbus-server-name="$BUS_NAME" >> final-score) &
(tarot --dbus-mcts="/eu/planete_kraus/Tarot/Server/Games/$GAME_ID/seat/$i" --server-bus-name="$BUS_NAME" >> final-score) &
done
SCORE=$(head -n 5 final-score | tee final-score-file)
......
......@@ -28,7 +28,7 @@ DISTCLEANFILES += %reldir%/eu.planete_kraus.Tarot.service
%reldir%/eu.planete_kraus.Tarot.service: config.h %reldir%/dbus-service.am
$(AM_V_GEN) (echo "[D-BUS Service]" ; \
echo "Name=eu.planete_kraus.Tarot" ; \
echo "Exec=$(pkglibexecdir)/tarot-en --dbus-server") \
echo "Exec=$(bindir)/tarot --gapplication-service --hold") \
> %reldir%/eu.planete_kraus.Tarot.service-t
@mv %reldir%/eu.planete_kraus.Tarot.service-t \
%reldir%/eu.planete_kraus.Tarot.service
// main.vala
//
// Copyright (C) 2019 Vivien Kraus <vivien@planete-kraus.eu>
//
// This program 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.
//
// This program 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 this program. If not, see
// <http://www.gnu.org/licenses/>.
namespace Tarot {
public int gui_try (size_t n_players, bool call, MctsParams mp, size_t retry, bool no_window, out string? output) {
output = null;
string[]? argv = null;
unowned string[]? argv_ref = argv;
if (!no_window && Gtk.init_check (ref argv_ref)) {
var app = new Gtk.Application (null, ApplicationFlags.FLAGS_NONE);
app.activate.connect (() => {
var win = app.active_window;
if (win == null) {
win = new Tarot.Window (app, n_players, call, mp, (int) retry);
}
win.present ();
});
return app.run (argv_ref);
} else {
string? my_output = null;
int ret = Solo.run (n_players, call, mp, (int) retry, out my_output);
output = my_output;
return ret;
}
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -18,7 +18,7 @@
AM_VALAFLAGS += --pkg cairo --pkg gtk+-3.0
TAROT_CLI_SOURCES_VALA = $(srcdir)/%reldir%/tarot_cli.vala \
TAROT_SOURCES_VALA = $(srcdir)/%reldir%/tarot_cli.vala \
$(srcdir)/%reldir%/pretty_status.vala \
$(srcdir)/%reldir%/application.vala \
$(srcdir)/%reldir%/history.vala \
......@@ -27,27 +27,12 @@ TAROT_CLI_SOURCES_VALA = $(srcdir)/%reldir%/tarot_cli.vala \
$(srcdir)/%reldir%/card_painter_default.vala \
$(srcdir)/%reldir%/main.vala \
$(srcdir)/%reldir%/server.vala \
$(srcdir)/%reldir%/mcts.vala
TAROT_GUI_SOURCES_VALA = \
$(srcdir)/%reldir%/gui/application.vala \
$(srcdir)/%reldir%/mcts.vala \
$(srcdir)/%reldir%/gui/window.vala \
$(srcdir)/%reldir%/gui/widget.vala \
$(srcdir)/%reldir%/gui/card_view.vala
TAROT_SOURCES_VALA = $(TAROT_CLI_SOURCES_VALA) $(TAROT_GUI_SOURCES_VALA)
TAROT_CLI_SOURCES_C = $(TAROT_CLI_SOURCES_VALA:.vala=.c)
TAROT_GUI_SOURCES_C = $(TAROT_GUI_SOURCES_VALA:.vala=.c) %reldir%/resources.c
TAROT_SOURCES_C = $(TAROT_CLI_SOURCES_C) $(TAROT_GUI_SOURCES_C)
if WITH_GTK
AM_CPPFLAGS += -DRUN_INTERACTIVE=tarot_gui_try
else # not WITH_GTK
AM_CPPFLAGS += -DRUN_INTERACTIVE=tarot_solo_run
endif # not WITH_GTK
TAROT_SOURCES_C = $(TAROT_SOURCES_VALA:.vala=.c) %reldir%/resources.c
if ENABLE_PROGRAM
bin_PROGRAMS += %reldir%/tarot
......@@ -63,28 +48,21 @@ dist_man6_MANS +=
%reldir%/main.c \
src/gettext.h \
%reldir%/server.c \
%reldir%/mcts.c
if WITH_GTK
%canon_reldir%_tarot_SOURCES += \
%reldir%/gui/application.c \
%reldir%/mcts.c \
%reldir%/gui/window.c \
%reldir%/gui/widget.c \
%reldir%/gui/card_view.c \
%reldir%/resources.c
endif # WITH_GTK
%canon_reldir%_tarot_CFLAGS = \
$(AM_CFLAGS) \
$(LIBOPTS_CFLAGS) \
$(GOBJECT_CFLAGS) \
$(CAIRO_CFLAGS) \
$(GTK_CFLAGS) \
-w \
-include config.h
if WITH_GTK
%canon_reldir%_tarot_CFLAGS += $(GTK_CFLAGS)
endif # WITH_GTK
-include config.h \
-include tuneconfig.h
%canon_reldir%_tarot_LDADD = \
lib/libgnu.la \
......@@ -93,15 +71,12 @@ endif # WITH_GTK
$(LIBOPTS_LDADD) \
$(GOBJECT_LIBS) \
$(CAIRO_LIBS) \
$(GTK_LIBS) \
$(LTLIBINTL) \
$(LTLIBREADLINE) \
$(LTLIBTHREAD) \
@INTL_MACOSX_LIBS@
if WITH_GTK
%canon_reldir%_tarot_LDADD += $(GTK_LIBS)
endif # WITH_GTK
TESTS += $(TAROT_CLI_TESTS)
endif # not ENABLE_PROGRAM
......
[CCode (cname="RUN_INTERACTIVE")]
extern int RUN_INTERACTIVE (size_t n_players, bool call, Tarot.MctsParams mp, size_t retry, bool no_window, out string? output);
namespace Tarot {
private static Tarot.Card parse_one_card (string card) {
unowned string end;
......@@ -288,16 +285,4 @@ namespace Tarot {
stderr.printf (_ ("Error: could not write PNG: %s\n"), status.to_string ());
return 1;
}
public static int run_interactive (size_t n_players, bool call, MctsParams mp, int retry, bool no_window, out string? output) {
string my_output = null;
string valid_seed = mp.seed;
(void) no_window;
if (mp.seed == null) {
valid_seed = "%ld".printf ((long) GLib.get_real_time ());
}
mp.seed = valid_seed;
int ret = RUN_INTERACTIVE (n_players, call, mp, retry, no_window, out my_output);
output = my_output;
return ret;
}
}
\ No newline at end of file
#!/bin/sh
(echo "pass" ; echo "pass") | tarot --no-window -s ":)"
(echo "pass" ; echo "pass") | tarot -s ":)"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment