Added path bar search dropdown.

This commit is contained in:
itdominator 2021-12-12 00:03:51 -06:00
parent 1eb6c81f6a
commit dd9d9572e8
7 changed files with 88 additions and 6 deletions

View File

@ -13,7 +13,6 @@ sudo apt-get install python3 wget ffmpegthumbnailer steamcmd
# TODO
<ul>
<li>Add path bar search dropdown.</li>
<li>Add "clear trash", "restore from trash" options.</li>
<li>Add drive size free and consumed info to bottom bar.</li>
<li>Add simpleish plugin system to run bash/python scripts.</li>

View File

@ -160,6 +160,7 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
images = self.hash_set(self.images),
desktops = self.hash_set(self.desktop),
ungrouped = self.hash_set(self.ungrouped)
hidden = self.hash_set(self.hidden)
return {
'path_head': self.get_path(),
@ -169,7 +170,8 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
'videos': videos,
'images': images,
'desktops': desktops,
'ungrouped': ungrouped
'ungrouped': ungrouped,
'hidden': hidden
}
}

View File

@ -110,6 +110,10 @@ class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \
self.arc_command_buffer.set_text(self.arc_commands[int(id)])
def clear_children(self, widget):
for child in widget.get_children():
widget.remove(child)
def get_current_state(self):
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)

View File

@ -35,6 +35,7 @@ class Controller_Data:
self.file_exists_dialog = self.builder.get_object("file_exists_dialog")
self.exists_file_label = self.builder.get_object("exists_file_label")
self.exists_file_field = self.builder.get_object("exists_file_field")
self.path_menu = self.builder.get_object("path_menu")
self.exists_file_rename_bttn = self.builder.get_object("exists_file_rename_bttn")
self.bottom_size_label = self.builder.get_object("bottom_size_label")
@ -44,7 +45,6 @@ class Controller_Data:
self.trash_files_path = GLib.get_user_data_dir() + "/Trash/files"
self.trash_info_path = GLib.get_user_data_dir() + "/Trash/info"
# In compress commands:
# %n: First selected filename/dir to archive
# %N: All selected filenames/dirs to archive, or (with %O) a single filename

View File

@ -1,6 +1,11 @@
# Python imports
import os
# Lib imports
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk, Gdk
# Application imports
from . import WidgetMixin
@ -144,9 +149,33 @@ class TabMixin(WidgetMixin):
self.window_controller.save_state()
return
if action == "path_entry":
path = widget.get_text()
dir = view.get_current_directory() + "/"
if path == dir :
focused_obj = self.window.get_focus()
dir = f"{view.get_current_directory()}/"
path = widget.get_text()
self.path_menu.popdown()
if isinstance(focused_obj, Gtk.Entry):
button_box = self.path_menu.get_children()[0].get_children()[0].get_children()[0]
query = widget.get_text().replace(dir, "")
files = view.files + view.hidden
self.clear_children(button_box)
show_path_menu = False
for file in files:
if query.lower() in file.lower() and os.path.isdir(f"{dir}{file}"):
show_path_menu = True
button = Gtk.Button(label=file)
button.show()
button.connect("clicked", self.set_path_entry)
button_box.add(button)
if show_path_menu:
self.path_menu.popup()
widget.grab_focus_without_selecting()
widget.set_position(-1)
if path == dir:
return
traversed = view.set_path(path)
@ -155,6 +184,20 @@ class TabMixin(WidgetMixin):
self.update_view(tab_label, view, store, wid, tid)
try:
widget.grab_focus_without_selecting()
widget.set_position(-1)
except Exception as e:
pass
def set_path_entry(self, button=None, eve=None):
wid, tid, view, iconview, store = self.get_current_state()
path = f"{view.get_current_directory()}/{button.get_label()}"
path_entry = self.builder.get_object("path_entry")
path_entry.set_text(path)
path_entry.grab_focus_without_selecting()
path_entry.set_position(-1)
self.path_menu.popdown()
def keyboard_close_tab(self):
wid, tid = self.window_controller.get_active_data()

View File

@ -114,11 +114,13 @@ class WindowMixin(TabMixin):
def grid_icon_single_left_click(self, iconview, eve):
try:
self.path_menu.popdown()
wid, tid = iconview.get_name().split("|")
self.window_controller.set_active_data(wid, tid)
self.set_path_text(wid, tid)
self.set_window_title()
if eve.type == Gdk.EventType.BUTTON_RELEASE and eve.button == 1: # l-click
if self.single_click_open: # FIXME: need to find a way to pass the model index
self.grid_icon_double_left_click(iconview)

View File

@ -1886,6 +1886,38 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
</object>
</child>
</object>
<object class="GtkPopover" id="path_menu">
<property name="width-request">240</property>
<property name="can-focus">False</property>
<property name="relative-to">path_entry</property>
<property name="position">bottom</property>
<property name="modal">False</property>
<child>
<object class="GtkScrolledWindow">
<property name="height-request">320</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="layout-style">start</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="win1_search">
<property name="can-focus">False</property>
<property name="margin-start">5</property>