Merge pull request #35 from christopher-l/new-window
Introduce new-window action, set non_unique
This commit is contained in:
commit
a23d76ab7d
14
src/main.rs
14
src/main.rs
@ -52,7 +52,7 @@ mod error;
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use gio::{ApplicationExt, FileExt};
|
use gio::prelude::*;
|
||||||
|
|
||||||
use ui::Ui;
|
use ui::Ui;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ const TIMEOUT_ARG: &str = "--timeout";
|
|||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init().expect("Can't initialize env_logger");
|
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) {
|
let app = if cfg!(debug_assertions) {
|
||||||
gtk::Application::new(Some("org.daa.NeovimGtkDebug"), app_flags)
|
gtk::Application::new(Some("org.daa.NeovimGtkDebug"), app_flags)
|
||||||
@ -73,10 +73,12 @@ fn main() {
|
|||||||
}.expect("Failed to initialize GTK application");
|
}.expect("Failed to initialize GTK application");
|
||||||
|
|
||||||
app.connect_activate(activate);
|
app.connect_activate(activate);
|
||||||
{
|
app.connect_open(open);
|
||||||
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");
|
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::prelude::*;
|
||||||
use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog, SettingsExt};
|
use gtk::{ApplicationWindow, HeaderBar, ToolButton, Image, AboutDialog, SettingsExt};
|
||||||
use gio::prelude::*;
|
use gio::prelude::*;
|
||||||
use gio::{Menu, MenuExt, MenuItem, MenuItemExt, SimpleAction};
|
use gio::{Menu, MenuExt, MenuItem, SimpleAction};
|
||||||
|
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use shell::{Shell, ShellOptions};
|
use shell::{Shell, ShellOptions};
|
||||||
@ -194,14 +194,16 @@ impl Ui {
|
|||||||
|
|
||||||
let menu = Menu::new();
|
let menu = Menu::new();
|
||||||
|
|
||||||
let plugs = MenuItem::new("Plugins", None);
|
let section = Menu::new();
|
||||||
plugs.set_detailed_action("app.Plugins");
|
section.append_item(&MenuItem::new("New Window", "app.new-window"));
|
||||||
menu.append_item(&plugs);
|
menu.append_section(None, §ion);
|
||||||
|
|
||||||
let about = MenuItem::new("About", None);
|
let section = Menu::new();
|
||||||
about.set_detailed_action("app.HelpAbout");
|
section.append_item(&MenuItem::new("Plugins", "app.Plugins"));
|
||||||
menu.append_item(&about);
|
section.append_item(&MenuItem::new("About", "app.HelpAbout"));
|
||||||
|
menu.append_section(None, §ion);
|
||||||
|
|
||||||
|
menu.freeze();
|
||||||
app.set_app_menu(Some(&menu));
|
app.set_app_menu(Some(&menu));
|
||||||
|
|
||||||
let plugs_action = SimpleAction::new("Plugins", None);
|
let plugs_action = SimpleAction::new("Plugins", None);
|
||||||
|
Loading…
Reference in New Issue
Block a user