[nautilus/wip/apoos-maximus/gsoc2020] properties-window: Add conditional prompt labels to the template



commit 5953986ca571209df0f56fc1760c782d9d6c17e6
Author: Apoorv Sachan <apoorv 99 sachan gmail com>
Date:   Fri Jun 19 17:01:05 2020 +0530

    properties-window: Add conditional prompt labels to the template
    
    Also document the code generating label text containing file names.

 src/nautilus-properties-window.c               | 28 ++++++++++++------
 src/resources/ui/nautilus-properties-window.ui | 41 +++++++++++++++++++++++++-
 2 files changed, 59 insertions(+), 10 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 9445d737b..004874827 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -148,6 +148,11 @@ struct _NautilusPropertiesWindow
     GtkWidget *permissions_box;
     GtkWidget *permissions_grid;
 
+    GtkWidget *bottom_prompt_seperator;
+    GtkWidget *not_the_owner_label;
+
+    GtkWidget *permission_indeterminable_label;
+
     GroupChange *group_change;
     OwnerChange *owner_change;
 
@@ -4702,9 +4707,8 @@ create_permissions_page (NautilusPropertiesWindow *window)
 
         if (!all_can_set_permissions (file_list))
         {
-            add_prompt_and_separator (
-                window->permissions_box,
-                _("You are not the owner, so you cannot change these permissions."));
+            gtk_widget_show (window->not_the_owner_label);
+            gtk_widget_show (window->bottom_prompt_seperator);
         }
 
         gtk_widget_show (window->permissions_grid);
@@ -4739,19 +4743,22 @@ create_permissions_page (NautilusPropertiesWindow *window)
     }
     else
     {
+        /*
+         *  This if block only gets executed if its a single file window,
+         *  in which case the label text needs to be different from the
+         *  default label text. The default label text for a multifile
+         *  window is set in nautilus-properties-window.ui so no else block.
+         */
         if (!is_multi_file_window (window))
         {
             file_name = nautilus_file_get_display_name (get_target_file (window));
             prompt_text = g_strdup_printf (_("The permissions of “%s” could not be determined."), file_name);
+            gtk_label_set_text (GTK_LABEL (window->permission_indeterminable_label), prompt_text);
             g_free (file_name);
-        }
-        else
-        {
-            prompt_text = g_strdup (_("The permissions of the selected file could not be determined."));
+            g_free (prompt_text);
         }
 
-        add_prompt (window->permissions_box, prompt_text, TRUE);
-        g_free (prompt_text);
+        gtk_widget_show (window->permission_indeterminable_label);
     }
 }
 
@@ -5793,6 +5800,9 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, open_in_disks_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_box);
     gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_grid);
+    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, 
permission_indeterminable_label);
 }
 
 static void
diff --git a/src/resources/ui/nautilus-properties-window.ui b/src/resources/ui/nautilus-properties-window.ui
index 4b710af78..1e91d3037 100644
--- a/src/resources/ui/nautilus-properties-window.ui
+++ b/src/resources/ui/nautilus-properties-window.ui
@@ -486,6 +486,45 @@
                 <property name="can_focus">False</property>
                 <property name="border_width">12</property>
                 <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkLabel" id="not_the_owner_label">
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">You are not the owner, so you cannot change 
these permissions.</property>
+                    <property name="wrap">True</property>
+                    <property name="max_width_chars">40</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSeparator" id="bottom_prompt_seperator">
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="padding">12</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="permission_indeterminable_label">
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">The permissions of the selected file could not 
be determined.</property>
+                    <property name="wrap">True</property>
+                    <property name="max_width_chars">40</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
                 <child>
                   <object class="GtkGrid" id="permissions_grid">
                     <property name="can_focus">False</property>
@@ -503,7 +542,7 @@
                   <packing>
                     <property name="expand">True</property>
                     <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="position">4</property>
                   </packing>
                 </child>
               </object>


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