Native UI
This commit is contained in:
parent
2df26b8ce0
commit
bf75b8b652
23 changed files with 841 additions and 5 deletions
38
aux/flatpak/space.arimelody.LiveSchedule.json
Normal file
38
aux/flatpak/space.arimelody.LiveSchedule.json
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"id" : "space.arimelody.LiveSchedule",
|
||||||
|
"runtime" : "org.gnome.Platform",
|
||||||
|
"runtime-version" : "48",
|
||||||
|
"sdk" : "org.gnome.Sdk",
|
||||||
|
"command" : "liveschedule",
|
||||||
|
"finish-args" : [
|
||||||
|
"--share=network",
|
||||||
|
"--share=ipc",
|
||||||
|
"--socket=fallback-x11",
|
||||||
|
"--device=dri",
|
||||||
|
"--socket=wayland"
|
||||||
|
],
|
||||||
|
"cleanup" : [
|
||||||
|
"/include",
|
||||||
|
"/lib/pkgconfig",
|
||||||
|
"/man",
|
||||||
|
"/share/doc",
|
||||||
|
"/share/gtk-doc",
|
||||||
|
"/share/man",
|
||||||
|
"/share/pkgconfig",
|
||||||
|
"*.la",
|
||||||
|
"*.a"
|
||||||
|
],
|
||||||
|
"modules" : [
|
||||||
|
{
|
||||||
|
"name" : "liveschedule",
|
||||||
|
"builddir" : true,
|
||||||
|
"buildsystem" : "meson",
|
||||||
|
"sources" : [
|
||||||
|
{
|
||||||
|
"type" : "git",
|
||||||
|
"url" : "file://var/run/media/julia/Projects/Live Schedule"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
66
main.js
66
main.js
|
|
@ -114,12 +114,68 @@ function altText() {
|
||||||
alert(altText);
|
alert(altText);
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyClipboard() {
|
if ('webkit' in window && 'messageHandlers' in window.webkit) {
|
||||||
// TODO: screen capture API: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API
|
let _promiseId = 0;
|
||||||
}
|
let _promises = new Map();
|
||||||
|
|
||||||
function saveImage() {
|
window.webkit.messageHandlers._nativePromiseResolved.addEventListener('message', (event) => {
|
||||||
// TODO: screen capture API: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API
|
const [id] = event.detail;
|
||||||
|
const [resolve,] = _promises.get(id) ?? [];
|
||||||
|
if (!resolve) return;
|
||||||
|
_promises.delete(id);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
window.webkit.messageHandlers._nativePromiseRejected.addEventListener('message', (event) => {
|
||||||
|
const [id] = event.detail;
|
||||||
|
const [,reject] = _promises.get(id) ?? [];
|
||||||
|
if (!reject) return;
|
||||||
|
_promises.delete(id);
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
|
||||||
|
function copyClipboard() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const thisPromiseId = ++promiseId;
|
||||||
|
|
||||||
|
_promises.set(thisPromiseId, [resolve, reject]);
|
||||||
|
|
||||||
|
const schedule = document.getElementById('schedule');
|
||||||
|
const boundingRect = getBoundingClientRect();
|
||||||
|
|
||||||
|
window.webkit.messageHandlers.copySnapshot.postMessage([
|
||||||
|
thisPromiseId,
|
||||||
|
'clipboard',
|
||||||
|
boundingRect.x,
|
||||||
|
boundingRect.y,
|
||||||
|
boundingRect.width,
|
||||||
|
boundingRect.height,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveImage() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const thisPromiseId = ++promiseId;
|
||||||
|
|
||||||
|
_promises.set(thisPromiseId, [resolve, reject]);
|
||||||
|
|
||||||
|
const schedule = document.getElementById('schedule');
|
||||||
|
const boundingRect = getBoundingClientRect();
|
||||||
|
|
||||||
|
window.webkit.messageHandlers.copySnapshot.postMessage([
|
||||||
|
thisPromiseId,
|
||||||
|
'file',
|
||||||
|
boundingRect.x,
|
||||||
|
boundingRect.y,
|
||||||
|
boundingRect.width,
|
||||||
|
boundingRect.height,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('clipboard').removeAttribute('disabled');
|
||||||
|
document.getElementById('save-image').removeAttribute('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportJSON() {
|
function exportJSON() {
|
||||||
|
|
|
||||||
6
meson.build
Normal file
6
meson.build
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
project('schedule', 'c',
|
||||||
|
version: '0.1.0',
|
||||||
|
meson_version: '>= 1.0.0',
|
||||||
|
default_options: [ 'warning_level=2', 'werror=false', 'c_std=gnu11', ])
|
||||||
|
|
||||||
|
subdir('native')
|
||||||
|
|
@ -0,0 +1,130 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="33.750061mm"
|
||||||
|
height="33.750061mm"
|
||||||
|
viewBox="0 0 33.750061 33.750061"
|
||||||
|
version="1.1"
|
||||||
|
id="svg974">
|
||||||
|
<defs
|
||||||
|
id="defs968">
|
||||||
|
<clipPath
|
||||||
|
clipPathUnits="userSpaceOnUse"
|
||||||
|
id="clipPath18689">
|
||||||
|
<rect
|
||||||
|
clip-path="none"
|
||||||
|
transform="rotate(45)"
|
||||||
|
ry="32.000008"
|
||||||
|
rx="32.000008"
|
||||||
|
y="123.9986"
|
||||||
|
x="486.03726"
|
||||||
|
height="362.94299"
|
||||||
|
width="362.94299"
|
||||||
|
id="rect18691"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#4a86cf;fill-opacity:1;stroke:none;stroke-width:26.0669;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</clipPath>
|
||||||
|
<clipPath
|
||||||
|
clipPathUnits="userSpaceOnUse"
|
||||||
|
id="clipPath18689-3">
|
||||||
|
<rect
|
||||||
|
clip-path="none"
|
||||||
|
transform="rotate(45)"
|
||||||
|
ry="32.000008"
|
||||||
|
rx="32.000008"
|
||||||
|
y="123.9986"
|
||||||
|
x="486.03726"
|
||||||
|
height="362.94299"
|
||||||
|
width="362.94299"
|
||||||
|
id="rect18691-6"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#4a86cf;fill-opacity:1;stroke:none;stroke-width:26.0669;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<metadata
|
||||||
|
id="metadata971">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-61.819823,-103.94395)">
|
||||||
|
<g
|
||||||
|
transform="matrix(0.26367235,0,0,0.26367235,61.819823,-529.39703)"
|
||||||
|
style="display:inline;stroke-width:0.25;enable-background:new"
|
||||||
|
id="g1836">
|
||||||
|
<title
|
||||||
|
id="title1838">application-x-executable</title>
|
||||||
|
<g
|
||||||
|
transform="matrix(0.25,0,0,0.25,0,2295)"
|
||||||
|
id="g18818"
|
||||||
|
style="stroke-width:0.25">
|
||||||
|
<g
|
||||||
|
style="stroke-width:0.269963"
|
||||||
|
transform="matrix(0.92605186,0,0,0.92605186,18.930729,50.876335)"
|
||||||
|
id="g18590">
|
||||||
|
<g
|
||||||
|
style="stroke-width:0.269963"
|
||||||
|
id="g18681"
|
||||||
|
clip-path="url(#clipPath18689-3)">
|
||||||
|
<rect
|
||||||
|
style="opacity:1;vector-effect:none;fill:#3584e4;fill-opacity:1;stroke:none;stroke-width:8.22095;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
||||||
|
id="rect18571"
|
||||||
|
width="424"
|
||||||
|
height="424"
|
||||||
|
x="458.33722"
|
||||||
|
y="90.641701"
|
||||||
|
rx="10.092117"
|
||||||
|
ry="10.092117"
|
||||||
|
transform="matrix(0.60528171,0.60528171,-0.60528171,0.60528171,33.440632,99.073632)"
|
||||||
|
clip-path="none" />
|
||||||
|
<circle
|
||||||
|
style="opacity:1;vector-effect:none;fill:#f66151;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
||||||
|
id="path18706"
|
||||||
|
cx="0"
|
||||||
|
cy="0"
|
||||||
|
r="0"
|
||||||
|
transform="translate(0,-212)" />
|
||||||
|
<circle
|
||||||
|
style="opacity:1;vector-effect:none;fill:#f66151;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal"
|
||||||
|
id="path18708"
|
||||||
|
cx="0"
|
||||||
|
cy="0"
|
||||||
|
r="0"
|
||||||
|
transform="translate(0,-212)" />
|
||||||
|
<path
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#98c1f1;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
|
||||||
|
d="m 408.91993,561.9183 -9.8861,29.82892 a 172.97099,172.97099 0 0 0 -1.42693,-0.0713 172.97099,172.97099 0 0 0 -23.92891,1.85189 l -13.80082,-28.50125 a 203.29325,203.29325 0 0 0 -29.40085,7.97217 l 2.28619,31.40474 a 172.97099,172.97099 0 0 0 -22.73152,11.31923 l -23.71796,-21.103 a 203.29325,203.29325 0 0 0 -24.05918,18.6741 l 14.09863,28.07319 a 172.97099,172.97099 0 0 0 -16.63608,19.21074 l -30.05845,-10.44758 a 203.29325,203.29325 0 0 0 -15.01683,26.48807 l 23.73035,20.50738 a 172.97099,172.97099 0 0 0 -7.98456,24.14293 l -31.73044,1.84879 a 203.29325,203.29325 0 0 0 -3.77825,30.21664 l 29.82892,9.8861 a 172.97099,172.97099 0 0 0 -0.0713,1.42693 172.97099,172.97099 0 0 0 1.85188,23.92889 l -28.50125,13.80084 a 203.29325,203.29325 0 0 0 7.97215,29.40084 l 31.40475,-2.28619 a 172.97099,172.97099 0 0 0 11.31922,22.73152 l -21.10296,23.71797 a 203.29325,203.29325 0 0 0 18.67409,24.05918 l 28.07319,-14.09863 a 172.97099,172.97099 0 0 0 19.21074,16.63606 l -10.44758,30.05847 a 203.29325,203.29325 0 0 0 26.48806,15.01683 l 20.50739,-23.73036 a 172.97099,172.97099 0 0 0 24.14293,7.98457 l 1.8488,31.73043 a 203.29325,203.29325 0 0 0 30.21666,3.77826 l 9.8861,-29.82892 a 172.97099,172.97099 0 0 0 1.42693,0.0713 172.97099,172.97099 0 0 0 23.9289,-1.85188 l 13.80084,28.50125 a 203.29325,203.29325 0 0 0 29.40084,-7.97217 l -2.2862,-31.40474 a 172.97099,172.97099 0 0 0 22.73153,-11.31922 l 23.71796,21.10297 A 203.29325,203.29325 0 0 0 532.96,916.00016 l -14.09864,-28.07319 a 172.97099,172.97099 0 0 0 16.63607,-19.21073 l 30.05846,10.44757 a 203.29325,203.29325 0 0 0 15.01683,-26.48807 l -23.73036,-20.50738 a 172.97099,172.97099 0 0 0 7.98457,-24.14293 l 31.73044,-1.84879 a 203.29325,203.29325 0 0 0 3.77825,-30.21667 l -29.82892,-9.8861 a 172.97099,172.97099 0 0 0 0.0713,-1.42692 172.97099,172.97099 0 0 0 -1.85189,-23.9289 l 28.50124,-13.80084 a 203.29325,203.29325 0 0 0 -7.97215,-29.40084 l -31.40474,2.2862 a 172.97099,172.97099 0 0 0 -11.31923,-22.73153 l 21.10297,-23.71797 a 203.29325,203.29325 0 0 0 -18.67409,-24.05918 l -28.07319,14.09863 a 172.97099,172.97099 0 0 0 -19.21074,-16.63606 l 10.44757,-30.05847 A 203.29325,203.29325 0 0 0 485.6357,581.68117 l -20.50738,23.73035 a 172.97099,172.97099 0 0 0 -24.14293,-7.98455 l -1.84879,-31.73044 a 203.29325,203.29325 0 0 0 -30.21667,-3.77826 z M 397.6069,637.72208 A 126.92605,126.92605 0 0 1 524.5318,764.64699 126.92605,126.92605 0 0 1 397.6069,891.57189 126.92605,126.92605 0 0 1 270.682,764.64699 126.92605,126.92605 0 0 1 397.6069,637.72208 Z"
|
||||||
|
id="path18717-4" />
|
||||||
|
<path
|
||||||
|
id="path18758"
|
||||||
|
d="m 51.748325,401.28402 -9.8861,29.82892 c -0.475543,-0.0257 -0.951191,-0.0495 -1.42693,-0.0713 -8.00956,0.0625 -16.005106,0.6813 -23.92891,1.85189 L 2.7055639,404.39228 c -9.9858697,1.91835 -19.8137359,4.58322 -29.4008489,7.97217 l 2.28619,31.40474 c -7.844275,3.21103 -15.441918,6.9943 -22.73152,11.31923 l -23.71796,-21.103 c -8.475372,5.61437 -16.517661,11.85658 -24.05918,18.6741 l 14.09863,28.07319 c -6.008901,5.98701 -11.569263,12.40791 -16.636077,19.21074 l -30.058438,-10.44758 c -5.66072,8.44155 -10.68041,17.29574 -15.01683,26.48807 l 23.73035,20.50738 c -3.25027,7.84084 -5.919,15.91028 -7.98456,24.14293 l -31.73044,1.84879 c -2.01308,9.96359 -3.27604,20.06413 -3.77825,30.21664 l 29.82892,9.8861 c -0.0257,0.47554 -0.0495,0.95119 -0.0713,1.42693 0.0625,8.00955 0.68129,16.00509 1.85188,23.92889 l -28.50125,13.80084 c 1.91835,9.98587 4.58321,19.81373 7.97215,29.40084 l 31.40475,-2.28619 c 3.21102,7.84427 6.99429,15.44192 11.31922,22.73152 l -21.10296,23.71797 c 5.61437,8.47537 11.85658,16.51766 18.67409,24.05918 l 28.073175,-14.09863 c 5.987006,6.00889 12.407911,11.56925 19.21074,16.63606 l -10.44758,30.05847 c 8.441549,5.66072 17.295731,10.68041 26.48806,15.01683 l 20.50739,-23.73036 c 7.840839,3.25027 15.910282,5.91901 24.142929,7.98457 l 1.8488,31.73043 c 9.9635962,2.01309 20.064147,3.27605 30.216661,3.77826 l 9.8861,-29.82892 c 0.475543,0.0257 0.951191,0.0495 1.42693,0.0713 8.009557,-0.0625 16.005099,-0.68129 23.9289,-1.85188 l 13.80084,28.50125 c 9.985867,-1.91835 19.813731,-4.58322 29.400855,-7.97217 l -2.2862,-31.40474 c 7.84428,-3.21102 15.44192,-6.99429 22.73153,-11.31922 l 23.71796,21.10297 c 8.47538,-5.61437 16.51767,-11.85658 24.05919,-18.6741 l -14.09864,-28.07319 c 6.0089,-5.987 11.56926,-12.4079 16.63607,-19.21073 l 30.05846,10.44757 c 5.66072,-8.44155 10.68041,-17.29574 15.01683,-26.48807 l -23.73036,-20.50738 c 3.25027,-7.84084 5.91901,-15.91028 7.98457,-24.14293 l 31.73044,-1.84879 c 2.01308,-9.9636 3.27604,-20.06415 3.77825,-30.21667 l -29.82892,-9.8861 c 0.0257,-0.47554 0.0495,-0.95118 0.0713,-1.42692 -0.0625,-8.00956 -0.6813,-16.0051 -1.85189,-23.9289 l 28.50124,-13.80084 c -1.91835,-9.98587 -4.58321,-19.81373 -7.97215,-29.40084 l -31.40474,2.2862 c -3.21103,-7.84428 -6.9943,-15.44192 -11.31923,-22.73153 l 21.10297,-23.71797 c -5.61437,-8.47537 -11.85658,-16.51766 -18.67409,-24.05918 l -28.07319,14.09863 c -5.98701,-6.00889 -12.40791,-11.56925 -19.21074,-16.63606 l 10.44757,-30.05847 c -8.44155,-5.66072 -17.29572,-10.6804 -26.48805,-15.01682 l -20.50738,23.73035 c -7.84085,-3.25027 -15.910298,-5.91899 -24.142945,-7.98455 l -1.84879,-31.73044 c -9.9636,-2.01309 -20.064152,-3.27605 -30.21667,-3.77826 z"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:#1a5fb4;fill-opacity:1;stroke:none;stroke-width:7.03712;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
style="display:inline;opacity:0.534;vector-effect:none;fill:#1a5fb4;fill-opacity:1;stroke:none;stroke-width:1.62918;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new"
|
||||||
|
clip-path="none"
|
||||||
|
d="m 8.4765625,2676 c -1.1711695,2.8866 -0.5827763,6.3078 1.7656255,8.6562 l 48.101562,48.1016 c 3.133898,3.1339 8.178602,3.1339 11.3125,0 l 48.10156,-48.1016 c 2.3484,-2.3484 2.9368,-5.7696 1.76563,-8.6562 -0.39174,0.9655 -0.98013,1.8708 -1.76563,2.6562 l -48.10156,48.1016 c -3.133898,3.1339 -8.178602,3.1339 -11.3125,0 L 10.242188,2678.6562 C 9.4566904,2677.8708 8.8682972,2676.9655 8.4765625,2676 Z"
|
||||||
|
transform="matrix(4,0,0,4,0,-10028)"
|
||||||
|
id="rect18571-6" />
|
||||||
|
</g>
|
||||||
|
<rect
|
||||||
|
y="2402"
|
||||||
|
x="-1.5000001e-06"
|
||||||
|
height="128"
|
||||||
|
width="128"
|
||||||
|
id="rect9125-7-2"
|
||||||
|
style="display:inline;opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:none;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal;enable-background:new" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 12 KiB |
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g color="#000" fill="#2e3436"><path d="M7.188 2.281c-.094.056-.192.125-.29.19L5.566 3.803a1.684 1.684 0 11-2.17 2.17L2.332 7.037c.506-.069 1.017-.136 1.2.026.242.214.139 1.031.155 1.656.213.088.427.171.657.219.04.008.085-.007.125 0 .337-.525.683-1.288 1-1.344.322-.057.905.562 1.406.937a3.67 3.67 0 00.656-.468c-.195-.595-.594-1.369-.437-1.657.158-.29 1.019-.37 1.625-.531.028-.183.062-.371.062-.562 0-.075-.027-.146-.031-.22-.587-.217-1.435-.385-1.562-.687-.128-.302.34-1.021.593-1.593a3.722 3.722 0 00-.593-.532zm3.875 3.25c-.165.475-.305 1.086-.47 1.563-.43.047-.84.14-1.218.312-.38-.322-.787-.773-1.156-1.093a5.562 5.562 0 00-.688.468c.177.46.453 1.001.625 1.469-.298.309-.531.67-.719 1.063-.494 0-1.102-.084-1.593-.094a5.68 5.68 0 00-.219.812c.435.24 1.006.468 1.438.72-.006.093-.032.185-.032.28 0 .333.049.66.125.97-.382.304-.898.63-1.28.937.015.044.04.083.058.127l.613.613c.417-.1.868-.223 1.266-.303.248.343.532.626.875.875-.027.135-.068.283-.104.428.174-.063.34-.155.482-.297l1.432-1.432a1.994 1.994 0 01.533-3.918c.919 0 1.684.623 1.918 1.467l1.338-1.338c.06-.06.11-.124.156-.191-.035-.062-.06-.13-.1-.188.096-.152.205-.31.315-.47.017-.348-.1-.7-.37-.971l-.177-.176c-.28.192-.561.387-.83.555-.345-.233-.746-.383-1.156-.5-.077-.507-.107-1.132-.187-1.625a5.44 5.44 0 00-.875-.063zm-9.247.608c-.087.068-.173.138-.254.205l.014.035z" style="marker:none" overflow="visible"/><path d="M8.707.293a1 1 0 00-1.415 0l-6.999 7a1 1 0 000 1.413l7 7.001a1 1 0 001.415 0l7-7a1 1 0 000-1.413zm-.708 2.121l5.587 5.587L8 13.586 2.414 7.999z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none" font-weight="400" font-family="sans-serif" overflow="visible"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 2 KiB |
13
native/data/icons/meson.build
Normal file
13
native/data/icons/meson.build
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
application_id = 'space.arimelody.Schedule'
|
||||||
|
|
||||||
|
scalable_dir = 'hicolor' / 'scalable' / 'apps'
|
||||||
|
install_data(
|
||||||
|
scalable_dir / ('@0@.svg').format(application_id),
|
||||||
|
install_dir: get_option('datadir') / 'icons' / scalable_dir
|
||||||
|
)
|
||||||
|
|
||||||
|
symbolic_dir = 'hicolor' / 'symbolic' / 'apps'
|
||||||
|
install_data(
|
||||||
|
symbolic_dir / ('@0@-symbolic.svg').format(application_id),
|
||||||
|
install_dir: get_option('datadir') / 'icons' / symbolic_dir
|
||||||
|
)
|
||||||
27
native/data/meson.build
Normal file
27
native/data/meson.build
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
desktop_utils = find_program('desktop-file-validate', required: false)
|
||||||
|
if desktop_utils.found()
|
||||||
|
test('Validate desktop file', desktop_utils, args: ['space.arimelody.LiveSchedule.desktop'])
|
||||||
|
endif
|
||||||
|
|
||||||
|
appstreamcli = find_program('appstreamcli', required: false, disabler: true)
|
||||||
|
test('Validate appstream file', appstreamcli,
|
||||||
|
args: ['validate', '--no-net', '--explain', 'space.arimelody.LiveSchedule.metainfo.xml'])
|
||||||
|
|
||||||
|
install_data('space.arimelody.LiveSchedule.gschema.xml',
|
||||||
|
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas')
|
||||||
|
|
||||||
|
compile_schemas = find_program('glib-compile-schemas', required: false, disabler: true)
|
||||||
|
test('Validate schema file',
|
||||||
|
compile_schemas,
|
||||||
|
args: ['--strict', '--dry-run', meson.current_source_dir()])
|
||||||
|
|
||||||
|
service_conf = configuration_data()
|
||||||
|
service_conf.set('bindir', get_option('prefix') / get_option('bindir'))
|
||||||
|
configure_file(
|
||||||
|
input: 'space.arimelody.LiveSchedule.service.in',
|
||||||
|
output: 'space.arimelody.LiveSchedule.service',
|
||||||
|
configuration: service_conf,
|
||||||
|
install_dir: get_option('datadir') / 'dbus-1' / 'services')
|
||||||
|
|
||||||
|
subdir('resources')
|
||||||
|
subdir('icons')
|
||||||
12
native/data/resources/application-window.ui
Normal file
12
native/data/resources/application-window.ui
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<template class="LSApplicationWindow" parent="GtkApplicationWindow">
|
||||||
|
<property name="title" translatable="yes">Live Schedule</property>
|
||||||
|
<property name="default-width">1400</property>
|
||||||
|
<property name="default-height">900</property>
|
||||||
|
<child>
|
||||||
|
<object class="LSWebView"></object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
12
native/data/resources/liveschedule.gresource.xml
Normal file
12
native/data/resources/liveschedule.gresource.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/space/arimelody/LiveSchedule">
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks">application-window.ui</file>
|
||||||
|
</gresource>
|
||||||
|
<gresource prefix="/space/arimelody/LiveSchedule/webview">
|
||||||
|
<file alias="index.html" compressed="true">../../../index.html</file>
|
||||||
|
<file alias="main.js" compressed="true">../../../main.js</file>
|
||||||
|
<file alias="style.css" compressed="true">../../../style.css</file>
|
||||||
|
<file alias="background.png">../../../background.png</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
||||||
3
native/data/resources/meson.build
Normal file
3
native/data/resources/meson.build
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
liveschedule_sources += gnome.compile_resources('ls-resources',
|
||||||
|
'liveschedule.gresource.xml',
|
||||||
|
c_name: 'liveschedule')
|
||||||
10
native/data/space.arimelody.LiveSchedule.desktop
Normal file
10
native/data/space.arimelody.LiveSchedule.desktop
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=LiveSchedule
|
||||||
|
Exec=LiveSchedule
|
||||||
|
Icon=space.arimelody.LiveSchedule
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
Categories=Utility;
|
||||||
|
Keywords=GTK;
|
||||||
|
StartupNotify=true
|
||||||
|
DBusActivatable=true
|
||||||
5
native/data/space.arimelody.LiveSchedule.gschema.xml
Normal file
5
native/data/space.arimelody.LiveSchedule.gschema.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<schemalist gettext-domain="schedule">
|
||||||
|
<schema id="space.arimelody.LiveSchedule" path="/space/arimelody/LiveSchedule/">
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
||||||
18
native/data/space.arimelody.LiveSchedule.metainfo.xml
Normal file
18
native/data/space.arimelody.LiveSchedule.metainfo.xml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<component type="desktop-application">
|
||||||
|
<id>space.arimelody.LiveSchedule</id>
|
||||||
|
<metadata_license>CC0-1.0</metadata_license>
|
||||||
|
<project_license>GPL-3.0-or-later</project_license>
|
||||||
|
|
||||||
|
<name>Live Schedule</name>
|
||||||
|
<summary>Render live schedules</summary>
|
||||||
|
<description>
|
||||||
|
<p>Render live schedules</p>
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<developer id="tld.vendor">
|
||||||
|
<name>Ari Melody</name>
|
||||||
|
</developer>
|
||||||
|
|
||||||
|
<!-- TODO (optional): fill this out -->
|
||||||
|
</component>
|
||||||
3
native/data/space.arimelody.LiveSchedule.service.in
Normal file
3
native/data/space.arimelody.LiveSchedule.service.in
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[D-BUS Service]
|
||||||
|
Name=space.arimelody.LiveSchedule
|
||||||
|
Exec=@bindir@/schedule --gapplication-service
|
||||||
79
native/meson.build
Normal file
79
native/meson.build
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
i18n = import('i18n')
|
||||||
|
gnome = import('gnome')
|
||||||
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
|
project_c_args = []
|
||||||
|
test_c_args = [
|
||||||
|
'-Wcast-align',
|
||||||
|
'-Wdeclaration-after-statement',
|
||||||
|
'-Werror=address',
|
||||||
|
'-Werror=array-bounds',
|
||||||
|
'-Werror=empty-body',
|
||||||
|
'-Werror=implicit',
|
||||||
|
'-Werror=implicit-function-declaration',
|
||||||
|
'-Werror=incompatible-pointer-types',
|
||||||
|
'-Werror=init-self',
|
||||||
|
'-Werror=int-conversion',
|
||||||
|
'-Werror=int-to-pointer-cast',
|
||||||
|
'-Werror=main',
|
||||||
|
'-Werror=misleading-indentation',
|
||||||
|
'-Werror=missing-braces',
|
||||||
|
'-Werror=missing-include-dirs',
|
||||||
|
'-Werror=nonnull',
|
||||||
|
'-Werror=overflow',
|
||||||
|
'-Werror=parenthesis',
|
||||||
|
'-Werror=pointer-arith',
|
||||||
|
'-Werror=pointer-to-int-cast',
|
||||||
|
'-Werror=redundant-decls',
|
||||||
|
'-Werror=return-type',
|
||||||
|
'-Werror=sequence-point',
|
||||||
|
'-Werror=shadow',
|
||||||
|
'-Werror=strict-prototypes',
|
||||||
|
'-Werror=trigraphs',
|
||||||
|
'-Werror=undef',
|
||||||
|
'-Werror=write-strings',
|
||||||
|
'-Wformat-nonliteral',
|
||||||
|
'-Wignored-qualifiers',
|
||||||
|
'-Wimplicit-function-declaration',
|
||||||
|
'-Wlogical-op',
|
||||||
|
'-Wmissing-declarations',
|
||||||
|
'-Wmissing-format-attribute',
|
||||||
|
'-Wmissing-include-dirs',
|
||||||
|
'-Wmissing-noreturn',
|
||||||
|
'-Wnested-externs',
|
||||||
|
'-Wno-cast-function-type',
|
||||||
|
'-Wno-dangling-pointer',
|
||||||
|
'-Wno-missing-field-initializers',
|
||||||
|
'-Wno-sign-compare',
|
||||||
|
'-Wno-unused-parameter',
|
||||||
|
'-Wold-style-definition',
|
||||||
|
'-Wpointer-arith',
|
||||||
|
'-Wredundant-decls',
|
||||||
|
'-Wstrict-prototypes',
|
||||||
|
'-Wswitch-default',
|
||||||
|
'-Wswitch-enum',
|
||||||
|
'-Wundef',
|
||||||
|
'-Wuninitialized',
|
||||||
|
'-Wunused',
|
||||||
|
'-fno-strict-aliasing',
|
||||||
|
['-Werror=format-security', '-Werror=format=2'],
|
||||||
|
]
|
||||||
|
if get_option('buildtype') != 'plain'
|
||||||
|
test_c_args += '-fstack-protector-strong'
|
||||||
|
endif
|
||||||
|
foreach arg: test_c_args
|
||||||
|
if cc.has_multi_arguments(arg)
|
||||||
|
project_c_args += arg
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
add_project_arguments(project_c_args, language: 'c')
|
||||||
|
|
||||||
|
liveschedule_sources = []
|
||||||
|
subdir('data')
|
||||||
|
subdir('src')
|
||||||
|
|
||||||
|
# TODO: UNCOMMENT WHEN YOU FIGURE OUT WHY THIS IS FAILING
|
||||||
|
#gnome.post_install(
|
||||||
|
# glib_compile_schemas: true,
|
||||||
|
# gtk_update_icon_cache: true,
|
||||||
|
# update_desktop_database: true)
|
||||||
22
native/src/ls-application-window.c
Normal file
22
native/src/ls-application-window.c
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "ls-application-window.h"
|
||||||
|
#include "ls-web-view.h"
|
||||||
|
|
||||||
|
struct _LSApplicationWindow {
|
||||||
|
GtkApplicationWindow parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE(LSApplicationWindow, ls_application_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||||
|
|
||||||
|
static void ls_application_window_class_init(LSApplicationWindowClass *klass) {
|
||||||
|
g_type_ensure(LS_TYPE_WEB_VIEW);
|
||||||
|
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
|
||||||
|
|
||||||
|
gtk_widget_class_set_template_from_resource(widget_class, "/space/arimelody/LiveSchedule/application-window.ui");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ls_application_window_init(LSApplicationWindow *self) {
|
||||||
|
gtk_widget_init_template(GTK_WIDGET(self));
|
||||||
|
}
|
||||||
14
native/src/ls-application-window.h
Normal file
14
native/src/ls-application-window.h
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define LS_TYPE_APPLICATION_WINDOW (ls_application_window_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE(LSApplicationWindow,
|
||||||
|
ls_application_window,
|
||||||
|
LS, APPLICATION_WINDOW,
|
||||||
|
GtkApplicationWindow)
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
46
native/src/ls-application.c
Normal file
46
native/src/ls-application.c
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include "config.h"
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include "ls-application.h"
|
||||||
|
#include "ls-application-window.h"
|
||||||
|
|
||||||
|
struct _LSApplication {
|
||||||
|
GtkApplication parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE(LSApplication, ls_application, GTK_TYPE_APPLICATION)
|
||||||
|
|
||||||
|
static void ls_application_activate(GApplication *app);
|
||||||
|
|
||||||
|
static void ls_application_class_init (LSApplicationClass *klass) {
|
||||||
|
GApplicationClass *app_class = G_APPLICATION_CLASS(klass);
|
||||||
|
app_class->activate = ls_application_activate;
|
||||||
|
}
|
||||||
|
|
||||||
|
LSApplication *ls_application_new(const char *application_id,
|
||||||
|
GApplicationFlags flags)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(application_id != NULL, NULL);
|
||||||
|
|
||||||
|
return g_object_new(LS_TYPE_APPLICATION,
|
||||||
|
"application-id", application_id,
|
||||||
|
"flags", flags,
|
||||||
|
"resource-base-path", "/space/arimelody/LiveSchedule",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ls_application_init(LSApplication *self) {}
|
||||||
|
|
||||||
|
static void ls_application_activate(GApplication *app) {
|
||||||
|
GtkWindow *window;
|
||||||
|
|
||||||
|
g_assert(LS_IS_APPLICATION(app));
|
||||||
|
|
||||||
|
window = gtk_application_get_active_window(GTK_APPLICATION(app));
|
||||||
|
|
||||||
|
if (window == NULL)
|
||||||
|
window = g_object_new(LS_TYPE_APPLICATION_WINDOW, "application", app, NULL);
|
||||||
|
|
||||||
|
gtk_window_present(window);
|
||||||
|
}
|
||||||
|
|
||||||
14
native/src/ls-application.h
Normal file
14
native/src/ls-application.h
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define LS_TYPE_APPLICATION (ls_application_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE(LSApplication, ls_application, LS, APPLICATION, GtkApplication)
|
||||||
|
|
||||||
|
LSApplication *ls_application_new(const char *application_id,
|
||||||
|
GApplicationFlags flags);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
284
native/src/ls-web-view.c
Normal file
284
native/src/ls-web-view.c
Normal file
|
|
@ -0,0 +1,284 @@
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "ls-web-view.h"
|
||||||
|
|
||||||
|
struct _LSWebView {
|
||||||
|
WebKitWebView parent_instance;
|
||||||
|
GCancellable *cancellable;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE(LSWebView, ls_web_view, WEBKIT_TYPE_WEB_VIEW)
|
||||||
|
|
||||||
|
static void ls_web_view_constructed(GObject *object);
|
||||||
|
|
||||||
|
static void ls_web_view_class_init(LSWebViewClass *klass) {
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||||
|
object_class->constructed = ls_web_view_constructed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ls_web_view_init(LSWebView *self) {}
|
||||||
|
|
||||||
|
static void ls_web_view_on_resource_request(WebKitURISchemeRequest *request,
|
||||||
|
gpointer user_data);
|
||||||
|
static void ls_web_view_on_snapshot_message_received(WebKitUserContentManager *manager,
|
||||||
|
JSCValue *value,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void ls_web_view_constructed(GObject *object) {
|
||||||
|
G_OBJECT_CLASS(ls_web_view_parent_class)->constructed(object);
|
||||||
|
|
||||||
|
WebKitWebView *web_view = WEBKIT_WEB_VIEW(object);
|
||||||
|
|
||||||
|
WebKitWebContext *web_context = webkit_web_view_get_context(web_view);
|
||||||
|
webkit_web_context_register_uri_scheme(web_context, "gresource",
|
||||||
|
ls_web_view_on_resource_request,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
WebKitUserContentManager *manager = webkit_web_view_get_user_content_manager(web_view);
|
||||||
|
g_signal_connect(manager, "script-message-received::copySnapshot",
|
||||||
|
G_CALLBACK(ls_web_view_on_snapshot_message_received),
|
||||||
|
g_object_ref(object));
|
||||||
|
webkit_user_content_manager_register_script_message_handler(manager, "copySnapshot", NULL);
|
||||||
|
|
||||||
|
webkit_web_view_load_uri(web_view, "gresource:///space/arimelody/LiveSchedule/webview/index.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
static GdkTexture *ls_web_view_copy_snapshot_to_texture(GtkWidget *widget,
|
||||||
|
float xoffset,
|
||||||
|
float yoffset,
|
||||||
|
float width,
|
||||||
|
float height)
|
||||||
|
{
|
||||||
|
GtkNative *native = gtk_widget_get_native(widget);
|
||||||
|
GskRenderer *renderer = gtk_native_get_renderer(native);
|
||||||
|
|
||||||
|
GtkSnapshot *snapshot = gtk_snapshot_new();
|
||||||
|
GTK_WIDGET_CLASS(G_OBJECT_GET_CLASS(widget))->snapshot(widget, snapshot);
|
||||||
|
GskRenderNode *node = gtk_snapshot_free_to_node(snapshot);
|
||||||
|
|
||||||
|
graphene_rect_t bounds;
|
||||||
|
gsk_render_node_get_bounds(node, &bounds);
|
||||||
|
|
||||||
|
bounds.origin.x += xoffset;
|
||||||
|
bounds.origin.y += yoffset;
|
||||||
|
bounds.size.width = width;
|
||||||
|
bounds.size.height = height;
|
||||||
|
|
||||||
|
return gsk_renderer_render_texture(renderer, node, &bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct _LSWebViewCopySnapshotUserData {
|
||||||
|
LSWebView *self;
|
||||||
|
GCancellable *cancellable;
|
||||||
|
guint callback_id;
|
||||||
|
float xoffset;
|
||||||
|
float yoffset;
|
||||||
|
float width;
|
||||||
|
float height;
|
||||||
|
GdkTexture *texture;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ls_web_view_copy_snapshot_to_clipboard(void *user_data) {
|
||||||
|
struct _LSWebViewCopySnapshotUserData *typed_user_data = (struct _LSWebViewCopySnapshotUserData *)user_data;
|
||||||
|
LSWebView *self = typed_user_data->self;
|
||||||
|
GCancellable *cancellable = typed_user_data->cancellable;
|
||||||
|
guint callback_id = typed_user_data->callback_id;
|
||||||
|
float xoffset = typed_user_data->xoffset;
|
||||||
|
float yoffset = typed_user_data->yoffset;
|
||||||
|
float width = typed_user_data->width;
|
||||||
|
float height = typed_user_data->height;
|
||||||
|
|
||||||
|
if (g_cancellable_is_cancelled(cancellable)) {
|
||||||
|
WebKitUserMessage *message =
|
||||||
|
webkit_user_message_new("_nativePromiseReject", g_variant_new("(i)", callback_id));
|
||||||
|
|
||||||
|
webkit_web_view_send_message_to_page(WEBKIT_WEB_VIEW(self), message, cancellable, NULL, NULL);
|
||||||
|
|
||||||
|
goto ls_webview_copy_snapshot_to_clipboard_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkTexture *texture = ls_web_view_copy_snapshot_to_texture(GTK_WIDGET(self), xoffset, yoffset, width, height);
|
||||||
|
|
||||||
|
GdkClipboard *clipboard = gdk_display_get_clipboard(gdk_display_get_default());
|
||||||
|
gdk_clipboard_set_texture(clipboard, texture);
|
||||||
|
|
||||||
|
WebKitUserMessage *message =
|
||||||
|
webkit_user_message_new("_nativePromiseResolve", g_variant_new("(i)", callback_id));
|
||||||
|
|
||||||
|
webkit_web_view_send_message_to_page(WEBKIT_WEB_VIEW(self), message, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
ls_webview_copy_snapshot_to_clipboard_exit:
|
||||||
|
if (self->cancellable == cancellable) {
|
||||||
|
g_object_unref(self->cancellable);
|
||||||
|
self->cancellable = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref(self);
|
||||||
|
g_object_unref(cancellable);
|
||||||
|
g_free(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ls_web_view_copy_snapshot_to_file_after_save_dialog(GObject *source,
|
||||||
|
GAsyncResult *result,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
struct _LSWebViewCopySnapshotUserData *typed_user_data = (struct _LSWebViewCopySnapshotUserData *)user_data;
|
||||||
|
LSWebView *self = typed_user_data->self;
|
||||||
|
GCancellable *cancellable = typed_user_data->cancellable;
|
||||||
|
guint callback_id = typed_user_data->callback_id;
|
||||||
|
GdkTexture *texture = typed_user_data->texture;
|
||||||
|
|
||||||
|
if (g_cancellable_is_cancelled(cancellable)) {
|
||||||
|
WebKitUserMessage *message =
|
||||||
|
webkit_user_message_new("_nativePromiseReject", g_variant_new("(i)", callback_id));
|
||||||
|
|
||||||
|
webkit_web_view_send_message_to_page(WEBKIT_WEB_VIEW(self), message, cancellable, NULL, NULL);
|
||||||
|
|
||||||
|
goto ls_web_view_copy_snapshot_to_file_after_save_dialog_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
GError *error = NULL;
|
||||||
|
GFile *file = gtk_file_dialog_save_finish(GTK_FILE_DIALOG(source), result, &error);
|
||||||
|
if (error) {
|
||||||
|
g_warning("File dialog error: %s", error->message);
|
||||||
|
g_error_free(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *path = g_file_get_path(file);
|
||||||
|
gdk_texture_save_to_png(texture, path);
|
||||||
|
|
||||||
|
WebKitUserMessage *message =
|
||||||
|
webkit_user_message_new("_nativePromiseResolve", g_variant_new("(i)", callback_id));
|
||||||
|
|
||||||
|
webkit_web_view_send_message_to_page(WEBKIT_WEB_VIEW(self), message, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
ls_web_view_copy_snapshot_to_file_after_save_dialog_exit:
|
||||||
|
if (self->cancellable == cancellable) {
|
||||||
|
g_object_unref(self->cancellable);
|
||||||
|
self->cancellable = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref(self);
|
||||||
|
g_object_unref(cancellable);
|
||||||
|
g_free(user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ls_web_view_copy_snapshot_to_file(void *user_data) {
|
||||||
|
struct _LSWebViewCopySnapshotUserData *typed_user_data = (struct _LSWebViewCopySnapshotUserData *)user_data;
|
||||||
|
LSWebView *self = typed_user_data->self;
|
||||||
|
GCancellable *cancellable = typed_user_data->cancellable;
|
||||||
|
guint callback_id = typed_user_data->callback_id;
|
||||||
|
float xoffset = typed_user_data->xoffset;
|
||||||
|
float yoffset = typed_user_data->yoffset;
|
||||||
|
float width = typed_user_data->width;
|
||||||
|
float height = typed_user_data->height;
|
||||||
|
|
||||||
|
if (g_cancellable_is_cancelled(cancellable)) {
|
||||||
|
WebKitUserMessage *message =
|
||||||
|
webkit_user_message_new("_nativePromiseReject", g_variant_new("(i)", callback_id));
|
||||||
|
|
||||||
|
webkit_web_view_send_message_to_page(WEBKIT_WEB_VIEW(self), message, cancellable, NULL, NULL);
|
||||||
|
|
||||||
|
if (self->cancellable == cancellable) {
|
||||||
|
g_object_unref(self->cancellable);
|
||||||
|
self->cancellable = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref(self);
|
||||||
|
g_object_unref(cancellable);
|
||||||
|
g_free(user_data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
typed_user_data->texture = ls_web_view_copy_snapshot_to_texture(GTK_WIDGET(self), xoffset, yoffset, width, height);
|
||||||
|
|
||||||
|
GtkFileDialog *dialog = gtk_file_dialog_new();
|
||||||
|
gtk_file_dialog_set_title(dialog, "Save Image");
|
||||||
|
gtk_file_dialog_set_initial_name(dialog, "image.png");
|
||||||
|
gtk_file_dialog_save(dialog, GTK_WINDOW(gtk_widget_get_root(GTK_WIDGET(self))), cancellable,
|
||||||
|
ls_web_view_copy_snapshot_to_file_after_save_dialog, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ls_web_view_on_snapshot_message_received(WebKitUserContentManager *manager,
|
||||||
|
JSCValue *value,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
JSCValue *id_val = jsc_value_object_get_property_at_index(value, 0);
|
||||||
|
JSCValue *kind_val = jsc_value_object_get_property_at_index(value, 1);
|
||||||
|
JSCValue *xoffset_val = jsc_value_object_get_property_at_index(value, 2);
|
||||||
|
JSCValue *yoffset_val = jsc_value_object_get_property_at_index(value, 3);
|
||||||
|
JSCValue *width_val = jsc_value_object_get_property_at_index(value, 4);
|
||||||
|
JSCValue *height_val = jsc_value_object_get_property_at_index(value, 5);
|
||||||
|
int callback_id = jsc_value_to_int32(id_val);
|
||||||
|
char *kind = jsc_value_to_string(kind_val);
|
||||||
|
float xoffset = (float)jsc_value_to_double(xoffset_val);
|
||||||
|
float yoffset = (float)jsc_value_to_double(yoffset_val);
|
||||||
|
float width = (float)jsc_value_to_double(width_val);
|
||||||
|
float height = (float)jsc_value_to_double(height_val);
|
||||||
|
|
||||||
|
LSWebView *self = LS_WEB_VIEW(user_data);
|
||||||
|
|
||||||
|
if (self->cancellable != NULL) {
|
||||||
|
g_cancellable_cancel(self->cancellable);
|
||||||
|
g_object_unref(self->cancellable);
|
||||||
|
}
|
||||||
|
self->cancellable = g_cancellable_new();
|
||||||
|
|
||||||
|
struct _LSWebViewCopySnapshotUserData *task_user_data =
|
||||||
|
(struct _LSWebViewCopySnapshotUserData *)g_malloc(sizeof(struct _LSWebViewCopySnapshotUserData));
|
||||||
|
task_user_data->self = g_object_ref(self);
|
||||||
|
task_user_data->cancellable = g_object_ref(self->cancellable);
|
||||||
|
task_user_data->xoffset = xoffset;
|
||||||
|
task_user_data->yoffset = yoffset;
|
||||||
|
task_user_data->width = width;
|
||||||
|
task_user_data->height = height;
|
||||||
|
|
||||||
|
if (strcmp(kind, "clipboard") == 0) {
|
||||||
|
g_idle_add_once(ls_web_view_copy_snapshot_to_clipboard, task_user_data);
|
||||||
|
} else {
|
||||||
|
g_idle_add_once(ls_web_view_copy_snapshot_to_file, task_user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref(id_val);
|
||||||
|
g_object_unref(kind_val);
|
||||||
|
g_object_unref(xoffset_val);
|
||||||
|
g_object_unref(yoffset_val);
|
||||||
|
g_object_unref(width_val);
|
||||||
|
g_object_unref(height_val);
|
||||||
|
g_free(kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ls_web_view_on_resource_request(WebKitURISchemeRequest *request,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
const char *uri = webkit_uri_scheme_request_get_uri(request);
|
||||||
|
GUri *parsed = g_uri_parse(uri, G_URI_FLAGS_NONE, NULL);
|
||||||
|
const char *path = g_uri_get_path(parsed);
|
||||||
|
|
||||||
|
GError *error = NULL;
|
||||||
|
GBytes *bytes = g_resources_lookup_data(path, G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
g_print("Resource error: %s\n", error->message);
|
||||||
|
webkit_uri_scheme_request_finish_error(request, error);
|
||||||
|
g_error_free(error);
|
||||||
|
g_uri_unref(parsed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gsize size;
|
||||||
|
const void *data = g_bytes_get_data(bytes, &size);
|
||||||
|
|
||||||
|
GInputStream *stream = g_memory_input_stream_new_from_bytes(bytes);
|
||||||
|
|
||||||
|
// guess the MIME type from the path
|
||||||
|
char *mime_type = g_content_type_guess(path, data, size, NULL);
|
||||||
|
|
||||||
|
webkit_uri_scheme_request_finish(request, stream, size, mime_type);
|
||||||
|
|
||||||
|
g_free(mime_type);
|
||||||
|
g_object_unref(stream);
|
||||||
|
g_bytes_unref(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
14
native/src/ls-web-view.h
Normal file
14
native/src/ls-web-view.h
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gdk/gdk.h>
|
||||||
|
#include <gsk/gsk.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <webkit/webkit.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define LS_TYPE_WEB_VIEW (ls_web_view_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE(LSWebView, ls_web_view, LS, WEB_VIEW, WebKitWebView)
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
8
native/src/main.c
Normal file
8
native/src/main.c
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "ls-application.h"
|
||||||
|
|
||||||
|
int main (int argc, char *argv[]) {
|
||||||
|
g_autoptr(LSApplication) app = ls_application_new("space.arimelody.LiveSchedule", G_APPLICATION_DEFAULT_FLAGS);
|
||||||
|
return g_application_run(G_APPLICATION(app), argc, argv);
|
||||||
|
}
|
||||||
21
native/src/meson.build
Normal file
21
native/src/meson.build
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
config_h = configuration_data()
|
||||||
|
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
configure_file(output: 'config.h', configuration: config_h)
|
||||||
|
add_project_arguments(['-I' + meson.project_build_root()], language: 'c')
|
||||||
|
|
||||||
|
liveschedule_sources += [
|
||||||
|
'main.c',
|
||||||
|
'ls-application.c',
|
||||||
|
'ls-application-window.c',
|
||||||
|
'ls-web-view.c',
|
||||||
|
]
|
||||||
|
|
||||||
|
liveschedule_deps = [
|
||||||
|
dependency('gtk4'),
|
||||||
|
dependency('javascriptcoregtk-6.0'),
|
||||||
|
dependency('webkitgtk-6.0'),
|
||||||
|
]
|
||||||
|
|
||||||
|
executable('liveschedule', liveschedule_sources,
|
||||||
|
dependencies: liveschedule_deps,
|
||||||
|
install: true)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue