Skip to content

Commit

Permalink
Fixed CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Nov 26, 2024
1 parent 41823fb commit 5843e7a
Show file tree
Hide file tree
Showing 16 changed files with 1,496 additions and 1,443 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
strategy:
fail-fast: false
matrix:
rust_version: [ stable, nightly, 1.73.0 ]
rust_version: [ stable, nightly, 1.79.0 ]
os: [ ubuntu-24.04 ]
# rust_version: [ stable, beta, nightly, 1.73.0, "stable minus 1 release", "stable minus 2 releases" ]
# rust_version: [ stable, beta, nightly, 1.79.0, "stable minus 1 release", "stable minus 2 releases" ]
# os: [ ubuntu-24.04, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_version }}
- name: Install dependencies
run: sudo apt update -y && sudo apt install libgtk4-dev -y
run: sudo apt update -y && sudo apt install libgtk-4-dev libglib2.0-dev -y
- name: Cache cargo
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -53,16 +53,16 @@ jobs:
strategy:
fail-fast: false
matrix:
rust_version: [ stable, nightly, 1.73.0 ]
rust_version: [ stable, nightly, 1.79.0 ]
os: [ ubuntu-24.04 ]
# rust_version: [ stable, beta, nightly, 1.73.0, "stable minus 1 release", "stable minus 2 releases" ]
# rust_version: [ stable, beta, nightly, 1.79.0, "stable minus 1 release", "stable minus 2 releases" ]
# os: [ ubuntu-24.04, windows-latest, macos-latest ]
steps:
- name: Print CPU info
run: lscpu
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt update -y && sudo apt install libgtk4-dev -y
run: sudo apt update -y && sudo apt install libgtk-4-dev libglib2.0-dev -y
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_version }}
Expand Down Expand Up @@ -90,10 +90,12 @@ jobs:
matrix:
rust_version: [ stable, nightly ]
os: [ ubuntu-24.04 ]
# rust_version: [ stable, beta, nightly, 1.73.0, "stable minus 1 release", "stable minus 2 releases" ]
# rust_version: [ stable, beta, nightly, 1.79.0, "stable minus 1 release", "stable minus 2 releases" ]
# os: [ ubuntu-24.04, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt update -y && sudo apt install libgtk-4-dev libglib2.0-dev -y
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_version }}
Expand Down
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.SILENT:

SHELL=/usr/bin/env bash -O globstar

all: help

test: test_unit test_clippy test_fmt ## Runs tests

bench: ## Benchmark the project
cargo bench

build: ## Build the project
source test-utils.sh ;\
section "Cargo build" ;\
cargo build --all

fix-format: ## Fix formatting and clippy errors
cargo fmt --all
cargo clippy --all --fix --allow-dirty --allow-staged

check-format: test_clippy test_fmt ## Check the project for clippy and formatting errors

test_unit:
source test-utils.sh ;\
section "Cargo test" ;\
cargo test --all --no-fail-fast --all-features --all-targets

test_clippy:
source test-utils.sh ;\
section "Cargo clippy" ;\
cargo clippy -- -D warnings

test_fmt:
source test-utils.sh ;\
section "Cargo fmt" ;\
cargo fmt --all -- --check

help: ## Display available commands
echo "Available make commands:"
echo
grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
12 changes: 4 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/// This will be run prior to compiling the project and will compile the resources
fn main() {
glib_build_tools::compile_resources(
&["./resources"],
"./resources/resources.gresource.xml",
"gosub.gresource",
);
}
/// This will be run prior to compiling the project and will compile the resources
fn main() {
glib_build_tools::compile_resources(&["./resources"], "./resources/resources.gresource.xml", "gosub.gresource");
}
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "stable"
90 changes: 48 additions & 42 deletions src/application.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use crate::dialog::about::About;
use crate::dialog::shortcuts::ShortcutsDialog;
use crate::window::BrowserWindow;
use crate::APP_ID;
use gtk4::glib::clone;
use gtk4::subclass::prelude::GtkApplicationImpl;
use gtk4::{gio, glib, prelude::*, subclass::prelude::*, Settings};
use gtk_macros::action;
use log::info;
use crate::dialog::shortcuts::ShortcutsDialog;
use crate::window::BrowserWindow;

mod imp {
use super::*;
use crate::window::BrowserWindow;

#[derive(Default)]
pub struct Application {}

#[glib::object_subclass]
Expand All @@ -21,12 +22,6 @@ mod imp {
type ParentType = gtk4::Application;
}

impl Default for Application {
fn default() -> Self {
Self {}
}
}

impl ObjectImpl for Application {}

impl ApplicationImpl for Application {
Expand Down Expand Up @@ -68,7 +63,7 @@ impl Application {
pub fn new() -> Self {
glib::Object::builder()
.property("application-id", APP_ID)
.property("resource-base-path", &Some("/io/gosub/browser-gtk"))
.property("resource-base-path", Some("/io/gosub/browser-gtk"))
.build()
}

Expand All @@ -78,46 +73,60 @@ impl Application {
}

fn setup_actions(&self) {

action!(self, "quit", clone!(
#[weak(rename_to=app)]
action!(
self,
move |_, _| {
app.quit();
})
"quit",
clone!(
#[weak(rename_to=app)]
self,
move |_, _| {
app.quit();
}
)
);

action!(self, "toggle-dark-mode", clone!(
#[weak(rename_to=_app)]
action!(
self,
move |_, _| {
info!("Toggle dark mode action triggered");
let settings = Settings::default().expect("Failed to get default GtkSettings");
let mode: bool = settings.property("gtk-application-prefer-dark-theme");
settings.set_property("gtk-application-prefer-dark-theme", !mode);
})
"toggle-dark-mode",
clone!(
#[weak(rename_to=_app)]
self,
move |_, _| {
info!("Toggle dark mode action triggered");
let settings = Settings::default().expect("Failed to get default GtkSettings");
let mode: bool = settings.property("gtk-application-prefer-dark-theme");
settings.set_property("gtk-application-prefer-dark-theme", !mode);
}
)
);

action!(self, "show-about", clone!(
#[weak(rename_to=_app)]
action!(
self,
move |_, _| {
info!("Show about dialog action triggered");
let about = About::new();
about.present();
})
"show-about",
clone!(
#[weak(rename_to=_app)]
self,
move |_, _| {
info!("Show about dialog action triggered");
let about = About::create_dialog();
about.present();
}
)
);

action!(self, "show-shortcuts", clone!(
#[weak(rename_to=app)]
action!(
self,
move |_, _| {
info!("Show about dialog action triggered");
let about = ShortcutsDialog::new(&app);
about.present();
})
"show-shortcuts",
clone!(
#[weak(rename_to=app)]
self,
move |_, _| {
info!("Show about dialog action triggered");
let about = ShortcutsDialog::create_dialog(&app);
about.present();
}
)
);

}

fn setup_accelerators(&self) {
Expand All @@ -136,9 +145,6 @@ impl Application {

impl Default for Application {
fn default() -> Self {
gio::Application::default()
.unwrap()
.downcast::<Application>()
.unwrap()
gio::Application::default().unwrap().downcast::<Application>().unwrap()
}
}
2 changes: 1 addition & 1 deletion src/dialog.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod about;
pub mod shortcuts;
pub mod shortcuts;
77 changes: 36 additions & 41 deletions src/dialog/about.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
use gtk4::gdk::Texture;
use gtk4::gdk_pixbuf::Pixbuf;

pub struct About;

impl About {
pub fn new() -> gtk4::AboutDialog {
let about = gtk4::AboutDialog::new();
about.set_program_name("Gosub Browser".into());
about.set_version(Some("0.0.1"));
about.set_website(Some("https://www.gosub.io".into()));
about.set_website_label("Gosub Website");
about.set_copyright(Some("© 2024 Gosub Team"));
about.set_license_type(gtk4::License::MitX11);
// about.set_logo_icon_name(Some("gosub"));

if let Ok(logo_pixbuf) = Pixbuf::from_resource_at_scale(
"/io/gosub/browser-gtk/assets/gosub.svg",
128,
128,
true,
) {
let logo_texture = Texture::for_pixbuf(&logo_pixbuf);
about.set_logo(Some(&logo_texture));
}
about.set_comments(Some("A simple browser written in Rust and GTK"));

about.set_authors(&["Gosub Team", "Joshua Thijssen", "SharkTheOne"]);
about.add_credit_section("Networking", &[ "Gosub Team" ]);
about.add_credit_section("HTML5 parser", &[ "Gosub Team" ]);
about.add_credit_section("CSS3 parser", &[ "Gosub Team" ]);
about.add_credit_section("Renderer", &[ "Gosub Team" ]);
about.add_credit_section("Javascript engine", &[ "Gosub Team" ]);
about.add_credit_section("UI", &[ "Gosub Team" ]);
about.add_credit_section("GTK integration", &[ "Gosub Team" ]);
about.add_credit_section("Rust integration", &[ "Gosub Team" ]);
about.set_translator_credits(Some("Gosub Team"));

about
}
}
use gtk4::gdk::Texture;
use gtk4::gdk_pixbuf::Pixbuf;

pub struct About;

impl About {
pub fn create_dialog() -> gtk4::AboutDialog {
let about = gtk4::AboutDialog::new();
about.set_program_name("Gosub Browser".into());
about.set_version(Some("0.0.1"));
about.set_website(Some("https://www.gosub.io"));
about.set_website_label("Gosub Website");
about.set_copyright(Some("© 2024 Gosub Team"));
about.set_license_type(gtk4::License::MitX11);
// about.set_logo_icon_name(Some("gosub"));

if let Ok(logo_pixbuf) = Pixbuf::from_resource_at_scale("/io/gosub/browser-gtk/assets/gosub.svg", 128, 128, true) {
let logo_texture = Texture::for_pixbuf(&logo_pixbuf);
about.set_logo(Some(&logo_texture));
}
about.set_comments(Some("A simple browser written in Rust and GTK"));

about.set_authors(&["Gosub Team", "Joshua Thijssen", "SharkTheOne"]);
about.add_credit_section("Networking", &["Gosub Team"]);
about.add_credit_section("HTML5 parser", &["Gosub Team"]);
about.add_credit_section("CSS3 parser", &["Gosub Team"]);
about.add_credit_section("Renderer", &["Gosub Team"]);
about.add_credit_section("Javascript engine", &["Gosub Team"]);
about.add_credit_section("UI", &["Gosub Team"]);
about.add_credit_section("GTK integration", &["Gosub Team"]);
about.add_credit_section("Rust integration", &["Gosub Team"]);
about.set_translator_credits(Some("Gosub Team"));

about
}
}
Loading

0 comments on commit 5843e7a

Please sign in to comment.