summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2018-03-24 20:41:06 +0100
committerCarlos Soriano <csoriano@gnome.org>2018-03-24 20:41:06 +0100
commite01c8d3ee52257024592d5591cf2e27b31604af3 (patch)
tree7a71fd187eeacc6fdb8d61ee3efbe567aa364b89
parent9d6f4ba8dd477c0ae074e2c922cd74890909c70e (diff)
downloadnautilus-action-info-bar-triple-section.tar.gz
actionbar: Another prototype, this time info bar in the middleaction-info-bar-triple-section
And buttons in two sections, left and right.
-rw-r--r--src/nautilus-action-bar.c170
-rw-r--r--src/resources/ui/nautilus-action-bar.ui168
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 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
- <property name="border_width">6</property>
+ <property name="border_width">4</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@@ -115,6 +115,11 @@
<class name="image-button"/>
</style>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
</child>
<child>
<object class="GtkButton">
@@ -126,7 +131,7 @@
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">star-new-symbolic</property>
+ <property name="icon_name">non-starred-symbolic</property>
</object>
</child>
<style>
@@ -154,26 +159,17 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="valign">center</property>
<property name="spacing">6</property>
+ <property name="homogeneous">True</property>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="move_to_button">
+ <property name="label" translatable="yes">New Folder…</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="always_show_image">True</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">folder-new-symbolic</property>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- </child>
- <style>
- <class name="image-button"/>
- </style>
+ <property name="tooltip_text" translatable="yes">Create a folder in the current view</property>
+ <property name="action_name">view.new-folder</property>
</object>
<packing>
<property name="expand">False</property>
@@ -182,22 +178,13 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="trash_button2">
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Open</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Move to trash</property>
- <property name="action_name">view.move-to-trash</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">user-trash-symbolic</property>
- </object>
- </child>
- <style>
- <class name="image-button"/>
- </style>
+ <property name="tooltip_text" translatable="yes">Open the selected items</property>
+ <property name="action_name">view.open-with-default-application</property>
</object>
<packing>
<property name="expand">False</property>
@@ -209,96 +196,76 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="padding">6</property>
+ <property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="primary_label">
+ <object class="GtkMenuButton">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="ellipsize">end</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">View more actions</property>
+ <property name="margin_right">6</property>
+ <property name="menu_model">selection-menu</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">view-more-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="image-button"/>
+ </style>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkButton" id="trash_button2">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkButton" id="copy_to_button">
- <property name="label" translatable="yes">Copy to…</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Copy files to a different place</property>
- <property name="action_name">view.copy-to</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="move_to_button">
- <property name="label" translatable="yes">Move to…</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Move files to a different place</property>
- <property name="action_name">view.move-to</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="properties_button">
- <property name="label" translatable="yes">Properties</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Show properties</property>
- <property name="action_name">view.properties</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Move to trash</property>
+ <property name="margin_left">6</property>
+ <property name="action_name">view.move-to-trash</property>
<child>
- <object class="GtkButton">
- <property name="label" translatable="yes">Open</property>
+ <object class="GtkImage">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Open the selected items</property>
- <property name="action_name">view.open-with-default-application</property>
- <style>
- <class name="suggested-action"/>
- </style>
+ <property name="can_focus">False</property>
+ <property name="icon_name">user-trash-symbolic</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
</child>
+ <style>
+ <class name="image-button"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="pack_type">end</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="primary_label">
+ <property name="width_request">200</property>
+ <property name="height_request">-1</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="ellipsize">middle</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
@@ -314,7 +281,6 @@
<property name="valign">center</property>
<property name="border_width">6</property>
<property name="spacing">6</property>
- <property name="valign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>