From eeef0a43300ce05dcd6874659d61916b4ab00aed Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Thu, 27 Oct 2022 17:23:27 -0500 Subject: [PATCH] Search changes, plugin changes --- plugins/favorites/manifest.json | 2 +- plugins/favorites/plugin.py | 4 +- plugins/searcher/manifest.json | 2 +- plugins/searcher/plugin.py | 2 + .../SolarFM/solarfm/core/controller_data.py | 3 - .../mixins/ui/widget_file_action_mixin.py | 35 +++-- .../solarfm/core/mixins/ui/window_mixin.py | 3 - .../SolarFM/solarfm/core/mixins/ui_mixin.py | 2 +- .../core/signals/keyboard_signals_mixin.py | 16 -- .../usr/share/solarfm/Main_Window.glade | 146 +++++++----------- 10 files changed, 87 insertions(+), 128 deletions(-) diff --git a/plugins/favorites/manifest.json b/plugins/favorites/manifest.json index b6f006b..ce8a2f3 100644 --- a/plugins/favorites/manifest.json +++ b/plugins/favorites/manifest.json @@ -8,7 +8,7 @@ "ui_target": "main_menu_bttn_box_bar", "pass_fm_events": "true", "pass_ui_objects": ["path_entry"], - "bind_keys": [] + "bind_keys": ["Favorites||show_favorites_menu:f"] } } } diff --git a/plugins/favorites/plugin.py b/plugins/favorites/plugin.py index e55fe8a..9dc40ed 100644 --- a/plugins/favorites/plugin.py +++ b/plugins/favorites/plugin.py @@ -30,7 +30,7 @@ class Plugin(PluginBase): super().__init__() self.name = "Favorites" # NOTE: Need to remove after establishing private bidirectional 1-1 message bus - # where self.name should not be needed for message comms + # where self.name should not be needed for message comms self.path = os.path.dirname(os.path.realpath(__file__)) self._GLADE_FILE = f"{self.path}/favorites.glade" self._FAVORITES_FILE = f"{self.path}/favorites.json" @@ -70,6 +70,8 @@ class Plugin(PluginBase): with open(self._FAVORITES_FILE, 'a') as f: f.write('[]') + self._event_system.subscribe("show_favorites_menu", self._show_favorites_menu) + def generate_reference_ui_element(self): button = Gtk.Button(label=self.name) diff --git a/plugins/searcher/manifest.json b/plugins/searcher/manifest.json index 845a31f..6b09f7d 100644 --- a/plugins/searcher/manifest.json +++ b/plugins/searcher/manifest.json @@ -7,7 +7,7 @@ "requests": { "ui_target": "context_menu", "pass_fm_events": "true", - "bind_keys": ["Search||_show_grep_list_page:f"] + "bind_keys": ["Search||show_search_page:s"] } } } diff --git a/plugins/searcher/plugin.py b/plugins/searcher/plugin.py index 17eaa63..a154805 100644 --- a/plugins/searcher/plugin.py +++ b/plugins/searcher/plugin.py @@ -76,6 +76,8 @@ class Plugin(IPCServer, FileSearchMixin, GrepSearchMixin, PluginBase): self._event_system.subscribe("update-file-ui", self._load_file_ui) self._event_system.subscribe("update-grep-ui", self._load_grep_ui) + self._event_system.subscribe("show_search_page", self._show_page) + self.create_ipc_listener() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/controller_data.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/controller_data.py index 9f9943c..f842051 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/controller_data.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/controller_data.py @@ -79,9 +79,6 @@ class Controller_Data: self.is_pane4_hidden = False self.override_drop_dest = None - self.is_searching = False - self.search_icon_grid = None - self.search_tab = None self.cancel_creation = False self.skip_edit = False diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/widget_file_action_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/widget_file_action_mixin.py index 04f8400..007008a 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/widget_file_action_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/widget_file_action_mixin.py @@ -102,24 +102,27 @@ class WidgetFileActionMixin: self.set_bottom_labels(tab) - def popup_search_files(self, wid, keyname): - entry = self.builder.get_object(f"win{wid}_search_field") - self.builder.get_object(f"win{wid}_search").popup() - entry.set_text(keyname) - entry.grab_focus_without_selecting() - entry.set_position(-1) - def do_file_search(self, widget, eve=None): - query = widget.get_text().lower() - self.search_icon_grid.unselect_all() - for i, file in enumerate(self.search_tab.get_files()): - if query and query in file[0].lower(): - path = Gtk.TreePath().new_from_indices([i]) - self.search_icon_grid.select_path(path) + if not self.ctrl_down and not self.shift_down and not self.alt_down: + target = widget.get_name() + notebook = self.builder.get_object(target) + page = notebook.get_current_page() + nth_page = notebook.get_nth_page(page) + icon_grid = nth_page.get_children()[0] - items = self.search_icon_grid.get_selected_items() - if len(items) > 0: - self.search_icon_grid.scroll_to_path(items[-1], True, 0.5, 0.5) + wid, tid = icon_grid.get_name().split("|") + tab = self.get_fm_window(wid).get_tab_by_id(tid) + query = widget.get_text().lower() + + icon_grid.unselect_all() + for i, file in enumerate(tab.get_files()): + if query and query in file[0].lower(): + path = Gtk.TreePath().new_from_indices([i]) + icon_grid.select_path(path) + + items = icon_grid.get_selected_items() + if len(items) == 1: + icon_grid.scroll_to_path(items[-1], True, 0.5, 0.5) def open_files(self): diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/window_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/window_mixin.py index fddb9d3..5b3d9b1 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/window_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui/window_mixin.py @@ -161,9 +161,6 @@ class WindowMixin(TabMixin): def grid_set_selected_items(self, icons_grid): self.selected_files = icons_grid.get_selected_items() - def grid_cursor_toggled(self, icons_grid): - print("wat...") - def grid_icon_single_click(self, icons_grid, eve): try: self.path_menu.popdown() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui_mixin.py index d127b28..6d61e3e 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/mixins/ui_mixin.py @@ -11,4 +11,4 @@ from .show_hide_mixin import ShowHideMixin class UIMixin(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin): - pass + ... diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/signals/keyboard_signals_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/signals/keyboard_signals_mixin.py index bde0689..00062a6 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/signals/keyboard_signals_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/core/signals/keyboard_signals_mixin.py @@ -21,7 +21,6 @@ class KeyboardSignalsMixin: self.ctrl_down = False self.shift_down = False self.alt_down = False - self.is_searching = False def on_global_key_press_controller(self, eve, user_data): keyname = Gdk.keyval_name(user_data.keyval).lower() @@ -62,21 +61,6 @@ class KeyboardSignalsMixin: if keyname in ["1", "kp_1", "2", "kp_2", "3", "kp_3", "4", "kp_4"]: self.builder.get_object(f"tggl_notebook_{keyname.strip('kp_')}").released() - if re.fullmatch(valid_keyvalue_pat, keyname): - if not self.is_searching and not self.ctrl_down \ - and not self.shift_down and not self.alt_down: - focused_obj = self.window.get_focus() - if isinstance(focused_obj, Gtk.IconView): - self.is_searching = True - state = self.get_current_state() - self.search_tab = state.tab - self.search_icon_grid = state.icon_grid - - self.unset_keys_and_data() - self.popup_search_files(state.wid, keyname) - return True - - def handle_plugin_key_event(self, sender, eve_type): event_system.emit(eve_type) diff --git a/user_config/usr/share/solarfm/Main_Window.glade b/user_config/usr/share/solarfm/Main_Window.glade index 0176307..c5d79b1 100644 --- a/user_config/usr/share/solarfm/Main_Window.glade +++ b/user_config/usr/share/solarfm/Main_Window.glade @@ -1073,6 +1073,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe + + + window_1 + True + True + edit-find-symbolic + False + False + Search... + + + + False + + False @@ -1111,6 +1126,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe + + + window_2 + True + True + edit-find-symbolic + False + False + Search... + + + + False + + False @@ -1163,6 +1193,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe + + + window_3 + True + True + edit-find-symbolic + False + False + Search... + + + + False + + False @@ -1200,6 +1245,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe + + + window_4 + True + True + edit-find-symbolic + False + False + Search... + + + + False + + False @@ -2045,92 +2105,6 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe - - False - 5 - 5 - 5 - 5 - window_1 - bottom - none - - - - 52 - True - True - - - - - - - False - 5 - 5 - 5 - 5 - window_2 - bottom - none - - - - 96 - True - True - - - - - - - False - 5 - 5 - 5 - 5 - window_3 - none - - - - 96 - True - True - - - - - - - False - 5 - 5 - 5 - 5 - window_4 - none - - - - 96 - True - True - - - - - False False