Commit 45dc8194 authored by Daniel García Moreno's avatar Daniel García Moreno

Merge branch 'Kagamihime/fractal-new-msg-divider'

parents f0afadcc fe3d63d7
......@@ -111,9 +111,6 @@ row .timestamp {
color: alpha(@theme_fg_color, 0.85);
padding: 12px 0px;
}
.msg-last-viewed-widget {
border-bottom: 1px solid @borders;
}
.messages-history row:selected .msg-mention,
.messages-history row:selected .msg-emote
......
......@@ -72,6 +72,12 @@ struct TmpMsg {
pub widget: gtk::Widget,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum LastViewed {
Inline,
Last,
No,
}
pub struct AppOp {
pub gtk_builder: gtk::Builder,
......@@ -1333,10 +1339,21 @@ impl AppOp {
}
}
pub fn is_last_viewed(&self, msg: &Message) -> bool {
pub fn is_last_viewed(&self, msg: &Message) -> LastViewed {
match self.last_viewed_messages.get(&msg.room) {
Some(lvm) if lvm == msg => true,
_ => false,
Some(lvm) if lvm == msg => {
match self.rooms.get(&msg.room) {
Some(r) => {
let lastm = r.messages.last();
match lastm {
Some(m) if m == msg => LastViewed::Last,
_ => LastViewed::Inline,
}
},
_ => LastViewed::Inline,
}
},
_ => LastViewed::No,
}
}
......@@ -1345,7 +1362,7 @@ impl AppOp {
msgpos: MsgPos,
prev: Option<Message>,
force_full: bool,
last: bool) {
last: LastViewed) {
let msg_entry: gtk::Entry = self.gtk_builder
.get_object("msg_entry")
.expect("Couldn't find msg_entry in ui file.");
......@@ -1388,12 +1405,6 @@ impl AppOp {
}
}
if last {
if let Some(style) = m.get_style_context() {
style.add_class("msg-last-viewed-widget");
}
}
match msgpos {
MsgPos::Bottom => messages.add(&m),
MsgPos::Top => messages.insert(&m, 1),
......@@ -1401,6 +1412,10 @@ impl AppOp {
if !is_small_widget {
m.get_parent().unwrap().set_margin_top(12);
}
if last == LastViewed::Inline {
let divider: gtk::Box = widgets::divider::new("New Messages");
messages.add(&divider);
}
self.shown_messages += 1;
}
self.remove_tmp_room_message(&msg);
......@@ -3498,7 +3513,7 @@ fn backend_loop(rx: Receiver<BKResponse>) {
#[derive(Debug)]
pub enum InternalCommand {
AddRoomMessage(Message, MsgPos, Option<Message>, bool, bool),
AddRoomMessage(Message, MsgPos, Option<Message>, bool, LastViewed),
SetPanel(RoomPanel),
NotifyClicked(Message),
SelectRoom(Room),
......
extern crate gtk;
use self::gtk::prelude::*;
pub fn new(text: &str) -> gtk::Box {
let divider = gtk::Box::new(gtk::Orientation::Horizontal, 6);
let left_separator = gtk::Separator::new(gtk::Orientation::Horizontal);
left_separator.set_valign(gtk::Align::Center);
let label = gtk::Label::new(text);
label.set_selectable(false);
let right_separator = gtk::Separator::new(gtk::Orientation::Horizontal);
right_separator.set_valign(gtk::Align::Center);
divider.pack_start(&left_separator, true, true, 0);
divider.pack_start(&label, false, false, 0);
divider.pack_start(&right_separator, true, true, 0);
divider.show_all();
divider
}
......@@ -4,6 +4,7 @@ mod member;
mod roomrow;
mod roomlist;
mod avatar;
pub mod divider;
pub use self::message::MessageBox;
pub use self::room::RoomBox;
......
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