Python plugin: Make it possible to query current and default account
authorHolger Berndt <hb@claws-mail.org>
Sat, 27 Jul 2013 14:46:57 +0000 (16:46 +0200)
committerHolger Berndt <hb@claws-mail.org>
Sat, 27 Jul 2013 14:50:09 +0000 (16:50 +0200)
src/plugins/python/clawsmailmodule.c

index d983c6e61cb21483af4ca31ea09a9a2e61317318..ec1f223e5cab981d956cbea2e551b719c019e6d2 100644 (file)
@@ -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"