[nautilus] toolbar: Set tooltip for view menu separately from toggle view



commit 512d508679f037d28ca2ed0c3dc0a02367b5543c
Author: Corey Berla <corey berla me>
Date:   Thu Jul 21 21:18:46 2022 +0000

    toolbar: Set tooltip for view menu separately from toggle view
    
    The toggle view button and view menu button are part of a
    AdwSplitButton.  They both show a tooltip for "Show grid" / "Show List"
    since the tooltip is set on the AdwSplitButton.
    
    Set the tooltip for the AdwSplitButton as "View options" (for the
    view menu) and overrid that tooltip for the toggle button using
    adw_split_button_get_child()
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2327

 src/nautilus-toolbar.c               | 5 ++++-
 src/resources/ui/nautilus-toolbar.ui | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index d84742143..0437f25a6 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -1351,6 +1351,7 @@ nautilus_toolbar_set_window_slot_real (NautilusToolbar    *self,
                                        NautilusWindowSlot *slot)
 {
     g_autoptr (GList) children = NULL;
+    GtkWidget *toggle_button;
 
     self->window_slot = slot;
 
@@ -1368,8 +1369,10 @@ nautilus_toolbar_set_window_slot_real (NautilusToolbar    *self,
                                                           self,
                                                           NULL);
 
+        /* HACK. We shouldn't be poking at internal children. But alas, no other option. */
+        toggle_button = gtk_widget_get_parent (adw_split_button_get_child (ADW_SPLIT_BUTTON 
(self->view_split_button)));
         self->tooltip_binding = g_object_bind_property_full (self->window_slot, "tooltip",
-                                                             self->view_split_button, "tooltip-text",
+                                                             toggle_button, "tooltip-text",
                                                              G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
                                                              (GBindingTransformFunc) 
nautilus_toolbar_view_toggle_tooltip_transform_to,
                                                              NULL,
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index b2b5632dc..6d4a92670 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -229,7 +229,7 @@
           <object class="AdwSplitButton" id="view_split_button">
             <property name="halign">center</property>
             <property name="valign">center</property>
-            <property name="tooltip_text" translatable="yes">Toggle view</property>
+            <property name="tooltip_text" translatable="yes">View options</property>
             <property name="action_name">slot.files-view-mode-toggle</property>
             <property name="menu-model">view_menu</property>
             <child>


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