Commit 57fbab79 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui
Browse files

Use monospace fonts for color entries.

This also refactor few import abuses from me.
and mark the contrast ratio as translatable
"
parent 50cc57f4
Pipeline #107773 failed with stages
in 4 minutes and 19 seconds
use crate::colour;
use crate::config;
use crate::styles::update_styles;
use crate::window::Window;
use super::colour;
use super::config;
use super::styles::update_styles;
use super::window::Window;
use gio::prelude::*;
use gtk::prelude::*;
use std::env;
......
use crate::colour;
use crate::colour_popover::ColourPopover;
use crate::dbus::{BusType, Connection, Message};
use crate::gtk::{BoxExt, ButtonExt, ColorChooserExt, ColorChooserWidgetExt, EntryExt, PopoverExt, StyleContextExt, WidgetExt};
use super::colour;
use super::colour_popover::ColourPopover;
use dbus::{BusType, Connection, Message};
use gtk::prelude::*;
use std::collections::HashMap;
use std::str::FromStr;
......@@ -25,7 +25,7 @@ impl ColourEntry {
fn init(&self, label: String) {
self.widget.set_halign(gtk::Align::Center);
self.widget.set_valign(gtk::Align::Center);
self.widget.get_style_context().add_class("linked");
self.widget.get_style_context().add_class(&gtk::STYLE_CLASS_LINKED);
self.widget.set_hexpand(true);
self.widget.set_tooltip_text(Some(&label));
......@@ -35,7 +35,8 @@ impl ColourEntry {
self.entry.set_property_primary_icon_name(Some("circle-symbolic"));
self.entry.set_property_primary_icon_activatable(true);
self.entry.get_style_context().add_class("colour-entry");
self.entry.set_width_chars(9);
self.entry.get_style_context().add_class(&gtk::STYLE_CLASS_MONOSPACE);
self.entry.set_width_chars(10);
self.entry.show();
let colour_selector_popover = ColourPopover::new(self.entry.clone());
......
use gettextrs::gettext;
use glib::Cast;
use gtk::{BoxExt, ContainerExt, LabelExt, OverlayExt, StyleContextExt, WidgetExt};
use libhandy::{Column, ColumnExt};
use gtk::prelude::*;
use libhandy::prelude::*;
use pango;
use pangocairo;
use std::{cell::RefCell, rc::Rc};
......@@ -12,7 +12,7 @@ struct ChartBarMarker {
}
struct ChartBarWidget {
pub widget: Column,
pub widget: libhandy::Column,
max_value: f64,
value: f64,
container: gtk::Box,
......@@ -22,7 +22,7 @@ struct ChartBarWidget {
impl ChartBarWidget {
pub fn new(max_value: f64) -> Rc<RefCell<Self>> {
let widget = Column::new();;
let widget = libhandy::Column::new();;
let chart_bar = Rc::new(RefCell::new(ChartBarWidget {
widget,
max_value: max_value.log(10.0),
......@@ -181,12 +181,12 @@ impl ContrastLevelBar {
pub fn set_contrast_level(&mut self, contrast_level: f64) {
self.chartbar.borrow_mut().set_value(contrast_level);
println!("fract {}", contrast_level.fract());
let mut level_label = String::new();
let mut level_label = String::from(gettext("Contrast Ratio: "));
if contrast_level.fract() != 0.0 {
level_label.push_str(&gettext(format!("Contrast Ratio: {:.1}:1", contrast_level)));
level_label.push_str(&format!("{:.1}:1", contrast_level));
} else {
level_label.push_str(&gettext(format!("Contrast Ratio: {:}:1", contrast_level as i32)));
level_label.push_str(&format!("{:}:1", contrast_level as i32));
}
self.level_label.set_text(&level_label);
}
......
use crate::gtk::{BoxExt, LabelExt, StyleContextExt, WidgetExt};
use gettextrs::gettext;
use gtk::prelude::*;
pub struct ContrastPreview {
pub widget: gtk::Box,
......
......@@ -2,15 +2,7 @@ extern crate pretty_env_logger;
#[macro_use]
extern crate log;
extern crate dbus;
extern crate gio;
extern crate glib;
extern crate gtk;
extern crate libhandy;
extern crate pango;
extern crate pangocairo;
extern crate rand;
use gettextrs::*;
mod application;
......
use crate::application::Message;
use crate::colour_entry::ColourEntry;
use crate::config::{APP_ID, PROFILE};
use crate::contrast_level::ContrastLevelBar;
use crate::contrast_preview::ContrastPreview;
use crate::libhandy::HeaderBarExt;
use crate::window_state::WindowState;
use super::application::Message;
use super::colour_entry::ColourEntry;
use super::config::{APP_ID, PROFILE};
use super::contrast_level::ContrastLevelBar;
use super::contrast_preview::ContrastPreview;
use super::window_state::WindowState;
use gettextrs::gettext;
use glib::ObjectExt;
use gtk::prelude::{BoxExt, BuilderExtManual, ButtonExt, ContainerExt, EditableSignals, MenuButtonExt, StyleContextExt, WidgetExt};
use gtk::Inhibit;
use std::cell::RefCell;
use std::rc::Rc;
use gtk::prelude::*;
use libhandy::prelude::*;
use std::{cell::RefCell, rc::Rc};
pub struct Window {
pub widget: gtk::ApplicationWindow,
......@@ -77,7 +76,7 @@ impl Window {
let state = self.state.clone();
self.widget.connect_delete_event(move |window, _| {
state.borrow_mut().dump(&window);
Inhibit(false)
gtk::Inhibit(false)
});
self.widget.show();
......
use crate::colour;
use crate::colour_entry::ColourEntry;
use crate::rand::Rng;
use super::colour;
use super::colour_entry::ColourEntry;
use gio::prelude::SettingsExt;
use gtk::prelude::GtkWindowExt;
use rand::Rng;
use std::str::FromStr;
// Default colors, randomized whenever you launch the app
......
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