[nautilus/wip/antoniof/properties-followup: 9/21] properties-window: Move size values under name




commit 650d9fdb1fec17b4b442f4c8706a56a5c1b4fa46
Author: António Fernandes <antoniof gnome org>
Date:   Wed Aug 3 13:44:19 2022 +0100

    properties-window: Move size values under name
    
    Instead of list row.
    
    This also means the list box where they used to be becomes the locations list,
    and must be hiden when none of its rows are shown.
    
    As proposed in mockups from https://gitlab.gnome.org/GNOME/nautilus/-/issues/2370

 src/nautilus-file.c                            |   5 +-
 src/nautilus-properties-window.c               |  48 ++++++----
 src/resources/ui/nautilus-properties-window.ui | 125 +++++++++----------------
 3 files changed, 74 insertions(+), 104 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 5961f6858..068b219c0 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -7818,7 +7818,10 @@ nautilus_file_get_volume_free_space (NautilusFile *file)
     res = NULL;
     if (file->details->free_space != (guint64) - 1)
     {
-        res = g_format_size (file->details->free_space);
+        g_autofree gchar *size_string = g_format_size (file->details->free_space);
+
+        /* Translators: This refers to available space in a folder; e.g.: 100 MB Free */
+        res = g_strdup_printf (_("%s Free"), size_string);
     }
 
     return res;
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 7dced1c3d..527f58785 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -93,6 +93,10 @@ struct _NautilusPropertiesWindow
     GtkLabel *name_value_label;
     GtkWidget *type_value_label;
     GtkLabel *type_file_system_label;
+    GtkWidget *size_value_label;
+    GtkWidget *contents_box;
+    GtkWidget *contents_value_label;
+    GtkWidget *free_space_value_label;
 
     GtkWidget *disk_list_box;
     GtkLevelBar *disk_space_level_bar;
@@ -100,12 +104,9 @@ struct _NautilusPropertiesWindow
     GtkWidget *disk_space_free_value;
     GtkWidget *disk_space_capacity_value;
 
+    GtkWidget *locations_list_box;
     GtkWidget *link_target_row;
     GtkWidget *link_target_value_label;
-    GtkWidget *size_row;
-    GtkWidget *size_value_label;
-    GtkWidget *contents_row;
-    GtkWidget *contents_value_label;
     GtkWidget *contents_spinner;
     guint update_directory_contents_timeout_id;
     guint update_files_timeout_id;
@@ -128,9 +129,6 @@ struct _NautilusPropertiesWindow
 
     GtkListBox *extension_list_box;
 
-    GtkWidget *free_space_list_box;
-    GtkWidget *free_space_value_label;
-
     /* Permissions page */
 
     GtkWidget *permissions_stack;
@@ -2004,11 +2002,11 @@ directory_contents_value_field_update (NautilusPropertiesWindow *self)
         {
             if (unreadable_directory_count == 0)
             {
-                text = g_strdup (_("nothing"));
+                text = g_strdup (_("Empty folder"));
             }
             else
             {
-                text = g_strdup (_("unreadable"));
+                text = g_strdup (_("Contents unreadable"));
             }
         }
         else
@@ -2203,6 +2201,7 @@ should_show_file_type (NautilusPropertiesWindow *self)
 
     if (!is_multi_file_window (self)
         && (nautilus_file_is_in_trash (get_target_file (self)) ||
+            nautilus_file_is_directory (get_original_file (self)) ||
             is_network_directory (get_target_file (self)) ||
             is_burn_directory (get_target_file (self)) ||
             is_volume_properties (self)))
@@ -2210,7 +2209,6 @@ should_show_file_type (NautilusPropertiesWindow *self)
         return FALSE;
     }
 
-
     return TRUE;
 }
 
@@ -2454,6 +2452,8 @@ add_updatable_label (NautilusPropertiesWindow *self,
 static void
 setup_basic_page (NautilusPropertiesWindow *self)
 {
+    gboolean should_show_locations_list_box = FALSE;
+
     /* Icon pixmap */
 
     setup_image_widget (self, should_show_custom_icon_buttons (self));
@@ -2478,6 +2478,8 @@ setup_basic_page (NautilusPropertiesWindow *self)
     {
         gtk_widget_show (self->link_target_row);
         add_updatable_label (self, self->link_target_value_label, "link_target");
+
+        should_show_locations_list_box = TRUE;
     }
 
     if (is_multi_file_window (self) ||
@@ -2486,13 +2488,13 @@ setup_basic_page (NautilusPropertiesWindow *self)
         /* We have a more efficient way to measure used space in volumes. */
         if (!is_volume_properties (self))
         {
-            gtk_widget_show (self->contents_row);
+            gtk_widget_show (self->contents_box);
             setup_contents_field (self);
         }
     }
     else
     {
-        gtk_widget_show (self->size_row);
+        gtk_widget_show (self->size_value_label);
         add_updatable_label (self, self->size_value_label, "size_detail");
     }
 
@@ -2500,6 +2502,8 @@ setup_basic_page (NautilusPropertiesWindow *self)
     {
         gtk_widget_show (self->parent_folder_row);
         add_updatable_label (self, self->parent_folder_value_label, "where");
+
+        should_show_locations_list_box = TRUE;
     }
 
     if (should_show_trashed_info (self))
@@ -2535,10 +2539,15 @@ setup_basic_page (NautilusPropertiesWindow *self)
         /* We have a more efficient way to measure free space in volumes. */
         if (!is_volume_properties (self))
         {
-            gtk_widget_show (self->free_space_list_box);
+            gtk_widget_show (self->free_space_value_label);
             add_updatable_label (self, self->free_space_value_label, "free_space");
         }
     }
+
+    if (should_show_locations_list_box)
+    {
+        gtk_widget_show (self->locations_list_box);
+    }
 }
 
 static FilterType
@@ -4213,18 +4222,19 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, name_value_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, type_value_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, type_file_system_label);
+    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, size_value_label);
+    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, contents_box);
+    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, contents_value_label);
+    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, contents_spinner);
+    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, bottom_prompt_seperator);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, disk_list_box);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, disk_space_level_bar);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, disk_space_used_value);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, disk_space_free_value);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, disk_space_capacity_value);
+    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, locations_list_box);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, link_target_row);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, link_target_value_label);
-    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, size_row);
-    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, size_value_label);
-    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, contents_row);
-    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, contents_value_label);
-    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, contents_spinner);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, parent_folder_row);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, parent_folder_value_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, trashed_list_box);
@@ -4239,10 +4249,8 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, accessed_value_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, 
permissions_navigation_row);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, extension_list_box);
-    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, free_space_list_box);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, free_space_value_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_stack);
-    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, bottom_prompt_seperator);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, not_the_owner_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, unknown_permissions_page);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, owner_row);
diff --git a/src/resources/ui/nautilus-properties-window.ui b/src/resources/ui/nautilus-properties-window.ui
index e8f6fd85a..f1ac303ce 100644
--- a/src/resources/ui/nautilus-properties-window.ui
+++ b/src/resources/ui/nautilus-properties-window.ui
@@ -92,9 +92,6 @@
                                     <property name="max-width-chars">24</property>
                                     <property name="selectable">True</property>
                                     <property name="visible">False</property>
-                                    <style>
-                                      <class name="dim-label"/>
-                                    </style>
                                     <attributes>
                                       <attribute name="text-transform"
                                                  value="PANGO_TEXT_TRANSFORM_UPPERCASE"
@@ -114,8 +111,47 @@
                                                  value="PANGO_TEXT_TRANSFORM_UPPERCASE"
                                                  start="0" end="1"/>
                                     </attributes>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="size_value_label">
+                                    <property name="visible">False</property>
+                                    <property name="selectable">True</property>
+                                    <property name="ellipsize">end</property>
+                                    <property name="max-width-chars">40</property>
                                     <style>
-                                      <class name="dim-label"/>
+                                      <class name="caption"/>
+                                    </style>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkBox" id="contents_box">
+                                    <property name="halign">center</property>
+                                    <property name="visible">False</property>
+                                    <property name="spacing">12</property>
+                                    <child>
+                                      <object class="GtkLabel" id="contents_value_label">
+                                        <property name="selectable">True</property>
+                                        <property name="ellipsize">end</property>
+                                        <property name="justify">center</property>
+                                        <property name="max-width-chars">40</property>
+                                      </object>
+                                    </child>
+                                    <child>
+                                      <object class="GtkSpinner" id="contents_spinner">
+                                        <property name="visible">False</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="free_space_value_label">
+                                    <property name="visible">False</property>
+                                    <property name="selectable">True</property>
+                                    <property name="ellipsize">end</property>
+                                    <property name="max-width-chars">24</property>
+                                    <style>
+                                      <class name="caption"/>
                                     </style>
                                   </object>
                                 </child>
@@ -265,7 +301,8 @@
                               </object>
                             </child>
                             <child>
-                              <object class="GtkListBox" id="file_data_list_box">
+                              <object class="GtkListBox" id="locations_list_box">
+                                <property name="visible">False</property>
                                 <property name="selection-mode">none</property>
                                 <child>
                                   <object class="AdwActionRow" id="link_target_row">
@@ -287,56 +324,6 @@
                                     </child>
                                   </object>
                                 </child>
-                                <child>
-                                  <object class="AdwActionRow" id="size_row">
-                                    <property name="visible">False</property>
-                                    <property name="activatable">False</property>
-                                    <property name="selectable">False</property>
-                                    <property name="title" translatable="yes">Size</property>
-                                    <child>
-                                      <object class="GtkLabel" id="size_value_label">
-                                        <property name="hexpand">True</property>
-                                        <property name="selectable">True</property>
-                                        <property name="ellipsize">end</property>
-                                        <property name="max-width-chars">24</property>
-                                        <property name="xalign">1</property>
-                                        <style>
-                                          <class name="dim-label"/>
-                                        </style>
-                                      </object>
-                                    </child>
-                                  </object>
-                                </child>
-                                <child>
-                                  <object class="AdwActionRow" id="contents_row">
-                                    <property name="visible">False</property>
-                                    <property name="activatable">False</property>
-                                    <property name="selectable">False</property>
-                                    <property name="title" translatable="yes">Contents</property>
-                                    <child>
-                                      <object class="GtkBox">
-                                        <property name="spacing">12</property>
-                                        <child>
-                                          <object class="GtkLabel" id="contents_value_label">
-                                            <property name="hexpand">True</property>
-                                            <property name="selectable">True</property>
-                                            <property name="ellipsize">end</property>
-                                            <property name="max-width-chars">24</property>
-                                            <property name="xalign">1</property>
-                                            <style>
-                                              <class name="dim-label"/>
-                                            </style>
-                                          </object>
-                                        </child>
-                                        <child>
-                                          <object class="GtkSpinner" id="contents_spinner">
-                                            <property name="visible">False</property>
-                                          </object>
-                                        </child>
-                                       </object>
-                                    </child>
-                                  </object>
-                                </child>
                                 <child>
                                   <object class="AdwActionRow" id="parent_folder_row">
                                     <property name="visible">False</property>
@@ -606,34 +593,6 @@
                                 </style>
                               </object>
                             </child>
-                            <child>
-                              <object class="GtkListBox" id="free_space_list_box">
-                                <property name="visible">False</property>
-                                <property name="selection-mode">none</property>
-                                <child>
-                                  <object class="AdwActionRow">
-                                    <property name="activatable">False</property>
-                                    <property name="selectable">False</property>
-                                    <property name="title" translatable="yes">Free Space</property>
-                                    <child>
-                                      <object class="GtkLabel" id="free_space_value_label">
-                                        <property name="hexpand">True</property>
-                                        <property name="selectable">True</property>
-                                        <property name="ellipsize">end</property>
-                                        <property name="max-width-chars">24</property>
-                                        <property name="xalign">1</property>
-                                        <style>
-                                          <class name="dim-label"/>
-                                        </style>
-                                      </object>
-                                    </child>
-                                  </object>
-                                </child>
-                                <style>
-                                  <class name="boxed-list"/>
-                                </style>
-                              </object>
-                            </child>
                             <child>
                               <object class="GtkBox" id="volume_widget_box">
                                 <property name="visible">False</property>


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