[gnote] Change window title according to what's displayed
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Change window title according to what's displayed
- Date: Sun, 25 Nov 2012 17:42:18 +0000 (UTC)
commit 7cbcd9a8b4e5b91b1dad451636651570309c2450
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Sun Nov 25 19:39:18 2012 +0200
Change window title according to what's displayed
Display note title in a window title, when displaying note.
Display notebook title in a window title, when selected notebook
is other then All Notes.
src/notewindow.cpp | 6 ++++++
src/notewindow.hpp | 5 +----
src/recentchanges.cpp | 14 ++++++++++++++
src/recentchanges.hpp | 2 ++
src/searchnoteswidget.cpp | 10 ++++++++--
src/searchnoteswidget.hpp | 2 +-
6 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 2ae49cb..8c9f752 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -156,6 +156,12 @@ namespace gnote {
return m_name;
}
+ void NoteWindow::set_name(const std::string & name)
+ {
+ m_name = name;
+ signal_name_changed(m_name);
+ }
+
void NoteWindow::embed(utils::EmbedableWidgetHost *h)
{
//remove from previous host, if any
diff --git a/src/notewindow.hpp b/src/notewindow.hpp
index 66be7fb..32995a3 100644
--- a/src/notewindow.hpp
+++ b/src/notewindow.hpp
@@ -107,10 +107,7 @@ public:
~NoteWindow();
virtual std::string get_name() const;
- void set_name(const std::string & name)
- {
- m_name = name;
- }
+ void set_name(const std::string & name);
virtual void embed(utils::EmbedableWidgetHost *h);
virtual void foreground();
virtual void background();
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 2c4c439..6dc098a 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -301,6 +301,9 @@ namespace gnote {
wid.show();
m_all_notes_button->set_sensitive(
dynamic_cast<SearchNotesWidget*>(&widget) != &m_search_notes_widget);
+ on_embeded_name_changed(widget.get_name());
+ m_current_embeded_name_slot = widget.signal_name_changed
+ .connect(sigc::mem_fun(*this, &NoteRecentChanges::on_embeded_name_changed));
}
catch(std::bad_cast&) {
}
@@ -312,6 +315,7 @@ namespace gnote {
if(currently_embeded() != &widget) {
return;
}
+ m_current_embeded_name_slot.disconnect();
Gtk::Widget &wid = dynamic_cast<Gtk::Widget&>(widget);
widget.background();
m_embed_box.remove(wid);
@@ -346,5 +350,15 @@ namespace gnote {
return res;
}
+ void NoteRecentChanges::on_embeded_name_changed(const std::string & name)
+ {
+ std::string title;
+ if(name != "") {
+ title = "[" + name + "] - ";
+ }
+ title += _("Notes");
+ set_title(title);
+ }
+
}
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index a07cd76..62c68b6 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -81,6 +81,7 @@ private:
utils::EmbedableWidget *currently_embeded();
Gtk::Toolbar *make_toolbar();
void on_all_notes_clicked();
+ void on_embeded_name_changed(const std::string & name);
NoteManager &m_note_manager;
SearchNotesWidget m_search_notes_widget;
@@ -89,6 +90,7 @@ private:
Gtk::ToolButton *m_all_notes_button;
std::list<utils::EmbedableWidget*> m_embeded_widgets;
bool m_mapped;
+ sigc::connection m_current_embeded_name_slot;
};
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 8990193..77d4461 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -187,7 +187,12 @@ SearchNotesWidget::~SearchNotesWidget()
std::string SearchNotesWidget::get_name() const
{
- return "All Notes"; //TODO change accrding selected notebook
+ notebooks::Notebook::Ptr selected_notebook = get_selected_notebook();
+ if(!selected_notebook
+ || std::tr1::dynamic_pointer_cast<notebooks::AllNotesNotebook>(selected_notebook)) {
+ return "";
+ }
+ return selected_notebook->get_name();
}
void SearchNotesWidget::make_actions()
@@ -574,6 +579,7 @@ void SearchNotesWidget::on_notebook_selection_changed()
}
update_results();
+ signal_name_changed(get_name());
}
bool SearchNotesWidget::on_notebooks_tree_button_pressed(GdkEventButton *ev)
@@ -613,7 +619,7 @@ bool SearchNotesWidget::on_notebooks_key_pressed(GdkEventKey *ev)
return false; // Let Escape be handled by the window.
}
-notebooks::Notebook::Ptr SearchNotesWidget::get_selected_notebook()
+notebooks::Notebook::Ptr SearchNotesWidget::get_selected_notebook() const
{
Gtk::TreeIter iter;
diff --git a/src/searchnoteswidget.hpp b/src/searchnoteswidget.hpp
index cfde14c..2f23639 100644
--- a/src/searchnoteswidget.hpp
+++ b/src/searchnoteswidget.hpp
@@ -78,7 +78,7 @@ private:
void on_notebook_selection_changed();
bool on_notebooks_tree_button_pressed(GdkEventButton *);
bool on_notebooks_key_pressed(GdkEventKey *);
- notebooks::Notebook::Ptr get_selected_notebook();
+ notebooks::Notebook::Ptr get_selected_notebook() const;
void update_results();
void popup_context_menu_at_location(Gtk::Menu *, int, int);
Note::List get_selected_notes();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]