Commit 915ce4b3 authored by Michael Terry's avatar Michael Terry

show display name (instead of basename) of files as we back them up

parent dab882e0
......@@ -444,30 +444,41 @@ 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)
void ensure_special_paths ()
{
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());
}
}
public string get_display_name (File f)
{
ensure_special_paths();
if (f.has_prefix(home)) {
// 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 = home.get_relative_path(f);
try {
return Filename.to_utf8(s, s.length, null, null);
}
catch (ConvertError e) {
warning("%s\n", e.message);
}
}
return f.get_parse_name();
}
public async string get_nickname (File f)
{
ensure_special_paths();
string s;
if (f.equal(home)) {
......@@ -488,13 +499,8 @@ public async string get_display_name (File f)
}
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();
else
s = DejaDup.get_display_name(f);
return s;
}
......
......@@ -164,12 +164,11 @@ public abstract class AssistantOperation : Assistant
void set_progress_label_file(DejaDup.Operation op, File file, bool actual)
{
var parse_name = file.get_parse_name();
string prefix;
if (actual) {
prefix = get_progress_file_prefix();
progress_label.label = prefix + " ";
progress_file_label.label = Path.get_basename(parse_name);
progress_file_label.label = DejaDup.get_display_name(file);
}
else {
prefix = _("Scanning:");
......@@ -177,7 +176,7 @@ public abstract class AssistantOperation : Assistant
progress_file_label.label = "";
}
string log_line = prefix + " " + parse_name;
string log_line = prefix + " " + file.get_parse_name();
bool adjustment_at_end = false;
Gtk.Adjustment adjust = progress_scroll.get_vadjustment();
......
......@@ -42,7 +42,7 @@ public class ConfigLabelList : ConfigLabel
var list = DejaDup.parse_dir_list(slist);
foreach (File f in list) {
string s = yield DejaDup.get_display_name(f);
string s = yield DejaDup.get_nickname(f);
if (val != null)
val += ", %s".printf(s);
else
......
......@@ -239,7 +239,7 @@ public class ConfigList : ConfigWidget
int i = 0;
var trash = File.new_for_path(DejaDup.get_trash_path());
foreach (File f in list) {
string s = yield DejaDup.get_display_name(f);
string s = yield DejaDup.get_nickname(f);
Gtk.TreeIter iter;
model.insert_with_values(out iter, i++, 0, f.get_path(), 1, s);
......
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