Restore Window: Exclude tab: Show relative path in exclude list; show items from ~/.local

This commit is contained in:
Tony George 2014-04-13 12:00:08 +05:30
parent 40978a520b
commit 9957d1ebc2
3 changed files with 59 additions and 31 deletions

View File

@ -512,10 +512,18 @@ public class Main : GLib.Object{
string item = home + "/" + name;
if (!name.has_prefix(".")){ continue; }
if (name == ".config"){ continue; }
if (!dir_exists(item)) { continue; }
if (name == ".local"){ continue; }
if (name == ".gvfs"){ continue; }
if (name.has_suffix(".lock")){ continue; }
AppExcludeEntry entry = new AppExcludeEntry("~/%s/**".printf(name), name[1:name.length]);
exclude_list_apps.add(entry);
if (dir_exists(item)) {
AppExcludeEntry entry = new AppExcludeEntry("~/" + name, false);
exclude_list_apps.add(entry);
}
else{
AppExcludeEntry entry = new AppExcludeEntry("~/" + name, true);
exclude_list_apps.add(entry);
}
}
File f_home_config = File.new_for_path (home + "/.config");
@ -523,10 +531,33 @@ public class Main : GLib.Object{
while ((file = enumerator.next_file ()) != null) {
string name = file.get_name();
string item = home + "/.config/" + name;
if (!dir_exists(item)) { continue; }
if (name.has_suffix(".lock")){ continue; }
AppExcludeEntry entry = new AppExcludeEntry("~/.config/%s/**".printf(name), name);
exclude_list_apps.add(entry);
if (dir_exists(item)) {
AppExcludeEntry entry = new AppExcludeEntry("~/.config/" + name, false);
exclude_list_apps.add(entry);
}
else{
AppExcludeEntry entry = new AppExcludeEntry("~/.config/" + name, true);
exclude_list_apps.add(entry);
}
}
File f_home_local = File.new_for_path (home + "/.local/share");
enumerator = f_home_local.enumerate_children ("standard::*", 0);
while ((file = enumerator.next_file ()) != null) {
string name = file.get_name();
string item = home + "/.local/share/" + name;
if (name.has_suffix(".lock")){ continue; }
if (dir_exists(item)) {
AppExcludeEntry entry = new AppExcludeEntry("~/.local/share/" + name, false);
exclude_list_apps.add(entry);
}
else{
AppExcludeEntry entry = new AppExcludeEntry("~/.local/share/" + name, true);
exclude_list_apps.add(entry);
}
}
}
catch(Error e){
@ -535,7 +566,7 @@ public class Main : GLib.Object{
//sort the list
CompareFunc<AppExcludeEntry> entry_compare = (a, b) => {
return strcmp(a.name,b.name);
return strcmp(a.relpath,b.relpath);
};
exclude_list_apps.sort(entry_compare);
}
@ -1410,12 +1441,12 @@ public class Main : GLib.Object{
//add app entries
foreach(AppExcludeEntry entry in exclude_list_apps){
if (entry.enabled){
pattern = entry.path.replace("~","/home/*");
pattern = entry.pattern();
if (!exclude_list_restore.contains(pattern)){
exclude_list_restore.add(pattern);
}
pattern = entry.path.replace("~","/root");
pattern = entry.pattern(true);
if (!exclude_list_restore.contains(pattern)){
exclude_list_restore.add(pattern);
}
@ -2655,26 +2686,23 @@ public class TimeShiftBackup : GLib.Object{
}
public class AppExcludeEntry : GLib.Object{
public string path = "";
public string name = "";
public string relpath = "";
public bool is_include = false;
public bool is_file = false;
public bool enabled = false;
public AppExcludeEntry(string exclude_pattern, string entry_name = ""){
pattern = exclude_pattern;
name = entry_name;
public AppExcludeEntry(string _relpath, bool _is_file, bool _is_include = false){
relpath = _relpath;
is_file = _is_file;
is_include = _is_include;
}
public string pattern{
owned get{
string str = (is_include) ? "+ " : "";
str += path;
return str.strip();
}
set{
path = value.has_prefix("+ ") ? value[2:value.length] : value;
is_include = value.has_prefix("+ ") ? true : false;
}
public string pattern(bool root_home = false){
string str = (is_include) ? "+ " : "";
str += (root_home) ? "/root" : "/home/*";
str += relpath[1:relpath.length];
str += (is_file) ? "" : "/**";
return str.strip();
}
}

View File

@ -558,7 +558,7 @@ public class RestoreWindow : Gtk.Dialog{
Gee.ArrayList<string> selected_app_list = new Gee.ArrayList<string>();
foreach(AppExcludeEntry entry in App.exclude_list_apps){
if (entry.enabled){
selected_app_list.add(entry.path);
selected_app_list.add(entry.relpath);
}
}
@ -567,7 +567,7 @@ public class RestoreWindow : Gtk.Dialog{
//restore app selections
foreach(AppExcludeEntry entry in App.exclude_list_apps){
if (selected_app_list.contains(entry.path)){
if (selected_app_list.contains(entry.relpath)){
entry.enabled = true;
}
}
@ -654,7 +654,7 @@ public class RestoreWindow : Gtk.Dialog{
private void cell_app_text_render (CellLayout cell_layout, CellRenderer cell, TreeModel model, TreeIter iter){
AppExcludeEntry entry;
model.get (iter, 0, out entry, -1);
(cell as Gtk.CellRendererText).text = entry.name;
(cell as Gtk.CellRendererText).text = entry.relpath;
}
private void cell_app_enabled_toggled (string path){
@ -1052,12 +1052,12 @@ public class RestoreWindow : Gtk.Dialog{
//add app entries
foreach(AppExcludeEntry entry in App.exclude_list_apps){
if (entry.enabled){
string pattern = entry.path.replace("~","/home/*");
string pattern = entry.pattern();
if (!App.exclude_list_restore.contains(pattern)){
App.exclude_list_restore.add(pattern);
}
pattern = entry.path.replace("~","/root");
pattern = entry.pattern(true);
if (!App.exclude_list_restore.contains(pattern)){
App.exclude_list_restore.add(pattern);
}
@ -1082,7 +1082,7 @@ public class RestoreWindow : Gtk.Dialog{
if (!App.exclude_list_restore.contains(timeshift_path)){
App.exclude_list_restore.add(timeshift_path);
}
//save grub install options ----------------------
//App.reinstall_grub2 = chk_restore_grub2.active;

View File

@ -18,7 +18,7 @@ long_line_column=80
[files]
current_page=0
FILE_NAME_0=1589;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Ftimeshift%2Fsrc%2FMain.vala;0;4
FILE_NAME_0=64977;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Ftimeshift%2Fsrc%2FMain.vala;0;4
FILE_NAME_1=3167;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Ftimeshift%2Fsrc%2FMainWindow.vala;0;4
FILE_NAME_2=2953;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Ftimeshift%2Fsrc%2FSettingsWindow.vala;0;4
FILE_NAME_3=3094;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Ftimeshift%2Fsrc%2FRestoreWindow.vala;0;4