Use popup instead of dialog

This commit is contained in:
daa 2017-11-18 23:15:03 +03:00
parent 932b7d98b4
commit 333c28e066
3 changed files with 18 additions and 12 deletions

View File

@ -1,23 +1,29 @@
use gtk;
use gtk::prelude::*;
//TODO: levels
pub struct CmdLine {
dlg: gtk::Dialog,
popover: gtk::Popover,
}
impl CmdLine {
pub fn new() -> Self {
let dlg = gtk::Dialog::new();
dlg.set_modal(true);
dlg.set_destroy_with_parent(true);
pub fn new(drawing: &gtk::DrawingArea) -> Self {
let popover = gtk::Popover::new(Some(drawing));
popover.set_modal(false);
let edit_frame = gtk::Frame::new(None);
edit_frame.set_shadow_type(gtk::ShadowType::In);
let drawing_area = gtk::DrawingArea::new();
edit_frame.add(&drawing_area);
edit_frame.show_all();
popover.add(&edit_frame);
CmdLine {
dlg,
popover,
}
}
pub fn show<W: gtk::IsA<gtk::Window>>(&self, parent: &W) {
self.dlg.set_transient_for(parent);
self.dlg.show();
pub fn show(&self) {
self.popover.popup();
}
}

View File

@ -11,7 +11,6 @@ use neovim_lib::{Neovim, NeovimApi};
use color::ColorModel;
use nvim::{self, ErrorReport, NeovimClient};
use shell;
use input;
use render;

View File

@ -90,6 +90,7 @@ impl State {
pub fn new(settings: Rc<RefCell<Settings>>, options: ShellOptions) -> State {
let drawing_area = gtk::DrawingArea::new();
let popup_menu = PopupMenu::new(&drawing_area);
let cmd_line = CmdLine::new(&drawing_area);
let font_ctx = render::Context::new(FontDescription::from_string(DEFAULT_FONT_NAME));
State {
@ -101,7 +102,7 @@ impl State {
font_ctx,
cursor: None,
popup_menu,
cmd_line: CmdLine::new(),
cmd_line,
settings,
mode: mode::Mode::new(),
@ -1089,7 +1090,7 @@ impl RedrawEvents for State {
indent: u64,
level: u64,
) -> RepaintMode {
self.cmd_line.show(&self.get_window());
self.cmd_line.show();
// TODO: implement
RepaintMode::Nothing
}