[gnote] Don't import sticky notes of Tomboy has already done it.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] Don't import sticky notes of Tomboy has already done it.
- Date: Tue, 16 Jun 2009 03:21:34 -0400 (EDT)
commit dda1f1100880fc9efd5aef499d0a2fcd0ce66750
Author: Hubert Figuiere <hub figuiere net>
Date: Sat Jun 13 22:00:23 2009 -0400
Don't import sticky notes of Tomboy has already done it.
We assume that in that case the Tomboy importer will have.
po/POTFILES.in | 1 +
.../stickynoteimport/stickynoteimportnoteaddin.cpp | 33 ++++++++++++++++++-
src/notemanager.cpp | 5 ++-
src/preferences.hpp | 4 ++
4 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6e64be1..e762904 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -31,3 +31,4 @@ src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
src/addins/inserttimestamp/inserttimestamppreferences.cpp
src/addins/printnotes/printnotesnoteaddin.cpp
src/addins/stickynoteimport/stickynoteimportnoteaddin.cpp
+src/addins/tomboyimport/tomboyimportaddin.cpp
diff --git a/src/addins/stickynoteimport/stickynoteimportnoteaddin.cpp b/src/addins/stickynoteimport/stickynoteimportnoteaddin.cpp
index f496eee..66cb3b7 100644
--- a/src/addins/stickynoteimport/stickynoteimportnoteaddin.cpp
+++ b/src/addins/stickynoteimport/stickynoteimportnoteaddin.cpp
@@ -76,6 +76,8 @@ static const char * DEBUG_CREATE_ERROR_BASE = "StickyNoteImporter: Error while t
static const char * DEBUG_FIRST_RUN_DETECTED = "StickyNoteImporter: Detecting that importer has never been run...";
//static const char * DEBUG_GCONF_SET_ERROR_BASE = "StickyNoteImporter: Error setting initial GConf first run key value: %s";
+const char * TB_STICKYNOTEIMPORTER_FIRST_RUN =
+ "/apps/tomboy/sticky_note_importer/sticky_importer_first_run";
bool StickyNoteImportNoteAddin::s_static_inited = false;
bool StickyNoteImportNoteAddin::s_sticky_file_might_exist = true;
@@ -125,10 +127,37 @@ void StickyNoteImportNoteAddin::shutdown()
bool StickyNoteImportNoteAddin::want_to_run()
{
+ bool want_run;
+
if(s_sticky_file_might_exist) {
- return Preferences::obj().get<bool>(Preferences::STICKYNOTEIMPORTER_FIRST_RUN);
+ want_run = Preferences::obj().get<bool>(Preferences::STICKYNOTEIMPORTER_FIRST_RUN);
+ if(want_run) {
+ // we think we want to run
+ // so we check for Tomboy. If Tomboy wants to run then we want
+
+ GConfClient * client = Preferences::obj().get_client();
+ GError * error = NULL;
+ gboolean tb_must_run = gconf_client_get_bool(client,
+ TB_STICKYNOTEIMPORTER_FIRST_RUN,
+ &error);
+ if(error) {
+ // the key don't exist. Tomboy has not been installed.
+ // we want to run.
+ DBG_OUT("gconf error %s", error->message);
+ tb_must_run = true;
+ g_error_free(error);
+ }
+ DBG_OUT("tb_must_run %d", tb_must_run);
+ // we decided that if Tomboy don't want to run then SticjyNotes are
+ // probably already imported.
+ if(!tb_must_run) {
+ // Mark like we already ran.
+ Preferences::obj().set<bool>(Preferences::STICKYNOTEIMPORTER_FIRST_RUN, false);
+ want_run = false;
+ }
+ }
}
- return false;
+ return want_run;
}
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index 6ed8976..4519f01 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -132,8 +132,9 @@ namespace gnote {
DBG_OUT("importing");
(*iter)->initialize();
- has_imported |= (*iter)->first_run(*this);
- (*iter)->shutdown();
+ if((*iter)->want_to_run()) {
+ has_imported |= (*iter)->first_run(*this);
+ }
}
// First run. Create "Start Here" notes.
diff --git a/src/preferences.hpp b/src/preferences.hpp
index f93acd4..2048b63 100644
--- a/src/preferences.hpp
+++ b/src/preferences.hpp
@@ -113,6 +113,10 @@ namespace gnote {
// this is very hackish. maybe I should just use gconfmm
guint add_notify(const char *ns, GConfClientNotifyFunc func, gpointer data);
void remove_notify(guint);
+ GConfClient * get_client() const
+ {
+ return m_client;
+ }
private:
Preferences(const Preferences &); // non implemented
GConfClient *m_client;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]