Commit d96defdc authored by Fabien Parent's avatar Fabien Parent
Browse files

Fix accelerators on gear menu actions

parent e76f67e6
...@@ -405,19 +405,20 @@ void MainWindow::init_actions() ...@@ -405,19 +405,20 @@ void MainWindow::init_actions()
struct actions struct actions
{ {
const char *const name; const char *const name;
const char* accelerator;
sigc::slot<void> slot; sigc::slot<void> slot;
}; };
static struct actions match_actions[] = static struct actions match_actions[] =
{ {
{"undo", sigc::mem_fun(*this, &MainWindow::on_undo)}, {"undo", "<Ctrl>Z", sigc::mem_fun(*this, &MainWindow::on_undo)},
{"previous-file", sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next_file), false)}, {"previous-file", "<Ctrl>P",sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next_file), false)},
{"back", sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next), false)}, {"back", "<Ctrl>B", sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next), false)},
{"forward", sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next), true)}, {"forward", "<Ctrl>N", sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next), true)},
{"next-file", sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next_file), true)}, {"next-file", "<Ctrl>E", sigc::bind(sigc::mem_fun(*this, &MainWindow::on_go_next_file), true)},
{"replace-current", sigc::mem_fun(*this, &MainWindow::on_replace)}, {"replace-current", "<Ctrl>R", sigc::mem_fun(*this, &MainWindow::on_replace)},
{"replace-in-file", sigc::mem_fun(*this, &MainWindow::on_replace_file)}, {"replace-in-file", NULL, sigc::mem_fun(*this, &MainWindow::on_replace_file)},
{"replace-in-all-files", sigc::mem_fun(*this, &MainWindow::on_replace_all)}, {"replace-in-all-files", NULL, sigc::mem_fun(*this, &MainWindow::on_replace_all)},
{0}, {0},
}; };
...@@ -428,14 +429,17 @@ void MainWindow::init_actions() ...@@ -428,14 +429,17 @@ void MainWindow::init_actions()
action->signal_activate().connect(sigc::hide(match_actions[i].slot)); action->signal_activate().connect(sigc::hide(match_actions[i].slot));
match_action_group_->insert(action); match_action_group_->insert(action);
action_to_group_[match_actions[i].name] = match_action_group_; action_to_group_[match_actions[i].name] = match_action_group_;
if (match_actions[i].accelerator)
application_->add_accelerator(match_actions[i].accelerator,
Glib::ustring("match.") + match_actions[i].name);
} }
static struct actions edit_actions[] = static struct actions edit_actions[] =
{ {
{"cut", sigc::mem_fun(*this, &MainWindow::on_cut)}, {"cut", "<Ctrl>X", sigc::mem_fun(*this, &MainWindow::on_cut)},
{"copy", sigc::mem_fun(*this, &MainWindow::on_copy)}, {"copy", "<Ctrl>C", sigc::mem_fun(*this, &MainWindow::on_copy)},
{"paste", sigc::mem_fun(*this, &MainWindow::on_paste)}, {"paste", "<Ctrl>V", sigc::mem_fun(*this, &MainWindow::on_paste)},
{"delete", sigc::mem_fun(*this, &MainWindow::on_erase)}, {"delete", NULL, sigc::mem_fun(*this, &MainWindow::on_erase)},
}; };
for (int i = 0; edit_actions[i].name; i++) for (int i = 0; edit_actions[i].name; i++)
...@@ -445,12 +449,15 @@ void MainWindow::init_actions() ...@@ -445,12 +449,15 @@ void MainWindow::init_actions()
action->signal_activate().connect(sigc::hide(edit_actions[i].slot)); action->signal_activate().connect(sigc::hide(edit_actions[i].slot));
edit_action_group_->insert(action); edit_action_group_->insert(action);
action_to_group_[edit_actions[i].name] = edit_action_group_; action_to_group_[edit_actions[i].name] = edit_action_group_;
if (edit_actions[i].accelerator)
application_->add_accelerator(edit_actions[i].accelerator,
Glib::ustring("edit.") + edit_actions[i].name);
} }
static struct actions save_actions[] = static struct actions save_actions[] =
{ {
{"save", sigc::mem_fun(*this, &MainWindow::on_save_file)}, {"save", "<Ctrl>S", sigc::mem_fun(*this, &MainWindow::on_save_file)},
{"save-all", sigc::mem_fun(*this, &MainWindow::on_save_all)}, {"save-all", NULL, sigc::mem_fun(*this, &MainWindow::on_save_all)},
}; };
for (int i = 0; save_actions[i].name; i++) for (int i = 0; save_actions[i].name; i++)
...@@ -460,6 +467,9 @@ void MainWindow::init_actions() ...@@ -460,6 +467,9 @@ void MainWindow::init_actions()
action->signal_activate().connect(sigc::hide(save_actions[i].slot)); action->signal_activate().connect(sigc::hide(save_actions[i].slot));
save_action_group_->insert(action); save_action_group_->insert(action);
action_to_group_[save_actions[i].name] = save_action_group_; action_to_group_[save_actions[i].name] = save_action_group_;
if (save_actions[i].accelerator)
application_->add_accelerator(save_actions[i].accelerator,
Glib::ustring("save.") + save_actions[i].name);
} }
window_->insert_action_group("match", match_action_group_); window_->insert_action_group("match", match_action_group_);
......
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