Merge pull request #35 from christopher-l/new-window

Introduce new-window action, set non_unique
This commit is contained in:
daa84 2017-12-20 17:46:17 +03:00 committed by GitHub
commit a23d76ab7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 13 deletions

View File

@ -52,7 +52,7 @@ mod error;
use std::env;
use std::time::Duration;
use std::str::FromStr;
use gio::{ApplicationExt, FileExt};
use gio::prelude::*;
use ui::Ui;
@ -64,7 +64,7 @@ const TIMEOUT_ARG: &str = "--timeout";
fn main() {
env_logger::init().expect("Can't initialize env_logger");
let app_flags = gio::APPLICATION_HANDLES_OPEN;
let app_flags = gio::APPLICATION_HANDLES_OPEN | gio::APPLICATION_NON_UNIQUE;
let app = if cfg!(debug_assertions) {
gtk::Application::new(Some("org.daa.NeovimGtkDebug"), app_flags)
@ -73,10 +73,12 @@ fn main() {
}.expect("Failed to initialize GTK application");
app.connect_activate(activate);
{
use gio::ApplicationExtManual;
app.connect_open(open);
}
app.connect_open(open);
let new_window_action = gio::SimpleAction::new("new-window", None);
let app_ref = app.clone();
new_window_action.connect_activate(move |_, _| activate(&app_ref));
app.add_action(&new_window_action);
gtk::Window::set_default_icon_name("org.daa.NeovimGtk");

View File

@ -8,7 +8,7 @@ use gtk_sys;
use gtk::prelude::*;
use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog, SettingsExt};
use gio::prelude::*;
use gio::{Menu, MenuExt, MenuItem, MenuItemExt, SimpleAction};
use gio::{Menu, MenuExt, MenuItem, SimpleAction};
use settings::Settings;
use shell::{Shell, ShellOptions};
@ -194,14 +194,16 @@ impl Ui {
let menu = Menu::new();
let plugs = MenuItem::new("Plugins", None);
plugs.set_detailed_action("app.Plugins");
menu.append_item(&plugs);
let section = Menu::new();
section.append_item(&MenuItem::new("New Window", "app.new-window"));
menu.append_section(None, &section);
let about = MenuItem::new("About", None);
about.set_detailed_action("app.HelpAbout");
menu.append_item(&about);
let section = Menu::new();
section.append_item(&MenuItem::new("Plugins", "app.Plugins"));
section.append_item(&MenuItem::new("About", "app.HelpAbout"));
menu.append_section(None, &section);
menu.freeze();
app.set_app_menu(Some(&menu));
let plugs_action = SimpleAction::new("Plugins", None);