gjdwebserver-overlay/mail-client/geary/files/0002-conversation-viewer-move-actions-to-the-bottom-when-.patch

259 lines
11 KiB
Diff
Raw Normal View History

2021-03-01 15:30:25 +01:00
From 40824723c63d869535f89e628289fdb46cbf9c49 Mon Sep 17 00:00:00 2001
From: Julian Sparber <julian@sparber.net>
Date: Fri, 9 Oct 2020 17:20:31 +0200
Subject: [PATCH 2/6] conversation-viewer: move actions to the bottom when they
don't fit
---
.../application/application-main-window.vala | 8 ++-
.../components-conversation-action-bar.vala | 12 ++--
src/client/components/main-toolbar.vala | 63 +++++++++++++++----
.../conversation-viewer.vala | 1 -
ui/application-main-window.ui | 18 ++++++
ui/components-conversation-action-bar.ui | 21 ++++++-
6 files changed, 100 insertions(+), 23 deletions(-)
diff --git a/src/client/application/application-main-window.vala b/src/client/application/application-main-window.vala
index 90d5b249..19f04492 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -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,
diff --git a/src/client/components/components-conversation-action-bar.vala b/src/client/components/components-conversation-action-bar.vala
index cb574521..cd868b21 100644
--- a/src/client/components/components-conversation-action-bar.vala
+++ b/src/client/components/components-conversation-action-bar.vala
@@ -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);
+ }
});
}
}
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 6458b7fb..f216238a 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -17,6 +17,11 @@ public class MainToolbar : Hdy.Leaflet {
// Search bar
public bool search_open { get; set; default = false; }
+ private ulong owner_notify;
+ private Gtk.Widget? reply_forward_buttons;
+ private Gtk.Widget? archive_trash_delete_buttons;
+ private Components.ConversationActionBar conversation_viewer_action_bar;
+
[GtkChild]
private Hdy.Leaflet conversations_leaflet;
@@ -47,11 +52,14 @@ public class MainToolbar : Hdy.Leaflet {
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;
+ conversation_header.size_allocate.connect(on_size_allocate);
// Assemble the main/mark menus
Gtk.Builder builder = new Gtk.Builder.from_resource("/org/gnome/Geary/main-toolbar-menus.ui");
@@ -63,17 +71,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 +108,46 @@ public class MainToolbar : Hdy.Leaflet {
conversations_group.add_swipeable(this.conversations_leaflet);
conversation_group.add_swipeable(this);
}
+
+ private void on_size_allocate() {
+ if (reply_forward_buttons != null && archive_trash_delete_buttons != null)
+ if (conversation_viewer_action_bar.reveal_child && get_allocated_width() > 600) {
+ conversation_viewer_action_bar.reveal_child = false;
+ remove_action_parent();
+ conversation_header.pack_start(reply_forward_buttons);
+ conversation_header.pack_end(archive_trash_delete_buttons);
+ } else if (!conversation_viewer_action_bar.reveal_child && get_allocated_width() < 600) {
+ remove_action_parent();
+ conversation_viewer_action_bar.action_box.pack_start(reply_forward_buttons, false, false);
+ conversation_viewer_action_bar.action_box.pack_end(archive_trash_delete_buttons, false, false);
+ conversation_viewer_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);
+ conversation_header.pack_start(actions.mark_copy_move_buttons);
+ conversation_header.pack_end(actions.find_button);
+
+ reply_forward_buttons = actions.reply_forward_buttons;
+ archive_trash_delete_buttons = actions.archive_trash_delete_buttons;
+ on_size_allocate();
+ this.owner_notify = actions.notify["owner"].connect(() => {
+ if (actions.owner != this) {
+ conversation_viewer_action_bar.reveal_child = false;
+ reply_forward_buttons = null;
+ archive_trash_delete_buttons = null;
+ actions.disconnect (this.owner_notify);
+ }
+ });
+ }
+ }
}
diff --git a/src/client/conversation-viewer/conversation-viewer.vala b/src/client/conversation-viewer/conversation-viewer.vala
index a5098764..74706f8c 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -532,5 +532,4 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
}
}
}
-
}
diff --git a/ui/application-main-window.ui b/ui/application-main-window.ui
index c55e42ab..1b41310d 100644
--- a/ui/application-main-window.ui
+++ b/ui/application-main-window.ui
@@ -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>
diff --git a/ui/components-conversation-action-bar.ui b/ui/components-conversation-action-bar.ui
index ae49683f..6fc03f44 100644
--- a/ui/components-conversation-action-bar.ui
+++ b/ui/components-conversation-action-bar.ui
@@ -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>
--
2.29.2