[gnote] Add background mode
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add background mode
- Date: Sun, 13 Nov 2011 16:07:05 +0000 (UTC)
commit f9e99f524dfe174b277a4930f03f71466f9e1993
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Sun Nov 13 17:48:42 2011 +0200
Add background mode
Also make D-Bus autostart to use it.
Thanks Casey Harkins.
data/org.gnome.Gnote.service.in | 2 +-
src/gnote.cpp | 13 ++++++++++++-
src/gnote.hpp | 12 +++++++++++-
3 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/data/org.gnome.Gnote.service.in b/data/org.gnome.Gnote.service.in
index 39169c8..28ce8f3 100644
--- a/data/org.gnome.Gnote.service.in
+++ b/data/org.gnome.Gnote.service.in
@@ -1,5 +1,5 @@
[D-BUS Service]
Name=org.gnome.Gnote
-Exec= bindir@/@wrapper@
+Exec= bindir@/@wrapper@ --background
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 6edbc18..c41a943 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -112,6 +112,7 @@ namespace gnote {
: m_manager(NULL)
, m_keybinder(NULL)
, m_is_panel_applet(false)
+ , m_is_background(false)
, m_prefsdlg(NULL)
, m_app(NULL)
{
@@ -212,6 +213,11 @@ namespace gnote {
void Gnote::end_main(bool bus_acquired, bool name_acquired)
{
+ ActionManager & am(ActionManager::obj());
+ if((m_is_background = cmd_line.background())) {
+ am["CloseWindowAction"]->set_visible(true);
+ am["QuitGNoteAction"]->set_visible(false);
+ }
if(cmd_line.needs_execute()) {
cmd_line.execute();
}
@@ -248,8 +254,11 @@ namespace gnote {
DBG_OUT("starting tray icon");
start_tray_icon();
}
+ else if(m_is_background) {
+ // Create Search All Notes window as we need it present for application to run
+ NoteRecentChanges::get_instance(default_note_manager());
+ }
else {
- ActionManager & am(ActionManager::obj());
am["ShowSearchAllNotesAction"]->activate();
}
}
@@ -548,6 +557,7 @@ namespace gnote {
GnoteCommandLine::GnoteCommandLine()
: m_context(g_option_context_new("Foobar"))
, m_use_panel(false)
+ , m_background(false)
, m_note_path(NULL)
, m_do_search(false)
, m_show_version(false)
@@ -559,6 +569,7 @@ namespace gnote {
static const GOptionEntry entries[] =
{
{ "panel-applet", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &m_use_panel, _("Run Gnote as a GNOME panel applet."), NULL },
+ { "background", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &m_background, _("Run Gnote in background."), NULL },
{ "note-path", 0, 0, G_OPTION_ARG_STRING, &m_note_path, _("Specify the path of the directory containing the notes."), _("path") },
{ "search", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, (void*)GnoteCommandLine::parse_func, _("Open the search all notes window with the search text."), _("text") },
{ "version", 0, 0, G_OPTION_ARG_NONE, &m_show_version, _("Print version information."), NULL },
diff --git a/src/gnote.hpp b/src/gnote.hpp
index 8fb2cb0..8ecb084 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -62,6 +62,10 @@ public:
{
return m_use_panel;
}
+ bool background()
+ {
+ return m_background;
+ }
void parse(int &argc, gchar ** & argv);
static gboolean parse_func(const gchar *option_name,
@@ -78,6 +82,7 @@ private:
GOptionContext *m_context;
bool m_use_panel;
+ bool m_background;
gchar * m_note_path;
bool m_do_search;
std::string m_search;
@@ -143,9 +148,13 @@ public:
{
return m_is_panel_applet;
}
+ bool is_background() const
+ {
+ return m_is_background;
+ }
bool windowed()
{
- return !tray_icon_showing();
+ return !tray_icon_showing() && !is_background();
}
void set_tray(const Tray::Ptr & tray)
{
@@ -167,6 +176,7 @@ private:
Glib::RefPtr<TrayIcon> m_tray_icon;
Tray::Ptr m_tray;
bool m_is_panel_applet;
+ bool m_is_background;
PreferencesDialog *m_prefsdlg;
GnoteCommandLine cmd_line;
GnoteApp *m_app;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]