From cba402db0e4873d24f2292eaeb7b7d2775623e6a Mon Sep 17 00:00:00 2001 From: Bit Borealis Date: Thu, 24 Aug 2023 16:07:25 +0000 Subject: [PATCH] finally get toolbarview working ._. --- Cargo.lock | 48 ++++++++++++++++++++++++------------------------ Cargo.toml | 12 ++++++++++-- default.nix | 14 ++++++++++++-- flake.lock | 51 +++++++++++++++++++++++++++++++++++++++++++-------- flake.nix | 23 +++++++++++++++++------ shell.nix | 4 +++- src/main.rs | 18 ++++++++++-------- 7 files changed, 119 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43e4a49..d02f94f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "app_units" @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] @@ -396,7 +396,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -581,7 +581,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -989,9 +989,9 @@ checksum = "8f1383dff4092fe903ac180e391a8d4121cc48f08ccf850614b0290c6673b69d" [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1041,9 +1041,9 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.183" +version = "1.0.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "9f5db24220c009de9bd45e69fb2938f4b6d2df856aa9304ce377b3180f83b7c1" dependencies = [ "serde_derive", ] @@ -1059,13 +1059,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "5ad697f7e0b65af4983a4ce8f56ed5b357e8d3c36651bf6a7e13639c17b8e670" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1101,9 +1101,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -1142,9 +1142,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -1184,22 +1184,22 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1380,9 +1380,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winnow" -version = "0.5.10" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5504cc7644f4b593cbc05c4a55bf9bd4e94b867c3c0bd440934174d50482427d" +checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index a079e2c..c358fd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,14 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -gtk4 = "0.7.2" -libadwaita = "0.5.2" webrender = "0.61.0" + +[dependencies.gtk] +package = "gtk4" +version = "0.7.2" +features = [ "v4_12"] + +[dependencies.adw] +package = "libadwaita" +version = "0.5.2" +features = [ "v1_4" ] diff --git a/default.nix b/default.nix index 7e272ef..ff35b11 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,15 @@ -{ lib, fetchFromGitHub, rustPlatform, cmake, pkg-config, gtk4, gdk-pixbuf, cairo, libadwaita, pango }: - +{# lib +#, fetchFromGitHub +#, +rustPlatform +, cmake +, pkg-config +, gtk4 +, gdk-pixbuf +, cairo +, pango +, libadwaita +}: rustPlatform.buildRustPackage rec { pname = "xenon-browser"; version = "0.1.0"; diff --git a/flake.lock b/flake.lock index 7edcd10..3c16458 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,58 @@ { "nodes": { - "nixpkgs": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1692128808, - "narHash": "sha256-Di1Zm/P042NuwThMiZNrtmaAjd4Tm2qBOKHX7xUOfMk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "4ed9856be002a730234a1a1ed9dcd9dd10cbdb40", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1692614049, + "narHash": "sha256-RF+eM5oQGZ58rvdBV4NoF/J3S1z11g52WPWcLsYJVVY=", + "owner": "theotheroracle", + "repo": "nixpkgs", + "rev": "908fc0c68613ee426a81427693a9b26aaba9b224", + "type": "github" + }, + "original": { + "owner": "theotheroracle", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 5ccb2d3..471d22b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,9 +1,20 @@ { - description = "xenon-browser"; + description = "xenon-browser"; - outputs = { self, nixpkgs }: - let pkgs = nixpkgs.legacyPackages.x86_64-linux; in + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:theotheroracle/nixpkgs"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in { - packages.x86_64-linux.default = pkgs.callPackage ./default.nix {}; - }; -} \ No newline at end of file + devShells.default = import ./shell.nix { inherit pkgs; }; + packages.default = pkgs.callPackage ./default.nix { }; + } + ); +} diff --git a/shell.nix b/shell.nix index 8292339..d990047 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,5 @@ -with import {}; +{ pkgs ? import {} }: +with pkgs; mkShell { buildInputs = [ # rust deps @@ -20,6 +21,7 @@ mkShell { # editor deps lapce + vscodium rust-analyzer nil ]; diff --git a/src/main.rs b/src/main.rs index 39a38a7..24d850e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,11 @@ -use libadwaita::prelude::*; -use libadwaita::{ActionRow, Application, ApplicationWindow, HeaderBar}; -use gtk4::{Box, ListBox, Orientation, SelectionMode}; +use adw::prelude::*; + +use adw::{ToolbarView, ActionRow, Application, ApplicationWindow, HeaderBar}; +use gtk::{Box, ListBox, Orientation, SelectionMode}; fn main() { let application = Application::builder() - .application_id("os.saturn.halogen") + .application_id("com.example.FirstAdwaitaApp") .build(); application.connect_activate(|app| { @@ -29,14 +30,14 @@ fn main() { list.append(&row); // Combine the content in a box - let content = Box::new(Orientation::Vertical, 0); + let content = ToolbarView ::new(); // Adwaitas' ApplicationWindow does not include a HeaderBar - content.append(&HeaderBar::new()); - content.append(&list); + content.add_top_bar(&HeaderBar::new()); + content.set_content(Some(&list)); let window = ApplicationWindow::builder() .application(app) - .title("First App") + .title("xenon") .default_width(350) // add content to window .content(&content) @@ -46,3 +47,4 @@ fn main() { application.run(); } +