Composer.Widget: Add focused_input_widget property
Support tracking the last focused input widget so that text can be inserted into it as needed.
This commit is contained in:
parent
2159a9a6ce
commit
2c7fe7dbc9
2 changed files with 22 additions and 0 deletions
|
|
@ -290,6 +290,15 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
|
|||
/** The email body editor widget. */
|
||||
public WebView editor { get; private set; }
|
||||
|
||||
/**
|
||||
* The last focused text input widget.
|
||||
*
|
||||
* This may be a Gtk.Entry if an address field or the subject was
|
||||
* most recently focused, or the {@link editor} if the body was
|
||||
* most recently focused.
|
||||
*/
|
||||
public Gtk.Widget? focused_input_widget { get; private set; default = null; }
|
||||
|
||||
/** Determines if the composer can send the message. */
|
||||
public bool can_send {
|
||||
get {
|
||||
|
|
@ -1352,6 +1361,18 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
|
|||
}
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void on_set_focus_child() {
|
||||
var window = get_toplevel() as Gtk.Window;
|
||||
if (window != null) {
|
||||
Gtk.Widget? last_focused = window.get_focus();
|
||||
if (last_focused == this.editor ||
|
||||
(last_focused is Gtk.Entry && last_focused.is_ancestor(this))) {
|
||||
this.focused_input_widget = last_focused;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private bool on_drag_motion() {
|
||||
show_attachment_overlay(true);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<signal name="drag-drop" handler="on_drag_drop" swapped="no"/>
|
||||
<signal name="drag-leave" handler="on_drag_leave" swapped="no"/>
|
||||
<signal name="drag-motion" handler="on_drag_motion" swapped="no"/>
|
||||
<signal name="set-focus-child" handler="on_set_focus_child" after="yes" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkBox" id="composer_container">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue