Limit tab title len (fix #16)
This commit is contained in:
parent
fb415cb0cb
commit
0f4234a622
@ -7,6 +7,8 @@ use gtk::prelude::*;
|
|||||||
|
|
||||||
use glib::signal;
|
use glib::signal;
|
||||||
|
|
||||||
|
use pango;
|
||||||
|
|
||||||
use neovim_lib::NeovimApi;
|
use neovim_lib::NeovimApi;
|
||||||
use neovim_lib::neovim_api::Tabpage;
|
use neovim_lib::neovim_api::Tabpage;
|
||||||
|
|
||||||
@ -66,10 +68,12 @@ impl Tabline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_state(&self,
|
fn update_state(
|
||||||
nvim: &Rc<RefCell<nvim::NeovimClient>>,
|
&self,
|
||||||
selected: &Tabpage,
|
nvim: &Rc<RefCell<nvim::NeovimClient>>,
|
||||||
tabs: &[(Tabpage, Option<String>)]) {
|
selected: &Tabpage,
|
||||||
|
tabs: &[(Tabpage, Option<String>)],
|
||||||
|
) {
|
||||||
let mut state = self.state.borrow_mut();
|
let mut state = self.state.borrow_mut();
|
||||||
|
|
||||||
if state.nvim.is_none() {
|
if state.nvim.is_none() {
|
||||||
@ -81,10 +85,12 @@ impl Tabline {
|
|||||||
state.data = tabs.iter().map(|item| item.0.clone()).collect();
|
state.data = tabs.iter().map(|item| item.0.clone()).collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_tabs(&self,
|
pub fn update_tabs(
|
||||||
nvim: &Rc<RefCell<nvim::NeovimClient>>,
|
&self,
|
||||||
selected: &Tabpage,
|
nvim: &Rc<RefCell<nvim::NeovimClient>>,
|
||||||
tabs: &[(Tabpage, Option<String>)]) {
|
selected: &Tabpage,
|
||||||
|
tabs: &[(Tabpage, Option<String>)],
|
||||||
|
) {
|
||||||
if tabs.len() <= 1 {
|
if tabs.len() <= 1 {
|
||||||
self.tabs.hide();
|
self.tabs.hide();
|
||||||
return;
|
return;
|
||||||
@ -102,7 +108,10 @@ impl Tabline {
|
|||||||
for _ in count..tabs.len() {
|
for _ in count..tabs.len() {
|
||||||
let empty = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
let empty = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
||||||
empty.show_all();
|
empty.show_all();
|
||||||
self.tabs.append_page(&empty, Some(>k::Label::new(None)));
|
let title = gtk::Label::new(None);
|
||||||
|
title.set_ellipsize(pango::EllipsizeMode::Middle);
|
||||||
|
title.set_width_chars(25);
|
||||||
|
self.tabs.append_page(&empty, Some(&title));
|
||||||
}
|
}
|
||||||
} else if count > tabs.len() {
|
} else if count > tabs.len() {
|
||||||
for _ in tabs.len()..count {
|
for _ in tabs.len()..count {
|
||||||
@ -112,8 +121,12 @@ impl Tabline {
|
|||||||
|
|
||||||
for (idx, tab) in tabs.iter().enumerate() {
|
for (idx, tab) in tabs.iter().enumerate() {
|
||||||
let tab_child = self.tabs.get_nth_page(Some(idx as u32));
|
let tab_child = self.tabs.get_nth_page(Some(idx as u32));
|
||||||
self.tabs
|
let tab_label = self.tabs
|
||||||
.set_tab_label_text(&tab_child.unwrap(), tab.1.as_ref().unwrap_or(&"??".to_owned()));
|
.get_tab_label(&tab_child.unwrap())
|
||||||
|
.unwrap()
|
||||||
|
.downcast::<gtk::Label>()
|
||||||
|
.unwrap();
|
||||||
|
tab_label.set_text(tab.1.as_ref().unwrap_or(&"??".to_owned()));
|
||||||
|
|
||||||
if *selected == tab.0 {
|
if *selected == tab.0 {
|
||||||
self.tabs.set_current_page(Some(idx as u32));
|
self.tabs.set_current_page(Some(idx as u32));
|
||||||
|
Loading…
Reference in New Issue
Block a user