Commit b29d83e5 authored by Michael Gratton's avatar Michael Gratton 🤞

Convert ConversationViewer to a Stack with a ListBox, remove its WebView.

* src/client/conversation-viewer/conversation-viewer.vala: Convert to a
  GtkStack. Use a GTK template for constructing the UI. Remove WebView
  and any DOM-related code. Replace the enum DisplayMode and hence the
  HTML spinner and HTML user message with widgets in the stack. Remove
  all menus since they're all message specific and will need to be
  re-implemented for ConversationViewer. Comment out composer related
  code for the moment.

* src/client/application/geary-controller.vala
  (GearyController::conversations_selected): Make both conversations and
  current_folder arguments non-nullable, since it doesn't make any sense
  for there not to be any and simplifies handler impls.
  (GearyController::on_conversations_selected): Don't fire when there
  isn't a current folder.

* src/client/components/main-window.vala (MainWindow::set_styling): Add
  CSS theme code for the the conversation message list.
  (MainWindow::create_layout): Remove GtkFrame, just add the
  ConversationViewer instance directly.

* ui/conversation-viewer.ui: New GtkBuilder template for
  ConversationViewer, implemented as a GtkStack containing widgets for
  displaying the loading spinner, conversation as a GtkListBox, and label
  for user messages.

* ui/CMakeLists.txt, po/POTFILES.in: Added new UI files.
parent 64aa037c
......@@ -387,6 +387,7 @@ src/mailer/main.vala
[type: gettext/glade]ui/composer-widget.ui
[type: gettext/glade]ui/conversation-message.ui
[type: gettext/glade]ui/conversation-message-menu.ui
[type: gettext/glade]ui/conversation-viewer.ui
[type: gettext/glade]ui/edit_alternate_emails.glade
[type: gettext/glade]ui/find_bar.glade
[type: gettext/glade]ui/gtk/help-overlay.ui
......
......@@ -138,8 +138,8 @@ public class GearyController : Geary.BaseObject {
/**
* Fired when the currently selected conversation(s) has/have changed.
*/
public signal void conversations_selected(Gee.Set<Geary.App.Conversation>? conversations,
Geary.Folder? current_folder);
public signal void conversations_selected(Gee.Set<Geary.App.Conversation> conversations,
Geary.Folder current_folder);
/**
* Fired when the number of conversations changes.
......@@ -1480,7 +1480,9 @@ public class GearyController : Geary.BaseObject {
private void on_conversations_selected(Gee.Set<Geary.App.Conversation> selected) {
selected_conversations = selected;
conversations_selected(selected_conversations, current_folder);
if (current_folder != null) {
conversations_selected(selected_conversations, current_folder);
}
}
private void on_conversation_activated(Geary.App.Conversation activated) {
......
......@@ -179,7 +179,7 @@ public class MainWindow : Gtk.ApplicationWindow {
folder_frame.add(folder_list_scrolled);
folder_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
folder_box.pack_start(folder_frame, true, true);
// message list
conversation_list_scrolled = new Gtk.ScrolledWindow(null, null);
conversation_list_scrolled.set_size_request(MESSAGE_LIST_WIDTH, -1);
......@@ -199,11 +199,7 @@ public class MainWindow : Gtk.ApplicationWindow {
status_bar.add(spinner);
folder_paned.get_style_context().add_class("geary-sidebar-pane-separator");
Gtk.Frame viewer_frame = new Gtk.Frame(null);
viewer_frame.shadow_type = Gtk.ShadowType.NONE;
viewer_frame.add(conversation_viewer);
// Folder list to the left of everything.
folder_paned.pack1(folder_box, false, false);
folder_paned.pack2(conversation_box, true, false);
......@@ -215,8 +211,7 @@ public class MainWindow : Gtk.ApplicationWindow {
// Message list left of message viewer.
conversations_paned.pack1(search_bar_box, false, false);
conversations_paned.pack2(viewer_frame, true, true);
conversations_paned.pack2(conversation_viewer, true, true);
main_layout.pack_end(conversations_paned, true, true, 0);
add(main_layout);
......
......@@ -404,15 +404,19 @@ public class ConversationMessage : Gtk.Box {
private void load_message_body() {
bool remote_images = false;
string body_text = "";
string? body_text = null;
try {
body_text = message.get_body(Geary.RFC822.TextFormat.HTML, inline_image_replacer) ?? "";
if (message.has_html_body()) {
body_text = message.get_html_body(inline_image_replacer);
} else {
body_text = message.get_plain_body(true, inline_image_replacer);
}
} catch (Error err) {
debug("Could not get message text. %s", err.message);
}
body_text = clean_html_markup(body_text, message, out remote_images);
web_view.load_string(body_text, "text/html", "UTF8", "");
web_view.load_string(body_text ?? "", "text/html", "UTF8", "");
// XXX The following will probably need to happen after the
// message has been loaded.
......
......@@ -10,6 +10,7 @@ set(RESOURCE_LIST
STRIPBLANKS "composer-widget.ui"
STRIPBLANKS "conversation-message.ui"
STRIPBLANKS "conversation-message-menu.ui"
STRIPBLANKS "conversation-viewer.ui"
STRIPBLANKS "edit_alternate_emails.glade"
STRIPBLANKS "find_bar.glade"
STRIPBLANKS "folder-popover.ui"
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<template class="ConversationViewer" parent="GtkStack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">crossfade</property>
<child>
<object class="GtkImage" id="splash_page">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">256</property>
<property name="icon_name">mail-inbox-symbolic</property>
</object>
<packing>
<property name="name">splash_page</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="loading_page">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">True</property>
</object>
<packing>
<property name="name">loading_page</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="conversation_page">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="conversation_listbox">
<property name="name">conversation_listbox</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<style>
<class name="background"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">conversation_page</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="user_message_page">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="user_message_label">
<property name="name">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xpad">18</property>
<property name="ypad">18</property>
<property name="label">🎔</property>
<style>
<class name="frame"/>
<class name="view"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="name">user_message_page</property>
<property name="position">3</property>
</packing>
</child>
</template>
</interface>
/*
* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2016 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
......@@ -55,3 +56,28 @@ row.geary-folder-popover-list-row {
row.geary-folder-popover-list-row > label {
color: @theme_text_color;
}
#conversation_listbox {
padding: 18px 18px 0;
}
#conversation_listbox > row {
margin: 0;
border-width: 1px 1px 0;
padding: 0;
box-shadow: 0 4px 8px 1px rgba(0,0,0,0.4);
transition: margin 0.1s;
}
#conversation_listbox > row.show-message {
margin-bottom: 18px;
border-bottom-width: 1px;
}
#ConversationMessage {
padding: 12px;
}
#ConversationMessage .header-label {
margin-right: 6px;
}
#ConversationMessage separator {
margin: 12px 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment