Commit ff90d3fa authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui
Browse files

use libhandy-1 widgets

mostly a HdyApplicationWindow to have a nicer UI
parent 596adc9b
Pipeline #195972 failed with stage
in 1 minute and 4 seconds
......@@ -105,7 +105,7 @@ dependencies = [
"glib 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gtk-macros 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libhandy 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libhandy 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pango 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pangocairo 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -498,8 +498,8 @@ dependencies = [
[[package]]
name = "libhandy"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
version = "1.0.0"
source = "git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git#8e83a51344d981f0cdb6a643ae3b6fc63b328d96"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gdk 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -513,16 +513,17 @@ dependencies = [
"gtk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
"libhandy-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libhandy-sys 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)",
"pango 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libhandy-sys"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
version = "1.0.0"
source = "git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git#8e83a51344d981f0cdb6a643ae3b6fc63b328d96"
dependencies = [
"gdk 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdk-pixbuf-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdk-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gio-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -532,6 +533,7 @@ dependencies = [
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
"pango-sys 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"system-deps 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -1009,8 +1011,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
"checksum libdbus-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc12a3bc971424edbbf7edaf6e5740483444db63aa8e23d3751ff12a30f306f0"
"checksum libhandy 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2aae364d9dc15598dbf1b3b5c1ac7857034bad622f8817002439125c9869a7"
"checksum libhandy-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01bb81849945cacdf8f8f0db8e4be16d5bd72a8d673d9b9691cbe0b7c5364412"
"checksum libhandy 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)" = "<none>"
"checksum libhandy-sys 1.0.0 (git+https://gitlab.gnome.org/World/Rust/libhandy-rs.git)" = "<none>"
"checksum locale_config 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "73ac19ebe45489e5d53b4346d8b90bb3dd03275c5fdf2ce22a982516d86b535c"
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
"checksum memchr 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53445de381a1f436797497c61d851644d0e8e88e6140f22872ad33a704933978"
......
......@@ -12,10 +12,10 @@ gdk = "0.13"
pangocairo = "0.10"
log = "0.4"
gettext-rs = { version = "0.4", features = ["gettext-system"] }
libhandy = "0.6"
libhandy = { git = "https://gitlab.gnome.org/World/Rust/libhandy-rs.git" }
pretty_env_logger = "0.4"
pango = "0.9"
sass-rs = "0.2"
pretty_env_logger = "0.4"
dbus = "0.8"
rand = "0.7"
gtk-macros = "0.2"
......@@ -51,7 +51,7 @@
"sources": [{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libhandy.git",
"branch": "libhandy-0-0"
"branch": "0.83.0"
}]
},
{
......
......@@ -59,3 +59,8 @@ entry selection{
background-color: shade(@background_color, 0.9);
color: shade(@foreground_color, 0.9);
}
window headerbar.titlebar {
background: none;
border: none;
}
......@@ -7,7 +7,7 @@ use glib::subclass::prelude::*;
use glib::translate::*;
use glib::{Receiver, Sender};
use gtk::prelude::*;
use gtk::subclass::prelude::{ApplicationImpl, GtkApplicationImpl};
use gtk::subclass::prelude::{ApplicationImpl, ApplicationImplExt, GtkApplicationImpl};
use gtk::SettingsExt;
use std::cell::RefCell;
use std::env;
......@@ -53,6 +53,11 @@ impl ObjectImpl for ApplicationPrivate {
impl GtkApplicationImpl for ApplicationPrivate {}
impl ApplicationImpl for ApplicationPrivate {
fn startup(&self, app: &gio::Application) {
self.parent_startup(app);
libhandy::init();
}
fn activate(&self, _app: &gio::Application) {
if let Some(ref window) = *self.window.borrow() {
window.present();
......@@ -76,7 +81,7 @@ glib_wrapper! {
pub struct Application(
Object<subclass::simple::InstanceStruct<ApplicationPrivate>,
subclass::simple::ClassStruct<ApplicationPrivate>,
SwApplicationClass>)
ApplicationClass>)
@extends gio::Application, gtk::Application, gio::ActionMap;
match fn {
......
......@@ -11,7 +11,7 @@ struct ChartBarMarker {
}
struct ChartBarWidget {
pub widget: libhandy::Column,
pub widget: libhandy::Clamp,
max_value: f64,
value: f64,
container: gtk::Box,
......@@ -21,7 +21,7 @@ struct ChartBarWidget {
impl ChartBarWidget {
pub fn new(max_value: f64) -> Rc<RefCell<Self>> {
let widget = libhandy::Column::new();
let widget = libhandy::Clamp::new();
let chart_bar = Rc::new(RefCell::new(ChartBarWidget {
widget,
max_value: max_value.log(10.0),
......@@ -93,7 +93,7 @@ impl ChartBarWidget {
self.container.pack_start(&self.filled_container, false, false, 0);
self.widget.set_maximum_width(900);
self.widget.set_maximum_size(900);
self.widget.add(&overlay);
self.widget.show();
......
......@@ -26,7 +26,6 @@ fn main() {
pretty_env_logger::init();
gtk::init().expect("Unable to start GTK3");
libhandy::init().expect("Failed to initialize libhandy-0.0");
// Prepare i18n
setlocale(LocaleCategory::LcAll, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
......
......@@ -13,7 +13,9 @@ use glib::subclass::prelude::*;
use glib::translate::*;
use glib::ObjectExt;
use gtk::prelude::*;
use gtk::subclass::prelude::{ApplicationWindowImpl, BinImpl, ContainerImpl, WidgetImpl, WindowImpl};
use gtk::subclass::prelude::ApplicationWindowImpl as GtkApplicationWindowImpl;
use gtk::subclass::prelude::{BinImpl, ContainerImpl, WidgetImpl, WindowImpl};
use libhandy::subclass::prelude::ApplicationWindowImpl;
use libhandy::HeaderBarExt;
use std::{cell::RefCell, rc::Rc};
......@@ -23,12 +25,13 @@ pub struct WindowPrivate {
state: Rc<RefCell<WindowState>>,
levelbar: RefCell<ContrastLevelBar>,
pub preview: ContrastPreview,
handle: libhandy::WindowHandle,
sender: RefCell<Option<glib::Sender<Action>>>,
}
impl ObjectSubclass for WindowPrivate {
const NAME: &'static str = "Window";
type ParentType = gtk::ApplicationWindow;
type ParentType = libhandy::ApplicationWindow;
type Instance = subclass::simple::InstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
......@@ -39,6 +42,7 @@ impl ObjectSubclass for WindowPrivate {
let fg_entry = ColourEntry::new(&gettext("Foreground Colour"));
let state = Rc::new(RefCell::new(WindowState::init()));
let handle = libhandy::WindowHandle::new();
let levelbar = RefCell::new(ContrastLevelBar::new());
let preview = ContrastPreview::new();
......@@ -48,6 +52,7 @@ impl ObjectSubclass for WindowPrivate {
levelbar,
preview,
state,
handle,
sender: RefCell::new(None),
}
}
......@@ -70,11 +75,14 @@ impl ObjectImpl for WindowPrivate {
get_widget!(builder, gtk::ShortcutsWindow, shortcuts_dialog);
self_.set_help_overlay(Some(&shortcuts_dialog));
let main_container = gtk::Box::new(gtk::Orientation::Vertical, 0);
// Header Bar
let headerbar = libhandy::HeaderBar::new();
headerbar.set_centering_policy(libhandy::CenteringPolicy::Strict);
headerbar.set_margin_top(6);
headerbar.set_show_close_button(true);
headerbar.set_title(Some(&gettext("Contrast")));
self_.set_titlebar(Some(&headerbar));
main_container.add(&headerbar);
self.fg_entry.get_entry().get_style_context().add_class("fg-entry");
self.bg_entry.get_entry().get_style_context().add_class("bg-entry");
......@@ -107,13 +115,17 @@ impl ObjectImpl for WindowPrivate {
// Main Container: Composed of ContrastPreview & ContrastLevelBar
let container = gtk::Box::new(gtk::Orientation::Vertical, 0);
container.set_property_margin(12);
container.get_style_context().add_class("main-container");
container.set_valign(gtk::Align::Center);
container.pack_start(&self.preview, true, true, 12);
container.pack_start(&self.levelbar.borrow().widget, true, true, 12);
self_.add(&container);
main_container.add(&container);
self.handle.add(&main_container);
self_.add(&self.handle);
// Restore state
self.state.borrow_mut().load_into(self_, &self.bg_entry, &self.fg_entry);
self_.show_all();
......@@ -128,6 +140,8 @@ impl BinImpl for WindowPrivate {}
impl WindowImpl for WindowPrivate {}
impl GtkApplicationWindowImpl for WindowPrivate {}
impl ApplicationWindowImpl for WindowPrivate {}
glib_wrapper! {
......@@ -135,7 +149,7 @@ glib_wrapper! {
Object<subclass::simple::InstanceStruct<WindowPrivate>,
subclass::simple::ClassStruct<WindowPrivate>,
SwApplicationWindowClass>)
@extends gtk::Widget, gtk::Container, gtk::Bin, gtk::Window, gtk::ApplicationWindow, gio::ActionMap;
@extends gtk::Widget, gtk::Container, gtk::Bin, gtk::Window, libhandy::ApplicationWindow, gtk::ApplicationWindow, gio::ActionMap;
match fn {
get_type => || WindowPrivate::get_type().to_glib(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment