[gnome-software: 1/2] gs-shell: Move the notifications overlay to below the header bar




commit 1fc45bb4cb896697dfb478297233757ab871a6b6
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Jul 30 13:33:30 2021 +0100

    gs-shell: Move the notifications overlay to below the header bar
    
    So that it doesn’t obscure the header bar and make navigation impossible
    until it’s dismissed.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Fixes: #1339

 src/gs-shell.c  | 28 ++++++++++++++++++++++++++++
 src/gs-shell.ui |  1 +
 2 files changed, 29 insertions(+)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 93fc4b77f..00e8ecefa 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -617,6 +617,33 @@ gs_shell_change_mode (GsShell *shell,
                gs_page_scroll_up (page);
 }
 
+static gboolean
+overlay_get_child_position_cb (GtkOverlay   *overlay,
+                               GtkWidget    *widget,
+                               GdkRectangle *allocation,
+                               gpointer      user_data)
+{
+       GsShell *self = GS_SHELL (user_data);
+       GtkRequisition overlay_natural_size;
+
+       /* Override the default position of the in-app notification overlay
+        * to position it below the header bar. The overlay can’t easily be
+        * moved in the widget hierarchy so it doesn’t have the header bar as
+        * a child, since there are several header bars in different pages of
+        * a HdyDeck. */
+       g_assert (gtk_widget_is_ancestor (self->main_header, GTK_WIDGET (overlay)));
+
+       gtk_widget_get_preferred_size (widget, NULL, &overlay_natural_size);
+
+       allocation->width = overlay_natural_size.width;
+       allocation->height = overlay_natural_size.height;
+
+       allocation->x = gtk_widget_get_allocated_width (GTK_WIDGET (overlay)) / 2 - 
overlay_natural_size.width / 2;
+       allocation->y = gtk_widget_get_allocated_height (GTK_WIDGET (self->main_header));
+
+       return TRUE;
+}
+
 static void
 gs_overview_page_button_cb (GtkWidget *widget, GsShell *shell)
 {
@@ -2542,6 +2569,7 @@ gs_shell_class_init (GsShellClass *klass)
        gtk_widget_class_bind_template_callback (widget_class, gs_shell_metered_updates_bar_response_cb);
        gtk_widget_class_bind_template_callback (widget_class, stack_notify_visible_child_cb);
        gtk_widget_class_bind_template_callback (widget_class, initial_refresh_done);
+       gtk_widget_class_bind_template_callback (widget_class, overlay_get_child_position_cb);
 }
 
 static void
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index 7b19ce829..48a3a2332 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -37,6 +37,7 @@
             <property name="halign">fill</property>
             <property name="valign">fill</property>
             <property name="vexpand">True</property>
+            <signal name="get-child-position" handler="overlay_get_child_position_cb"/>
             <child type="overlay">
               <object class="GtkRevealer" id="notification_event">
                 <property name="visible">True</property>


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