Commit 917ee891 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Use GtkTemplate

parent 839fde12
Pipeline #97010 passed with stages
in 4 minutes and 5 seconds
......@@ -10,7 +10,7 @@ cd build/
--enable-silent-rules=yes \
--enable-valgrind=yes \
--without-cairo \
--without-gtk+ \
--without-gtk \
|| (cat config.log; exit 1)
make -j 16 check || exit 1
make distclean || exit 1
#!/bin/sh
# HACKS!!!!
#
# Remove VALAFLAGS="--target-glib=2.50"
SOURCE_TOP=$(pwd)
CLEAN_TOP=$(cd .. && pwd)/clean
mkdir -p ../clean
......@@ -24,7 +28,7 @@ make indent || exit 1
(cd lib-library && make -j 16) || exit 1
(cd lib-program && make -j 16) || exit 1
# I don't know exactly which targets are not thread safe...
make dist || exit 1
make VALAFLAGS="--target-glib=2.50" dist || exit 1
make -j 16 distcheck \
|| (cat "$SOURCE_TOP/tarot-$(cat .version)/_build/sub/test-suite.log" ; exit 1) \
|| exit 1
......
......@@ -8,7 +8,7 @@ cp public/tarot-$VERSION.tar.gz ./upstream.tar.gz || exit 1
rm -rf build-dir || exit 1
flatpak-builder build-dir eu.planete_kraus.Tarot.json || exit 1
echo "help" | flatpak-builder --run build-dir eu.planete_kraus.Tarot.json tarot || exit 1
echo "help" | flatpak-builder --run build-dir eu.planete_kraus.Tarot.json tarot --batch || exit 1
flatpak-builder --repo=flatpak --gpg-sign=C8ECB5A2 --force-clean build-dir eu.planete_kraus.Tarot.json || exit 1
cat > tarot.flatpakrepo <<EOF
[Flatpak Repo]
......
......@@ -11,7 +11,7 @@ cd build/
--enable-silent-rules=yes \
--enable-valgrind=yes \
--without-cairo \
--without-gtk+ \
--without-gtk \
CFLAGS="-g -fprofile-arcs -ftest-coverage" \
|| (cat config.log; exit 1)
make -j 16 install-html || exit 1
......
......@@ -42,6 +42,7 @@ GOBJECT_INTROSPECTION_CHECK([1.30.0])
PKG_CHECK_VAR([GLIB_MKENUMS], [glib-2.0], [glib_mkenums])
AM_PROG_VALAC
VAPIGEN_CHECK
AM_MISSING_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
# Checks for libraries.
gl_lib_INIT
......@@ -74,13 +75,13 @@ 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]))
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+.])
AC_MSG_ERROR([Gtk+ was not found. Please use --without-gtk.])
])
])
AM_CONDITIONAL([WITH_GTK], [test "x$WITH_GTK" != "xno"])
......
......@@ -16,14 +16,27 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
AM_VALAFLAGS += --pkg gtk+-3.0
AM_VALAFLAGS += \
--pkg gtk+-3.0 \
--gresources %reldir%/tarot-resources.xml
noinst_LTLIBRARIES += \
%reldir%/libtarot-application-gui.la
EXTRA_DIST += \
%reldir%/main_window.ui \
%reldir%/tarot-resources.xml \
%reldir%/tarot-resources.c
%reldir%/tarot-resources.xml: %reldir%/main_window.ui
%reldir%/tarot-resources.c: %reldir%/tarot-resources.xml
$(AM_V_GEN) (cd $(srcdir)/%reldir% && $(GLIB_COMPILE_RESOURCES) --generate-source \
--target tarot-resources.c \
tarot-resources.xml)
if WITH_GTK
%canon_reldir%_libtarot_application_gui_la_SOURCES = \
%reldir%/tarot_application_with_gui.vala
%reldir%/tarot_application_with_gui.vala \
%reldir%/tarot-resources.c
%canon_reldir%_libtarot_application_gui_la_CFLAGS = \
$(AM_CFLAGS) \
$(GTK_CFLAGS) \
......@@ -38,9 +51,11 @@ else # not WITH_GTK
%reldir%/tarot_application_without_gui.vala
%canon_reldir%_libtarot_application_gui_la_CFLAGS = \
$(AM_CFLAGS) \
$(GOBJECT_CFLAGS) \
-include "config.h" \
-w
%canon_reldir%_libtarot_application_gui_la_LIBS = \
$(GOBJECT_LIBS) \
$(AM_LIBS)
AM_CPPFLAGS += -Dtarot_gui_try_run=tarot_gui_try_run_without_gui
endif # not WITH_GTK
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="TarotWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="default_width">600</property>
<property name="default_height">300</property>
<child>
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkDrawingArea" id="tarot_drawing_area">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="console">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="input">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Tarot</property>
<property name="show_close_button">True</property>
</object>
</child>
</template>
</interface>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/eu/planete_kraus/Tarot">
<file compressed="true" preprocess="xml-stripblanks">main_window.ui</file>
</gresource>
</gresources>
// 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
......@@ -17,26 +17,19 @@
// <http://www.gnu.org/licenses/>.
namespace Tarot {
[GtkTemplate (ui = "/eu/planete_kraus/Tarot/main_window.ui")]
public class Window: Gtk.ApplicationWindow {
public Window (Gtk.Application app) {
Object (application: app);
}
}
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 = new Window (app);
window.show_all ();
}
window.present ();
......
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