Initial commit
This commit is contained in:
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*.cr]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
||||||
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/docs/
|
||||||
|
/lib/
|
||||||
|
/bin/
|
||||||
|
/.shards/
|
||||||
|
*.dwarf
|
||||||
|
/data/ui/compiled
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Zoe Moore <zoenb@mailbox.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
18
README.md
Normal file
18
README.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# gtktest
|
||||||
|
|
||||||
|
Crystal GTK test application
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
You gotta have blueprint installed
|
||||||
|
|
||||||
|
```
|
||||||
|
pacman -S blueprint-compiler crystal shards libadwaita
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can test run with
|
||||||
|
|
||||||
|
```
|
||||||
|
crystal run src/gtktest.cr
|
||||||
|
```
|
||||||
|
|
||||||
6
data/gtktest.gresource.xml
Normal file
6
data/gtktest.gresource.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/gtktest">
|
||||||
|
<file compressed="true" preprocess="xml-stripblanks">ui/compiled/main.ui</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
||||||
14
data/ui/main.blp
Normal file
14
data/ui/main.blp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Gtk 4.0;
|
||||||
|
using Adw 1;
|
||||||
|
|
||||||
|
Adw.ApplicationWindow mainWindow {
|
||||||
|
title: "Hello world";
|
||||||
|
default-width: 300;
|
||||||
|
default-height: 400;
|
||||||
|
|
||||||
|
Gtk.Box {
|
||||||
|
orientation: vertical;
|
||||||
|
|
||||||
|
Adw.HeaderBar {}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
shard.lock
Normal file
18
shard.lock
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
version: 2.0
|
||||||
|
shards:
|
||||||
|
gi-crystal:
|
||||||
|
git: https://github.com/hugopl/gi-crystal.git
|
||||||
|
version: 0.14.0
|
||||||
|
|
||||||
|
gtk4:
|
||||||
|
git: https://github.com/hugopl/gtk4.cr.git
|
||||||
|
version: 0.12.0
|
||||||
|
|
||||||
|
libadwaita:
|
||||||
|
git: https://github.com/geopjr/libadwaita.cr.git
|
||||||
|
version: 1.0.0+git.commit.72f2e42c7dafbf7a427fb24db5dce4e66199d680
|
||||||
|
|
||||||
|
version_from_shard:
|
||||||
|
git: https://github.com/hugopl/version_from_shard.git
|
||||||
|
version: 1.2.5
|
||||||
|
|
||||||
19
shard.yml
Normal file
19
shard.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: gtktest
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- Zoe Moore <zoenb@mailbox.org>
|
||||||
|
|
||||||
|
targets:
|
||||||
|
gtktest:
|
||||||
|
main: src/gtktest.cr
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
gtk4:
|
||||||
|
github: hugopl/gtk4.cr
|
||||||
|
libadwaita:
|
||||||
|
github: GeopJr/libadwaita.cr
|
||||||
|
|
||||||
|
crystal: 1.6.2
|
||||||
|
|
||||||
|
license: MIT
|
||||||
9
spec/gtktest_spec.cr
Normal file
9
spec/gtktest_spec.cr
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
require "./spec_helper"
|
||||||
|
|
||||||
|
describe Gtktest do
|
||||||
|
# TODO: Write tests
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
false.should eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
2
spec/spec_helper.cr
Normal file
2
spec/spec_helper.cr
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
require "spec"
|
||||||
|
require "../src/gtktest"
|
||||||
10
src/gtktest.cr
Normal file
10
src/gtktest.cr
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
require "libadwaita"
|
||||||
|
|
||||||
|
require "./modules/prerequisites.cr"
|
||||||
|
require "./modules/views/main.cr"
|
||||||
|
|
||||||
|
module GtkTest
|
||||||
|
B_UI = Gtk::Builder.new_from_resource("/gtktest/ui/compiled/main.ui")
|
||||||
|
|
||||||
|
APP = Adw::Application.new("dev.gtktest", Gio::ApplicationFlags::None)
|
||||||
|
end
|
||||||
9
src/modules/prerequisites.cr
Normal file
9
src/modules/prerequisites.cr
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module GtkTest
|
||||||
|
extend self
|
||||||
|
|
||||||
|
VERSION = {{read_file("./shard.yml").split("version: ")[1].split("\n")[0]}}
|
||||||
|
{%
|
||||||
|
`blueprint-compiler batch-compile ./data/ui/compiled ./data/ui/ ./data/ui/*.blp`
|
||||||
|
%}
|
||||||
|
Gio.register_resource("data/gtktest.gresource.xml", "data")
|
||||||
|
end
|
||||||
18
src/modules/views/main.cr
Normal file
18
src/modules/views/main.cr
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
module GtkTest
|
||||||
|
@@main_window_id = 0_u32
|
||||||
|
|
||||||
|
def activate(app : Adw::Application)
|
||||||
|
main_window = APP.window_by_id(@@main_window_id)
|
||||||
|
return main_window.present if main_window
|
||||||
|
|
||||||
|
window = Adw::ApplicationWindow.cast(B_UI["mainWindow"])
|
||||||
|
window.application = app
|
||||||
|
|
||||||
|
@@main_window_id = window.id
|
||||||
|
|
||||||
|
window.present
|
||||||
|
end
|
||||||
|
|
||||||
|
APP.activate_signal.connect(->activate(Adw::Application))
|
||||||
|
exit(APP.run(ARGV))
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user