Skip to content

Commit

Permalink
Update gtk ecosystem to gtk-rs-core 0.19 and gtk4-rs 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
RealKC committed Feb 11, 2024
1 parent 7536e8d commit 60fc04d
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 160 deletions.
324 changes: 203 additions & 121 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ redundant_else = "warn"
single_match_else = "warn"

[workspace.dependencies]
cairo = { package = "cairo-rs", version = "0.18.0", features = ["png"] }
gtk4 = { version = "0.7", features = ["blueprint"] }
cairo = { package = "cairo-rs", version = "0.19.0", features = ["png"] }
gtk4 = { version = "0.8", features = ["blueprint"] }
once_cell = "1.13.1"
tokio = { version = "1.25.0", features = ["rt-multi-thread"] }
tracing = "0.1.23"
Expand All @@ -48,8 +48,8 @@ ksni = "0.2.0"
# Screenshot editing & capturing
kcshot-screenshot = { path = "./kcshot-screenshot" }
cairo.workspace = true
gdk4-x11 = "0.7.0"
pangocairo = "0.18.0"
gdk4-x11 = "0.8.0"
pangocairo = "0.19.0"
pulldown-cmark = { version = "0.9.1", default-features = false }
regex = "1.5.6"
stackblur-iter = "0.2.0"
Expand All @@ -70,7 +70,7 @@ tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
thiserror = "1.0.30"

[build-dependencies]
glib-build-tools = "0.18.0"
glib-build-tools = "0.19.0"

[features]
default = ["xdg-paths"]
Expand Down
2 changes: 1 addition & 1 deletion kcshot-data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ edition = "2021"
workspace = true

[dependencies]
gsettings-macro = "0.1.19"
gsettings-macro = "0.2.0"
gtk4.workspace = true
2 changes: 1 addition & 1 deletion kcshot-data/src/colour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;

use gtk4::{
gdk::RGBA,
glib::{self, FromVariant, StaticVariantType, ToVariant},
glib::{self, prelude::*},
};

#[derive(Clone, Copy, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion kcshot-screenshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ workspace = true
kcshot-data = { path = "../kcshot-data" }

# Actually taking the screeenshot
ashpd = { version = "0.6.0", default-features = false, features = [
ashpd = { version = "0.7.0", default-features = false, features = [
"gtk4",
"tokio",
"tracing",
Expand Down
3 changes: 1 addition & 2 deletions src/appwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::{history::HistoryModel, kcshot::KCShot};

glib::wrapper! {
pub struct AppWindow(ObjectSubclass<underlying::AppWindow>)
@extends gtk4::Widget, gtk4::Window, gtk4::ApplicationWindow,
@implements gtk4::Native;
@extends gtk4::Widget, gtk4::Window, gtk4::ApplicationWindow;
}

impl AppWindow {
Expand Down
10 changes: 2 additions & 8 deletions src/editor.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
use gtk4::{
gio,
glib::{self, CastNone},
prelude::Cast,
subclass::prelude::ObjectSubclassIsExt,
traits::{GtkWindowExt, NativeExt, WidgetExt},
};
use gtk4::{gio, glib, prelude::*, subclass::prelude::ObjectSubclassIsExt};
use kcshot_data::{colour::Colour, settings::Settings};

use self::operations::Tool;
Expand Down Expand Up @@ -51,7 +45,7 @@ impl EditorWindow {

let surface = window
.native()
.map(|native| native.surface())
.and_then(|native| native.surface())
.and_downcast::<gdk4_x11::X11Surface>();

if let Some(surface) = surface {
Expand Down
6 changes: 1 addition & 5 deletions src/editor/colourchooser.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use gtk4::{
gdk, glib,
glib::{ObjectExt, ToValue},
subclass::prelude::*,
};
use gtk4::{gdk, glib, glib::prelude::*, subclass::prelude::*};

use crate::editor::Colour;

Expand Down
13 changes: 7 additions & 6 deletions src/editor/operations.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cairo::{Context, Error as CairoError, ImageSurface};
use gtk4::pango::FontDescription;
use kcshot_data::{colour::Colour, geometry::*, Text};
use pangocairo::functions::{create_layout, show_layout, update_layout};
use rand::Rng;

pub use self::{stack::*, tool::*};
Expand Down Expand Up @@ -350,14 +351,14 @@ fn draw_text_at(
colour: Colour,
font_description: &FontDescription,
) {
let layout = pangocairo::create_layout(cairo);
let layout = create_layout(cairo);

layout.set_markup(text);
layout.set_font_description(Some(font_description));
cairo.move_to(x, y);
cairo.set_source_colour(colour);
pangocairo::update_layout(cairo, &layout);
pangocairo::show_layout(cairo, &layout);
update_layout(cairo, &layout);
show_layout(cairo, &layout);
}

fn draw_text_centred_at(
Expand All @@ -367,7 +368,7 @@ fn draw_text_centred_at(
colour: Colour,
font_description: &FontDescription,
) {
let layout = pangocairo::create_layout(cairo);
let layout = create_layout(cairo);

layout.set_markup(text);
layout.set_font_description(Some(font_description));
Expand All @@ -378,6 +379,6 @@ fn draw_text_centred_at(

cairo.move_to(x - w / 2.0, y - h / 2.0);
cairo.set_source_colour(colour);
pangocairo::update_layout(cairo, &layout);
pangocairo::show_layout(cairo, &layout);
update_layout(cairo, &layout);
show_layout(cairo, &layout);
}
2 changes: 1 addition & 1 deletion src/ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use gtk4::{glib::BorrowedObject, traits::WidgetExt};
use gtk4::{glib::BorrowedObject, prelude::*};

pub trait DisposeExt {
/// Disposes all children of a widget
Expand Down
3 changes: 1 addition & 2 deletions src/history/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ mod underlying {

use gtk4::{
gio,
glib::{self, Object, StaticType},
prelude::*,
glib::{self, prelude::*, Object},
subclass::prelude::*,
};

Expand Down
4 changes: 1 addition & 3 deletions src/kcshot.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;

use diesel::SqliteConnection;
use gtk4::{gio, glib, subclass::prelude::*};
use gtk4::{gio, glib, prelude::*, subclass::prelude::*};
use kcshot_data::settings::Settings;

use crate::{
Expand Down Expand Up @@ -29,8 +29,6 @@ impl KCShot {

#[track_caller]
pub fn the() -> Self {
use glib::CastNone;

gio::Application::default()
.and_downcast()
.expect("The global application should be of type `KCShot`")
Expand Down
6 changes: 2 additions & 4 deletions src/settings_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use gtk4::glib;

glib::wrapper! {
pub struct SettingsWindow(ObjectSubclass<underlying::SettingsWindow>)
@extends gtk4::Widget, gtk4::Window,
@implements gtk4::Native;
@extends gtk4::Widget, gtk4::Window;
}

impl Default for SettingsWindow {
Expand All @@ -15,7 +14,7 @@ impl Default for SettingsWindow {
mod underlying {
use std::cell::OnceCell;

use gtk4::{glib, prelude::*, subclass::prelude::*, traits::DialogExt, CompositeTemplate};
use gtk4::{glib, prelude::*, subclass::prelude::*, CompositeTemplate};
use kcshot_data::settings::Settings;

use crate::ext::DisposeExt;
Expand Down Expand Up @@ -117,5 +116,4 @@ mod underlying {

impl WidgetImpl for SettingsWindow {}
impl WindowImpl for SettingsWindow {}
impl NativeImpl for SettingsWindow {}
}

0 comments on commit 60fc04d

Please sign in to comment.