Commit ef7a2846 authored by Michael Terry's avatar Michael Terry

add username to Home string and guarantee that displayed file strings are utf8

parent 03703d4f
......@@ -431,6 +431,61 @@ public string get_file_desc(File file)
return desc;
}
public string? get_utf8_relative_path (File parent, File child)
{
// Unfortunately, the results of File.get_relative_path() are in local
// encoding, not utf8, and there is no easy function to get a utf8 version.
// So we manually convert.
string s = parent.get_relative_path(child);
try {
return Filename.to_utf8(s, s.length, null, null);
}
catch (ConvertError e) {
warning("%s\n", e.message);
return null;
}
}
static File home;
static File trash;
public async string get_display_name (File f)
{
if (home == null) {
// Fill these out for the first time
home = File.new_for_path(Environment.get_home_dir());
trash = File.new_for_path(DejaDup.get_trash_path());
}
string s;
if (f.equal(home)) {
// Try to use the username in the display because several users have
// previously assumed that "Home" meant "/home", and thus thought they
// were backing up more than they were. This should help avoid such data
// loss accidents.
try {
var info = yield f.query_info_async(FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
// Translators: %s is the user's username
s = _("Home (%s)").printf(info.get_display_name());
}
catch (Error e) {
warning("%s\n", e.message);
s = _("Home");
}
}
else if (f.equal(trash))
s = _("Trash");
else if (f.has_prefix(home)) {
s = get_utf8_relative_path(home, f);
if (s == null)
s = f.get_parse_name();
}
else
s = f.get_parse_name();
return s;
}
public int get_full_backup_threshold()
{
int threshold = 7 * 6; // default to 6 weeks
......
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: mike@mterry.name\n"
"POT-Creation-Date: 2011-07-31 23:34-0400\n"
"POT-Creation-Date: 2011-08-12 11:07-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -312,21 +312,21 @@ msgstr ""
msgid "Scanning…"
msgstr ""
#: ../nautilus/NautilusExtension.c:165
#: ../nautilus/NautilusExtension.c:176
msgid "Restore Missing Files…"
msgstr ""
#: ../nautilus/NautilusExtension.c:166
#: ../nautilus/NautilusExtension.c:177
msgid "Restore deleted files from backup"
msgstr ""
#: ../nautilus/NautilusExtension.c:208
#: ../nautilus/NautilusExtension.c:219
msgid "Revert to Previous Version…"
msgid_plural "Revert to Previous Versions…"
msgstr[0] ""
msgstr[1] ""
#: ../nautilus/NautilusExtension.c:212
#: ../nautilus/NautilusExtension.c:223
msgid "Restore file from backup"
msgid_plural "Restore files from backup"
msgstr[0] ""
......@@ -366,7 +366,7 @@ msgstr ""
msgid "You must specify a Rackspace container in your preferences."
msgstr ""
#: ../common/BackendRackspace.vala:67 ../widgets/ConfigLocation.vala:199
#: ../common/BackendRackspace.vala:67 ../widgets/ConfigLocation.vala:193
msgid "Rackspace Cloud Files"
msgstr ""
......@@ -403,7 +403,7 @@ msgstr ""
msgid "Enter Rackspace Cloud Files API key"
msgstr ""
#: ../common/BackendS3.vala:122 ../widgets/ConfigLocation.vala:183
#: ../common/BackendS3.vala:122 ../widgets/ConfigLocation.vala:177
msgid "Amazon S3"
msgstr ""
......@@ -438,7 +438,7 @@ msgstr ""
msgid "Enter Amazon S3 access key"
msgstr ""
#: ../common/BackendU1.vala:162 ../widgets/ConfigLocation.vala:191
#: ../common/BackendU1.vala:162 ../widgets/ConfigLocation.vala:185
msgid "Ubuntu One"
msgstr ""
......@@ -456,6 +456,20 @@ msgstr ""
msgid "Connect to Ubuntu One"
msgstr ""
#. Translators: %s is the user's username
#: ../common/CommonUtils.vala:469
#, c-format
msgid "Home (%s)"
msgstr ""
#: ../common/CommonUtils.vala:473
msgid "Home"
msgstr ""
#: ../common/CommonUtils.vala:477
msgid "Trash"
msgstr ""
#: ../common/DuplicityInfo.vala:115
msgid "Could not run duplicity"
msgstr ""
......@@ -1181,14 +1195,6 @@ msgstr ""
msgid "No"
msgstr ""
#: ../widgets/ConfigLabelList.vala:52 ../widgets/ConfigList.vala:150
msgid "Home"
msgstr ""
#: ../widgets/ConfigLabelList.vala:54 ../widgets/ConfigList.vala:152
msgid "Trash"
msgstr ""
#: ../widgets/ConfigLabelLocation.vala:75
msgid "Unknown"
msgstr ""
......@@ -1244,48 +1250,48 @@ msgid_plural ""
msgstr[0] ""
msgstr[1] ""
#: ../widgets/ConfigList.vala:86
#: ../widgets/ConfigList.vala:175
msgid "_Add"
msgstr ""
#: ../widgets/ConfigList.vala:87
#: ../widgets/ConfigList.vala:176
msgid "Add"
msgstr ""
#: ../widgets/ConfigList.vala:95
#: ../widgets/ConfigList.vala:184
msgid "_Remove"
msgstr ""
#: ../widgets/ConfigList.vala:96
#: ../widgets/ConfigList.vala:185
msgid "Remove"
msgstr ""
#: ../widgets/ConfigList.vala:189
#: ../widgets/ConfigList.vala:270
msgid "Choose folders"
msgstr ""
#: ../widgets/ConfigLocation.vala:120
#: ../widgets/ConfigLocation.vala:119
msgid "SSH"
msgstr ""
#: ../widgets/ConfigLocation.vala:122
#: ../widgets/ConfigLocation.vala:121
msgid "Windows Share"
msgstr ""
#: ../widgets/ConfigLocation.vala:124
#: ../widgets/ConfigLocation.vala:123
msgid "FTP"
msgstr ""
#: ../widgets/ConfigLocation.vala:126
#: ../widgets/ConfigLocation.vala:125
msgid "WebDAV"
msgstr ""
#: ../widgets/ConfigLocation.vala:129
#: ../widgets/ConfigLocation.vala:128
msgid "Custom Location"
msgstr ""
#. And a local folder option
#: ../widgets/ConfigLocation.vala:135
#: ../widgets/ConfigLocation.vala:134
msgid "Local Folder"
msgstr ""
......
......@@ -44,19 +44,8 @@ public class ConfigLabelList : ConfigLabel
var list = DejaDup.parse_dir_list(slist);
int i = 0;
File home = File.new_for_path(Environment.get_home_dir());
File trash = File.new_for_path(DejaDup.get_trash_path());
foreach (File f in list) {
string s;
if (f.equal(home))
s = _("Home");
else if (f.equal(trash))
s = _("Trash");
else if (f.has_prefix(home))
s = home.get_relative_path(f);
else
s = f.get_parse_name();
string s = yield DejaDup.get_display_name(f);
if (i > 0)
val += ", ";
val += s;
......
......@@ -233,19 +233,9 @@ public class ConfigList : ConfigWidget
model.row_deleted.connect(write_to_config);
int i = 0;
File home = File.new_for_path(Environment.get_home_dir());
File trash = File.new_for_path(DejaDup.get_trash_path());
foreach (File f in list) {
string s;
if (f.equal(home))
s = _("Home");
else if (f.equal(trash))
s = _("Trash");
else if (f.has_prefix(home))
s = home.get_relative_path(f);
else
s = f.get_path();
string s = yield DejaDup.get_display_name(f);
Gtk.TreeIter iter;
model.insert_with_values(out iter, i++, 0, f.get_path(), 1, s);
......
......@@ -391,7 +391,6 @@ public class ConfigLocation : ConfigWidget
{
Gtk.TreeIter iter0;
sort_model.convert_child_iter_to_iter(out iter0, iter);
warning("setting active iter");
button.set_active_iter(iter0);
}
......
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