Added file search
This commit is contained in:
parent
19c683d9c7
commit
49ebfc6293
@ -82,6 +82,11 @@ class Controller_Data:
|
||||
self.is_pane3_hidden = False
|
||||
self.is_pane4_hidden = False
|
||||
|
||||
self.is_searching = False
|
||||
self.search_iconview = None
|
||||
self.search_view = None
|
||||
|
||||
|
||||
self.skip_edit = False
|
||||
self.cancel_edit = False
|
||||
self.ctrlDown = False
|
||||
|
@ -1,4 +1,5 @@
|
||||
# Python imports
|
||||
import re
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
@ -9,6 +10,7 @@ from gi.repository import Gtk, Gdk
|
||||
# Application imports
|
||||
|
||||
|
||||
valid_fname_pat = re.compile(r"[a-z0-9A-Z-_\[\]\(\)\| ]")
|
||||
|
||||
|
||||
class KeyboardSignalsMixin:
|
||||
@ -37,6 +39,16 @@ class KeyboardSignalsMixin:
|
||||
if "alt" in keyname:
|
||||
self.altDown = False
|
||||
|
||||
|
||||
if re.fullmatch(valid_fname_pat, keyname):
|
||||
if not self.ctrlDown and not self.shiftDown and not self.altDown:
|
||||
if not self.is_searching:
|
||||
self.is_searching = True
|
||||
wid, tid, self.search_view, self.search_iconview, store = self.get_current_state()
|
||||
self.popup_search_files(wid, keyname)
|
||||
return
|
||||
|
||||
|
||||
if self.ctrlDown and self.shiftDown and keyname == "t":
|
||||
self.trash_files()
|
||||
|
||||
|
@ -13,6 +13,9 @@ class ShowHideMixin:
|
||||
def show_messages_popup(self, type, text, seconds=None):
|
||||
self.message_widget.popup()
|
||||
|
||||
def stop_file_searching(self, widget=None, eve=None):
|
||||
self.is_searching = False
|
||||
|
||||
|
||||
def show_exists_page(self, widget=None, eve=None):
|
||||
response = self.file_exists_dialog.run()
|
||||
|
@ -55,6 +55,19 @@ class WidgetFileActionMixin:
|
||||
|
||||
|
||||
|
||||
def popup_search_files(self, wid, keyname):
|
||||
entry = self.builder.get_object(f"win{wid}_search_field")
|
||||
entry.set_text(keyname)
|
||||
entry.grab_focus_without_selecting()
|
||||
self.builder.get_object(f"win{wid}_search").popup()
|
||||
|
||||
def do_file_search(self, widget, eve=None):
|
||||
query = widget.get_text()
|
||||
self.search_iconview.unselect_all()
|
||||
for i, file in enumerate(self.search_view.files):
|
||||
if query and query in file.lower():
|
||||
path = Gtk.TreePath().new_from_indices([i])
|
||||
self.search_iconview.select_path(path)
|
||||
|
||||
def open_files(self):
|
||||
wid, tid, view, iconview, store = self.get_current_state()
|
||||
|
@ -1658,6 +1658,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||
<property name="name">notebook1</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="can-default">True</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
@ -1695,6 +1696,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||
<property name="name">notebook2</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="can-default">True</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
@ -1746,6 +1748,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||
<property name="name">notebook3</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="can-default">True</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
@ -1783,6 +1786,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||
<property name="name">notebook4</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="can-default">True</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
@ -1882,6 +1886,92 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||
</object>
|
||||
</child>
|
||||
</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="GtkImage" id="trash_img">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
|
@ -35,6 +35,10 @@ notebook > header > tabs > tab:checked {
|
||||
border: 2px solid rgba(116, 0, 0, 0.64);
|
||||
}
|
||||
|
||||
.search-border {
|
||||
border: 2px solid rgba(136, 204, 39, 1);
|
||||
}
|
||||
|
||||
.notebook-selected-focus {
|
||||
/* Neon Blue 00e8ff border */
|
||||
border: 2px solid rgba(0, 232, 255, 0.34);
|
||||
|
Loading…
Reference in New Issue
Block a user