Skip to content

Commit

Permalink
Bring back saved searches
Browse files Browse the repository at this point in the history
  • Loading branch information
diegogangl committed Aug 4, 2022
1 parent 29b863d commit ed6d67e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 3 additions & 7 deletions GTG/gtk/browser/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import datetime
import logging
import ast
import re
#import liblarch_gtk # Just for types

from gi.repository import GObject, Gtk, Gdk, Gio, GLib
Expand Down Expand Up @@ -557,15 +558,10 @@ def on_search(self, data):

def on_save_search(self, action, param):
query = self.search_entry.get_text()
name = re.sub(r'!(?=\w)+', '', query)

# Try if this is a new search tag and save it correctly
tag_id = self.req.new_search_tag(query)
self.app.ds.saved_searches.new(name, query)

# Apply new search right now
if self.tagtreeview is not None:
self.select_search_tag(tag_id)
else:
self.get_selected_tree().apply_filter(tag_id)

def select_search_tag(self, tag_id):
tag = self.req.get_tag(tag_id)
Expand Down
3 changes: 3 additions & 0 deletions GTG/gtk/browser/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ def on_search_selected(self, model, position, user_data=None):
self.unselect_tags()
self.unselect_general_box()

item = model.get_item(position)
self.app.browser.get_pane().set_search_query(item.query)


def selected_tags(self, names_only: bool = False) -> list:
"""Get a list of selected tags"""
Expand Down

0 comments on commit ed6d67e

Please sign in to comment.