Move detach button to bottom of compose widget
Also, remove the embed toolbar at the top. Note that the focus is stolen by the detach button when it's clicked, so we can't re-establish it in the window. Instead, we use the existing set_focus() method to put in a (hopefully) appropriate place.
This commit is contained in:
parent
98018c386e
commit
35e3cdfd9b
3 changed files with 36 additions and 34 deletions
|
|
@ -4,7 +4,7 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class ComposerEmbed : Gtk.Box, ComposerContainer {
|
||||
public class ComposerEmbed : Gtk.Bin, ComposerContainer {
|
||||
|
||||
private ComposerWidget composer;
|
||||
private ConversationViewer conversation_viewer;
|
||||
|
|
@ -17,28 +17,12 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
|
|||
|
||||
public ComposerEmbed(ComposerWidget composer, ConversationViewer conversation_viewer,
|
||||
Geary.Email? referred) {
|
||||
Object(orientation: Gtk.Orientation.VERTICAL);
|
||||
//Object(orientation: Gtk.Orientation.VERTICAL);
|
||||
this.composer = composer;
|
||||
this.conversation_viewer = conversation_viewer;
|
||||
halign = Gtk.Align.FILL;
|
||||
valign = Gtk.Align.FILL;
|
||||
|
||||
Gtk.Toolbar toolbar = new Gtk.Toolbar();
|
||||
toolbar.set_icon_size(Gtk.IconSize.MENU);
|
||||
Gtk.ToolButton close = new Gtk.ToolButton.from_stock("gtk-close");
|
||||
Gtk.ToolButton detach = new Gtk.ToolButton.from_stock("gtk-goto-top");
|
||||
Gtk.SeparatorToolItem filler = new Gtk.SeparatorToolItem();
|
||||
filler.set_expand(true);
|
||||
filler.set_draw(false);
|
||||
toolbar.insert(filler, -1);
|
||||
toolbar.insert(detach, -1);
|
||||
toolbar.insert(close, -1);
|
||||
pack_start(toolbar, false, false);
|
||||
toolbar.show_all();
|
||||
|
||||
close.clicked.connect(on_close);
|
||||
detach.clicked.connect(on_detach);
|
||||
|
||||
WebKit.DOM.HTMLElement? email_element = null;
|
||||
if (referred != null) {
|
||||
email_element = conversation_viewer.web_view.get_dom_document().get_element_by_id(
|
||||
|
|
@ -64,7 +48,8 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
|
|||
debug("Error creating embed element: %s", error.message);
|
||||
return;
|
||||
}
|
||||
pack_start(composer, true, true);
|
||||
//pack_start(composer, true, true);
|
||||
add(composer);
|
||||
composer.editor.focus_in_event.connect(on_focus_in);
|
||||
composer.editor.focus_out_event.connect(on_focus_out);
|
||||
conversation_viewer.compose_overlay.add_overlay(this);
|
||||
|
|
@ -72,23 +57,16 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
|
|||
present();
|
||||
}
|
||||
|
||||
private void on_close() {
|
||||
if (composer.should_close() == ComposerWidget.CloseStatus.DO_CLOSE)
|
||||
close();
|
||||
}
|
||||
|
||||
public void on_detach() {
|
||||
composer.inline = false;
|
||||
if (composer.editor.has_focus)
|
||||
on_focus_out();
|
||||
composer.editor.focus_in_event.disconnect(on_focus_in);
|
||||
composer.editor.focus_out_event.disconnect(on_focus_out);
|
||||
Gtk.Widget focus = top_window.get_focus();
|
||||
|
||||
remove(composer);
|
||||
ComposerWindow window = new ComposerWindow(composer);
|
||||
ComposerWindow focus_win = focus.get_toplevel() as ComposerWindow;
|
||||
if (focus_win != null && focus_win == window)
|
||||
focus.grab_focus();
|
||||
new ComposerWindow(composer);
|
||||
composer.set_focus();
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +103,7 @@ public class ComposerEmbed : Gtk.Box, ComposerContainer {
|
|||
|
||||
public void vanish() {
|
||||
hide();
|
||||
composer.inline = false;
|
||||
composer.editor.focus_in_event.disconnect(on_focus_in);
|
||||
composer.editor.focus_out_event.disconnect(on_focus_out);
|
||||
|
||||
|
|
|
|||
|
|
@ -134,9 +134,7 @@ public class ComposerWidget : Gtk.EventBox {
|
|||
set { ((Gtk.ToggleAction) actions.get_action(ACTION_COMPOSE_AS_HTML)).active = value; }
|
||||
}
|
||||
|
||||
public bool inline {
|
||||
get { return parent is ComposerEmbed && visible; }
|
||||
}
|
||||
public bool inline { get; set; default = true; }
|
||||
|
||||
public ComposeType compose_type { get; private set; default = ComposeType.NEW_MESSAGE; }
|
||||
|
||||
|
|
@ -158,6 +156,7 @@ public class ComposerWidget : Gtk.EventBox {
|
|||
public Gtk.Entry subject_entry;
|
||||
private Gtk.Button close_button;
|
||||
private Gtk.Button send_button;
|
||||
private Gtk.Button detach_button;
|
||||
private Gtk.Label message_overlay_label;
|
||||
private WebKit.DOM.Element? prev_selected_link = null;
|
||||
private Gtk.Box attachments_box;
|
||||
|
|
@ -221,6 +220,10 @@ public class ComposerWidget : Gtk.EventBox {
|
|||
close_button.clicked.connect(on_close);
|
||||
send_button = builder.get_object("Send") as Gtk.Button;
|
||||
send_button.clicked.connect(on_send);
|
||||
detach_button = builder.get_object("Detach") as Gtk.Button;
|
||||
detach_button.clicked.connect(on_detach);
|
||||
bind_property("inline", detach_button, "visible",
|
||||
BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE);
|
||||
add_attachment_button = builder.get_object("add_attachment_button") as Gtk.Button;
|
||||
add_attachment_button.clicked.connect(on_add_attachment_button_clicked);
|
||||
pending_attachments_button = builder.get_object("add_pending_attachments") as Gtk.Button;
|
||||
|
|
@ -519,7 +522,7 @@ public class ComposerWidget : Gtk.EventBox {
|
|||
}
|
||||
}
|
||||
|
||||
private void set_focus() {
|
||||
public void set_focus() {
|
||||
if (Geary.String.is_empty(to)) {
|
||||
to_entry.grab_focus();
|
||||
} else if (Geary.String.is_empty(subject)) {
|
||||
|
|
@ -730,6 +733,11 @@ public class ComposerWidget : Gtk.EventBox {
|
|||
container.close();
|
||||
}
|
||||
|
||||
private void on_detach() {
|
||||
if (parent is ComposerEmbed)
|
||||
((ComposerEmbed) parent).on_detach();
|
||||
}
|
||||
|
||||
private bool email_contains_attachment_keywords() {
|
||||
// Filter out all content contained in block quotes
|
||||
string filtered = @"$subject\n";
|
||||
|
|
|
|||
|
|
@ -597,6 +597,21 @@
|
|||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">3</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="Detach">
|
||||
<property name="label" translatable="yes">Detach</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
|
|
@ -618,7 +633,7 @@
|
|||
<property name="fill">True</property>
|
||||
<property name="padding">3</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue