[gnote] Create main window interface
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Create main window interface
- Date: Sat, 19 Jan 2013 16:48:29 +0000 (UTC)
commit 7001dd390ff8dbd1d179e59e034c7917a88f6e87
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Sat Jan 19 18:27:08 2013 +0200
Create main window interface
Use MainWindow everywhere, make NoteRecentChanges it's implementation.
src/Makefile.am | 1 +
src/addins/backlinks/backlinkmenuitem.cpp | 2 +-
src/dbus/remotecontrol.cpp | 5 +--
src/gnote.cpp | 27 ++++++++--------
src/gnote.hpp | 9 ++---
src/ignote.hpp | 8 ++--
src/mainwindow.cpp | 48 +++++++++++++++++++++++++++++
src/mainwindow.hpp | 48 +++++++++++++++++++++++++++++
src/noterenamedialog.cpp | 5 +--
src/notewindow.cpp | 1 -
src/prefskeybinder.cpp | 1 -
src/recentchanges.cpp | 25 ++------------
src/recentchanges.hpp | 17 +++------
src/synchronization/syncdialog.cpp | 2 +-
src/tray.cpp | 2 +-
src/watchers.cpp | 3 +-
16 files changed, 137 insertions(+), 67 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 9ac9351..4d3cfa1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -112,6 +112,7 @@ libgnote_la_SOURCES = \
importaddin.hpp importaddin.cpp \
itagmanager.hpp itagmanager.cpp \
keybinder.hpp \
+ mainwindow.hpp mainwindow.cpp \
noteaddin.hpp noteaddin.cpp \
notebuffer.hpp notebuffer.cpp \
noteeditor.hpp noteeditor.cpp \
diff --git a/src/addins/backlinks/backlinkmenuitem.cpp b/src/addins/backlinks/backlinkmenuitem.cpp
index 3aa08f5..e3aee08 100644
--- a/src/addins/backlinks/backlinkmenuitem.cpp
+++ b/src/addins/backlinks/backlinkmenuitem.cpp
@@ -56,7 +56,7 @@ void BacklinkMenuItem::on_activate()
find.property_visible() = true;
find.set_search_text(m_title_search);
- gnote::NoteRecentChanges *window = gnote::NoteRecentChanges::get_owning(*this);
+ gnote::MainWindow *window = gnote::MainWindow::get_owning(*this);
if(!window) {
window = gnote::IGnote::obj().new_main_window();
}
diff --git a/src/dbus/remotecontrol.cpp b/src/dbus/remotecontrol.cpp
index edfa2be..ca2481b 100644
--- a/src/dbus/remotecontrol.cpp
+++ b/src/dbus/remotecontrol.cpp
@@ -24,7 +24,6 @@
#include "ignote.hpp"
#include "notemanager.hpp"
#include "notewindow.hpp"
-#include "recentchanges.hpp"
#include "remotecontrolproxy.hpp"
#include "search.hpp"
#include "tag.hpp"
@@ -154,7 +153,7 @@ namespace gnote {
void RemoteControl::DisplaySearchWithText(const std::string& search_text)
{
- NoteRecentChanges *recent_changes = IGnote::obj().get_main_window();
+ MainWindow *recent_changes = IGnote::obj().get_main_window();
recent_changes->set_search_text(search_text);
recent_changes->present();
}
@@ -409,7 +408,7 @@ void RemoteControl::on_note_saved(const Note::Ptr & note)
void RemoteControl::present_note(const Note::Ptr & note)
{
- NoteRecentChanges *window = IGnote::obj().get_window_for_note();
+ MainWindow *window = IGnote::obj().get_window_for_note();
window->present_note(note);
window->present();
}
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 167a851..8a7b972 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -45,6 +45,7 @@
#include "notemanager.hpp"
#include "notewindow.hpp"
#include "preferencesdialog.hpp"
+#include "recentchanges.hpp"
#include "remotecontrolproxy.hpp"
#include "utils.hpp"
#include "tagmanager.hpp"
@@ -388,7 +389,7 @@ namespace gnote {
about.set_documenters(documenters);
about.set_translator_credits(translators);
// about.set_icon_name("gnote");
- NoteRecentChanges *recent_changes = get_main_window();
+ MainWindow *recent_changes = get_main_window();
if(recent_changes && recent_changes->get_visible()) {
about.set_transient_for(*recent_changes);
recent_changes->present();
@@ -396,7 +397,7 @@ namespace gnote {
about.run();
}
- NoteRecentChanges *Gnote::new_main_window()
+ MainWindow *Gnote::new_main_window()
{
NoteRecentChanges *win = new NoteRecentChanges(default_note_manager());
win->signal_hide().connect(sigc::mem_fun(*this, &Gnote::on_main_window_closed));
@@ -404,12 +405,12 @@ namespace gnote {
return win;
}
- NoteRecentChanges *Gnote::get_main_window()
+ MainWindow *Gnote::get_main_window()
{
std::vector<Gtk::Window*> windows = Gtk::Window::list_toplevels();
for(std::vector<Gtk::Window*>::iterator iter = windows.begin();
iter != windows.end(); ++iter) {
- NoteRecentChanges *rc = dynamic_cast<NoteRecentChanges*>(*iter);
+ MainWindow *rc = dynamic_cast<MainWindow*>(*iter);
if(rc) {
return rc;
}
@@ -426,12 +427,12 @@ namespace gnote {
}
}
- NoteRecentChanges *Gnote::get_window_for_note()
+ MainWindow *Gnote::get_window_for_note()
{
std::vector<Gtk::Window*> windows = Gtk::Window::list_toplevels();
- NoteRecentChanges *window = NULL;
+ MainWindow *window = NULL;
for(std::vector<Gtk::Window*>::iterator iter = windows.begin(); iter != windows.end(); ++iter) {
- NoteRecentChanges *rc = dynamic_cast<NoteRecentChanges*>(*iter);
+ MainWindow *rc = dynamic_cast<MainWindow*>(*iter);
if(rc) {
window = rc;
if(rc->get_visible()) {
@@ -449,7 +450,7 @@ namespace gnote {
void Gnote::open_search_all()
{
- NoteRecentChanges *main_window = get_main_window();
+ MainWindow *main_window = get_main_window();
main_window->present_search();
main_window->present();
}
@@ -503,12 +504,12 @@ namespace gnote {
}
- NoteRecentChanges *Gnote::get_active_window()
+ MainWindow *Gnote::get_active_window()
{
std::vector<Gtk::Window*> windows = Gtk::Window::list_toplevels();
for(std::vector<Gtk::Window*>::iterator iter = windows.begin(); iter != windows.end(); ++iter) {
if((*iter)->property_is_active()) {
- return dynamic_cast<NoteRecentChanges*>(*iter);
+ return dynamic_cast<MainWindow*>(*iter);
}
}
@@ -518,12 +519,12 @@ namespace gnote {
void Gnote::on_new_note_app_action(const Glib::VariantBase&)
{
- NoteRecentChanges *rc = get_active_window();
+ MainWindow *rc = get_active_window();
if(rc) {
rc->new_note();
}
else {
- NoteRecentChanges *recent_changes = get_main_window();
+ MainWindow *recent_changes = get_main_window();
recent_changes->new_note();
recent_changes->present();
}
@@ -532,7 +533,7 @@ namespace gnote {
void Gnote::open_note(const Note::Ptr & note)
{
- NoteRecentChanges *main_window = get_window_for_note();
+ MainWindow *main_window = get_window_for_note();
main_window->present_note(note);
main_window->present();
}
diff --git a/src/gnote.hpp b/src/gnote.hpp
index e09cf69..2273ed4 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -34,7 +34,6 @@
#include "actionmanager.hpp"
#include "ignote.hpp"
#include "keybinder.hpp"
-#include "recentchanges.hpp"
#include "remotecontrolproxy.hpp"
#include "tray.hpp"
#include "synchronization/syncdialog.hpp"
@@ -127,9 +126,9 @@ public:
void on_show_preferences_action(const Glib::VariantBase&);
void on_show_help_action(const Glib::VariantBase&);
void on_show_about_action(const Glib::VariantBase&);
- virtual NoteRecentChanges *new_main_window();
- virtual NoteRecentChanges *get_main_window();
- virtual NoteRecentChanges *get_window_for_note();
+ virtual MainWindow *new_main_window();
+ virtual MainWindow *get_main_window();
+ virtual MainWindow *get_window_for_note();
virtual void open_search_all();
void open_note_sync_window(const Glib::VariantBase&);
@@ -169,7 +168,7 @@ private:
void make_app_menu();
void on_new_window_action(const Glib::VariantBase&);
void on_new_note_app_action(const Glib::VariantBase&);
- NoteRecentChanges *get_active_window();
+ MainWindow *get_active_window();
bool show_tray_icon_timeout();
void register_object();
diff --git a/src/ignote.hpp b/src/ignote.hpp
index 32f02e3..417ff22 100644
--- a/src/ignote.hpp
+++ b/src/ignote.hpp
@@ -20,7 +20,7 @@
#ifndef _IGNOTE_HPP_
#define _IGNOTE_HPP_
-#include "recentchanges.hpp"
+#include "mainwindow.hpp"
#include "base/singleton.hpp"
namespace gnote {
@@ -35,9 +35,9 @@ public:
static std::string old_note_dir();
virtual ~IGnote();
- virtual NoteRecentChanges *get_main_window() = 0;
- virtual NoteRecentChanges *get_window_for_note() = 0; //TODO change to return reference
- virtual NoteRecentChanges *new_main_window() = 0; //TODO change to return reference
+ virtual MainWindow *get_main_window() = 0;
+ virtual MainWindow *get_window_for_note() = 0; //TODO change to return reference
+ virtual MainWindow *new_main_window() = 0; //TODO change to return reference
virtual void open_note(const Note::Ptr & note) = 0;
virtual void open_search_all() = 0;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
new file mode 100644
index 0000000..2db59f6
--- /dev/null
+++ b/src/mainwindow.cpp
@@ -0,0 +1,48 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2013 Aurimas Cernius
+ *
+ * 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 "mainwindow.hpp"
+
+namespace gnote {
+
+MainWindow *MainWindow::get_owning(Gtk::Widget & widget)
+{
+ Gtk::Container *container = widget.get_parent();
+ if(!container) {
+ return dynamic_cast<MainWindow*>(&widget);
+ }
+
+ Gtk::Container *cntr = container->get_parent();
+ while(cntr) {
+ container = cntr;
+ cntr = container->get_parent();
+ }
+
+ return dynamic_cast<MainWindow*>(container);
+}
+
+
+MainWindow::MainWindow(const std::string & title)
+ : utils::ForcedPresentWindow(title)
+{
+}
+
+}
+
diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp
new file mode 100644
index 0000000..7821e5b
--- /dev/null
+++ b/src/mainwindow.hpp
@@ -0,0 +1,48 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2013 Aurimas Cernius
+ *
+ * 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 _MAINWINDOW_HPP_
+#define _MAINWINDOW_HPP_
+
+#include "note.hpp"
+#include "utils.hpp"
+
+
+namespace gnote {
+
+class MainWindow
+ : public utils::ForcedPresentWindow
+ , public utils::EmbeddableWidgetHost
+{
+public:
+ static MainWindow *get_owning(Gtk::Widget & widget);
+
+ explicit MainWindow(const std::string & title);
+
+ virtual void set_search_text(const std::string & value) = 0;
+ virtual void present_note(const Note::Ptr & note) = 0;
+ virtual void present_search() = 0;
+ virtual void new_note() = 0;
+};
+
+}
+
+#endif
+
diff --git a/src/noterenamedialog.cpp b/src/noterenamedialog.cpp
index f050982..8df2c26 100644
--- a/src/noterenamedialog.cpp
+++ b/src/noterenamedialog.cpp
@@ -31,7 +31,6 @@
#include "ignote.hpp"
#include "notewindow.hpp"
#include "noterenamedialog.hpp"
-#include "recentchanges.hpp"
namespace gnote {
@@ -362,9 +361,9 @@ void NoteRenameDialog::on_notes_view_row_activated(
return;
Gtk::Widget *parent = get_parent();
- NoteRecentChanges *window = NULL;
+ MainWindow *window = NULL;
if(parent) {
- window = NoteRecentChanges::get_owning(*parent);
+ window = MainWindow::get_owning(*parent);
}
if(!window) {
window = IGnote::obj().new_main_window();
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 4d90cfc..20d20f2 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -42,7 +42,6 @@
#include "preferences.hpp"
#include "utils.hpp"
#include "undo.hpp"
-#include "recentchanges.hpp"
#include "search.hpp"
#include "itagmanager.hpp"
#include "notebooks/notebookmanager.hpp"
diff --git a/src/prefskeybinder.cpp b/src/prefskeybinder.cpp
index fe85549..37050d5 100644
--- a/src/prefskeybinder.cpp
+++ b/src/prefskeybinder.cpp
@@ -28,7 +28,6 @@
#include "notewindow.hpp"
#include "preferences.hpp"
#include "prefskeybinder.hpp"
-#include "recentchanges.hpp"
#include "tray.hpp"
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 85fde7d..165cbb0 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -40,7 +40,7 @@
namespace gnote {
NoteRecentChanges::NoteRecentChanges(NoteManager& m)
- : NoteRecentChangesParent(_("Notes"))
+ : MainWindow(_("Notes"))
, m_note_manager(m)
, m_search_notes_widget(m)
, m_content_vbox(false, 0)
@@ -135,23 +135,6 @@ namespace gnote {
}
- NoteRecentChanges *NoteRecentChanges::get_owning(Gtk::Widget & widget)
- {
- Gtk::Container *container = widget.get_parent();
- if(!container) {
- return dynamic_cast<NoteRecentChanges*>(&widget);
- }
-
- Gtk::Container *cntr = container->get_parent();
- while(cntr) {
- container = cntr;
- cntr = container->get_parent();
- }
-
- return dynamic_cast<NoteRecentChanges*>(container);
- }
-
-
void NoteRecentChanges::on_open_note(const Note::Ptr & note)
{
present_note(note);
@@ -159,7 +142,7 @@ namespace gnote {
void NoteRecentChanges::on_open_note_new_window(const Note::Ptr & note)
{
- NoteRecentChanges *window = IGnote::obj().new_main_window();
+ MainWindow *window = IGnote::obj().new_main_window();
window->present();
window->present_note(note);
}
@@ -230,7 +213,7 @@ namespace gnote {
if(embedded.size() == 1 && embedded.front() == &m_search_notes_widget) {
m_search_notes_widget.focus_search_entry();
}
- NoteRecentChangesParent::on_show();
+ MainWindow::on_show();
}
void NoteRecentChanges::set_search_text(const std::string & value)
@@ -331,7 +314,7 @@ namespace gnote {
bool NoteRecentChanges::on_map_event(GdkEventAny *evt)
{
- bool res = NoteRecentChangesParent::on_map_event(evt);
+ bool res = MainWindow::on_map_event(evt);
m_mapped = true;
return res;
}
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index c67f42a..40a2275 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2012 Aurimas Cernius
+ * Copyright (C) 2010-2013 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -36,21 +36,16 @@
namespace gnote {
class NoteManager;
-typedef utils::ForcedPresentWindow NoteRecentChangesParent;
-
class NoteRecentChanges
- : public NoteRecentChangesParent
- , public utils::EmbeddableWidgetHost
+ : public MainWindow
{
public:
- static NoteRecentChanges *get_owning(Gtk::Widget & widget);
-
NoteRecentChanges(NoteManager& m);
virtual ~NoteRecentChanges();
- void set_search_text(const std::string & value);
- void present_note(const Note::Ptr & note);
- void new_note();
- void present_search();
+ virtual void set_search_text(const std::string & value);
+ virtual void present_note(const Note::Ptr & note);
+ virtual void new_note();
+ virtual void present_search();
virtual void embed_widget(utils::EmbeddableWidget &);
virtual void unembed_widget(utils::EmbeddableWidget &);
diff --git a/src/synchronization/syncdialog.cpp b/src/synchronization/syncdialog.cpp
index 3685821..547e9cd 100644
--- a/src/synchronization/syncdialog.cpp
+++ b/src/synchronization/syncdialog.cpp
@@ -795,7 +795,7 @@ void SyncDialog::rename_note(const Note::Ptr & note, const std::string & newTitl
void SyncDialog::present_note(const Note::Ptr & note)
{
- NoteRecentChanges *window = IGnote::obj().get_window_for_note();
+ MainWindow *window = IGnote::obj().get_window_for_note();
window->present_note(note);
window->present();
}
diff --git a/src/tray.cpp b/src/tray.cpp
index cd0e72d..f25f28c 100644
--- a/src/tray.cpp
+++ b/src/tray.cpp
@@ -93,7 +93,7 @@ namespace gnote {
{
if(!m_inhibit_activate) {
if(m_note) {
- NoteRecentChanges *window = IGnote::obj().get_window_for_note();
+ MainWindow *window = IGnote::obj().get_window_for_note();
window->present_note(m_note);
window->present();
}
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 5ac4ba9..9f370c2 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -38,7 +38,6 @@
#include "notemanager.hpp"
#include "notewindow.hpp"
#include "preferences.hpp"
-#include "recentchanges.hpp"
#include "itagmanager.hpp"
#include "triehit.hpp"
#include "watchers.hpp"
@@ -913,7 +912,7 @@ namespace gnote {
// also works around the bug.
if (link) {
DBG_OUT ("Opening note '%s' on click...", link_name.c_str());
- NoteRecentChanges *window = NoteRecentChanges::get_owning(const_cast<NoteEditor&>(editor));
+ MainWindow *window = MainWindow::get_owning(const_cast<NoteEditor&>(editor));
if(!window) {
window = IGnote::obj().new_main_window();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]