Skip to content
Open
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
26 changes: 9 additions & 17 deletions src/Services/Document.vala
Original file line number Diff line number Diff line change
Expand Up @@ -256,24 +256,16 @@ 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 (() => {
return_if_fail (!locked);
if (source_view.is_focus) {
Comment thread
jeremypw marked this conversation as resolved.
if (!is_file_temporary) {
check_undoable_actions ();
check_file_status.begin ();
}
} else if (Scratch.settings.get_boolean ("autosave")) {
save_with_hold.begin ();
}

return false;
});

source_view.buffer.changed.connect (() => {
Expand Down
24 changes: 9 additions & 15 deletions src/Widgets/SearchBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,15 @@ 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 && text_buffer != null) {
Idle.add (() => {
update_search_widgets ();
search_entry.select_region (0, -1);
return Source.REMOVE;
});
}
});
search_entry.icon_release.connect ((p0, p1) => {
if (p0 == Gtk.EntryIconPosition.PRIMARY) {
search_next ();
Expand Down Expand Up @@ -359,20 +367,6 @@ namespace Scratch.Widgets {
update_search_widgets ();
}

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

Idle.add (() => {
update_search_widgets ();
search_entry.select_region (0, -1);
return Source.REMOVE;
});

return Gdk.EVENT_PROPAGATE;
}

public bool search () {
search_entry.grab_focus ();
if (search_context == null) {
Expand Down