Introduce new-window action, set non_unique
This commit is contained in:
parent
d938b2ef76
commit
85fd26736e
12
src/main.rs
12
src/main.rs
@ -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);
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
|
16
src/ui.rs
16
src/ui.rs
@ -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, §ion);
|
||||
|
||||
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, §ion);
|
||||
|
||||
menu.freeze();
|
||||
app.set_app_menu(Some(&menu));
|
||||
|
||||
let plugs_action = SimpleAction::new("Plugins", None);
|
||||
|
Loading…
Reference in New Issue
Block a user