From 00814dd7e47f8929d572d8ed70c4be0798ffa3f1 Mon Sep 17 00:00:00 2001 From: Zoe Moore Date: Fri, 16 Dec 2022 16:35:38 -0800 Subject: [PATCH] Initial search layout and rename to wince --- README.md | 4 +-- data/ui/main.blp | 25 ++++++++++++++++--- ...test.gresource.xml => wince.gresource.xml} | 2 +- shard.yml | 4 +-- src/gtktest.cr | 10 -------- src/modules/prerequisites.cr | 4 +-- src/modules/views/main.cr | 11 +++++++- src/wince.cr | 14 +++++++++++ 8 files changed, 53 insertions(+), 21 deletions(-) rename data/{gtktest.gresource.xml => wince.gresource.xml} (83%) delete mode 100644 src/gtktest.cr create mode 100644 src/wince.cr diff --git a/README.md b/README.md index 1f9825e..0f2d279 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# gtktest +# Wince -Crystal GTK test application +A GTK 4 frontend for yelp ## Build diff --git a/data/ui/main.blp b/data/ui/main.blp index 937642f..7397016 100644 --- a/data/ui/main.blp +++ b/data/ui/main.blp @@ -2,13 +2,32 @@ using Gtk 4.0; using Adw 1; Adw.ApplicationWindow mainWindow { - title: "Hello world"; - default-width: 300; - default-height: 400; + title: "Wince"; + default-width: 400; + default-height: 500; Gtk.Box { orientation: vertical; Adw.HeaderBar {} + + Gtk.Box { + orientation: horizontal; + margin-top: 10; + margin-start: 14; + margin-end: 14; + + styles ["linked"] + + Gtk.Entry searchEntry { + placeholder-text: "Search"; + } + Gtk.Entry locationEntry { + placeholder-text: "Location"; + } + Gtk.Button searchButton { + icon-name: "edit-find"; + } + } } } \ No newline at end of file diff --git a/data/gtktest.gresource.xml b/data/wince.gresource.xml similarity index 83% rename from data/gtktest.gresource.xml rename to data/wince.gresource.xml index 8712acb..4224ddd 100644 --- a/data/gtktest.gresource.xml +++ b/data/wince.gresource.xml @@ -1,6 +1,6 @@ - + ui/compiled/main.ui diff --git a/shard.yml b/shard.yml index 7e78e78..1aa1d55 100644 --- a/shard.yml +++ b/shard.yml @@ -1,4 +1,4 @@ -name: gtktest +name: wince version: 0.1.0 authors: @@ -6,7 +6,7 @@ authors: targets: gtktest: - main: src/gtktest.cr + main: src/wince.cr dependencies: gtk4: diff --git a/src/gtktest.cr b/src/gtktest.cr deleted file mode 100644 index c15880a..0000000 --- a/src/gtktest.cr +++ /dev/null @@ -1,10 +0,0 @@ -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 diff --git a/src/modules/prerequisites.cr b/src/modules/prerequisites.cr index f9686e3..a49cf30 100644 --- a/src/modules/prerequisites.cr +++ b/src/modules/prerequisites.cr @@ -1,9 +1,9 @@ -module GtkTest +module Wince 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") + Gio.register_resource("data/wince.gresource.xml", "data") end diff --git a/src/modules/views/main.cr b/src/modules/views/main.cr index df58fee..71a4033 100644 --- a/src/modules/views/main.cr +++ b/src/modules/views/main.cr @@ -1,4 +1,4 @@ -module GtkTest +module Wince @@main_window_id = 0_u32 def activate(app : Adw::Application) @@ -10,9 +10,18 @@ module GtkTest @@main_window_id = window.id + SEARCH_BUTTON.clicked_signal.connect do + handle_search + end + window.present end + def handle_search + puts "searched for " + SEARCH_ENTRY.buffer.text + puts "location for " + LOCATION_ENTRY.buffer.text + end + APP.activate_signal.connect(->activate(Adw::Application)) exit(APP.run(ARGV)) end \ No newline at end of file diff --git a/src/wince.cr b/src/wince.cr new file mode 100644 index 0000000..f08dd96 --- /dev/null +++ b/src/wince.cr @@ -0,0 +1,14 @@ +require "libadwaita" + +require "./modules/prerequisites.cr" +require "./modules/views/main.cr" + +module Wince + B_UI = Gtk::Builder.new_from_resource("/wince/ui/compiled/main.ui") + + SEARCH_ENTRY = Gtk::Entry.cast(B_UI["searchEntry"]) + LOCATION_ENTRY = Gtk::Entry.cast(B_UI["locationEntry"]) + SEARCH_BUTTON = Gtk::Button.cast(B_UI["searchButton"]) + + APP = Adw::Application.new("dev.wince", Gio::ApplicationFlags::None) +end