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