[niepce] Issue 22 - Remove menu bar. Add undo/redo button.
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Issue 22 - Remove menu bar. Add undo/redo button.
- Date: Fri, 10 Aug 2018 23:03:17 +0000 (UTC)
commit bf3be29e6977c13fb410bea468a86d7e6df74667
Author: Hubert Figuière <hub figuiere net>
Date: Fri Aug 10 17:45:01 2018 -0400
Issue 22 - Remove menu bar. Add undo/redo button.
https://gitlab.gnome.org/GNOME/niepce/issues/22
src/fwk/toolkit/frame.cpp | 18 ++++++--------
src/fwk/toolkit/frame.hpp | 6 ++---
src/niepce/ui/niepcewindow.cpp | 55 ++++++++++++++++++++++++------------------
3 files changed, 41 insertions(+), 38 deletions(-)
---
diff --git a/src/fwk/toolkit/frame.cpp b/src/fwk/toolkit/frame.cpp
index 29f70b1..eb82bae 100644
--- a/src/fwk/toolkit/frame.cpp
+++ b/src/fwk/toolkit/frame.cpp
@@ -144,13 +144,12 @@ void Frame::redo_state()
Glib::RefPtr<Gio::Action>
-Frame::create_undo_action(const Glib::RefPtr<Gio::ActionMap> & g,
- const Glib::RefPtr<Gio::Menu> & menu)
+Frame::create_undo_action(const Glib::RefPtr<Gio::ActionMap> & g)
{
- m_undo_action = fwk::add_menu_action(g, "Undo",
- sigc::mem_fun(Application::app()->undo_history(),
- &UndoHistory::undo),
- menu, _("Undo"), "win", "<control>Z");
+ m_undo_action = fwk::add_action(g, "Undo",
+ sigc::mem_fun(Application::app()->undo_history(),
+ &UndoHistory::undo),
+ "win", "<control>Z");
Application::app()->undo_history().signal_changed.connect(
sigc::mem_fun(*this, &Frame::undo_state));
undo_state();
@@ -159,13 +158,12 @@ Frame::create_undo_action(const Glib::RefPtr<Gio::ActionMap> & g,
Glib::RefPtr<Gio::Action>
-Frame::create_redo_action(const Glib::RefPtr<Gio::ActionMap> & g,
- const Glib::RefPtr<Gio::Menu> & menu)
+Frame::create_redo_action(const Glib::RefPtr<Gio::ActionMap> & g)
{
- m_redo_action = fwk::add_menu_action(g, "Redo",
+ m_redo_action = fwk::add_action(g, "Redo",
sigc::mem_fun(Application::app()->undo_history(),
&UndoHistory::redo),
- menu, _("Redo"), "win", "<control><shift>Z");
+ "win", "<control><shift>Z");
Application::app()->undo_history().signal_changed.connect(
sigc::mem_fun(*this, &Frame::redo_state));
redo_state();
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index 3432a5b..990fe98 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -102,10 +102,8 @@ protected:
void undo_state();
void redo_state();
- Glib::RefPtr<Gio::Action> create_undo_action(const Glib::RefPtr<Gio::ActionMap> & g,
- const Glib::RefPtr<Gio::Menu> & menu);
- Glib::RefPtr<Gio::Action> create_redo_action(const Glib::RefPtr<Gio::ActionMap> & g,
- const Glib::RefPtr<Gio::Menu> & menu);
+ Glib::RefPtr<Gio::Action> create_undo_action(const Glib::RefPtr<Gio::ActionMap> & g);
+ Glib::RefPtr<Gio::Action> create_redo_action(const Glib::RefPtr<Gio::ActionMap> & g);
/** close signal handler */
virtual bool _close();
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index c150819..ee876ad 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -73,6 +73,21 @@ NiepceWindow::NiepceWindow()
menu_btn->set_menu_model(m_main_menu);
header->pack_end(*menu_btn);
+ // Undo redo buttons
+ Gtk::Box *button_box = Gtk::manage(new Gtk::Box);
+ button_box->get_style_context()->add_class("linked");
+ Gtk::Button *undo_button = Gtk::manage(new Gtk::Button);
+ undo_button->set_image_from_icon_name("edit-undo-symbolic");
+ undo_button->set_label(_("Undo"));
+ undo_button->set_always_show_image(true);
+ gtk_actionable_set_action_name(GTK_ACTIONABLE(undo_button->gobj()), "win.Undo");
+ Gtk::Button *redo_button = Gtk::manage(new Gtk::Button);
+ redo_button->set_image_from_icon_name("edit-redo-symbolic");
+ gtk_actionable_set_action_name(GTK_ACTIONABLE(redo_button->gobj()), "win.Redo");
+ button_box->pack_start(*undo_button, false, false, 0);
+ button_box->pack_start(*redo_button, false, false, 0);
+ header->pack_start(*button_box);
+
setHeaderBar(header);
}
@@ -196,30 +211,22 @@ void NiepceWindow::init_actions()
sigc::mem_fun(
gtkWindow(), &Gtk::Window::hide), "win", "<Primary>w");
- submenu = Gio::Menu::create();
- m_menu->append_submenu(_("Edit"), submenu);
-
- section = Gio::Menu::create();
- submenu->append_section(section);
-
- create_undo_action(m_action_group, section);
- create_redo_action(m_action_group, section);
-
- section = Gio::Menu::create();
- submenu->append_section(section);
-
- fwk::add_menu_action(m_action_group, "Cut",
- Gio::ActionMap::ActivateSlot(), section,
- _("Cut"), "win", "<control>x");
- fwk::add_menu_action(m_action_group, "Copy",
- Gio::ActionMap::ActivateSlot(), section,
- _("Copy"), "win", "<control>c");
- fwk::add_menu_action(m_action_group, "Paste",
- Gio::ActionMap::ActivateSlot(), section,
- _("Paste"), "win" "<control>v");
- fwk::add_menu_action(m_action_group, "Delete",
- sigc::mem_fun(*this, &NiepceWindow::on_action_edit_delete),
- section, _("Delete"), "win", "Delete");
+ // XXX Move to shell?
+ create_undo_action(m_action_group);
+ create_redo_action(m_action_group);
+
+ fwk::add_action(m_action_group, "Cut",
+ Gio::ActionMap::ActivateSlot(),
+ "win", "<control>x");
+ fwk::add_action(m_action_group, "Copy",
+ Gio::ActionMap::ActivateSlot(),
+ "win", "<control>c");
+ fwk::add_action(m_action_group, "Paste",
+ Gio::ActionMap::ActivateSlot(),
+ "win" "<control>v");
+ fwk::add_action(m_action_group, "Delete",
+ sigc::mem_fun(*this, &NiepceWindow::on_action_edit_delete),
+ "win", "Delete");
// Main "hamburger" menu
section = Gio::Menu::create();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]