commit d17846613422b6615ad1f97820b6df3ec7c6e052
parent 3887eb3fd30f291fd162a5c33fac282033d727eb
Author: Holger Berndt <hb@claws-mail.org>
Date: Sat, 27 Jul 2013 16:46:57 +0200
Python plugin: Make it possible to query current and default account
Diffstat:
1 file changed, 33 insertions(+), 0 deletions(-)
diff --git a/src/plugins/python/clawsmailmodule.c b/src/plugins/python/clawsmailmodule.c
@@ -625,6 +625,29 @@ static PyObject* copy_messages(PyObject *self, PyObject *args)
return move_or_copy_messages(self, args, FALSE);
}
+static PyObject* get_current_account(PyObject *self, PyObject *args)
+{
+ PrefsAccount *account;
+ account = account_get_cur_account();
+ if(account) {
+ return clawsmail_account_new(account);
+ }
+ else
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_default_account(PyObject *self, PyObject *args)
+{
+ PrefsAccount *account;
+ account = account_get_default();
+ if(account) {
+ return clawsmail_account_new(account);
+ }
+ else
+ Py_RETURN_NONE;
+}
+
+
static PyMethodDef ClawsMailMethods[] = {
/* public */
{"get_mainwindow_action_group", get_mainwindow_action_group, METH_NOARGS,
@@ -731,6 +754,16 @@ static PyMethodDef ClawsMailMethods[] = {
"\n"
"Get a tuple of Account objects representing all accounts that are defined in Claws Mail."},
+ {"get_current_account", get_current_account, METH_NOARGS,
+ "get_current_account() - get the current account\n"
+ "\n"
+ "Return the object representing the currently selected account."},
+
+ {"get_default_account", get_default_account, METH_NOARGS,
+ "get_default_account() - get the default account\n"
+ "\n"
+ "Return the object representing the default account."},
+
/* private */
{"__gobj", private_wrap_gobj, METH_VARARGS,
"__gobj(ptr) - transforms a C GObject pointer into a PyGObject\n"