[gnote] Add plug-in to export to GTG
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add plug-in to export to GTG
- Date: Thu, 31 Oct 2013 22:05:26 +0000 (UTC)
commit 5cee77a86ea413a9358856243dfa56c4a75fa2d5
Author: Aurimas Černius <aurisc4 gmail com>
Date: Fri Nov 1 00:01:34 2013 +0200
Add plug-in to export to GTG
Export note as Getting Things GNOME task.
Fixes Bug 697934.
configure.ac | 1 +
po/POTFILES.in | 2 +
src/addins/Makefile.am | 1 +
src/addins/exporttogtg/Makefile.am | 18 ++++
src/addins/exporttogtg/exporttogtg.desktop.in | 9 ++
src/addins/exporttogtg/exporttogtgnoteaddin.cpp | 120 +++++++++++++++++++++++
src/addins/exporttogtg/exporttogtgnoteaddin.hpp | 67 +++++++++++++
src/iactionmanager.hpp | 1 +
8 files changed, 219 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9a32460..410c475 100644
--- a/configure.ac
+++ b/configure.ac
@@ -171,6 +171,7 @@ src/addins/Makefile
src/addins/addins.mk
src/addins/backlinks/Makefile
src/addins/bugzilla/Makefile
+src/addins/exporttogtg/Makefile
src/addins/exporttohtml/Makefile
src/addins/filesystemsyncservice/Makefile
src/addins/fixedwidth/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fb414cb..693c0e0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -9,6 +9,8 @@ src/addins/backlinks/backlinks.desktop.in
src/addins/backlinks/backlinksnoteaddin.cpp
src/addins/bugzilla/bugzilla.desktop.in
src/addins/bugzilla/bugzillapreferences.cpp
+src/addins/exporttogtg/exporttogtg.desktop.in
+src/addins/exporttogtg/exporttogtgnoteaddin.cpp
src/addins/exporttohtml/exporttohtml.desktop.in
src/addins/exporttohtml/exporttohtmldialog.cpp
src/addins/exporttohtml/exporttohtmlnoteaddin.cpp
diff --git a/src/addins/Makefile.am b/src/addins/Makefile.am
index 1eea091..c7d00ce 100644
--- a/src/addins/Makefile.am
+++ b/src/addins/Makefile.am
@@ -3,6 +3,7 @@
SUBDIRS = backlinks \
bugzilla \
+ exporttogtg \
exporttohtml \
filesystemsyncservice \
fixedwidth \
diff --git a/src/addins/exporttogtg/Makefile.am b/src/addins/exporttogtg/Makefile.am
new file mode 100644
index 0000000..e07a23a
--- /dev/null
+++ b/src/addins/exporttogtg/Makefile.am
@@ -0,0 +1,18 @@
+
+include $(builddir)/../addins.mk
+
+ INTLTOOL_DESKTOP_RULE@
+
+desktop_in_files = exporttogtg.desktop.in
+desktop_files = $(desktop_in_files:.desktop.in=.desktop)
+
+addinsdir = $(ADDINSDIR)
+addins_LTLIBRARIES = exporttogtg.la
+addins_DATA = $(desktop_files)
+
+exporttogtg_la_SOURCES = \
+ exporttogtgnoteaddin.hpp exporttogtgnoteaddin.cpp \
+ $(NULL)
+
+EXTRA_DIST = $(desktop_in_files)
+DISTCLEANFILES = $(desktop_files)
diff --git a/src/addins/exporttogtg/exporttogtg.desktop.in b/src/addins/exporttogtg/exporttogtg.desktop.in
new file mode 100644
index 0000000..ebc1cd4
--- /dev/null
+++ b/src/addins/exporttogtg/exporttogtg.desktop.in
@@ -0,0 +1,9 @@
+[AddinInfo]
+Id=ExportToGTGAddin
+_Name=Export to Getting Things GNOME
+_Description=Exports individual notes as Getting Things GNOME tasks
+_Authors=Aurimas Černius
+Category=Tools
+Version=0.1
+DefaultEnabled=false
+Module=exporttogtg
diff --git a/src/addins/exporttogtg/exporttogtgnoteaddin.cpp b/src/addins/exporttogtg/exporttogtgnoteaddin.cpp
new file mode 100644
index 0000000..47546b5
--- /dev/null
+++ b/src/addins/exporttogtg/exporttogtgnoteaddin.cpp
@@ -0,0 +1,120 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2013 Aurimas Cernius
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <giomm/dbusproxy.h>
+#include <glibmm/i18n.h>
+
+#include "debug.hpp"
+
+#include "exporttogtgnoteaddin.hpp"
+#include "iactionmanager.hpp"
+#include "notewindow.hpp"
+#include "sharp/string.hpp"
+
+
+namespace {
+
+const char *GTG_INTERFACE =
+"<?xml version=\"1.0\" ?>"
+"<node name=\"/org/gnome/GTG\">"
+" <interface name=\"org.gnome.GTG\">"
+" <method name=\"OpenNewTask\">"
+" <arg type=\"s\" name=\"title\" direction=\"in\"/>"
+" <arg type=\"s\" name=\"description\" direction=\"in\"/>"
+" </method>"
+" </interface>"
+"</node>";
+
+}
+
+
+namespace exporttogtg {
+
+
+ExportToGTGModule::ExportToGTGModule()
+{
+ ADD_INTERFACE_IMPL(ExportToGTGNoteAddin);
+}
+
+
+Glib::RefPtr<Gio::DBus::InterfaceInfo> ExportToGTGNoteAddin::s_gtg_interface;
+
+
+void ExportToGTGNoteAddin::initialize()
+{
+}
+
+void ExportToGTGNoteAddin::shutdown()
+{
+}
+
+void ExportToGTGNoteAddin::on_note_opened()
+{
+ Glib::RefPtr<gnote::NoteWindow::NonModifyingAction> action =
+ gnote::NoteWindow::NonModifyingAction::create("ExportToGTGAction", _("Export to Getting Things GNOME"),
+ _("Export note as Getting Things GNOME task"));
+ action->signal_activate().connect(
+ sigc::mem_fun(*this, &ExportToGTGNoteAddin::export_button_clicked));
+ add_note_action(action, gnote::EXPORT_TO_GTG_ORDER);
+}
+
+
+void ExportToGTGNoteAddin::export_button_clicked()
+{
+ try {
+ if (s_gtg_interface == 0) {
+ Glib::RefPtr<Gio::DBus::NodeInfo> node_info = Gio::DBus::NodeInfo::create_for_xml(GTG_INTERFACE);
+ s_gtg_interface = node_info->lookup_interface("org.gnome.GTG");
+ if(s_gtg_interface == 0) {
+ ERR_OUT(_("GTG XML loaded, but interface not found"));
+ return;
+ }
+ }
+ }
+ catch(Glib::Error & e) {
+ ERR_OUT(_("Failed to create GTG interface from XML: %s"), e.what().c_str());
+ return;
+ }
+
+ try {
+ Glib::RefPtr<Gio::DBus::Proxy> proxy = Gio::DBus::Proxy::create_for_bus_sync(
+ Gio::DBus::BUS_TYPE_SESSION, "org.gnome.GTG", "/org/gnome/GTG", "org.gnome.GTG", s_gtg_interface);
+ if(proxy == 0) {
+ ERR_OUT(_("Failed to create D_Bus proxy for GTG"));
+ return;
+ }
+
+ gnote::Note::Ptr note(get_note());
+ std::string title = note->get_title();
+ std::string body = sharp::string_trim(sharp::string_replace_first(note->text_content(), title, ""));
+
+ std::vector<Glib::VariantBase> parameters;
+ parameters.reserve(2);
+ parameters.push_back(Glib::Variant<Glib::ustring>::create(title));
+ parameters.push_back(Glib::Variant<Glib::ustring>::create(body));
+ Glib::VariantContainerBase params = Glib::VariantContainerBase::create_tuple(parameters);
+ proxy->call_sync("OpenNewTask", params);
+ }
+ catch(Glib::Error & e) {
+ ERR_OUT(_("Failed to call GTG: %s"), e.what().c_str());
+ }
+}
+
+}
diff --git a/src/addins/exporttogtg/exporttogtgnoteaddin.hpp b/src/addins/exporttogtg/exporttogtgnoteaddin.hpp
new file mode 100644
index 0000000..b70a580
--- /dev/null
+++ b/src/addins/exporttogtg/exporttogtgnoteaddin.hpp
@@ -0,0 +1,67 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2013 Aurimas Cernius
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+
+
+
+#ifndef _EXPORTTOGTG_ADDIN_HPP_
+#define _EXPORTTOGTG_ADDIN_HPP_
+
+#include <giomm/dbusintrospection.h>
+
+#include "base/macros.hpp"
+#include "sharp/dynamicmodule.hpp"
+#include "noteaddin.hpp"
+
+namespace exporttogtg {
+
+
+class ExportToGTGModule
+ : public sharp::DynamicModule
+{
+public:
+ ExportToGTGModule();
+};
+
+
+DECLARE_MODULE(ExportToGTGModule);
+
+
+class ExportToGTGNoteAddin
+ : public gnote::NoteAddin
+{
+public:
+ static ExportToGTGNoteAddin *create()
+ {
+ return new ExportToGTGNoteAddin;
+ }
+ virtual void initialize() override;
+ virtual void shutdown() override;
+ virtual void on_note_opened() override;
+private:
+ void export_button_clicked();
+
+ static Glib::RefPtr<Gio::DBus::InterfaceInfo> s_gtg_interface;
+};
+
+}
+
+#endif
diff --git a/src/iactionmanager.hpp b/src/iactionmanager.hpp
index 019bdfe..7f13c6b 100644
--- a/src/iactionmanager.hpp
+++ b/src/iactionmanager.hpp
@@ -32,6 +32,7 @@ namespace gnote {
enum NoteActionOrder {
BACKLINKS_ORDER = 100,
EXPORT_TO_HTML_ORDER = 200,
+ EXPORT_TO_GTG_ORDER = 250,
INSERT_TIMESTAMP_ORDER = 300,
PRINT_ORDER = 400,
REPLACE_TITLE_ORDER = 500,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]