Search changes, plugin changes
This commit is contained in:
parent
d0612a2b37
commit
eeef0a4330
|
@ -8,7 +8,7 @@
|
||||||
"ui_target": "main_menu_bttn_box_bar",
|
"ui_target": "main_menu_bttn_box_bar",
|
||||||
"pass_fm_events": "true",
|
"pass_fm_events": "true",
|
||||||
"pass_ui_objects": ["path_entry"],
|
"pass_ui_objects": ["path_entry"],
|
||||||
"bind_keys": []
|
"bind_keys": ["Favorites||show_favorites_menu:<Control>f"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Plugin(PluginBase):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.name = "Favorites" # NOTE: Need to remove after establishing private bidirectional 1-1 message bus
|
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.path = os.path.dirname(os.path.realpath(__file__))
|
||||||
self._GLADE_FILE = f"{self.path}/favorites.glade"
|
self._GLADE_FILE = f"{self.path}/favorites.glade"
|
||||||
self._FAVORITES_FILE = f"{self.path}/favorites.json"
|
self._FAVORITES_FILE = f"{self.path}/favorites.json"
|
||||||
|
@ -70,6 +70,8 @@ class Plugin(PluginBase):
|
||||||
with open(self._FAVORITES_FILE, 'a') as f:
|
with open(self._FAVORITES_FILE, 'a') as f:
|
||||||
f.write('[]')
|
f.write('[]')
|
||||||
|
|
||||||
|
self._event_system.subscribe("show_favorites_menu", self._show_favorites_menu)
|
||||||
|
|
||||||
|
|
||||||
def generate_reference_ui_element(self):
|
def generate_reference_ui_element(self):
|
||||||
button = Gtk.Button(label=self.name)
|
button = Gtk.Button(label=self.name)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"requests": {
|
"requests": {
|
||||||
"ui_target": "context_menu",
|
"ui_target": "context_menu",
|
||||||
"pass_fm_events": "true",
|
"pass_fm_events": "true",
|
||||||
"bind_keys": ["Search||_show_grep_list_page:<Control>f"]
|
"bind_keys": ["Search||show_search_page:<Control>s"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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-file-ui", self._load_file_ui)
|
||||||
self._event_system.subscribe("update-grep-ui", self._load_grep_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()
|
self.create_ipc_listener()
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,6 @@ class Controller_Data:
|
||||||
self.is_pane4_hidden = False
|
self.is_pane4_hidden = False
|
||||||
|
|
||||||
self.override_drop_dest = None
|
self.override_drop_dest = None
|
||||||
self.is_searching = False
|
|
||||||
self.search_icon_grid = None
|
|
||||||
self.search_tab = None
|
|
||||||
|
|
||||||
self.cancel_creation = False
|
self.cancel_creation = False
|
||||||
self.skip_edit = False
|
self.skip_edit = False
|
||||||
|
|
|
@ -102,24 +102,27 @@ class WidgetFileActionMixin:
|
||||||
self.set_bottom_labels(tab)
|
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):
|
def do_file_search(self, widget, eve=None):
|
||||||
query = widget.get_text().lower()
|
if not self.ctrl_down and not self.shift_down and not self.alt_down:
|
||||||
self.search_icon_grid.unselect_all()
|
target = widget.get_name()
|
||||||
for i, file in enumerate(self.search_tab.get_files()):
|
notebook = self.builder.get_object(target)
|
||||||
if query and query in file[0].lower():
|
page = notebook.get_current_page()
|
||||||
path = Gtk.TreePath().new_from_indices([i])
|
nth_page = notebook.get_nth_page(page)
|
||||||
self.search_icon_grid.select_path(path)
|
icon_grid = nth_page.get_children()[0]
|
||||||
|
|
||||||
items = self.search_icon_grid.get_selected_items()
|
wid, tid = icon_grid.get_name().split("|")
|
||||||
if len(items) > 0:
|
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||||
self.search_icon_grid.scroll_to_path(items[-1], True, 0.5, 0.5)
|
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):
|
def open_files(self):
|
||||||
|
|
|
@ -161,9 +161,6 @@ class WindowMixin(TabMixin):
|
||||||
def grid_set_selected_items(self, icons_grid):
|
def grid_set_selected_items(self, icons_grid):
|
||||||
self.selected_files = icons_grid.get_selected_items()
|
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):
|
def grid_icon_single_click(self, icons_grid, eve):
|
||||||
try:
|
try:
|
||||||
self.path_menu.popdown()
|
self.path_menu.popdown()
|
||||||
|
|
|
@ -11,4 +11,4 @@ from .show_hide_mixin import ShowHideMixin
|
||||||
|
|
||||||
|
|
||||||
class UIMixin(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin):
|
class UIMixin(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin):
|
||||||
pass
|
...
|
||||||
|
|
|
@ -21,7 +21,6 @@ class KeyboardSignalsMixin:
|
||||||
self.ctrl_down = False
|
self.ctrl_down = False
|
||||||
self.shift_down = False
|
self.shift_down = False
|
||||||
self.alt_down = False
|
self.alt_down = False
|
||||||
self.is_searching = False
|
|
||||||
|
|
||||||
def on_global_key_press_controller(self, eve, user_data):
|
def on_global_key_press_controller(self, eve, user_data):
|
||||||
keyname = Gdk.keyval_name(user_data.keyval).lower()
|
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"]:
|
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()
|
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):
|
def handle_plugin_key_event(self, sender, eve_type):
|
||||||
event_system.emit(eve_type)
|
event_system.emit(eve_type)
|
||||||
|
|
||||||
|
|
|
@ -1073,6 +1073,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
<child type="tab">
|
<child type="tab">
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="action-end">
|
||||||
|
<object class="GtkSearchEntry" id="win1_search_field">
|
||||||
|
<property name="name">window_1</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="primary-icon-name">edit-find-symbolic</property>
|
||||||
|
<property name="primary-icon-activatable">False</property>
|
||||||
|
<property name="primary-icon-sensitive">False</property>
|
||||||
|
<property name="placeholder-text" translatable="yes">Search...</property>
|
||||||
|
<signal name="changed" handler="do_file_search" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="tab-fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">False</property>
|
<property name="resize">False</property>
|
||||||
|
@ -1111,6 +1126,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
<child type="tab">
|
<child type="tab">
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="action-end">
|
||||||
|
<object class="GtkSearchEntry" id="win2_search_field">
|
||||||
|
<property name="name">window_2</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="primary-icon-name">edit-find-symbolic</property>
|
||||||
|
<property name="primary-icon-activatable">False</property>
|
||||||
|
<property name="primary-icon-sensitive">False</property>
|
||||||
|
<property name="placeholder-text" translatable="yes">Search...</property>
|
||||||
|
<signal name="changed" handler="do_file_search" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="tab-fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">False</property>
|
<property name="resize">False</property>
|
||||||
|
@ -1163,6 +1193,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
<child type="tab">
|
<child type="tab">
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="action-end">
|
||||||
|
<object class="GtkSearchEntry" id="win3_search_field">
|
||||||
|
<property name="name">window_3</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="primary-icon-name">edit-find-symbolic</property>
|
||||||
|
<property name="primary-icon-activatable">False</property>
|
||||||
|
<property name="primary-icon-sensitive">False</property>
|
||||||
|
<property name="placeholder-text" translatable="yes">Search...</property>
|
||||||
|
<signal name="changed" handler="do_file_search" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="tab-fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">False</property>
|
<property name="resize">False</property>
|
||||||
|
@ -1200,6 +1245,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
<child type="tab">
|
<child type="tab">
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
<child type="action-end">
|
||||||
|
<object class="GtkSearchEntry" id="win4_search_field">
|
||||||
|
<property name="name">window_4</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="primary-icon-name">edit-find-symbolic</property>
|
||||||
|
<property name="primary-icon-activatable">False</property>
|
||||||
|
<property name="primary-icon-sensitive">False</property>
|
||||||
|
<property name="placeholder-text" translatable="yes">Search...</property>
|
||||||
|
<signal name="changed" handler="do_file_search" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="tab-fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">False</property>
|
<property name="resize">False</property>
|
||||||
|
@ -2045,92 +2105,6 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkPopover" id="win1_search">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="margin-start">5</property>
|
|
||||||
<property name="margin-end">5</property>
|
|
||||||
<property name="margin-top">5</property>
|
|
||||||
<property name="margin-bottom">5</property>
|
|
||||||
<property name="relative-to">window_1</property>
|
|
||||||
<property name="position">bottom</property>
|
|
||||||
<property name="constrain-to">none</property>
|
|
||||||
<signal name="closed" handler="stop_file_searching" swapped="no"/>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="win1_search_field">
|
|
||||||
<property name="width-request">52</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<signal name="changed" handler="do_file_search" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<style>
|
|
||||||
<class name="search-border"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
<object class="GtkPopover" id="win2_search">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="margin-start">5</property>
|
|
||||||
<property name="margin-end">5</property>
|
|
||||||
<property name="margin-top">5</property>
|
|
||||||
<property name="margin-bottom">5</property>
|
|
||||||
<property name="relative-to">window_2</property>
|
|
||||||
<property name="position">bottom</property>
|
|
||||||
<property name="constrain-to">none</property>
|
|
||||||
<signal name="closed" handler="stop_file_searching" swapped="no"/>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="win2_search_field">
|
|
||||||
<property name="width-request">96</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<signal name="changed" handler="do_file_search" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<style>
|
|
||||||
<class name="search-border"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
<object class="GtkPopover" id="win3_search">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="margin-start">5</property>
|
|
||||||
<property name="margin-end">5</property>
|
|
||||||
<property name="margin-top">5</property>
|
|
||||||
<property name="margin-bottom">5</property>
|
|
||||||
<property name="relative-to">window_3</property>
|
|
||||||
<property name="constrain-to">none</property>
|
|
||||||
<signal name="closed" handler="stop_file_searching" swapped="no"/>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="win3_search_field">
|
|
||||||
<property name="width-request">96</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<signal name="changed" handler="do_file_search" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<style>
|
|
||||||
<class name="search-border"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
<object class="GtkPopover" id="win4_search">
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="margin-start">5</property>
|
|
||||||
<property name="margin-end">5</property>
|
|
||||||
<property name="margin-top">5</property>
|
|
||||||
<property name="margin-bottom">5</property>
|
|
||||||
<property name="relative-to">window_4</property>
|
|
||||||
<property name="constrain-to">none</property>
|
|
||||||
<signal name="closed" handler="stop_file_searching" swapped="no"/>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="win4_search_field">
|
|
||||||
<property name="width-request">96</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<signal name="changed" handler="do_file_search" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<style>
|
|
||||||
<class name="search-border"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
<object class="GtkMessageDialog" id="warning_alert">
|
<object class="GtkMessageDialog" id="warning_alert">
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="resizable">False</property>
|
<property name="resizable">False</property>
|
||||||
|
|
Loading…
Reference in New Issue