[gnote] Restore note position in new window
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Restore note position in new window
- Date: Sun, 21 Oct 2012 20:09:00 +0000 (UTC)
commit 49b01b07993d846e3e099d599c06ea79cecbe217
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Sun Oct 21 23:06:49 2012 +0300
Restore note position in new window
When note get opened in a new window (multiple open), restore
it's window position.
src/note.cpp | 7 +++----
src/notewindow.cpp | 18 +++++++++++++-----
src/notewindow.hpp | 7 +++++++
3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index d8bdc62..fa95538 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -1009,10 +1009,9 @@ namespace gnote {
if(m_data.data().has_extent()) {
m_window->set_size(m_data.data().width(), m_data.data().height());
}
-#if 0
- if (m_data.data().has_position())
- m_window->move(m_data.data().x(), m_data.data().y());
-#endif
+ if(m_data.data().has_position()) {
+ m_window->set_position(m_data.data().x(), m_data.data().y());
+ }
m_window->signal_embeded.connect(sigc::mem_fun(*this, &Note::on_note_window_embeded));
}
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 4b65850..320a45b 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -57,6 +57,8 @@ namespace gnote {
, m_name(note.get_title())
, m_height(360)
, m_width(450)
+ , m_x(-1)
+ , m_y(-1)
, m_global_keys(NULL)
{
m_template_tag = TagManager::obj().get_or_create_system_tag(TagManager::TEMPLATE_NOTE_SYSTEM_TAG);
@@ -152,17 +154,23 @@ namespace gnote {
void NoteWindow::foreground()
{
//addins may add accelarators, so accel group must be there
- Gtk::Window *parent = dynamic_cast<Gtk::Window*>(host());
+ utils::EmbedableWidgetHost *current_host = host();
+ Gtk::Window *parent = dynamic_cast<Gtk::Window*>(current_host);
if(parent) {
add_accel_group(*parent);
}
utils::EmbedableWidget::foreground();
- parent->set_default_size(m_width, m_height);
- if((parent->get_window()->get_state() & Gdk::WINDOW_STATE_MAXIMIZED) == 0 && parent->get_visible()) {
- parent->get_window()->resize(m_width, m_height);
+ if(parent) {
+ parent->set_default_size(m_width, m_height);
+ if((parent->get_window()->get_state() & Gdk::WINDOW_STATE_MAXIMIZED) == 0 && parent->get_visible()) {
+ parent->get_window()->resize(m_width, m_height);
+ }
+ if(m_x >= 0 && m_y >= 0 && !current_host->running()) {
+ parent->move(m_x, m_y);
+ }
+ parent->set_focus(*m_editor);
}
- parent->set_focus(*m_editor);
m_editor->scroll_to(m_editor->get_buffer()->get_insert());
}
diff --git a/src/notewindow.hpp b/src/notewindow.hpp
index a911eda..2b1b684 100644
--- a/src/notewindow.hpp
+++ b/src/notewindow.hpp
@@ -120,6 +120,11 @@ public:
m_width = width;
m_height = height;
}
+ void set_position(int x, int y)
+ {
+ m_x = x;
+ m_y = y;
+ }
Gtk::TextView * editor() const
{
return m_editor;
@@ -179,6 +184,8 @@ private:
std::string m_name;
int m_height;
int m_width;
+ int m_x;
+ int m_y;
Glib::RefPtr<Gtk::AccelGroup> m_accel_group;
Gtk::Toolbar *m_toolbar;
Gtk::ToolButton *m_link_button;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]