[gnote] Add action support in addin info
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add action support in addin info
- Date: Sun, 27 Dec 2015 13:03:57 +0000 (UTC)
commit 1c9821de86dc6436b73faa8ed56ffc3d4a98f189
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Dec 27 14:58:29 2015 +0200
Add action support in addin info
src/addininfo.cpp | 20 ++++++++++++++++++--
src/addininfo.hpp | 7 +++++++
2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/addininfo.cpp b/src/addininfo.cpp
index 33dd48c..06642a4 100644
--- a/src/addininfo.cpp
+++ b/src/addininfo.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2013-2014 Aurimas Cernius
+ * Copyright (C) 2013-2015 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
@@ -22,7 +22,6 @@
#include <boost/lexical_cast.hpp>
#include <glibmm/i18n.h>
-#include <glibmm/keyfile.h>
#include "base/macros.hpp"
#include "addininfo.hpp"
@@ -36,6 +35,7 @@ namespace gnote {
const char * ADDIN_INFO = "AddinInfo";
const char * ADDIN_ATTS = "AddinAttributes";
+ const char * ADDIN_ACTIONS = "Actions";
AddinCategory resolve_addin_category(const std::string & cat)
{
@@ -100,12 +100,28 @@ void AddinInfo::load_from_file(const std::string & info_file)
m_attributes[key] = addin_info.get_string(ADDIN_ATTS, key);
}
}
+ if(addin_info.has_group(ADDIN_ACTIONS)) {
+ load_actions(addin_info, "actions_void", NULL);
+ load_actions(addin_info, "actions_bool", &Glib::Variant<bool>::variant_type());
+ load_actions(addin_info, "actions_string", &Glib::Variant<Glib::ustring>::variant_type());
+ }
}
catch(Glib::Error & e) {
throw std::runtime_error(e.what());
}
}
+void AddinInfo::load_actions(Glib::KeyFile & addin_info, const Glib::ustring & key, const Glib::VariantType
*type)
+{
+ if(addin_info.has_key(ADDIN_ACTIONS, key)) {
+ std::vector<std::string> actions;
+ sharp::string_split(actions, addin_info.get_string(ADDIN_ACTIONS, key), ",");
+ for(auto action : actions) {
+ m_actions[action] = type;
+ }
+ }
+}
+
Glib::ustring AddinInfo::get_attribute(const Glib::ustring & att)
{
std::map<Glib::ustring, Glib::ustring>::iterator iter = m_attributes.find(att);
diff --git a/src/addininfo.hpp b/src/addininfo.hpp
index fa346db..958235a 100644
--- a/src/addininfo.hpp
+++ b/src/addininfo.hpp
@@ -23,6 +23,7 @@
#include <string>
#include <map>
+#include <glibmm/keyfile.h>
#include <glibmm/ustring.h>
@@ -88,6 +89,10 @@ public:
{
return m_attributes;
}
+ const std::map<Glib::ustring, const Glib::VariantType*> & actions() const
+ {
+ return m_actions;
+ }
Glib::ustring get_attribute(const Glib::ustring & att);
bool validate(const Glib::ustring & release, const Glib::ustring & version_info) const;
private:
@@ -104,8 +109,10 @@ private:
Glib::ustring m_libgnote_version_info;
std::map<Glib::ustring, Glib::ustring> m_attributes;
+ std::map<Glib::ustring, const Glib::VariantType*> m_actions;
bool validate_compatibility(const Glib::ustring & release, const Glib::ustring & version_info) const;
+ void load_actions(Glib::KeyFile & addin_info, const Glib::ustring & key, const Glib::VariantType *type);
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]