Commit 839fde12 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Clicky click

parent 7e52814c
Pipeline #96980 failed with stages
in 6 minutes and 3 seconds
......@@ -10,6 +10,7 @@ cd build/
--enable-silent-rules=yes \
--enable-valgrind=yes \
--without-cairo \
--without-gtk+ \
|| (cat config.log; exit 1)
make -j 16 check || exit 1
make distclean || exit 1
......@@ -11,6 +11,7 @@ cd build/
--enable-silent-rules=yes \
--enable-valgrind=yes \
--without-cairo \
--without-gtk+ \
CFLAGS="-g -fprofile-arcs -ftest-coverage" \
|| (cat config.log; exit 1)
make -j 16 install-html || exit 1
......
......@@ -74,6 +74,16 @@ AS_IF([test "x$with_cairo" != "xno"], [
])
])
AM_CONDITIONAL([WITH_CAIRO], [test "x$WITH_CAIRO" != "xno"])
AC_ARG_WITH([gtk+], AS_HELP_STRING([--without-gtk+], [Do not build the Gtk+ bindings]))
WITH_GTK="no"
AS_IF([test "x$with_gtk" != "xno"], [
PKG_CHECK_MODULES([GTK], [gtk+-3.0], [
WITH_GTK="yes"
], [
AC_MSG_ERROR([Gtk+ was not found. Please use --without-gtk+.])
])
])
AM_CONDITIONAL([WITH_GTK], [test "x$WITH_GTK" != "xno"])
AC_SEARCH_LIBS([atan2], [m])
AC_SEARCH_LIBS([sin], [m])
AC_SEARCH_LIBS([cos], [m])
......
......@@ -2032,6 +2032,8 @@ tarot_run ()
Of course, we need some vala code to actually do the job.
#+BEGIN_SRC vala :noweb no-export :tangle ../src/application.vala
extern bool tarot_gui_try_run (bool brief, out int exit_status);
public class Application {
private static Tarot.Game current_game;
......@@ -2060,11 +2062,9 @@ Of course, we need some vala code to actually do the job.
if (!brief) {
print_user_greeting ();
}
#if WITH_GTK
if (!batch) {
return Tarot.Gui.try_run (brief, out exit_status);
return tarot_gui_try_run (brief, out exit_status);
}
#endif
return true;
}
private static string read_whole_file (GLib.FileStream file) {
......
......@@ -87,10 +87,12 @@ dist_man_MANS += %reldir%/tarot.6
%canon_reldir%_tarot_LDADD = \
%reldir%/libtarot.la \
%reldir%/libtarot-gobject.la \
src/gtk/libtarot-application-gui.la \
lib-program/libgnulibrary.la \
$(LTLIBREADLINE) \
$(LIBOPTS_LDADD) \
$(GOBJECT_LIBS)
$(GOBJECT_LIBS) \
$(GTK_LIBS)
else # not WITH_GOBJECT
EXTRA_DIST += %reldir%/main.c \
%reldir%/tarot-opts.c \
......@@ -184,3 +186,4 @@ include %reldir%/cli/Makefile.am
include %reldir%/xml/Makefile.am
include %reldir%/layout/Makefile.am
include %reldir%/cairo/Makefile.am
include %reldir%/gtk/Makefile.am
# Makefile.am
#
# Copyright (C) 2018 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/>.
AM_VALAFLAGS += --pkg gtk+-3.0
noinst_LTLIBRARIES += \
%reldir%/libtarot-application-gui.la
if WITH_GTK
%canon_reldir%_libtarot_application_gui_la_SOURCES = \
%reldir%/tarot_application_with_gui.vala
%canon_reldir%_libtarot_application_gui_la_CFLAGS = \
$(AM_CFLAGS) \
$(GTK_CFLAGS) \
-include "config.h" \
-w
%canon_reldir%_libtarot_application_gui_la_LIBS = \
$(AM_LIBS) \
$(GTK_LIBS)
AM_CPPFLAGS += -Dtarot_gui_try_run=tarot_gui_try_run_with_gui
else # not WITH_GTK
%canon_reldir%_libtarot_application_gui_la_SOURCES = \
%reldir%/tarot_application_without_gui.vala
%canon_reldir%_libtarot_application_gui_la_CFLAGS = \
$(AM_CFLAGS) \
-include "config.h" \
-w
%canon_reldir%_libtarot_application_gui_la_LIBS = \
$(AM_LIBS)
AM_CPPFLAGS += -Dtarot_gui_try_run=tarot_gui_try_run_without_gui
endif # not WITH_GTK
// file tarot_application.vala
//
// Copyright (C) 2017, 2018 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 {
namespace Gui {
public static bool try_run (bool brief, out int exit_status) {
var app = new Gtk.Application ("eu.planete_kraus.Tarot", ApplicationFlags.FLAGS_NONE);
app.activate.connect (() => {
var window = app.active_window;
if (window == null) {
window.title = "First GTK+ Program";
window.border_width = 10;
window.window_position = WindowPosition.CENTER;
window.set_default_size (350, 70);
window.destroy.connect (Gtk.main_quit);
var button = new Button.with_label ("Click me!");
button.clicked.connect (() => {
button.label = "Thank you";
});
window.add (button);
window.show_all ();
}
window.present ();
})
stderr.printf ("Running the gui\n");
exit_status = app.run (null);
return false;
}
}
}
\ No newline at end of file
// file tarot_application.vala
//
// Copyright (C) 2017, 2018 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 {
namespace Gui {
public static bool try_run_with_gui (bool brief, out int exit_status) {
var app = new Gtk.Application ("eu.planete_kraus.Tarot", ApplicationFlags.FLAGS_NONE);
app.activate.connect (() => {
var window = app.active_window;
if (window == null) {
window = new Gtk.Window ();
window.application = app;
window.title = "First GTK+ Program";
window.border_width = 10;
window.window_position = Gtk.WindowPosition.CENTER;
window.set_default_size (350, 70);
window.destroy.connect (Gtk.main_quit);
var button = new Gtk.Button.with_label ("Click me!");
button.clicked.connect (() => {
button.label = "Thank you";
});
window.add (button);
window.show_all ();
}
window.present ();
});
var return_value = app.run (null);
exit_status = return_value;
return false;
}
}
}
\ No newline at end of file
// file tarot_application.vala
//
// Copyright (C) 2017, 2018 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 {
namespace Gui {
public static bool try_run_without_gui (bool brief, out int exit_status) {
exit_status = 0;
return true;
}
}
}
\ No newline at end of file
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