From e01c8d3ee52257024592d5591cf2e27b31604af3 Mon Sep 17 00:00:00 2001 From: Carlos Soriano Date: Sat, 24 Mar 2018 20:41:06 +0100 Subject: actionbar: Another prototype, this time info bar in the middle And buttons in two sections, left and right. --- src/nautilus-action-bar.c | 170 +++----------------------------- src/resources/ui/nautilus-action-bar.ui | 168 +++++++++++++------------------ 2 files changed, 78 insertions(+), 260 deletions(-) diff --git a/src/nautilus-action-bar.c b/src/nautilus-action-bar.c index 8f320d345..79e607c3d 100644 --- a/src/nautilus-action-bar.c +++ b/src/nautilus-action-bar.c @@ -114,175 +114,27 @@ static void setup_multiple_files_selection (NautilusActionBar *actionbar, GList *selection) { - NautilusFile *file; - goffset non_folder_size; - gboolean non_folder_size_known; - guint non_folder_count, folder_count, folder_item_count; - gboolean folder_item_count_known; - guint file_item_count; - GList *p; + guint count; char *first_item_name; - char *non_folder_count_str; - char *non_folder_item_count_str; - char *folder_count_str; - char *folder_item_count_str; - gchar *primary_text; - gchar *secondary_text; - - folder_item_count_known = TRUE; - folder_count = 0; - folder_item_count = 0; - non_folder_count = 0; - non_folder_size_known = FALSE; - non_folder_size = 0; - first_item_name = NULL; - folder_count_str = NULL; - folder_item_count_str = NULL; - non_folder_count_str = NULL; - non_folder_item_count_str = NULL; - - for (p = selection; p != NULL; p = p->next) - { - file = p->data; - - if (nautilus_file_is_directory (file)) - { - folder_count++; - - if (nautilus_file_get_directory_item_count (file, &file_item_count, NULL)) - folder_item_count += file_item_count; - else - folder_item_count_known = FALSE; - } - else - { - non_folder_count++; - - if (!nautilus_file_can_get_size (file)) - { - non_folder_size_known = TRUE; - non_folder_size += nautilus_file_get_size (file); - } - } - - if (first_item_name == NULL) - first_item_name = nautilus_file_get_display_name (file); - } - - nautilus_file_list_free (selection); - - /* - * Break out cases for localization's sake. But note that there are still pieces - * being assembled in a particular order, which may be a problem for some localizers. - */ - if (folder_count != 0) - { - if (folder_count == 1 && non_folder_count == 0) - { - folder_count_str = g_strdup_printf (_("“%s” selected"), first_item_name); - } - else - { - folder_count_str = g_strdup_printf (ngettext("%'d folder selected", - "%'d folders selected", - folder_count), - folder_count); - } - - if (folder_count == 1) - { - if (!folder_item_count_known) - folder_item_count_str = g_strdup (""); - else - folder_item_count_str = g_strdup_printf (ngettext("(%'d item)", "(%'d items)", folder_item_count), - folder_item_count); - } - else - { - if (!folder_item_count_known) - { - folder_item_count_str = g_strdup (""); - } - else - { - /* translators: this is preceded with a string of form 'N folders' (N more than 1) */ - folder_item_count_str = g_strdup_printf (ngettext("(total of %'d item)", - "(total of %'d items)", - folder_item_count), - folder_item_count); - } - } - } + g_autofree gchar *primary_text = NULL; - if (non_folder_count != 0) - { - if (folder_count == 0) - { - if (non_folder_count == 1) { - non_folder_count_str = g_strdup_printf (_("“%s” selected"), first_item_name); - } else { - non_folder_count_str = g_strdup_printf (ngettext("%'d item selected", - "%'d items selected", - non_folder_count), - non_folder_count); - } - } - else - { - /* Folders selected also, use "other" terminology */ - non_folder_count_str = g_strdup_printf (ngettext("%'d other item selected", - "%'d other items selected", - non_folder_count), - non_folder_count); - } - - if (non_folder_size_known) - { - char *size_string; - - size_string = g_format_size (non_folder_size); - /* This is marked for translation in case a localiser - * needs to use something other than parentheses. The - * the message in parentheses is the size of the selected items. - */ - non_folder_item_count_str = g_strdup_printf (_("(%s)"), size_string); - g_free (size_string); - } - else - { - non_folder_item_count_str = g_strdup (""); - } - } + count = 0; + first_item_name = NULL; - if (folder_count == 0 && non_folder_count == 0) + count = g_list_length (selection); + if (count == 1) { - primary_text = secondary_text = NULL; - } - else if (folder_count == 0) - { - primary_text = g_strdup_printf ("%s, %s", non_folder_count_str, non_folder_item_count_str); - secondary_text = NULL; - } - else if (non_folder_count == 0) - { - primary_text = g_strdup_printf ("%s %s", folder_count_str, folder_item_count_str); - secondary_text = NULL; + first_item_name = nautilus_file_get_display_name (selection->data); + primary_text = g_strdup_printf (_("“%s” selected"), first_item_name); } else { - primary_text = g_strdup_printf ("%s %s", folder_count_str, folder_item_count_str); - secondary_text = g_strdup_printf ("%s, %s", non_folder_count_str, non_folder_item_count_str); + primary_text = g_strdup_printf (_("%'d items selected"), count); } - gtk_label_set_label (GTK_LABEL (actionbar->primary_label), primary_text ? primary_text : ""); + nautilus_file_list_free (selection); - g_free (first_item_name); - g_free (folder_count_str); - g_free (folder_item_count_str); - g_free (non_folder_count_str); - g_free (non_folder_item_count_str); - g_free (secondary_text); - g_free (primary_text); + gtk_label_set_label (GTK_LABEL (actionbar->primary_label), primary_text ? primary_text : ""); } static void diff --git a/src/resources/ui/nautilus-action-bar.ui b/src/resources/ui/nautilus-action-bar.ui index 016e317a6..b5b8d10e4 100644 --- a/src/resources/ui/nautilus-action-bar.ui +++ b/src/resources/ui/nautilus-action-bar.ui @@ -19,7 +19,7 @@ True False center - 6 + 4 True @@ -115,6 +115,11 @@ + + False + True + 3 + @@ -126,7 +131,7 @@ True False - star-new-symbolic + non-starred-symbolic - - - + Create a folder in the current view + view.new-folder False @@ -182,22 +178,13 @@ - + + Open True True True - Move to trash - view.move-to-trash - - - True - False - user-trash-symbolic - - - + Open the selected items + view.open-with-default-application False @@ -209,96 +196,76 @@ False True - 6 + end 1 - + True - False - end + True + True + View more actions + 6 + selection-menu + + + True + False + view-more-symbolic + + + - True + False True - 3 + end + 2 - + True - False - center - 6 - - - Copy to… - True - True - True - Copy files to a different place - view.copy-to - - - False - True - 1 - - - - - Move to… - True - True - True - Move files to a different place - view.move-to - - - False - True - 2 - - - - - Properties - True - True - True - Show properties - view.properties - - - False - True - 3 - - + True + True + Move to trash + 6 + view.move-to-trash - - Open + True - True - True - Open the selected items - view.open-with-default-application - + False + user-trash-symbolic - - False - True - 4 - + False True - end + 3 + + + + + 200 + -1 + True + False + 12 + 12 + 12 + 12 + middle + + + True + True 4 @@ -314,7 +281,6 @@ center 6 6 - center True -- cgit v1.2.1