[nautilus] gtkplacesview: Name root directory after OS



commit d96a307dafbcf236b997661df364228e8962987a
Author: StarShot <excl13 icloud com>
Date:   Mon Jun 13 12:00:15 2022 +0000

    gtkplacesview: Name root directory after OS
    
    Having a "Computer" palce inside "On This Computer" section does not make
    sense and sounds strange. Also, if someone wants to save files in their
    computer, the "Computer" location might sound like the right place, and
    it's not.
    
    Sometimes the root directory is not even the root of a disk or partition,
    but some special mount (e.g. under ostree).
    
    The root directory is directly related to the operating system, so let's
    name it after the operating system. This helps convey the idea that making
    changes there is going to affect how the system works and possible break it.
    
    Closes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2250

 src/gtk/nautilusgtkplacesview.c |  5 ++++-
 src/nautilus-pathbar.c          | 16 +++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c
index 11d7323b8..f95ff4943 100644
--- a/src/gtk/nautilusgtkplacesview.c
+++ b/src/gtk/nautilusgtkplacesview.c
@@ -1085,6 +1085,7 @@ update_places (NautilusGtkPlacesView *view)
   GIcon *icon;
   GFile *file;
   GtkWidget *child;
+  gchar *osname;
 
   /* Clear all previously added items */
   while ((child = gtk_widget_get_first_child (GTK_WIDGET (view->listbox))))
@@ -1097,11 +1098,13 @@ update_places (NautilusGtkPlacesView *view)
   /* Add "Computer" row */
   file = g_file_new_for_path ("/");
   icon = g_themed_icon_new_with_default_fallbacks ("drive-harddisk");
+  osname = g_get_os_info (G_OS_INFO_KEY_NAME);
 
-  add_file (view, file, icon, _("Computer"), "/", FALSE);
+  add_file (view, file, icon, ((osname != NULL) ? osname : _("Operating System")), "/", FALSE);
 
   g_clear_object (&file);
   g_clear_object (&icon);
+  g_free (osname);
 
   /* Add currently connected drives */
   drives = g_volume_monitor_get_connected_drives (view->volume_monitor);
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index f47d181fd..1b5671b09 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -103,6 +103,8 @@ struct _NautilusPathBar
     GMenu *extensions_section;
     GMenu *templates_submenu;
     GMenu *button_menu;
+
+    gchar *os_name;
 };
 
 G_DEFINE_TYPE (NautilusPathBar, nautilus_path_bar, GTK_TYPE_BOX);
@@ -224,6 +226,8 @@ nautilus_path_bar_init (NautilusPathBar *self)
     GtkBuilder *builder;
     g_autoptr (GError) error = NULL;
 
+    self->os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
+
     self->scrolled = gtk_scrolled_window_new ();
     /* Scroll horizontally only and don't use internal scrollbar. */
     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self->scrolled),
@@ -307,6 +311,7 @@ nautilus_path_bar_finalize (GObject *object)
     g_clear_object (&self->button_menu);
     g_clear_pointer (&self->button_menu_popover, gtk_widget_unparent);
     g_clear_object (&self->current_view_menu_popover);
+    g_free (self->os_name);
 
     unschedule_pop_up_context_menu (NAUTILUS_PATH_BAR (object));
 
@@ -330,9 +335,14 @@ get_dir_name (ButtonData *button_data)
     {
         case ROOT_BUTTON:
         {
+            if (button_data->path_bar != NULL &&
+                button_data->path_bar->os_name != NULL)
+            {
+                return button_data->path_bar->os_name;
+            }
             /* Translators: This is the label used in the pathbar when seeing
              * the root directory (also known as /) */
-            return _("Computer");
+            return _("Operating System");
         }
 
         case ADMIN_ROOT_BUTTON:
@@ -1093,10 +1103,10 @@ make_button_data (NautilusPathBar *self,
     gtk_button_set_child (GTK_BUTTON (button_data->button), child);
     gtk_widget_show (button_data->container);
 
-    nautilus_path_bar_update_button_state (button_data, current_dir);
-
     button_data->path_bar = self;
 
+    nautilus_path_bar_update_button_state (button_data, current_dir);
+
     g_signal_connect (button_data->button, "clicked", G_CALLBACK (button_clicked_cb), button_data);
 
     /* A gesture is needed here, because GtkButton doesn’t react to middle- or


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