Commit 120797ce authored by Cosimo Cecchi's avatar Cosimo Cecchi

Use a consistent name for the Home folder (#341894)

Based on a patchset by Marcus Husar
<marcus.husar@rose.uni-heidelberg.de>
parent 50e0c03f
......@@ -31,8 +31,9 @@
#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-icon-names.h>
......@@ -195,7 +196,7 @@ nautilus_bookmark_copy (NautilusBookmark *bookmark)
char *
nautilus_bookmark_get_name (NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return g_strdup (bookmark->details->name);
}
......@@ -413,9 +414,15 @@ bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
if (!bookmark->details->has_custom_name) {
display_name = nautilus_file_get_display_name (file);
if (nautilus_file_is_home (file)) {
g_free (bookmark->details->name);
g_free (display_name);
if (strcmp (bookmark->details->name, display_name) != 0) {
bookmark->details->name = g_strdup (_("Home"));
} else if (strcmp (bookmark->details->name, display_name) != 0) {
g_free (bookmark->details->name);
bookmark->details->name = display_name;
should_emit_appearance_changed_signal = TRUE;
} else {
......@@ -516,13 +523,20 @@ nautilus_bookmark_connect_file (NautilusBookmark *bookmark)
if (!bookmark->details->has_custom_name &&
bookmark->details->file &&
nautilus_file_check_if_ready (bookmark->details->file, NAUTILUS_FILE_ATTRIBUTE_INFO)) {
display_name = nautilus_file_get_display_name (bookmark->details->file);
if (strcmp (bookmark->details->name, display_name) != 0) {
g_free (bookmark->details->name);
bookmark->details->name = display_name;
} else {
g_free (display_name);
}
display_name = nautilus_file_get_display_name (bookmark->details->file);
if (nautilus_file_is_home (bookmark->details->file)) {
g_free (bookmark->details->name);
g_free (display_name);
bookmark->details->name = g_strdup (_("Home"));
} else if (strcmp (bookmark->details->name, display_name) != 0) {
g_free (bookmark->details->name);
bookmark->details->name = display_name;
} else {
g_free (display_name);
}
}
}
......@@ -577,8 +591,10 @@ nautilus_bookmark_menu_item_new (NautilusBookmark *bookmark)
GtkWidget *menu_item;
GtkWidget *image_widget;
GtkLabel *label;
menu_item = gtk_image_menu_item_new_with_label (bookmark->details->name);
char *name;
name = nautilus_bookmark_get_name (bookmark);
menu_item = gtk_image_menu_item_new_with_label (name);
label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (menu_item)));
gtk_label_set_use_underline (label, FALSE);
gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
......@@ -591,6 +607,8 @@ nautilus_bookmark_menu_item_new (NautilusBookmark *bookmark)
image_widget);
}
g_free (name);
return menu_item;
}
......
......@@ -117,15 +117,7 @@ home_name_changed (gpointer callback_data)
NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME);
if (link->details->display_name[0] == 0) {
g_free (link->details->display_name);
/* Note to translators: If it's hard to compose a good home
* icon name from the user name, you can use a string without
* an "%s" here, in which case the home icon name will not
* include the user's name, which should be fine. To avoid a
* warning, put "%.0s" somewhere in the string, which will
* match the user name string passed by the C code, but not
* put the user name in the final string.
*/
link->details->display_name = g_strdup_printf (_("%s's Home"), g_get_user_name ());
link->details->display_name = g_strdup (_("Home"));
}
nautilus_desktop_link_changed (link);
......
......@@ -7312,11 +7312,11 @@ static const GtkActionEntry directory_view_entries[] = {
NULL, N_("Move the current selection to the other pane in the window"),
G_CALLBACK (action_move_to_next_pane_callback) },
/* name, stock id, label */ {FM_ACTION_COPY_TO_HOME, NAUTILUS_ICON_HOME,
N_("_Home Folder"), NULL,
N_("_Home"), NULL,
N_("Copy the current selection to the home folder"),
G_CALLBACK (action_copy_to_home_callback) },
/* name, stock id, label */ {FM_ACTION_MOVE_TO_HOME, NAUTILUS_ICON_HOME,
N_("_Home Folder"), NULL,
N_("_Home"), NULL,
N_("Move the current selection to the home folder"),
G_CALLBACK (action_move_to_home_callback) },
/* name, stock id, label */ {FM_ACTION_COPY_TO_DESKTOP, NAUTILUS_ICON_DESKTOP,
......
......@@ -242,6 +242,10 @@ is_built_in_bookmark (NautilusFile *file)
gboolean built_in;
gint idx;
if (nautilus_file_is_home (file)) {
return TRUE;
}
built_in = FALSE;
for (idx = 0; idx < G_USER_N_DIRECTORIES; idx++) {
......@@ -631,18 +635,14 @@ update_places (NautilusPlacesSidebar *sidebar)
/* home folder */
if (strcmp (g_get_home_dir(), desktop_path) != 0) {
char *display_name;
mount_uri = nautilus_get_home_directory_uri ();
display_name = g_filename_display_basename (g_get_home_dir ());
icon = g_themed_icon_new (NAUTILUS_ICON_HOME);
last_iter = add_place (sidebar, PLACES_BUILT_IN,
SECTION_COMPUTER,
display_name, icon,
_("Home"), icon,
mount_uri, NULL, NULL, NULL, 0,
_("Open your personal folder"));
g_object_unref (icon);
g_free (display_name);
compare_for_selection (sidebar,
location, mount_uri, last_uri,
&last_iter, &select_path);
......
......@@ -1313,7 +1313,7 @@ create_tree (FMTreeView *view)
view, G_CONNECT_AFTER);
home_uri = nautilus_get_home_directory_uri ();
icon = g_themed_icon_new (NAUTILUS_ICON_HOME);
fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home Folder"), icon, NULL);
fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home"), icon, NULL);
g_object_unref (icon);
g_free (home_uri);
icon = g_themed_icon_new (NAUTILUS_ICON_FILESYSTEM);
......
......@@ -820,7 +820,7 @@ static const GtkActionEntry main_entries[] = {
/* tooltip */ N_("Connect to a remote computer or shared disk"),
G_CALLBACK (action_connect_to_server_callback) },
/* name, stock id */ { "Home", NAUTILUS_ICON_HOME,
/* label, accelerator */ N_("_Home Folder"), "<alt>Home",
/* label, accelerator */ N_("_Home"), "<alt>Home",
/* tooltip */ N_("Open your personal folder"),
G_CALLBACK (action_home_callback) },
/* name, stock id */ { "Go to Computer", NAUTILUS_ICON_COMPUTER,
......
......@@ -308,9 +308,7 @@ nautilus_window_slot_set_title (NautilusWindowSlot *slot,
slot->title = g_strdup (title);
}
if (eel_strlen (slot->title) > 0 && slot->current_location_bookmark &&
nautilus_bookmark_set_name (slot->current_location_bookmark,
slot->title)) {
if (eel_strlen (slot->title) > 0 && slot->current_location_bookmark) {
changed = TRUE;
/* Name of item in history list changed, tell listeners. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment