diff --git a/src/Core/Main.vala b/src/Core/Main.vala index 0148699..7209340 100644 --- a/src/Core/Main.vala +++ b/src/Core/Main.vala @@ -2756,7 +2756,7 @@ public class Main : GLib.Object{ } } sh_fsck += "echo '' \n"; - int ret_val = exec_script_sync(sh_fsck, null, null, false, false, false, true); + exec_script_sync(sh_fsck, null, null, false, false, false, true); } } diff --git a/src/Core/SnapshotRepo.vala b/src/Core/SnapshotRepo.vala index 125794a..3cdafb2 100755 --- a/src/Core/SnapshotRepo.vala +++ b/src/Core/SnapshotRepo.vala @@ -270,10 +270,6 @@ public class SnapshotRepo : GLib.Object{ else{ return ""; } - - log_debug("SnapshotRepo: unlock_and_mount_device(): exit"); - - return ""; } public Device? unlock_encrypted_device(Device luks_device){ diff --git a/src/Gtk/MainWindow.vala b/src/Gtk/MainWindow.vala index b8d1ce7..6eeca1a 100644 --- a/src/Gtk/MainWindow.vala +++ b/src/Gtk/MainWindow.vala @@ -922,7 +922,7 @@ class MainWindow : Gtk.Window{ private void btn_about_clicked (){ - var dialog = new AboutWindow(); + var dialog = new AboutWindow(this); dialog.set_transient_for (this); dialog.authors = { diff --git a/src/Utility/CronTab.vala b/src/Utility/CronTab.vala index 55d60ce..282a92c 100644 --- a/src/Utility/CronTab.vala +++ b/src/Utility/CronTab.vala @@ -327,7 +327,6 @@ public class CronTab : GLib.Object { log_error("Cron directory type parameter not valid" + ": %s".printf(cron_dir_type)); log_error("Expected values: d, hourly, daily, weekly, monthly"); return false; - break; } string file_path = "/etc/cron.%s/%s".printf(cron_dir_type, file_name.replace(".","-")); // dot is not allowed in file name diff --git a/src/Utility/Device.vala b/src/Utility/Device.vala index 3daa5bb..18f09de 100755 --- a/src/Utility/Device.vala +++ b/src/Utility/Device.vala @@ -1962,51 +1962,10 @@ public class Device : GLib.Object{ return "%s".printf(tt); } - private string display_name(bool short_name = true, bool show_label = true, bool show_parent = true, bool show_alias = false){ - - string txt = ""; - - if (short_name){ - txt += kname; - } - else{ - txt += device; - } - - if (type == "disk"){ - if (vendor.length > 0){ - txt += " " + vendor; - } - if (model.length > 0){ - txt += " " + model; - } - if (size_bytes > 0) { - if (txt.strip().length == 0){ - txt += "%s Device".printf(format_file_size(size_bytes, false, "", true, 0)); - } - else{ - txt += " (%s)".printf(format_file_size(size_bytes, false, "", true, 0)); - } - } - } - else{ - if (show_label && (label.length > 0)){ - txt += "(%s)".printf(label); - } - if (show_parent && has_parent() && (parent.type == "part")){ // TODO: if parent is crypt (like lvm on luks) - txt += "(%s)".printf(pkname); - } - if (show_alias && (mapped_name.length > 0)){ - txt += "(%s)".printf(mapped_name); - } - } - - return txt; - } - // testing ----------------------------------- public static void test_all(){ + var list = get_block_devices_using_lsblk(); log_msg("\n> get_block_devices_using_lsblk()"); print_device_list(list); diff --git a/src/Utility/Gtk/AboutWindow.vala b/src/Utility/Gtk/AboutWindow.vala index d4561e5..6d8db8d 100644 --- a/src/Utility/Gtk/AboutWindow.vala +++ b/src/Utility/Gtk/AboutWindow.vala @@ -31,7 +31,7 @@ using TeeJee.GtkHelper; using TeeJee.System; using TeeJee.Misc; -public class AboutWindow : Dialog { +public class AboutWindow : Gtk.Window { private Gtk.Box vbox_main; private Gtk.Box vbox_logo; @@ -42,6 +42,7 @@ public class AboutWindow : Dialog { private Gtk.Button btn_license; private Gtk.Button btn_credits; private Gtk.Button btn_close; + private Gtk.Window window; private Gtk.Image img_logo; private Gtk.Label lbl_program_name; @@ -203,22 +204,26 @@ public class AboutWindow : Dialog { private string username = ""; - public AboutWindow() { + public AboutWindow(Gtk.Window _window) { + + window = _window; window_position = WindowPosition.CENTER_ON_PARENT; set_destroy_with_parent (true); set_modal (true); skip_taskbar_hint = false; - set_default_size (450, 400); + set_default_size(450, 450); if (get_user_id_effective() == 0){ username = get_username(); + log_debug("username: %s".printf(username)); } - - vbox_main = get_content_area(); - vbox_main.margin = 6; + + vbox_main = new Gtk.Box(Orientation.VERTICAL,0); + vbox_main.margin = 12; vbox_main.spacing = 6; - + this.add(vbox_main); + vbox_logo = new Gtk.Box(Orientation.VERTICAL,0); vbox_main.add(vbox_logo); @@ -243,7 +248,6 @@ public class AboutWindow : Dialog { label.wrap_mode = Pango.WrapMode.WORD_CHAR; label.use_markup = true; label.margin = 6; - label.margin_right = 25; sw_license.add(label); lbl_license = label; @@ -309,8 +313,8 @@ public class AboutWindow : Dialog { } private void add_action_buttons(){ - - hbox_action = (Box) get_action_area(); + + hbox_action = add_button_box(vbox_main, Gtk.Orientation.HORIZONTAL, Gtk.ButtonBoxStyle.CENTER, 6); //btn_license btn_license = new Gtk.Button.with_label(" " + _("License")); diff --git a/src/Utility/Gtk/CustomMessageDialog.vala b/src/Utility/Gtk/CustomMessageDialog.vala index 6c955d9..e02c815 100644 --- a/src/Utility/Gtk/CustomMessageDialog.vala +++ b/src/Utility/Gtk/CustomMessageDialog.vala @@ -48,9 +48,7 @@ public class CustomMessageDialog : Gtk.Dialog { private Gtk.MessageType msg_type; private Gtk.ButtonsType buttons_type; - public CustomMessageDialog( - string _msg_title, string _msg_body, - Gtk.MessageType _msg_type, Window? parent, Gtk.ButtonsType _buttons_type) { + public CustomMessageDialog(string _msg_title, string _msg_body, Gtk.MessageType _msg_type, Window? parent, Gtk.ButtonsType _buttons_type) { set_transient_for(parent); set_modal(true); @@ -62,34 +60,18 @@ public class CustomMessageDialog : Gtk.Dialog { init_window(); - //lbl_msg.label += string.nfill(4000, 'n'); - lbl_msg.expand = true; sw_msg.expand = true; sw_msg.vscrollbar_policy = PolicyType.NEVER; - - //log_debug("0: label=%dx%d".printf(lbl_msg.get_allocated_width(), lbl_msg.get_allocated_height())); - //log_debug("0: scroll=%dx%d".printf(sw_msg.get_allocated_width(), sw_msg.get_allocated_height())); sw_msg.set_size_request(500, 150); // sets minimum size - //log_debug("0: label=%dx%d".printf(lbl_msg.get_allocated_width(), lbl_msg.get_allocated_height())); - //log_debug("0: scroll=%dx%d".printf(sw_msg.get_allocated_width(), sw_msg.get_allocated_height())); - show_all(); - //log_debug("1: label=%dx%d".printf(lbl_msg.get_allocated_width(), lbl_msg.get_allocated_height())); - //log_debug("1: scroll=%dx%d".printf(sw_msg.get_allocated_width(), sw_msg.get_allocated_height())); - if (lbl_msg.get_allocated_height() > 400){ sw_msg.vscrollbar_policy = PolicyType.AUTOMATIC; sw_msg.set_size_request(500, 400); - //gtk_do_events(); - //this.set_position(WindowPosition.CENTER); } - - //log_debug("1: label=%dx%d".printf(lbl_msg.get_allocated_width(), lbl_msg.get_allocated_height())); - //log_debug("1: scroll=%dx%d".printf(sw_msg.get_allocated_width(), sw_msg.get_allocated_height())); } public void init_window () { @@ -131,7 +113,6 @@ public class CustomMessageDialog : Gtk.Dialog { // image ---------------- var img = new Image.from_icon_name(icon_name, Gtk.IconSize.DIALOG); - img.margin_right = 12; hbox_contents.add(img); // label ------------------- @@ -146,8 +127,7 @@ public class CustomMessageDialog : Gtk.Dialog { lbl_msg.wrap = true; lbl_msg.wrap_mode = Pango.WrapMode.WORD_CHAR; lbl_msg.use_markup = true; - lbl_msg.margin_right = 25; - + //sw_msg sw_msg = new Gtk.ScrolledWindow(null, null); //sw_msg.set_shadow_type (ShadowType.ETCHED_IN); @@ -159,9 +139,6 @@ public class CustomMessageDialog : Gtk.Dialog { // actions ------------------------- - var action_area = get_action_area () as Gtk.Box; - action_area.margin_top = 12; - switch(buttons_type){ case Gtk.ButtonsType.OK: btn_ok = (Gtk.Button) add_button (_("OK"), Gtk.ResponseType.OK); diff --git a/src/Utility/GtkHelper.vala b/src/Utility/GtkHelper.vala index 5478ccd..9ac2f7e 100644 --- a/src/Utility/GtkHelper.vala +++ b/src/Utility/GtkHelper.vala @@ -115,11 +115,8 @@ namespace TeeJee.GtkHelper{ content.margin = 6; //add buttons - var actions = (Box) dlg.get_action_area (); dlg.add_button(_("OK"),Gtk.ResponseType.OK); dlg.add_button(_("Cancel"),Gtk.ResponseType.CANCEL); - //actions.margin = 6; - actions.margin_top = 12; //keyboard shortcuts txt_input.key_press_event.connect ((w, event) => { @@ -308,7 +305,6 @@ namespace TeeJee.GtkHelper{ // TreeView var treeview = new TreeView(); treeview.get_selection().mode = selection_mode; - treeview.set_rules_hint (true); treeview.show_expanders = true; treeview.enable_tree_lines = true; @@ -450,10 +446,7 @@ namespace TeeJee.GtkHelper{ if (show_border){ scroll.set_shadow_type (ShadowType.ETCHED_IN); } - else{ - label.margin_left = 0; - } - + return label; } @@ -498,7 +491,6 @@ namespace TeeJee.GtkHelper{ private Gtk.Label add_label_subnote(Gtk.Box box, string text){ var label = add_label(box, text, false, true); - label.margin_left = 6; return label; } @@ -590,70 +582,26 @@ namespace TeeJee.GtkHelper{ return button; } - - // add_toggle_button - private Gtk.ToggleButton add_toggle_button(Gtk.Box box, string text, string tooltip, Gtk.SizeGroup? size_group, Gtk.Image? icon = null){ - - var button = new Gtk.ToggleButton(); - box.add(button); - - button.set_label(text); - button.set_tooltip_text(tooltip); - - if (icon != null){ - button.set_image(icon); - button.set_always_show_image(true); - } - - if (size_group != null){ - size_group.add_widget(button); - } - - return button; - } - // add_directory_chooser - private Gtk.Entry add_directory_chooser(Gtk.Box box, string selected_directory, Gtk.Window parent_window){ - - // Entry - var entry = new Gtk.Entry(); - entry.hexpand = true; - //entry.margin_left = 6; - entry.secondary_icon_stock = "gtk-open"; - entry.placeholder_text = _("Enter path or browse for directory"); - box.add (entry); + public Gtk.ButtonBox add_button_box(Gtk.Container box, Gtk.Orientation orientation = Gtk.Orientation.HORIZONTAL, + Gtk.ButtonBoxStyle layout = Gtk.ButtonBoxStyle.CENTER, int spacing = 6){ - if ((selected_directory != null) && dir_exists(selected_directory)){ - entry.text = selected_directory; - } + var bbox = new Gtk.ButtonBox(orientation); + bbox.set_layout(layout); + bbox.set_spacing(spacing); + box.add(bbox); - entry.icon_release.connect((p0, p1) => { - //chooser - var chooser = new Gtk.FileChooserDialog( - _("Select Path"), - parent_window, - FileChooserAction.SELECT_FOLDER, - "_Cancel", - Gtk.ResponseType.CANCEL, - "_Open", - Gtk.ResponseType.ACCEPT - ); - - chooser.select_multiple = false; - chooser.set_filename(selected_directory); - - if (chooser.run() == Gtk.ResponseType.ACCEPT) { - entry.text = chooser.get_filename(); - - //App.repo = new SnapshotRepo.from_path(entry.text, this); - //check_backup_location(); - } - - chooser.destroy(); - }); - - return entry; + /* + Gtk.ButtonBoxStyle.CENTER + CENTER - Buttons are centered in the box. + EDGE - Buttons are placed at the edges of the box. + END - Buttons are grouped towards the end of the box, (on the right for a HBox, or the bottom for a VBox). + EXPAND - Buttons expand to fill the box. + SPREAD - Buttons are evenly spread across the box. + START - Buttons are grouped towards the start of the box, (on the left for a HBox, or the top for a VBox). + */ + + return bbox; } - } diff --git a/src/Utility/TeeJee.Process.vala b/src/Utility/TeeJee.Process.vala index 5541521..eb11f6e 100644 --- a/src/Utility/TeeJee.Process.vala +++ b/src/Utility/TeeJee.Process.vala @@ -422,13 +422,13 @@ namespace TeeJee.ProcessHelper{ * */ int[] child_pids = get_process_children (process_pid); - Posix.kill (process_pid, Posix.SIGTERM); + Posix.kill (process_pid, Posix.Signal.TERM); if (killChildren){ Pid childPid; foreach (long pid in child_pids){ childPid = (Pid) pid; - Posix.kill (childPid, Posix.SIGTERM); + Posix.kill (childPid, Posix.Signal.TERM); } } } @@ -441,13 +441,13 @@ namespace TeeJee.ProcessHelper{ * */ int[] child_pids = get_process_children (process_pid); - Posix.kill (process_pid, Posix.SIGKILL); + Posix.kill (process_pid, Posix.Signal.KILL); if (killChildren){ Pid childPid; foreach (long pid in child_pids){ childPid = (Pid) pid; - Posix.kill (childPid, Posix.SIGKILL); + Posix.kill (childPid, Posix.Signal.KILL); } } } diff --git a/src/Utility/TeeJee.System.vala b/src/Utility/TeeJee.System.vala index 882ae5b..239d416 100644 --- a/src/Utility/TeeJee.System.vala +++ b/src/Utility/TeeJee.System.vala @@ -275,14 +275,6 @@ namespace TeeJee.System{ return list; } - public int get_display_width(){ - return Gdk.Screen.get_default().get_width(); - } - - public int get_display_height(){ - return Gdk.Screen.get_default().get_height(); - } - // internet helpers ---------------------- public bool shutdown (){