[gnote] Timeout when started as shell search provider



commit 551c0bc537b8171d6dc3ae732b48e56e5e86ee2c
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Sep 14 17:51:56 2014 +0300

    Timeout when started as shell search provider
    
    When started by GNOME Shell as search provider, exit automatically after
    timeout.
    Fixes Bug 736472.

 data/org.gnome.Gnote.service.in |    2 +-
 src/gnote.cpp                   |   12 ++++++++++--
 src/gnote.hpp                   |   10 ++++++++--
 3 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.Gnote.service.in b/data/org.gnome.Gnote.service.in
index 28ce8f3..e1aea07 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@ --background
+Exec= bindir@/@wrapper@ --shell-search
 
diff --git a/src/gnote.cpp b/src/gnote.cpp
index ebc7093..d6322c5 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -67,6 +67,7 @@ namespace gnote {
     : Gtk::Application("org.gnome.Gnote", Gio::APPLICATION_HANDLES_COMMAND_LINE)
     , m_manager(NULL)
     , m_is_background(false)
+    , m_is_shell_search(false)
     , m_prefsdlg(NULL)
 #ifdef HAVE_X11_SUPPORT
     , m_keybinder(NULL)
@@ -134,7 +135,7 @@ namespace gnote {
     else if(cmdline.needs_execute()) {
       cmdline.execute();
     }
-    else if(!cmdline.background()) {
+    else if(!cmdline.background() && !cmdline.shell_search()) {
       new_main_window().present();
     }
 
@@ -169,6 +170,7 @@ namespace gnote {
     if((m_is_background = cmd_line.background())) {
       am["QuitGNoteAction"]->set_visible(false);
     }
+    m_is_shell_search = cmd_line.shell_search();
     if(cmd_line.needs_execute()) {
       cmd_line.execute();
     }
@@ -208,9 +210,13 @@ namespace gnote {
       DBG_OUT("starting tray icon");
       start_tray_icon();
     }
-    else if(m_is_background) {
+    else if(is_background()) {
       // do not exit when all windows are closed
       hold();
+      if(m_is_shell_search) {
+        set_inactivity_timeout(30000);
+        release();
+      }
     }
     else {
       get_main_window().present();
@@ -550,6 +556,7 @@ namespace gnote {
     : m_context(g_option_context_new("Foobar"))
     , m_use_panel(false)
     , m_background(false)
+    , m_shell_search(false)
     , m_note_path(NULL)
     , m_do_search(false)
     , m_show_version(false)
@@ -561,6 +568,7 @@ namespace gnote {
     const GOptionEntry entries[] =
       {
         { "background", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &m_background, _("Run Gnote in 
background."), NULL },
+        { "shell-search", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &m_shell_search, _("Run Gnote as GNOME 
Shell search provider."), 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 39054d5..30ac62c 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2013 Aurimas Cernius
+ * Copyright (C) 2010-2014 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -66,6 +66,10 @@ public:
     {
       return m_background;
     }
+  bool shell_search()
+    {
+      return m_shell_search;
+    }
   void parse(int &argc, gchar ** & argv);
 
   static gboolean parse_func(const gchar *option_name,
@@ -83,6 +87,7 @@ private:
 
   bool        m_use_panel;
   bool        m_background;
+  bool        m_shell_search;
   gchar *     m_note_path;
   bool        m_do_search;
   std::string m_search;
@@ -144,7 +149,7 @@ public:
     }
   bool is_background() const
     {
-      return m_is_background;
+      return m_is_background || m_is_shell_search;
     }
   bool windowed()
     {
@@ -181,6 +186,7 @@ private:
   Glib::RefPtr<TrayIcon> m_tray_icon;
   Tray::Ptr m_tray;
   bool m_is_background;
+  bool m_is_shell_search;
   PreferencesDialog *m_prefsdlg;
   GnoteCommandLine cmd_line;
   sync::SyncDialog::Ptr m_sync_dlg;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]