refactor: switch to libadwaita

This commit is contained in:
MeexReay 2025-08-31 15:25:59 +03:00
parent 85d63ff9b2
commit ba57aefd4b
4 changed files with 319 additions and 284 deletions

530
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ homedir = "0.3.4"
native-tls = "0.2.14" native-tls = "0.2.14"
clap = { version = "4.5.36", features = ["derive"] } clap = { version = "4.5.36", features = ["derive"] }
serde = { version = "1.0.219", features = ["serde_derive"] } serde = { version = "1.0.219", features = ["serde_derive"] }
gtk4 = { version = "0.9.6", optional = true } # gtk4 = { version = "0.9.6", optional = true }
chrono = "0.4.40" chrono = "0.4.40"
serde_default = "0.2.0" serde_default = "0.2.0"
socks = "0.3.4" socks = "0.3.4"
@ -22,13 +22,14 @@ gdk-pixbuf = { version = "0.3.0", optional = true } # DO NOT UPDATE
winapi = { version = "0.3.9", optional = true, features = ["wincon", "winuser"] } winapi = { version = "0.3.9", optional = true, features = ["wincon", "winuser"] }
tungstenite = "0.27.0" tungstenite = "0.27.0"
reqwest = { version = "0.12.20", features = ["blocking"] } reqwest = { version = "0.12.20", features = ["blocking"] }
libadwaita = { version = "0.8.0", optional = true }
[build-dependencies] [build-dependencies]
winresource = { version = "0.1.20", optional = true } winresource = { version = "0.1.20", optional = true }
[features] [features]
default = ["gtk"] default = ["gtk"]
gtk = ["dep:gtk4"] gtk = ["dep:libadwaita"]
libnotify = ["dep:libnotify", "dep:gdk-pixbuf"] libnotify = ["dep:libnotify", "dep:gdk-pixbuf"]
notify-rust = ["dep:notify-rust"] notify-rust = ["dep:notify-rust"]
winapi = ["dep:winapi", "dep:winresource"] winapi = ["dep:winapi", "dep:winresource"]

View File

@ -12,23 +12,25 @@ use std::time::{Duration, SystemTime};
use chrono::Local; use chrono::Local;
use gtk4::gdk_pixbuf::InterpType; use libadwaita as adw;
use gtk4 as gtk; use adw::gdk::{Cursor, Display, Texture};
use adw::gio::{self, ActionEntry, ApplicationFlags, MemoryInputStream, Menu};
use gtk::gdk::{Cursor, Display, Texture}; use adw::glib::clone;
use gtk::gdk_pixbuf::{Pixbuf, PixbufAnimation, PixbufLoader}; use adw::glib::{
use gtk::gio::{self, ActionEntry, ApplicationFlags, MemoryInputStream, Menu};
use gtk::glib::clone;
use gtk::glib::{
self, clone::Downgrade, source::timeout_add_local_once, timeout_add_local, timeout_add_once, self, clone::Downgrade, source::timeout_add_local_once, timeout_add_local, timeout_add_once,
ControlFlow, ControlFlow,
}; };
use adw::prelude::*;
use adw::{Application, ApplicationWindow, Window};
use adw::gtk;
use gtk::gdk_pixbuf::InterpType;
use gtk::gdk_pixbuf::{Pixbuf, PixbufAnimation, PixbufLoader};
use gtk::pango::WrapMode; use gtk::pango::WrapMode;
use gtk::prelude::*;
use gtk::{ use gtk::{
AboutDialog, Align, Application, ApplicationWindow, Box as GtkBox, Button, Calendar, AboutDialog, Align, Box as GtkBox, Button, Calendar,
CheckButton, CssProvider, Entry, Fixed, GestureClick, Justification, Label, ListBox, CheckButton, CssProvider, Entry, Fixed, GestureClick, Justification, Label, ListBox,
Orientation, Overlay, Picture, ScrolledWindow, Settings, Window, Orientation, Overlay, Picture, ScrolledWindow, Settings,
}; };
use crate::chat::grab_avatar; use crate::chat::grab_avatar;
@ -397,7 +399,7 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
.default_height(500) .default_height(500)
.resizable(true) .resizable(true)
.decorated(true) .decorated(true)
.child(&vbox) .content(&vbox)
.build(); .build();
let controller = gtk::EventControllerKey::new(); let controller = gtk::EventControllerKey::new();
@ -736,7 +738,7 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
.resizable(true) .resizable(true)
.decorated(true) .decorated(true)
.show_menubar(true) .show_menubar(true)
.child(&main_box) .content(&main_box)
.build(); .build();
window.connect_default_width_notify({ window.connect_default_width_notify({
@ -954,7 +956,7 @@ fn send_notification(_: Arc<Context>, ui: &UiModel, title: &str, message: &str)
time::UNIX_EPOCH, time::UNIX_EPOCH,
}; };
use gtk4::gio::Notification; use gtk::gio::Notification;
let mut hash = DefaultHasher::new(); let mut hash = DefaultHasher::new();
hash.write(title.as_bytes()); hash.write(title.as_bytes());

View File

@ -1,26 +1,30 @@
.send-button, .send-text { border-radius: 0; } /* .send-button, .send-text { border-radius: 0; } */
.calendar { .calendar {
transform: scale(0.6); transform: scale(0.6);
margin: -35px; margin: -35px;
}
.widget_box {
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.20);
border-bottom: 2px solid rgba(0, 0, 0, 0.20);
min-height: 121px;
}
.time {
font-size: 20px;
font-family: monospace;
font-weight: bold;
} }
.message-avatar { .widget_box {
border-radius: 64px; box-shadow: 0 10px 10px rgba(0, 0, 0, 0.20);
border-bottom: 2px solid rgba(0, 0, 0, 0.20);
min-height: 121px;
}
.time {
font-size: 20px;
font-family: monospace;
font-weight: bold;
}
.message-avatar {
border-radius: 64px;
} }
/* Now made with GTK Pango Markup */ /* Now made with GTK Pango Markup */
.message-name { font-weight: bold; } .message-name {
font-weight: bold;
}
/* .message-name-green { color: #70fa7a; } /* .message-name-green { color: #70fa7a; }
.message-name-red { color: #fa7070; } .message-name-red { color: #fa7070; }