Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions src/Services/Document.vala
Original file line number Diff line number Diff line change
Expand Up @@ -256,24 +256,17 @@ namespace Scratch.Services {

this.source_view.buffer.create_tag ("highlight_search_all", "background", "yellow", null);

// Focus in event for SourceView
// Check if file changed externally or permissions changed
this.source_view.focus_in_event.connect (() => {
if (!locked && !is_file_temporary) {
check_undoable_actions ();
check_file_status.begin ();
}

return false;
});

// Focus out event for SourceView
this.source_view.focus_out_event.connect (() => {
if (!locked && Scratch.settings.get_boolean ("autosave")) {
save_with_hold.begin ();
this.source_view.notify["is-focus"].connect (() => {
if (source_view.is_focus) {
if (!locked && !is_file_temporary) {
check_undoable_actions ();
check_file_status.begin ();
}
} else {
if (!locked && Scratch.settings.get_boolean ("autosave")) {
save_with_hold.begin ();
}
}

return false;
});

source_view.buffer.changed.connect (() => {
Expand Down
14 changes: 6 additions & 8 deletions src/Widgets/SearchBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ namespace Scratch.Widgets {
// Connecting to some signals
search_entry.changed.connect (on_search_parameters_changed);
search_entry.key_press_event.connect (on_search_entry_key_press);
search_entry.focus_in_event.connect (on_search_entry_focused_in);
search_entry.notify["is-focus"].connect (() => {
if (search_entry.is_focus) {
on_search_entry_focused_in ();
}
});
search_entry.icon_release.connect ((p0, p1) => {
if (p0 == Gtk.EntryIconPosition.PRIMARY) {
search_next ();
Expand Down Expand Up @@ -359,18 +363,12 @@ namespace Scratch.Widgets {
update_search_widgets ();
}

private bool on_search_entry_focused_in (Gdk.EventFocus event) {
if (text_buffer == null) {
return false;
}

private void on_search_entry_focused_in () requires (text_buffer != null) {
Idle.add (() => {
update_search_widgets ();
search_entry.select_region (0, -1);
return Source.REMOVE;
});

return Gdk.EVENT_PROPAGATE;
}

public bool search () {
Expand Down