uhh lotsa stuff idk

This commit is contained in:
Bit Borealis 2023-08-16 10:51:58 +00:00
commit ef3164f1af
Signed by: theotheroracle
GPG Key ID: 2D816A2DCA6E5649
8 changed files with 1530 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1413
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

11
Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "neon-gtk"
version = "0.1.0"
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"

1
README.md Normal file
View File

@ -0,0 +1 @@
# test

11
default.nix Normal file
View File

@ -0,0 +1,11 @@
with import <nixpkgs> {};
let
rustChannel = rustChannelOf {
channel = "stable";
date = "2023-08-16";
};
in
rustChannel.workspaceMembers.libadwaita.build.override {
src = ./.;
}

19
flake.nix Normal file
View File

@ -0,0 +1,19 @@
{
description = "A libadwaita application in Rust";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
appDerivation = import ./default.nix { inherit pkgs; };
in
{
defaultPackage = appDerivation;
}
);
}

26
shell.nix Normal file
View File

@ -0,0 +1,26 @@
with import <nixpkgs> {};
mkShell {
buildInputs = [
# rust deps
cargo
rustc
# build deps
cmake
pkg-config
# gtk deps
gtk4
gdk-pixbuf
cairo
libadwaita
# servo deps
pango
# editor deps
lapce
rust-analyzer
];
}

48
src/main.rs Normal file
View File

@ -0,0 +1,48 @@
use libadwaita::prelude::*;
use libadwaita::{ActionRow, Application, ApplicationWindow, HeaderBar};
use gtk4::{Box, ListBox, Orientation, SelectionMode};
fn main() {
let application = Application::builder()
.application_id("os.saturn.halogen")
.build();
application.connect_activate(|app| {
// ActionRows are only available in Adwaita
let row = ActionRow::builder()
.activatable(true)
.title("Click me")
.build();
row.connect_activated(|_| {
eprintln!("Clicked!");
});
let list = ListBox::builder()
.margin_top(32)
.margin_end(32)
.margin_bottom(32)
.margin_start(32)
.selection_mode(SelectionMode::None)
// makes the list look nicer
.css_classes(vec![String::from("boxed-list")])
.build();
list.append(&row);
// Combine the content in a box
let content = Box::new(Orientation::Vertical, 0);
// Adwaitas' ApplicationWindow does not include a HeaderBar
content.append(&HeaderBar::new());
content.append(&list);
let window = ApplicationWindow::builder()
.application(app)
.title("First App")
.default_width(350)
// add content to window
.content(&content)
.build();
window.show();
});
application.run();
}