conversation-viewer: move actions to the bottom when they don't fit
This commit is contained in:
parent
0923de098f
commit
9c6ca541cc
11 changed files with 170 additions and 54 deletions
|
|
@ -334,6 +334,10 @@ public class Application.MainWindow :
|
|||
[GtkChild]
|
||||
private Gtk.ScrolledWindow conversation_list_scrolled;
|
||||
[GtkChild]
|
||||
private Gtk.Box conversation_viewer_box;
|
||||
[GtkChild]
|
||||
private Components.ConversationActionBar conversation_viewer_action_bar;
|
||||
[GtkChild]
|
||||
private Gtk.SizeGroup folder_size_group;
|
||||
[GtkChild]
|
||||
private Gtk.SizeGroup folder_separator_size_group;
|
||||
|
|
@ -1266,7 +1270,7 @@ public class Application.MainWindow :
|
|||
|
||||
this.conversation_viewer.hexpand = true;
|
||||
this.conversation_size_group.add_widget(this.conversation_viewer);
|
||||
this.main_leaflet.add_with_properties(this.conversation_viewer, "name", "conversation", null);
|
||||
this.conversation_viewer_box.add(this.conversation_viewer);
|
||||
|
||||
|
||||
// Setup conversation actions
|
||||
|
|
@ -1279,7 +1283,7 @@ public class Application.MainWindow :
|
|||
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
|
||||
|
||||
// Main toolbar
|
||||
this.main_toolbar = new MainToolbar(config);
|
||||
this.main_toolbar = new MainToolbar(config, conversation_viewer_action_bar);
|
||||
this.main_toolbar.add_to_size_groups(this.folder_size_group,
|
||||
this.folder_separator_size_group,
|
||||
this.conversations_size_group,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class Components.ConversationActionBar : Gtk.Revealer {
|
|||
private ulong owner_notify;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Box action_box;
|
||||
public Gtk.Box action_box;
|
||||
|
||||
public ConversationActionBar() {
|
||||
}
|
||||
|
|
@ -23,17 +23,17 @@ public class Components.ConversationActionBar : Gtk.Revealer {
|
|||
*/
|
||||
public void add_conversation_actions(Components.ConversationActions actions) {
|
||||
if (actions.owner == this)
|
||||
return;
|
||||
return;
|
||||
|
||||
actions.take_ownership(this);
|
||||
action_box.pack_start(actions.mark_copy_move_buttons, false, false);
|
||||
action_box.pack_end(actions.archive_trash_delete_buttons, false, false);
|
||||
reveal_child = true;
|
||||
this.owner_notify = actions.notify["owner"].connect(() => {
|
||||
if (actions.owner != this) {
|
||||
reveal_child = false;
|
||||
actions.disconnect (this.owner_notify);
|
||||
}
|
||||
if (actions.owner != this) {
|
||||
reveal_child = false;
|
||||
actions.disconnect (this.owner_notify);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright © 2020 Purism SPC
|
||||
*
|
||||
* This software is licensed under the GNU Lesser General Public License
|
||||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
[GtkTemplate (ui = "/org/gnome/Geary/components-conversation-header-bar.ui")]
|
||||
public class Components.ConversationHeaderBar : Gtk.HeaderBar {
|
||||
public Components.ConversationActionBar action_bar { get; set; }
|
||||
public bool folded { get; set; }
|
||||
|
||||
private ulong owner_notify;
|
||||
private Gtk.Widget? reply_forward_buttons;
|
||||
private Gtk.Widget? archive_trash_delete_buttons;
|
||||
|
||||
public ConversationHeaderBar() {
|
||||
}
|
||||
|
||||
public override void size_allocate(Gtk.Allocation allocation) {
|
||||
update_action_bar();
|
||||
base.size_allocate(allocation);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void update_action_bar () {
|
||||
/* Only show the action_bar when the conversation_header is shown */
|
||||
if (parent == null)
|
||||
action_bar.reveal_child = false;
|
||||
else if (reply_forward_buttons != null && archive_trash_delete_buttons != null)
|
||||
if (action_bar.reveal_child && get_allocated_width() > 600) {
|
||||
action_bar.reveal_child = false;
|
||||
remove_action_parent();
|
||||
pack_start(reply_forward_buttons);
|
||||
pack_end(archive_trash_delete_buttons);
|
||||
} else if (!action_bar.reveal_child && get_allocated_width() < 600) {
|
||||
remove_action_parent();
|
||||
action_bar.action_box.pack_start(reply_forward_buttons, false, false);
|
||||
action_bar.action_box.pack_end(archive_trash_delete_buttons, false, false);
|
||||
action_bar.reveal_child = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void remove_action_parent() {
|
||||
if (reply_forward_buttons != null && reply_forward_buttons.parent != null)
|
||||
reply_forward_buttons.parent.remove(reply_forward_buttons);
|
||||
if (archive_trash_delete_buttons != null && archive_trash_delete_buttons.parent != null)
|
||||
archive_trash_delete_buttons.parent.remove(archive_trash_delete_buttons);
|
||||
}
|
||||
|
||||
public void add_conversation_actions(Components.ConversationActions actions) {
|
||||
if (actions.owner != this) {
|
||||
actions.take_ownership(this);
|
||||
pack_start(actions.mark_copy_move_buttons);
|
||||
pack_end(actions.find_button);
|
||||
|
||||
reply_forward_buttons = actions.reply_forward_buttons;
|
||||
archive_trash_delete_buttons = actions.archive_trash_delete_buttons;
|
||||
update_action_bar();
|
||||
this.owner_notify = actions.notify["owner"].connect(() => {
|
||||
if (actions.owner != this) {
|
||||
action_bar.reveal_child = false;
|
||||
reply_forward_buttons = null;
|
||||
archive_trash_delete_buttons = null;
|
||||
actions.disconnect (this.owner_notify);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,8 @@ public class MainToolbar : Hdy.Leaflet {
|
|||
// Search bar
|
||||
public bool search_open { get; set; default = false; }
|
||||
|
||||
private Components.ConversationActionBar conversation_viewer_action_bar;
|
||||
|
||||
[GtkChild]
|
||||
private Hdy.Leaflet conversations_leaflet;
|
||||
|
||||
|
|
@ -40,18 +42,21 @@ public class MainToolbar : Hdy.Leaflet {
|
|||
|
||||
// Conversation header elements
|
||||
[GtkChild]
|
||||
private Gtk.HeaderBar conversation_header;
|
||||
private Components.ConversationHeaderBar conversation_header;
|
||||
|
||||
[GtkChild]
|
||||
private Hdy.HeaderGroup header_group;
|
||||
|
||||
Gtk.SizeGroup conversation_group;
|
||||
|
||||
public MainToolbar(Application.Configuration config) {
|
||||
public MainToolbar(Application.Configuration config,
|
||||
Components.ConversationActionBar action_bar) {
|
||||
if (config.desktop_environment != UNITY) {
|
||||
this.bind_property("account", this.conversations_header, "title", BindingFlags.SYNC_CREATE);
|
||||
this.bind_property("folder", this.conversations_header, "subtitle", BindingFlags.SYNC_CREATE);
|
||||
}
|
||||
this.conversation_viewer_action_bar = action_bar;
|
||||
this.conversation_header.action_bar = action_bar;
|
||||
|
||||
// Assemble the main/mark menus
|
||||
Gtk.Builder builder = new Gtk.Builder.from_resource("/org/gnome/Geary/main-toolbar-menus.ui");
|
||||
|
|
@ -63,17 +68,6 @@ public class MainToolbar : Hdy.Leaflet {
|
|||
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
|
||||
}
|
||||
|
||||
public void add_conversation_actions(Components.ConversationActions actions) {
|
||||
if (actions.owner == this)
|
||||
return;
|
||||
|
||||
actions.take_ownership(this);
|
||||
conversation_header.pack_start(actions.mark_copy_move_buttons);
|
||||
conversation_header.pack_start(actions.reply_forward_buttons);
|
||||
conversation_header.pack_end(actions.find_button);
|
||||
conversation_header.pack_end(actions.archive_trash_delete_buttons);
|
||||
}
|
||||
|
||||
public void set_conversation_header(Gtk.HeaderBar header) {
|
||||
remove(conversation_header);
|
||||
this.header_group.add_gtk_header_bar(header);
|
||||
|
|
@ -111,4 +105,8 @@ public class MainToolbar : Hdy.Leaflet {
|
|||
conversations_group.add_swipeable(this.conversations_leaflet);
|
||||
conversation_group.add_swipeable(this);
|
||||
}
|
||||
|
||||
public void add_conversation_actions(Components.ConversationActions actions) {
|
||||
conversation_header.add_conversation_actions(actions);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -532,5 +532,4 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ client_vala_sources = files(
|
|||
'components/components-attachment-pane.vala',
|
||||
'components/components-conversation-actions.vala',
|
||||
'components/components-conversation-action-bar.vala',
|
||||
'components/components-conversation-header-bar.vala',
|
||||
'components/components-entry-undo.vala',
|
||||
'components/components-info-bar-stack.vala',
|
||||
'components/components-info-bar.vala',
|
||||
|
|
|
|||
|
|
@ -137,6 +137,24 @@
|
|||
<property name="navigatable">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="conversation_viewer_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="ComponentsConversationActionBar" id="conversation_viewer_action_bar">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack_type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">conversation</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,28 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="transition_type">slide-up</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="action_box">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="action_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="margin_start">6</property>
|
||||
<property name="margin_end">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
|
|
|||
36
ui/components-conversation-header-bar.ui
Normal file
36
ui/components-conversation-header-bar.ui
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<template class="ComponentsConversationHeaderBar" parent="GtkHeaderBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<signal name="notify::parent" handler="update_action_bar" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkButton" id="conversation_back">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="visible" bind-property="folded" bind-source="ComponentsConversationHeaderBar" bind-flags="sync-create"/>
|
||||
<property name="action_name">win.navigation-back</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="a11y-conversation-back">
|
||||
<property name="accessible-name" translatable="yes">Back</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="conversation_back_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">go-previous-symbolic</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
|
|
@ -158,37 +158,9 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHeaderBar" id="conversation_header">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<object class="ComponentsConversationHeaderBar" id="conversation_header">
|
||||
<property name="show_close_button" bind-source="MainToolbar" bind-property="show_close_button" bind-flags="sync-create"/>
|
||||
<child>
|
||||
<object class="GtkButton" id="conversation_back">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="visible" bind-source="MainToolbar" bind-property="folded" bind-flags="sync-create"/>
|
||||
<property name="action_name">win.navigation-back</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="a11y-conversation-back">
|
||||
<property name="accessible-name" translatable="yes">Back</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="conversation_back_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">go-previous-symbolic</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<property name="folded" bind-source="MainToolbar" bind-property="folded" bind-flags="sync-create"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">conversation</property>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
<file compressed="true" preprocess="xml-stripblanks">components-attachment-pane.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">components-attachment-pane-menus.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">components-attachment-view.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">components-conversation-header-bar.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">components-conversation-action-bar.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">components-conversation-actions.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">components-in-app-notification.ui</file>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue