fractal-gtk: Reduce margins when leaflet is folded

Our current margins are a little too big for a mobile screen.
So, we reduce them to 6px when we detect that the app is
folded with HdyLeaflet.

Closes https://gitlab.gnome.org/GNOME/fractal/issues/480
This commit is contained in:
Christopher Davis 2019-04-19 02:52:18 -04:00 committed by Daniel Garcia Moreno
parent ab299524aa
commit f96d72654a
2 changed files with 46 additions and 0 deletions

View file

@ -327,3 +327,15 @@ button.forgot-password {
.error-label {
color: @error_color;
}
box.folded-history
> overlay
> scrolledwindow
> viewport
> box
> hdycolumn
> box
> list {
padding-left: 6px;
padding-right: 6px;
}

View file

@ -2,6 +2,7 @@ use gettextrs::{bindtextdomain, setlocale, textdomain, LocaleCategory};
use gio::prelude::*;
use gtk;
use gtk::prelude::*;
use libhandy::prelude::*;
use std::cell::RefCell;
use std::ops;
use std::rc::{Rc, Weak};
@ -126,6 +127,39 @@ impl App {
window.get_style_context().map(|c| c.add_class("devel"));
}
let leaflet = ui
.builder
.get_object::<libhandy::Leaflet>("chat_state_leaflet")
.expect("Can't find chat_state_leaflet in ui file.");
let container = ui
.builder
.get_object::<gtk::Box>("history_container")
.expect("Can't find history_container in ui file.");
if let libhandy::Fold::Folded = leaflet.get_fold() {
container
.get_style_context()
.unwrap()
.add_class("folded-history");
}
let weak_container = container.downgrade();
leaflet.connect_property_fold_notify(move |leaflet| {
let container = upgrade_weak!(weak_container);
match leaflet.get_fold() {
libhandy::Fold::Folded => container
.get_style_context()
.unwrap()
.add_class("folded-history"),
libhandy::Fold::Unfolded => container
.get_style_context()
.unwrap()
.remove_class("folded-history"),
_ => (),
}
});
let stack = ui
.builder
.get_object::<gtk::Stack>("main_content_stack")