From f202cd15bc88e0ec2107af49bec029551d379ca3 Mon Sep 17 00:00:00 2001 From: heliguy4599 Date: Mon, 9 Oct 2023 06:57:35 -0400 Subject: [PATCH] Add open buttons to leftover data window --- src/orphans.blp | 5 +++++ src/orphans_window.py | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/orphans.blp b/src/orphans.blp index 2e556a0..d44da99 100644 --- a/src/orphans.blp +++ b/src/orphans.blp @@ -13,6 +13,11 @@ template OrphansWindow : Adw.Window { icon-name: "system-search-symbolic"; tooltip-text: _("Search for an Installed App"); } + [end] + Button oepn_folder_button { + icon-name: "document-open-symbolic"; + tooltip-text: _("Open the User Data Folder"); + } } [top] SearchBar search_bar { diff --git a/src/orphans_window.py b/src/orphans_window.py index ee92b1f..1901b15 100644 --- a/src/orphans_window.py +++ b/src/orphans_window.py @@ -19,6 +19,7 @@ class OrphansWindow(Adw.Window): action_bar = Gtk.Template.Child() search_bar = Gtk.Template.Child() search_entry = Gtk.Template.Child() + oepn_folder_button = Gtk.Template.Child() window_title = _("Manage Leftover Data") host_home = str(pathlib.Path.home()) @@ -163,6 +164,12 @@ class OrphansWindow(Adw.Window): dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE) dialog.present() + def open_button_handler(self, _widget, path=user_data_path): + try: + Gio.AppInfo.launch_default_for_uri(f"file://{path}", None) + except GLib.GError: + properties_toast_overlay.add_toast(Adw.Toast.new(_("Can't open folder"))) + def sizeThread(self, row, path): row.set_subtitle(self.my_utils.getSizeWithFormat(path)) @@ -199,6 +206,11 @@ class OrphansWindow(Adw.Window): task = Gio.Task.new(None, None, None) task.run_in_thread(lambda _task, _obj, _data, _cancellable: self.sizeThread(dir_row, path)) + open_row_button = Gtk.Button(icon_name="document-open-symbolic", valign=Gtk.Align.CENTER) + open_row_button.add_css_class("flat") + open_row_button.connect("clicked", self.open_button_handler, (self.user_data_path + dir_name)) + dir_row.add_suffix(open_row_button) + select_button = Gtk.CheckButton() select_button.add_css_class("selection-mode") select_button.connect("toggled", self.selectionHandler, dir_name) @@ -244,4 +256,5 @@ class OrphansWindow(Adw.Window): self.list_of_data.set_filter_func(self.filter_func) self.search_entry.connect("search-changed", lambda *_: self.list_of_data.invalidate_filter()) - self.search_bar.connect_entry(self.search_entry) \ No newline at end of file + self.search_bar.connect_entry(self.search_entry) + self.oepn_folder_button.connect("clicked", self.open_button_handler) \ No newline at end of file