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;
use gtk::prelude::*; use gtk::prelude::*;
//TODO: levels
pub struct CmdLine { pub struct CmdLine {
dlg: gtk::Dialog, popover: gtk::Popover,
} }
impl CmdLine { impl CmdLine {
pub fn new() -> Self { pub fn new(drawing: &gtk::DrawingArea) -> Self {
let dlg = gtk::Dialog::new(); let popover = gtk::Popover::new(Some(drawing));
dlg.set_modal(true); popover.set_modal(false);
dlg.set_destroy_with_parent(true); 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 { CmdLine {
dlg, popover,
} }
} }
pub fn show<W: gtk::IsA<gtk::Window>>(&self, parent: &W) { pub fn show(&self) {
self.dlg.set_transient_for(parent); self.popover.popup();
self.dlg.show();
} }
} }

View File

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

View File

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