[fractal] fractal-gtk: Reduce margins when leaflet is folded
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-gtk: Reduce margins when leaflet is folded
- Date: Mon, 29 Apr 2019 08:49:36 +0000 (UTC)
commit f96d72654ac5ad43e070ad38f980ac2979c155ff
Author: Christopher Davis <brainblasted disroot org>
Date: Fri Apr 19 02:52:18 2019 -0400
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
fractal-gtk/res/app.css | 12 ++++++++++++
fractal-gtk/src/app/mod.rs | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
---
diff --git a/fractal-gtk/res/app.css b/fractal-gtk/res/app.css
index b968a482..470a9492 100644
--- a/fractal-gtk/res/app.css
+++ b/fractal-gtk/res/app.css
@@ -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;
+}
diff --git a/fractal-gtk/src/app/mod.rs b/fractal-gtk/src/app/mod.rs
index 0d91fdb4..47dfd04a 100644
--- a/fractal-gtk/src/app/mod.rs
+++ b/fractal-gtk/src/app/mod.rs
@@ -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")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]