[gnote] Add option to open notes in new window
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add option to open notes in new window
- Date: Thu, 20 Jun 2013 11:43:52 +0000 (UTC)
commit cf0179e5fcf8f0dd6f25f02b7a6993440621e319
Author: Aurimas Černius <aurisc4 gmail com>
Date: Thu Jun 20 14:42:50 2013 +0300
Add option to open notes in new window
Add GSettings key and make it work.
Part of Bug 700458.
data/org.gnome.gnote.gschema.xml.in | 5 +++++
src/preferences.cpp | 3 ++-
src/preferences.hpp | 3 ++-
src/recentchanges.cpp | 22 +++++++++++++++++++---
src/recentchanges.hpp | 2 ++
src/searchnoteswidget.cpp | 28 +++++++++++++++++++++++-----
src/searchnoteswidget.hpp | 1 +
src/watchers.cpp | 6 +++++-
8 files changed, 59 insertions(+), 11 deletions(-)
---
diff --git a/data/org.gnome.gnote.gschema.xml.in b/data/org.gnome.gnote.gschema.xml.in
index 53572f4..c0fce03 100644
--- a/data/org.gnome.gnote.gschema.xml.in
+++ b/data/org.gnome.gnote.gschema.xml.in
@@ -120,6 +120,11 @@
<_summary>Use status icon, when started as an application</_summary>
<_description>Has affect only when started as an application. When set to TRUE, shows a status icon.
If set to FALSE, Search All Notes window is used as main application window, closing which makes application
to exit.</_description>
</key>
+ <key name="open-notes-in-new-window" type="b">
+ <default>false</default>
+ <_summary>Open notes in new window</_summary>
+ <_description>Open notes in new window instead of replacing active content of the same
window</_description>
+ </key>
<child name="global-keybindings" schema="org.gnome.gnote.global-keybindings" />
<child name="export-html" schema="org.gnome.gnote.export-html" />
<child name="sync" schema="org.gnome.gnote.sync" />
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 873ff26..43347d0 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2012 Aurimas Cernius
+ * Copyright (C) 2011-2013 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -60,6 +60,7 @@ namespace gnote {
const char * Preferences::NOTE_RENAME_BEHAVIOR = "note-rename-behavior";
const char * Preferences::USE_STATUS_ICON = "use-status-icon";
+ const char * Preferences::OPEN_NOTES_IN_NEW_WINDOW = "open-notes-in-new-window";
const char * Preferences::MAIN_WINDOW_MAXIMIZED = "main-window-maximized";
const char * Preferences::SEARCH_WINDOW_X_POS = "search-window-x-pos";
diff --git a/src/preferences.hpp b/src/preferences.hpp
index 3d3c621..49e245a 100644
--- a/src/preferences.hpp
+++ b/src/preferences.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2012 Aurimas Cernius
+ * Copyright (C) 2011-2013 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -58,6 +58,7 @@ namespace gnote {
static const char *NOTE_RENAME_BEHAVIOR;
static const char *USE_STATUS_ICON;
+ static const char *OPEN_NOTES_IN_NEW_WINDOW;
static const char *MAIN_WINDOW_MAXIMIZED;
static const char *SEARCH_WINDOW_X_POS;
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index c5c6d27..a240964 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -51,14 +51,17 @@ namespace gnote {
, m_window_menu_embedded(NULL)
, m_window_menu_default(NULL)
, m_keybinder(get_accel_group())
+ , m_open_notes_in_new_window(Preferences::obj().get_schema_settings(
+ Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW))
{
set_default_size(450,400);
set_resizable(true);
set_hide_titlebar_when_maximized(true);
- if(Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
- Preferences::MAIN_WINDOW_MAXIMIZED)) {
+ Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+ if(settings->get_boolean(Preferences::MAIN_WINDOW_MAXIMIZED)) {
maximize();
}
+ settings->signal_changed().connect(sigc::mem_fun(*this, &NoteRecentChanges::on_settings_changed));
set_has_resize_grip(true);
@@ -311,7 +314,12 @@ namespace gnote {
void NoteRecentChanges::on_open_note(const Note::Ptr & note)
{
- present_note(note);
+ if(m_open_notes_in_new_window) {
+ on_open_note_new_window(note);
+ }
+ else {
+ present_note(note);
+ }
}
void NoteRecentChanges::on_open_note_new_window(const Note::Ptr & note)
@@ -706,5 +714,13 @@ namespace gnote {
}
}
+ void NoteRecentChanges::on_settings_changed(const Glib::ustring & key)
+ {
+ if(key == Preferences::OPEN_NOTES_IN_NEW_WINDOW) {
+ m_open_notes_in_new_window = Preferences::obj().get_schema_settings(
+ Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
+ }
+ }
+
}
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index 18bc9e6..2b75a2f 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -85,6 +85,7 @@ private:
std::vector<Gtk::MenuItem*> & make_menu_items(std::vector<Gtk::MenuItem*> & items,
const std::vector<Glib::RefPtr<Gtk::Action> > & actions);
void on_main_window_actions_changed(Gtk::Menu **menu);
+ void on_settings_changed(const Glib::ustring & key);
NoteManager &m_note_manager;
SearchNotesWidget m_search_notes_widget;
@@ -106,6 +107,7 @@ private:
Gtk::Menu *m_window_menu_embedded;
Gtk::Menu *m_window_menu_default;
utils::GlobalKeybinder m_keybinder;
+ bool m_open_notes_in_new_window;
};
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 35cabb1..d2a4856 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -100,6 +100,9 @@ SearchNotesWidget::SearchNotesWidget(NoteManager & m)
.connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_removed_from_notebook));
notebooks::NotebookManager::obj().signal_note_pin_status_changed
.connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_pin_status_changed));
+
+ Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->signal_changed()
+ .connect(sigc::mem_fun(*this, &SearchNotesWidget::on_settings_changed));
}
SearchNotesWidget::~SearchNotesWidget()
@@ -1267,11 +1270,16 @@ Gtk::Menu *SearchNotesWidget::get_note_list_context_menu()
{
if(!m_note_list_context_menu) {
m_note_list_context_menu = new Gtk::Menu;
-
- Gtk::MenuItem *item = manage(new Gtk::MenuItem);
- item->set_related_action(m_open_note_action);
- item->add_accelerator("activate", m_accel_group, GDK_KEY_O, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
- m_note_list_context_menu->add(*item);
+ bool open_notes_in_new_window = Preferences::obj().get_schema_settings(
+ Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
+
+ Gtk::MenuItem *item;
+ if(!open_notes_in_new_window) {
+ item = manage(new Gtk::MenuItem);
+ item->set_related_action(m_open_note_action);
+ item->add_accelerator("activate", m_accel_group, GDK_KEY_O, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
+ m_note_list_context_menu->add(*item);
+ }
item = manage(new Gtk::MenuItem);
item->set_related_action(m_open_note_new_window_action);
@@ -1414,4 +1422,14 @@ sigc::signal<void> & SearchNotesWidget::signal_actions_changed()
return IActionManager::obj().signal_main_window_search_actions_changed;
}
+void SearchNotesWidget::on_settings_changed(const Glib::ustring & key)
+{
+ if(key == Preferences::OPEN_NOTES_IN_NEW_WINDOW) {
+ if(m_note_list_context_menu) {
+ delete m_note_list_context_menu;
+ m_note_list_context_menu = NULL;
+ }
+ }
+}
+
}
diff --git a/src/searchnoteswidget.hpp b/src/searchnoteswidget.hpp
index 502b753..0e3cc7a 100644
--- a/src/searchnoteswidget.hpp
+++ b/src/searchnoteswidget.hpp
@@ -121,6 +121,7 @@ private:
void on_open_notebook_template_note();
void on_new_notebook();
void on_delete_notebook();
+ void on_settings_changed(const Glib::ustring & key);
class RecentSearchColumnTypes
: public Gtk::TreeModelColumnRecord
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 3d92b89..29aca14 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -910,7 +910,11 @@ namespace gnote {
// also works around the bug.
if (link) {
DBG_OUT ("Opening note '%s' on click...", link_name.c_str());
- MainWindow *window = MainWindow::get_owning(const_cast<NoteEditor&>(editor));
+ MainWindow *window = NULL;
+ if(false == Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+ Preferences::OPEN_NOTES_IN_NEW_WINDOW)) {
+ 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]