[niepce] [cw] Initial UI shell.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] [cw] Initial UI shell.
- Date: Sat, 23 May 2009 03:30:30 -0400 (EDT)
commit 6e94c3e9a7add690860504d52f41b4e573a83ed4
Author: Hubert Figuiere <hub figuiere net>
Date: Thu May 21 20:29:06 2009 -0400
[cw] Initial UI shell.
[niepce] Refactor the undo manager actions.
---
ChangeLog | 4 +
camerawire/ChangeLog | 4 +-
camerawire/src/Makefile.am | 1 +
camerawire/src/cwapplication.cpp | 21 +++++-
camerawire/src/cwapplication.hpp | 20 ++++-
camerawire/src/cwwindow.cpp | 166 ++++++++++++++++++++++++++++++++++++++
camerawire/src/cwwindow.hpp | 54 ++++++++++++
src/fwk/toolkit/frame.cpp | 45 ++++++++++
src/fwk/toolkit/frame.hpp | 8 ++
src/niepce/ui/niepcewindow.cpp | 33 +-------
src/niepce/ui/niepcewindow.hpp | 5 -
11 files changed, 322 insertions(+), 39 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6d3f28e..216d02f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-05-21 Hubert Figuiere <hub figuiere net>
+ * src/fwk/toolkit/frame.{hpp,cpp}
+ * src/niepce/ui/niepcewindow.{hpp,cpp}
+ Refactor the undo manager actions.
+
* Add camerawire.
* Use format attributes and enforce them.
diff --git a/camerawire/ChangeLog b/camerawire/ChangeLog
index 757b7af..aeb21bd 100644
--- a/camerawire/ChangeLog
+++ b/camerawire/ChangeLog
@@ -1,4 +1,6 @@
2009-05-21 Hubert Figuiere <hub figuiere net>
- * Intial bootstrap.
+ * Initial UI shell.
+
+ * Initial bootstrap.
diff --git a/camerawire/src/Makefile.am b/camerawire/src/Makefile.am
index a935129..41972de 100644
--- a/camerawire/src/Makefile.am
+++ b/camerawire/src/Makefile.am
@@ -12,6 +12,7 @@ INCLUDES = -DDATADIR=\"$(datadir)\" \
camerawire_SOURCES = \
cwapplication.hpp cwapplication.cpp \
+ cwwindow.hpp cwwindow.cpp \
main.cpp
camerawire_LDADD = @LIBGLIBMM_LIBS@ @LIBGTKMM_LIBS@ \
diff --git a/camerawire/src/cwapplication.cpp b/camerawire/src/cwapplication.cpp
index 9c2d650..371f309 100644
--- a/camerawire/src/cwapplication.cpp
+++ b/camerawire/src/cwapplication.cpp
@@ -1,8 +1,27 @@
+/*
+ * niepce - cwapplication.cpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include "cwapplication.hpp"
+#include "cwwindow.hpp"
namespace cw {
@@ -24,7 +43,7 @@ namespace cw {
fwk::Frame::Ptr CwApplication::makeMainFrame()
{
- return fwk::Frame::Ptr();
+ return fwk::Frame::Ptr(new CwWindow);
}
}
diff --git a/camerawire/src/cwapplication.hpp b/camerawire/src/cwapplication.hpp
index 18944f1..347f021 100644
--- a/camerawire/src/cwapplication.hpp
+++ b/camerawire/src/cwapplication.hpp
@@ -1,5 +1,21 @@
-
-
+/*
+ * niepce - cwwindow.hpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef __CW_APPLICATION_HPP_
#define __CW_APPLICATION_HPP_
diff --git a/camerawire/src/cwwindow.cpp b/camerawire/src/cwwindow.cpp
new file mode 100644
index 0000000..1cd6b54
--- /dev/null
+++ b/camerawire/src/cwwindow.cpp
@@ -0,0 +1,166 @@
+/*
+ * niepce - cwwindow.cpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <glibmm/i18n.h>
+
+#include <gtkmm/stock.h>
+#include <gtkmm/window.h>
+
+#include "fwk/toolkit/application.hpp"
+#include "fwk/toolkit/undo.hpp"
+#include "cwwindow.hpp"
+
+
+using fwk::Application;
+using fwk::UndoHistory;
+
+namespace cw {
+
+
+CwWindow::CwWindow()
+ : fwk::Frame("cw-window-frame")
+{
+}
+
+
+Gtk::Widget * CwWindow::buildWidget()
+{
+ Gtk::Window & win(gtkWindow());
+
+ Application::Ptr pApp = Application::app();
+
+ init_actions();
+ init_ui();
+
+ win.add(m_vbox);
+
+ Gtk::Widget* pMenuBar = pApp->uiManager()->get_widget("/MenuBar");
+ m_vbox.pack_start(*pMenuBar, Gtk::PACK_SHRINK);
+
+ win.set_size_request(600, 400);
+ win.show_all_children();
+ return &win;
+}
+
+
+void CwWindow::init_actions()
+{
+ Glib::RefPtr<Gtk::Action> an_action;
+
+ m_refActionGroup = Gtk::ActionGroup::create();
+
+ m_refActionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
+ m_refActionGroup->add(Gtk::Action::create("Import", _("_Import...")),
+ sigc::mem_fun(*this,
+ &CwWindow::on_action_import));
+ m_refActionGroup->add(Gtk::Action::create("Close", Gtk::Stock::CLOSE),
+ sigc::mem_fun(gtkWindow(),
+ &Gtk::Window::hide));
+ m_refActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
+ sigc::mem_fun(*Application::app(),
+ &Application::quit));
+
+ m_refActionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
+
+ create_undo_action(m_refActionGroup);
+ create_redo_action(m_refActionGroup);
+
+ // FIXME: bind
+ m_refActionGroup->add(Gtk::Action::create("Cut", Gtk::Stock::CUT));
+ m_refActionGroup->add(Gtk::Action::create("Copy", Gtk::Stock::COPY));
+ m_refActionGroup->add(Gtk::Action::create("Paste", Gtk::Stock::PASTE));
+ m_refActionGroup->add(Gtk::Action::create("Delete", Gtk::Stock::DELETE));
+
+ m_refActionGroup->add(Gtk::Action::create("Preferences",
+ Gtk::Stock::PREFERENCES),
+ sigc::mem_fun(*this,
+ &CwWindow::on_preferences));
+
+ m_refActionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
+ m_hide_tools_action = Gtk::ToggleAction::create("ToggleToolsVisible",
+ _("_Hide tools"));
+ m_refActionGroup->add(m_hide_tools_action,
+ sigc::mem_fun(*this, &Frame::toggle_tools_visible));
+
+ m_refActionGroup->add(Gtk::Action::create("MenuHelp", _("_Help")));
+ m_refActionGroup->add(Gtk::Action::create("Help", Gtk::Stock::HELP));
+ m_refActionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),
+ sigc::mem_fun(*Application::app(),
+ &Application::about));
+
+ Application::app()->uiManager()->insert_action_group(m_refActionGroup);
+
+ gtkWindow().add_accel_group(Application::app()
+ ->uiManager()->get_accel_group());
+}
+
+
+void CwWindow::init_ui()
+{
+ fwk::Application::Ptr pApp = fwk::Application::app();
+ Glib::ustring ui_info =
+ "<ui>"
+ " <menubar name='MenuBar'>"
+ " <menu action='MenuFile'>"
+ " <menuitem action='Import'/>"
+ " <separator/>"
+ " <menuitem action='Close'/>"
+ " <menuitem action='Quit'/>"
+ " </menu>"
+ " <menu action='MenuEdit'>"
+ " <menuitem action='Undo'/>"
+ " <menuitem action='Redo'/>"
+ " <separator/>"
+ " <menuitem action='Cut'/>"
+ " <menuitem action='Copy'/>"
+ " <menuitem action='Paste'/>"
+ " <menuitem action='Delete'/>"
+ " <separator/>"
+ " <menuitem action='Preferences'/>"
+ " </menu>"
+ " <menu action='MenuTools'>"
+ " <menuitem action='ToggleToolsVisible'/>"
+ " <separator/>"
+ " </menu>"
+ " <menu action='MenuHelp'>"
+ " <menuitem action='Help'/>"
+ " <menuitem action='About'/>"
+ " </menu>"
+ " </menubar>"
+ " <toolbar name='ToolBar'>"
+ " <toolitem action='Import'/>"
+ " <toolitem action='Quit'/>"
+ " </toolbar>"
+ "</ui>";
+ pApp->uiManager()->add_ui_from_string(ui_info);
+}
+
+
+void CwWindow::on_action_import()
+{
+}
+
+
+void CwWindow::on_preferences()
+{
+}
+
+
+}
diff --git a/camerawire/src/cwwindow.hpp b/camerawire/src/cwwindow.hpp
new file mode 100644
index 0000000..10051bc
--- /dev/null
+++ b/camerawire/src/cwwindow.hpp
@@ -0,0 +1,54 @@
+/*
+ * niepce - cwwindow.hpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __CW_WINDOW_HPP_
+#define __CW_WINDOW_HPP_
+
+#include <gtkmm/action.h>
+#include <gtkmm/actiongroup.h>
+#include <gtkmm/box.h>
+
+#include "fwk/toolkit/frame.hpp"
+
+namespace cw {
+
+class CwWindow
+ : public fwk::Frame
+{
+public:
+ CwWindow();
+
+protected:
+ virtual Gtk::Widget * buildWidget();
+
+private:
+ void init_ui();
+ void init_actions();
+ void on_action_import();
+ void on_preferences();
+
+ Gtk::VBox m_vbox;
+ Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
+};
+
+}
+
+#endif
+
diff --git a/src/fwk/toolkit/frame.cpp b/src/fwk/toolkit/frame.cpp
index 07bc82e..53976f8 100644
--- a/src/fwk/toolkit/frame.cpp
+++ b/src/fwk/toolkit/frame.cpp
@@ -21,7 +21,9 @@
#include <vector>
#include <boost/bind.hpp>
+#include <glibmm/i18n.h>
#include <gtkmm/dialog.h>
+#include <gtkmm/stock.h>
#include "fwk/base/debug.hpp"
#include "fwk/base/geometry.hpp"
@@ -114,6 +116,49 @@ void Frame::toggle_tools_visible()
}
}
+void Frame::undo_state()
+{
+ fwk::UndoHistory & history(Application::app()->undo_history());
+ m_undo_action->set_sensitive(history.has_undo());
+ std::string s = history.next_undo();
+ m_undo_action->property_label() = Glib::ustring(_("Undo ")) + s;
+}
+
+
+void Frame::redo_state()
+{
+ fwk::UndoHistory & history(Application::app()->undo_history());
+ m_redo_action->set_sensitive(history.has_redo());
+ std::string s = history.next_redo();
+ m_redo_action->property_label() = Glib::ustring(_("Redo ")) + s;
+}
+
+
+Glib::RefPtr<Gtk::Action> Frame::create_undo_action(const Glib::RefPtr<Gtk::ActionGroup> & g)
+{
+ m_undo_action = Gtk::Action::create("Undo", Gtk::Stock::UNDO);
+ g->add(m_undo_action, Gtk::AccelKey("<control>Z"),
+ sigc::mem_fun(Application::app()->undo_history(),
+ &UndoHistory::undo));
+ Application::app()->undo_history().signal_changed.connect(
+ sigc::mem_fun(*this, &Frame::undo_state));
+ undo_state();
+ return m_undo_action;
+}
+
+
+Glib::RefPtr<Gtk::Action> Frame::create_redo_action(const Glib::RefPtr<Gtk::ActionGroup> & g)
+{
+ m_redo_action = Gtk::Action::create("Redo", Gtk::Stock::REDO);
+ g->add(m_redo_action, Gtk::AccelKey("<control><shift>Z"),
+ sigc::mem_fun(Application::app()->undo_history(),
+ &UndoHistory::redo));
+ Application::app()->undo_history().signal_changed.connect(
+ sigc::mem_fun(*this, &Frame::redo_state));
+ redo_state();
+ return m_redo_action;
+}
+
bool Frame::_close()
{
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index 7e91082..12d187c 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -76,9 +76,17 @@ public:
sigc::signal<void> signal_hide_tools;
sigc::signal<void> signal_show_tools;
protected:
+
+ void undo_state();
+ void redo_state();
+ Glib::RefPtr<Gtk::Action> create_undo_action(const Glib::RefPtr<Gtk::ActionGroup> & g);
+ Glib::RefPtr<Gtk::Action> create_redo_action(const Glib::RefPtr<Gtk::ActionGroup> & g);
+
/** close signal handler */
virtual bool _close();
Glib::RefPtr<Gtk::ToggleAction> m_hide_tools_action;
+ Glib::RefPtr<Gtk::Action> m_undo_action;
+ Glib::RefPtr<Gtk::Action> m_redo_action;
private:
/** frame have the widget set at construction time
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index 985b052..0df86f2 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -259,20 +259,9 @@ void NiepceWindow::init_actions()
&Application::quit));
m_refActionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
- m_undo_action = Gtk::Action::create("Undo", Gtk::Stock::UNDO);
- m_refActionGroup->add(m_undo_action, Gtk::AccelKey("<control>Z"),
- sigc::mem_fun(Application::app()->undo_history(),
- &UndoHistory::undo));
- Application::app()->undo_history().signal_changed.connect(
- sigc::mem_fun(*this, &NiepceWindow::undo_state));
- undo_state();
- m_redo_action = Gtk::Action::create("Redo", Gtk::Stock::REDO);
- m_refActionGroup->add(m_redo_action, Gtk::AccelKey("<control><shift>Z"),
- sigc::mem_fun(Application::app()->undo_history(),
- &UndoHistory::redo));
- Application::app()->undo_history().signal_changed.connect(
- sigc::mem_fun(*this, &NiepceWindow::redo_state));
- redo_state();
+
+ create_undo_action(m_refActionGroup);
+ create_redo_action(m_refActionGroup);
// FIXME: bind
m_refActionGroup->add(Gtk::Action::create("Cut", Gtk::Stock::CUT));
@@ -380,22 +369,6 @@ void NiepceWindow::init_actions()
->uiManager()->get_accel_group());
}
-void NiepceWindow::undo_state()
-{
- fwk::UndoHistory & history(Application::app()->undo_history());
- m_undo_action->set_sensitive(history.has_undo());
- std::string s = history.next_undo();
- m_undo_action->property_label() = Glib::ustring(_("Undo ")) + s;
-}
-
-
-void NiepceWindow::redo_state()
-{
- fwk::UndoHistory & history(Application::app()->undo_history());
- m_redo_action->set_sensitive(history.has_redo());
- std::string s = history.next_redo();
- m_redo_action->property_label() = Glib::ustring(_("Redo ")) + s;
-}
void NiepceWindow::on_action_file_import()
{
diff --git a/src/niepce/ui/niepcewindow.hpp b/src/niepce/ui/niepcewindow.hpp
index b5d2e17..7ce3cf5 100644
--- a/src/niepce/ui/niepcewindow.hpp
+++ b/src/niepce/ui/niepcewindow.hpp
@@ -60,9 +60,6 @@ public:
protected:
virtual Gtk::Widget * buildWidget();
private:
- void undo_state();
- void redo_state();
-
void on_action_file_import();
void on_action_file_quit();
@@ -94,8 +91,6 @@ private:
ui::SelectionController::Ptr m_selection_controller;
Gtk::Statusbar m_statusBar;
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
- Glib::RefPtr<Gtk::Action> m_undo_action;
- Glib::RefPtr<Gtk::Action> m_redo_action;
libraryclient::LibraryClient::Ptr m_libClient;
eng::Label::List m_labels;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]