Refactor plugin event API: rename message* to emit* and requests_ui_element to request_ui_element
This commit is contained in:
@@ -37,17 +37,17 @@ class Plugin(PluginCode):
|
||||
)
|
||||
|
||||
def load(self):
|
||||
footer = self.requests_ui_element("footer-container")
|
||||
footer = self.request_ui_element("footer-container")
|
||||
footer.add( search_replace )
|
||||
|
||||
event = Event_Factory.create_event("register_command",
|
||||
command_name = "search_replace",
|
||||
command = Handler,
|
||||
binding_mode = "released",
|
||||
binding = "<Control>f"
|
||||
binding = ["<Control>f", "<Control>r"]
|
||||
)
|
||||
|
||||
self.message_to("source_views", event)
|
||||
self.emit_to("source_views", event)
|
||||
|
||||
def run(self):
|
||||
...
|
||||
@@ -62,4 +62,5 @@ class Handler:
|
||||
):
|
||||
logger.debug("Command: Search/Replace")
|
||||
|
||||
search_replace.last_key = args[0]
|
||||
search_replace.hide() if search_replace.is_visible() else search_replace.show()
|
||||
|
||||
@@ -19,9 +19,10 @@ class SearchReplace(Gtk.Grid, SearchReplaceMixin):
|
||||
def __init__(self):
|
||||
super(SearchReplace, self).__init__()
|
||||
|
||||
self.active_view = None
|
||||
self.highlight_tag = None
|
||||
self.matches: list[tuple] = []
|
||||
self.active_view = None
|
||||
self.highlight_tag: Gtk.TextTag = None
|
||||
self.matches: list[tuple] = []
|
||||
self.last_key: str = None
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
@@ -112,7 +113,13 @@ class SearchReplace(Gtk.Grid, SearchReplaceMixin):
|
||||
|
||||
def _handle_show(self, widget):
|
||||
self.find_entry.set_text("")
|
||||
self.find_entry.grab_focus()
|
||||
if not self.last_key == "r":
|
||||
self.find_entry.grab_focus()
|
||||
return
|
||||
|
||||
self.replace_entry.grab_focus()
|
||||
# Fake focus call to prompt search
|
||||
self._find_entry_focus_in_event(self.find_entry, None)
|
||||
|
||||
def _handle_hide(self, widget):
|
||||
if not self.active_view: return
|
||||
|
||||
Reference in New Issue
Block a user