From 639a1690c8f5c6c49eeacd3763ffe2717240bdf2 Mon Sep 17 00:00:00 2001 From: Aleksandar Dezelin Date: Sat, 1 Oct 2022 16:41:49 +0200 Subject: [PATCH] #2466 Properties for remote server are broken I have modified nautilus-properties-window.c to stop displaying volume usage, location info and permissions for files and volumes which don't have that information. Fixes #2466 Code reformatted. Fixed style check errors. Trying to fix coding style errors. #2466 Properties for remote server are broken I have modified nautilus-properties-window.c to stop displaying volume usage, location info and permissions for files and volumes which don't have that information. Fixes #2466 Uncrustify run to fix the problem with the pipeline style check.. Revert "Uncrustify run to fix the problem with the pipeline style check.." This reverts commit 797a8c5fa1796951aff269d0aff32c06e14142a7. #2466 Properties for remote server are broken I have modified nautilus-properties-window.c to stop displaying volume usage, location info and permissions for files and volumes which don't have that information. Fixes #2466 --- meson.build.user | 286 +++++++++++++++++++++++++++++++ src/nautilus-properties-window.c | 64 ++++++- 2 files changed, 346 insertions(+), 4 deletions(-) create mode 100644 meson.build.user diff --git a/meson.build.user b/meson.build.user new file mode 100644 index 0000000000..e5aacf3ad4 --- /dev/null +++ b/meson.build.user @@ -0,0 +1,286 @@ + + + + + + EnvironmentId + {86f40071-48c9-4d2c-84f6-c7ddab9e7865} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.4.0 GCC 64bit + Desktop Qt 6.4.0 GCC 64bit + qt.qt6.640.gcc_64_kit + 0 + 0 + 0 + + + debug + /home/dezelin/Work/build-nautilus-Desktop_Qt_6_4_0_GCC_64bit-debug + + + + all + true + Build + MesonProjectManager.BuildStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + true + Build + MesonProjectManager.BuildStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + MesonProjectManager.BuildConfiguration + + + + release + /home/dezelin/Work/build-nautilus-Desktop_Qt_6_4_0_GCC_64bit-release + + + + all + true + MesonProjectManager.BuildStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + true + MesonProjectManager.BuildStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + MesonProjectManager.BuildConfiguration + + + + debugoptimized + /home/dezelin/Work/build-nautilus-Desktop_Qt_6_4_0_GCC_64bit-debugoptimized + + + + all + true + MesonProjectManager.BuildStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + true + MesonProjectManager.BuildStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug With Optimizations + MesonProjectManager.BuildConfiguration + + + + minsize + /home/dezelin/Work/build-nautilus-Desktop_Qt_6_4_0_GCC_64bit-minsize + + + + all + true + MesonProjectManager.BuildStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + true + MesonProjectManager.BuildStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Minimum Size + MesonProjectManager.BuildConfiguration + + 4 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + + true + + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c index 1d823edd7d..6de1ff7948 100644 --- a/src/nautilus-properties-window.c +++ b/src/nautilus-properties-window.c @@ -2310,6 +2310,30 @@ is_volume_properties (NautilusPropertiesWindow *self) return success; } +static gboolean +is_volume_usage_valid (NautilusPropertiesWindow *self) +{ + NautilusFile *file; + g_autofree gchar *uri = NULL; + g_autoptr (GFile) location = NULL; + g_autoptr (GFileInfo) info = NULL; + guint64 volume_capacity = 0; + + file = get_original_file (self); + + uri = nautilus_file_get_activation_uri (file); + + location = g_file_new_for_uri (uri); + info = g_file_query_filesystem_info (location, "filesystem::*", NULL, NULL); + + if (info) + { + volume_capacity = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE); + } + + return volume_capacity > 0; +} + static gboolean should_show_custom_icon_buttons (NautilusPropertiesWindow *self) { @@ -2471,7 +2495,7 @@ should_show_free_space (NautilusPropertiesWindow *self) static gboolean should_show_volume_usage (NautilusPropertiesWindow *self) { - return is_volume_properties (self); + return is_volume_properties (self) && is_volume_usage_valid (self); } static void @@ -2656,6 +2680,34 @@ add_updatable_label (NautilusPropertiesWindow *self, self->value_fields = g_list_prepend (self->value_fields, label); } +static gboolean +is_updatable_label_empty (NautilusPropertiesWindow *self, + GtkWidget *label) +{ + GList *file_list = NULL; + const char *attribute_name; + g_autofree char *attribute_value = NULL; + gboolean is_where; + + attribute_name = g_object_get_data (G_OBJECT (self->parent_folder_value_label), "file_attribute"); + + is_where = (g_strcmp0 (attribute_name, "where") == 0); + if (is_where && location_show_original (self)) + { + file_list = self->original_files; + } + else + { + file_list = self->target_files; + } + + attribute_value = file_list_get_string_attribute (file_list, + attribute_name); + + return strlen (attribute_value) == 0; +} + + static void setup_basic_page (NautilusPropertiesWindow *self) { @@ -2712,10 +2764,13 @@ setup_basic_page (NautilusPropertiesWindow *self) if (should_show_location_info (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 (!is_updatable_label_empty (self, self->parent_folder_value_label)) + { + gtk_widget_show (self->parent_folder_row); + should_show_locations_list_box = TRUE; + } } if (should_show_trashed_info (self)) @@ -3708,7 +3763,8 @@ should_show_permissions (NautilusPropertiesWindow *self) for (l = self->original_files; l != NULL; l = l->next) { if (nautilus_file_is_in_trash (NAUTILUS_FILE (l->data)) || - nautilus_file_is_in_recent (NAUTILUS_FILE (l->data))) + nautilus_file_is_in_recent (NAUTILUS_FILE (l->data)) || + !nautilus_file_can_get_permissions (NAUTILUS_FILE (l->data))) { return FALSE; } -- GitLab