Commit ffbab013 authored by Zander Brown's avatar Zander Brown

Bind F10 to open the menu

Because we aren't using app-menu accels aren't automatically binded
parent b5f7399b
......@@ -257,12 +257,12 @@ Tobias Bernard
</object>
</child>
<child>
<object class="GtkMenuButton" id="menu_toggle">
<object class="GtkMenuButton" id="menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="valign">center</property>
<property name="popover">menu_popover</property>
<property name="use_popover">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......@@ -281,8 +281,4 @@ Tobias Bernard
</packing>
</child>
</object>
<object class="GtkPopover" id="menu_popover">
<property name="can_focus">False</property>
<property name="relative_to">menu_toggle</property>
</object>
</interface>
\ No newline at end of file
......@@ -75,6 +75,7 @@ impl App {
}));
}));
app.add_action(&refresh);
app.set_accels_for_action("app.refresh", &["<primary>r"]);
let import = SimpleAction::new("import", None);
import.connect_activate(clone!(sender, app => move |_, _| {
......@@ -93,6 +94,9 @@ impl App {
let quit = SimpleAction::new("quit", None);
quit.connect_activate(clone!(app => move |_, _| app.quit()));
app.add_action(&quit);
app.set_accels_for_action("app.quit", &["<primary>q"]);
app.set_accels_for_action("win.menu", &["F10"]);
app.connect_activate(clone!(sender, settings, receiver => move |app| {
// Get the current window (if any)
......@@ -119,6 +123,12 @@ impl App {
// Create the headerbar
let header = Rc::new(Header::new(&content, &window, &sender));
let menu = SimpleAction::new("menu", None);
menu.connect_activate(clone!(header => move |_, _| {
header.open_menu();
}));
window.add_action(&menu);
// Add the content main stack to the overlay.
let overlay = gtk::Overlay::new();
overlay.add(&content.get_stack());
......
......@@ -26,7 +26,7 @@ pub struct Header {
update_box: gtk::Box,
update_label: gtk::Label,
update_spinner: gtk::Spinner,
menu_popover: gtk::Popover,
menu_button: gtk::MenuButton,
app_menu: MenuModel,
}
......@@ -42,7 +42,7 @@ impl Default for Header {
let update_box = builder.get_object("update_notification").unwrap();
let update_label = builder.get_object("update_label").unwrap();
let update_spinner = builder.get_object("update_spinner").unwrap();
let menu_popover = builder.get_object("menu_popover").unwrap();
let menu_button = builder.get_object("menu_button").unwrap();
let menus = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/menus.ui");
let app_menu = menus.get_object("menu").unwrap();
......@@ -55,7 +55,7 @@ impl Default for Header {
update_box,
update_label,
update_spinner,
menu_popover,
menu_button,
app_menu,
}
}
......@@ -120,7 +120,7 @@ impl Header {
}),
);
self.menu_popover.bind_model(Some(&self.app_menu), None);
self.menu_button.set_menu_model(Some(&self.app_menu));
}
pub fn switch_to_back(&self, title: &str) {
......@@ -155,6 +155,10 @@ impl Header {
self.update_spinner.hide();
self.update_label.hide();
}
pub fn open_menu(&self) {
self.menu_button.clicked();
}
}
// FIXME: THIS ALSO SUCKS!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment