From 213f6196686e42fd26da3a0bc8914653762e67c1 Mon Sep 17 00:00:00 2001
From: Santanu Sinha
Date: Wed, 9 Sep 2009 15:26:00 +0530
Subject: [PATCH] Cleanup of Editor renderer
- Removed menu items that will not be used anymore
+ Added save, undo and redo to toolbars
+ Modified cursor changer to use dispatchers
---
data/solang-editor.ui | 11 ++++++++
src/application/Makefile.am | 2 +-
src/common/Makefile.am | 1 +
src/common/cursor-changer.cpp | 56 +++++++++++++++++++++++++++++++++++++++++
src/common/cursor-changer.h | 33 ++++++++++++++----------
src/editor/editor.cpp | 4 ++-
6 files changed, 91 insertions(+), 16 deletions(-)
create mode 100644 src/common/cursor-changer.cpp
diff --git a/data/solang-editor.ui b/data/solang-editor.ui
index a203c10..1047b6c 100644
--- a/data/solang-editor.ui
+++ b/data/solang-editor.ui
@@ -6,6 +6,7 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application/Makefile.am b/src/application/Makefile.am
index 0a6757a..606789d 100644
--- a/src/application/Makefile.am
+++ b/src/application/Makefile.am
@@ -22,9 +22,9 @@ solang_LDADD = \
$(top_builddir)/src/storage/libstorage.la \
$(top_builddir)/src/attribute/libattribute.la \
$(top_builddir)/src/database/libdatabase.la \
- $(top_builddir)/src/common/libcommon.la \
$(top_builddir)/src/editor/libeditor.la \
$(top_builddir)/src/edit-engine/libeditengine.la \
+ $(top_builddir)/src/common/libcommon.la \
$(EXIV2_LIBS) \
$(FLICKCURL_LIBS) \
$(GPHOTO2_LIBS) \
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 6ccca8b..84c3b43 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = \
content-type-repo.cpp \
content-type-repo.h \
+ cursor-changer.cpp \
cursor-changer.h \
error.cpp \
error.h \
diff --git a/src/common/cursor-changer.cpp b/src/common/cursor-changer.cpp
new file mode 100644
index 0000000..5153dec
--- /dev/null
+++ b/src/common/cursor-changer.cpp
@@ -0,0 +1,56 @@
+#include "cursor-changer.h"
+
+namespace Solang
+{
+CursorChanger::State CursorChanger::state_;
+
+CursorChanger::CursorChanger(Gtk::Widget &widget)
+{
+ CursorChanger::State *state
+ = &CursorChanger::state_;
+ state->widget_ = &widget;
+ state->change_.emit();
+}
+
+CursorChanger::~CursorChanger()
+{
+ CursorChanger::state_.change_.emit();
+}
+
+void
+CursorChanger::set_cursor()
+{
+ CursorChanger::State *state = &CursorChanger::state_;
+ if( !state->busy_ )
+ {
+ state->widget_->get_window()->set_cursor(
+ Gdk::Cursor( state->widget_->get_display(),
+ Gdk::WATCH ) );
+ state->widget_->set_sensitive( false );
+ state->busy_ = true;
+ }
+ else
+ {
+ state->widget_->get_window()->set_cursor();
+ state->widget_->set_sensitive( true );
+ state->busy_ = false;
+ }
+}
+
+CursorChanger::State::State()
+ :widget_( 0 ),
+ change_(),
+ busy_( false ),
+ conn_()
+{
+ conn_ = change_.connect(
+ &CursorChanger::set_cursor );
+}
+
+CursorChanger::State::~State()
+{
+ conn_.disconnect();
+}
+
+} //namespace Solang
+
diff --git a/src/common/cursor-changer.h b/src/common/cursor-changer.h
index c48ba70..86b51bd 100644
--- a/src/common/cursor-changer.h
+++ b/src/common/cursor-changer.h
@@ -1,30 +1,35 @@
#ifndef SOLANG_CURSOR_CHANGER_H
#define SOLANG_CURSOR_CHANGER_H
+#include
+
namespace Solang
{
class CursorChanger
{
public:
- CursorChanger(Gtk::Widget &widget)
- :widget_( widget )
- {
- widget_.get_window()->set_cursor(
- Gdk::Cursor( widget_.get_display(),
- Gdk::WATCH ) );
- widget_.set_sensitive( false );
- }
+ CursorChanger(Gtk::Widget &widget);
+ ~CursorChanger();
+
+ private:
+
+ static void
+ set_cursor();
- ~CursorChanger()
+ struct State
{
- widget_.get_window()->set_cursor();
- widget_.set_sensitive( true );
- }
+ Gtk::Widget *widget_;
+ Glib::Dispatcher change_;
+ bool busy_;
+ sigc::connection conn_;
+ State();
+ ~State();
+ };
- private:
- Gtk::Widget &widget_;
+ static State state_;
+ friend struct CursorChanger::State;
};
diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp
index 4da2beb..930df9f 100644
--- a/src/editor/editor.cpp
+++ b/src/editor/editor.cpp
@@ -132,6 +132,8 @@ Editor::Editor( )
Gtk::AccelKey("y"),
sigc::mem_fun(*this, &Editor::on_action_redo));
+#if 0
+
actionGroup_->add(
Gtk::Action::create(
"ActionEditFlipHorizontal",
@@ -176,7 +178,7 @@ Editor::Editor( )
_("Scale/resize the selected image(s)")),
Gtk::AccelKey(""),
sigc::mem_fun(*this, &Editor::on_action_scale));
-
+#endif
actionGroup_->add(
Gtk::Action::create(
"ActionEditSaveAs", Gtk::Stock::SAVE,
--
1.6.0.4