Skip to content

[Next] Some cleanup of the code #425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/Core/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public class Main : GLib.Object{
}
else{
//timeshift is running from system directory - update app_path
this.app_path = get_cmd_path("timeshift");
this.app_path = Environment.find_program_in_path("timeshift");
}

// initialize lists -----------------
Expand Down Expand Up @@ -347,17 +347,13 @@ public class Main : GLib.Object{
}

public bool check_dependencies(out string msg){

msg = "";

log_debug("Main: check_dependencies()");

string[] dependencies = { "rsync","/sbin/blkid","df","mount","umount","fuser","crontab","cp","rm","touch","ln","sync","which", "run-parts"}; //"shutdown","chroot",
string[] dependencies = { "rsync","/sbin/blkid","df","mount","umount","fuser","crontab","cp","rm","touch","ln","sync", "run-parts"}; //"shutdown","chroot",

string path;
msg = "";
foreach(string cmd_tool in dependencies){
path = get_cmd_path (cmd_tool);
if ((path == null) || (path.length == 0)){
if(!cmd_exists(cmd_tool)) {
msg += " * " + cmd_tool + "\n";
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/Gtk/BootOptionsWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ using TeeJee.Misc;
class BootOptionsWindow : Gtk.Window{

private Gtk.Box vbox_main;
private Gtk.ButtonBox bbox_action;
private BootOptionsBox boot_options_box;

private uint tmr_init;
private int def_width = 450;
private int def_height = 500;

public BootOptionsWindow() {

Expand Down
59 changes: 1 addition & 58 deletions src/Gtk/ExcludeBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -370,44 +370,6 @@ class ExcludeBox : Gtk.Box{
save_changes();
}

private void add_folder_contents_clicked(){

var list = browse_folder();

if (list.length() > 0){
foreach(string item in list){

string pattern = item;

if (!pattern.has_suffix("/**")){
pattern = "%s/**".printf(pattern);
}

/*
NOTE:

+ <dir>/** will include the directory along with the contents
+ <dir>/ will include only the directory without the contents

<dir>/** will exclude the directory contents but include the empty directory
<dir>/ will exclude the directory along with the contents
*/

if (!App.exclude_list_user.contains(pattern)){
App.exclude_list_user.add(pattern);
treeview_add_item(treeview, pattern);
log_debug("contents: %s".printf(pattern));
Main.first_snapshot_size = 0; //re-calculate
}
else{
log_debug("exclude_list_user contains: %s".printf(pattern));
}
}
}

save_changes();
}

private SList<string> browse_files(){

var list = new SList<string>();
Expand Down Expand Up @@ -506,25 +468,6 @@ class ExcludeBox : Gtk.Box{
model.set (iter, 3, !include);
}

private void cell_exclude_text_edited(string path, string new_text) {

string old_pattern;
string new_pattern;

TreeIter iter;
var model = (Gtk.ListStore) treeview.model;
model.get_iter_from_string (out iter, path);
model.get (iter, 0, out old_pattern, -1);

if (old_pattern.has_prefix("+ ")){
new_pattern = "+ " + new_text;
}
else{
new_pattern = new_text;
}
model.set (iter, 0, new_pattern);
}

public void save_changes(){

App.exclude_list_user.clear();
Expand All @@ -540,7 +483,7 @@ class ExcludeBox : Gtk.Box{
if (!App.exclude_list_user.contains(pattern)
&& !App.exclude_list_default.contains(pattern)
&& !App.exclude_list_home.contains(pattern)){

App.exclude_list_user.add(pattern);
}

Expand Down
27 changes: 1 addition & 26 deletions src/Gtk/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,6 @@ class MainWindow : Gtk.Window{

return menu_item;
}

private Gtk.MenuItem create_menu_item_separator(){

var menu_item = new Gtk.MenuItem();
menu_item.sensitive = false;

var box = new Gtk.Box(Orientation.HORIZONTAL, 3);
menu_item.add(box);

box.add(new Gtk.Separator(Gtk.Orientation.HORIZONTAL));

return menu_item;
}

private bool refresh_all(){

Expand Down Expand Up @@ -463,9 +450,7 @@ class MainWindow : Gtk.Window{
var msg = _("Select another device?");

var type = Gtk.MessageType.ERROR;
var buttons_type = Gtk.ButtonsType.YES_NO;

var dlg = new CustomMessageDialog(title, msg, type, this, buttons_type);
var dlg = new CustomMessageDialog(title, msg, type, this, Gtk.ButtonsType.YES_NO);
var response = dlg.run();
dlg.destroy();

Expand Down Expand Up @@ -748,16 +733,6 @@ class MainWindow : Gtk.Window{
restore();
}

private void btn_clone_clicked(){

if (check_if_deletion_running()){
return;
}

App.mirror_system = true;
restore();
}

private bool check_if_deletion_running(){

if (App.thread_delete_running){
Expand Down
3 changes: 0 additions & 3 deletions src/Gtk/MiscBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"%Y-%m-%d %I:%M %p", // 2019-08-11 08:00 PM
"%d %b %Y %I:%M %p", // 11 Aug 2019 08:00 PM
"%Y %b %d, %I:%M %p", // 2019 Aug 11, 08:00 PM
"%c" // Sunday, 11 August 2019 08:00:00 PM IST

Check failure on line 110 in src/Gtk/MiscBox.vala

View workflow job for this annotation

GitHub Actions / build / build (mint22, linuxmintd/mint22-amd64, Mint 22, true) / Mint 22

IST ==> IS, IT, ITS, IT'S, SIT, LIST
}){

index++;
Expand All @@ -131,9 +131,6 @@
bool selected = combo.get_active_iter(out iter_active);
if (!selected){ return; }

TreeIter iter_combo;
var store = (Gtk.ListStore) combo.model;

string txt;
model.get (iter_active, 0, out txt, -1);

Expand Down
5 changes: 0 additions & 5 deletions src/Gtk/RestoreExcludeBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,4 @@ class RestoreExcludeBox : Gtk.Box{
chk_web.toggled();
chk_torrent.toggled();
}

public bool show_all_apps(){

return chk_other.active;
}
}
7 changes: 2 additions & 5 deletions src/Gtk/RestoreWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,8 @@ class RestoreWindow : Gtk.Window{
var title = _("Cancel restore?");

var msg = _("Cancelling the restore process will leave the target system in an inconsistent state. The system may fail to boot or you may run into various issues. After cancelling, you need to restore another snapshot, to bring the system to a consistent state. Click Yes to confirm.");

var type = Gtk.MessageType.ERROR;
var buttons_type = Gtk.ButtonsType.YES_NO;

var dlg = new CustomMessageDialog(title, msg, type, this, buttons_type);

var dlg = new CustomMessageDialog(title, msg, Gtk.MessageType.ERROR, this, Gtk.ButtonsType.YES_NO);
var response = dlg.run();
dlg.destroy();

Expand Down
44 changes: 0 additions & 44 deletions src/Gtk/RsyncLogBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -667,48 +667,4 @@ public class RsyncLogBox : Gtk.Box {
return (item.file_status == status_filter);
}
}

private void exclude_selected_items(){
var list = new Gee.ArrayList<string>();
foreach(var pattern in App.exclude_list_user){
list.add(pattern);
}
App.exclude_list_user.clear();

// TODO: medium: exclude selected items: not working

// add include list
TreeIter iter;
var store = (Gtk.ListStore) treeview.model;
bool iterExists = store.get_iter_first (out iter);
while (iterExists) {
FileItem item;
store.get (iter, 0, out item);

string pattern = item.file_path;

if (item.file_type == FileType.DIRECTORY){
pattern = "%s/***".printf(pattern);
}
else{
//pattern = "%s/***".printf(pattern);
}

if (!App.exclude_list_user.contains(pattern)
&& !App.exclude_list_default.contains(pattern)
&& !App.exclude_list_home.contains(pattern)){

list.add(pattern);
}

iterExists = store.iter_next (ref iter);
}

App.exclude_list_user = list;

log_debug("exclude_selected_items()");
foreach(var item in App.exclude_list_user){
log_debug(item);
}
}
}
6 changes: 4 additions & 2 deletions src/Gtk/SnapshotListBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ class SnapshotListBox : Gtk.Box{
var model = (Gtk.ListStore) treeview.model;
model.get_iter_from_string (out iter, path);
model.get (iter, 0, out bak, -1);
bak.description = new_text;
bak.update_control_file();
if (bak.description != new_text) {
bak.description = new_text;
bak.update_control_file();
}
});

var col_buffer = new TreeViewColumn();
Expand Down
29 changes: 0 additions & 29 deletions src/Gtk/UsersBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -427,33 +427,4 @@ class UsersBox : Gtk.Box{

exclude_box.refresh_treeview();
}

public void save_changes(){

//App.exclude_list_user.clear();

// add include patterns from treeview
/*TreeIter iter;
var store = (Gtk.ListStore) treeview.model;
bool iterExists = store.get_iter_first (out iter);
while (iterExists) {
string pattern;
store.get(iter, 0, out pattern);

if (!App.exclude_list_user.contains(pattern)
&& !App.exclude_list_default.contains(pattern)
&& !App.exclude_list_home.contains(pattern)){

App.exclude_list_user.add(pattern);
}

iterExists = store.iter_next(ref iter);
}*/

log_debug("save_changes(): exclude_list_user:");
foreach(var item in App.exclude_list_user){
log_debug(item);
}
log_debug("");
}
}
4 changes: 2 additions & 2 deletions src/Utility/CronTab.vala
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ public class CronTab : GLib.Object {
}

file_write(file_path, sh);
chown(file_path, "root", "root");
chmod(file_path, "644");
Posix.chown(file_path, 0, 0); // chown to root:root
Posix.chmod(file_path, 0644);

log_msg(_("Added cron task") + ": %s".printf(file_path));

Expand Down
10 changes: 9 additions & 1 deletion src/Utility/Gtk/CustomMessageDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,19 @@ public class CustomMessageDialog : Gtk.Dialog {
// actions -------------------------

switch(buttons_type){
case Gtk.ButtonsType.NONE: break;
case Gtk.ButtonsType.OK:
btn_ok = (Gtk.Button) add_button (_("OK"), Gtk.ResponseType.OK);
btn_ok.grab_focus();
break;
case Gtk.ButtonsType.CLOSE:
btn_cancel = (Gtk.Button) add_button (_("Close"), Gtk.ResponseType.CLOSE);
btn_cancel.grab_focus();
break;
case Gtk.ButtonsType.CANCEL:
btn_cancel = (Gtk.Button) add_button (_("Cancel"), Gtk.ResponseType.CANCEL);
btn_cancel.grab_focus();
break;
case Gtk.ButtonsType.OK_CANCEL:
btn_ok = (Gtk.Button) add_button (_("OK"), Gtk.ResponseType.OK);
btn_cancel = (Gtk.Button) add_button (_("Cancel"), Gtk.ResponseType.CANCEL);
Expand All @@ -157,7 +166,6 @@ public class CustomMessageDialog : Gtk.Dialog {
btn_no = (Gtk.Button) add_button (_("No"), Gtk.ResponseType.NO);
btn_yes.grab_focus();
break;

}
}
}
Expand Down
Loading
Loading