[fractal] autocompletion-popover: Fix misplacement on small window widths



commit 37ea7c77aa1228a7ff08f8deb90a6a152bd5b5b7
Author: Daniel Pauls <daniel1708 de+git gmail com>
Date:   Thu Aug 15 19:56:15 2019 +0000

    autocompletion-popover: Fix misplacement on small window widths
    
    Currently the autocompletion-popover has a margin-left in its stylesheet
    which does look misplaced if the window has a small width.
    
    To fix this remove the left margin of the autocompletion-popover once the
    transition between the 'narrow' and 'non-narrow' mode happens.
    
    Fixes https://gitlab.gnome.org/GNOME/fractal/issues/516

 fractal-gtk/res/app.css    |  4 ++++
 fractal-gtk/src/app/mod.rs | 11 ++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/fractal-gtk/res/app.css b/fractal-gtk/res/app.css
index d1b2c3b0..ac9e89d6 100644
--- a/fractal-gtk/res/app.css
+++ b/fractal-gtk/res/app.css
@@ -214,6 +214,10 @@ row .timestamp {
   margin-left: 150px;
 }
 
+.autocomplete.narrow {
+  margin-left: 0;
+}
+
 .autocomplete,
 .autocomplete list,
 .autocomplete row:not(:hover):not(:selected) {
diff --git a/fractal-gtk/src/app/mod.rs b/fractal-gtk/src/app/mod.rs
index 365435fb..92847414 100644
--- a/fractal-gtk/src/app/mod.rs
+++ b/fractal-gtk/src/app/mod.rs
@@ -135,9 +135,14 @@ impl App {
             .builder
             .get_object::<gtk::Box>("history_container")
             .expect("Can't find history_container in ui file.");
+        let popover = ui
+            .builder
+            .get_object::<gtk::Popover>("autocomplete_popover")
+            .expect("Can't find autocomplete_popover in ui file.");
 
         if let libhandy::Fold::Folded = leaflet.get_fold() {
             container.get_style_context().add_class("folded-history");
+            popover.get_style_context().add_class("narrow");
         }
 
         let weak_container = container.downgrade();
@@ -145,9 +150,13 @@ impl App {
             let container = upgrade_weak!(weak_container);
 
             match leaflet.get_fold() {
-                libhandy::Fold::Folded => container.get_style_context().add_class("folded-history"),
+                libhandy::Fold::Folded => {
+                    container.get_style_context().add_class("folded-history");
+                    popover.get_style_context().add_class("narrow");
+                }
                 libhandy::Fold::Unfolded => {
                     container.get_style_context().remove_class("folded-history");
+                    popover.get_style_context().remove_class("narrow");
                 }
                 _ => (),
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]