[Commits] [SCM] claws branch, master, updated. 3.10.1-146-g9166dc6

holger at claws-mail.org holger at claws-mail.org
Thu Aug 14 23:46:14 CEST 2014


The branch, master has been updated
       via  9166dc63e4d2f3f4d62293b48706cfa9b9a0afc1 (commit)
      from  fa8fd46c1f9945fd21ab78e5eaeaf89fa6e9df15 (commit)

Summary of changes:
 src/plugins/python/accounttype.c       |   12 +++++++++++
 src/plugins/python/accounttype.h       |    2 ++
 src/plugins/python/composewindowtype.c |   35 +++++++++++++++++++++++++++++++-
 3 files changed, 48 insertions(+), 1 deletion(-)


- Log -----------------------------------------------------------------
commit 9166dc63e4d2f3f4d62293b48706cfa9b9a0afc1
Author: Holger Berndt <hb at claws-mail.org>
Date:   Thu Aug 14 23:41:00 2014 +0200

    Python plugin: Make 'account' property of ComposeWindow read/write

diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
index 6239ead..e5cbe32 100644
--- a/src/plugins/python/accounttype.c
+++ b/src/plugins/python/accounttype.c
@@ -160,3 +160,15 @@ PyObject* clawsmail_account_new(PrefsAccount *account)
   ff->account = account;
   return (PyObject*)ff;
 }
+
+gboolean clawsmail_account_check(PyObject *self)
+{
+  return (PyObject_TypeCheck(self, &clawsmail_AccountType) != 0);
+}
+
+PrefsAccount* clawsmail_account_get_account(PyObject *self)
+{
+  g_return_val_if_fail(clawsmail_account_check(self), NULL);
+
+  return ((clawsmail_AccountObject*)self)->account;
+}
diff --git a/src/plugins/python/accounttype.h b/src/plugins/python/accounttype.h
index cf5da0a..07328d6 100644
--- a/src/plugins/python/accounttype.h
+++ b/src/plugins/python/accounttype.h
@@ -27,5 +27,7 @@ gboolean cmpy_add_account(PyObject *module);
 
 PyObject* clawsmail_account_new(PrefsAccount *account);
 
+gboolean clawsmail_account_check(PyObject *self);
+PrefsAccount* clawsmail_account_get_account(PyObject *self);
 
 #endif /* ACCOUNTTYPE_H */
diff --git a/src/plugins/python/composewindowtype.c b/src/plugins/python/composewindowtype.c
index d07a735..3a54116 100644
--- a/src/plugins/python/composewindowtype.c
+++ b/src/plugins/python/composewindowtype.c
@@ -30,6 +30,7 @@
 #include "mainwindow.h"
 #include "account.h"
 #include "summaryview.h"
+#include "gtk/combobox.h"
 
 #include <glib.h>
 #include <glib/gi18n.h>
@@ -443,6 +444,38 @@ static PyObject* get_account(clawsmail_ComposeWindowObject *self, void *closure)
   Py_RETURN_NONE;
 }
 
+static int set_account(clawsmail_ComposeWindowObject *self, PyObject *value, void *closure)
+{
+  PrefsAccount *target_account;
+
+  if(value == NULL) {
+    PyErr_SetString(PyExc_TypeError, "Cannot delete 'account' attribute");
+    return -1;
+  }
+
+  if(!clawsmail_account_check(value)) {
+    PyErr_SetString(PyExc_TypeError, "ComposeWindow.account: Can only assign an account");
+    return -1;
+  }
+
+
+  target_account = clawsmail_account_get_account(value);
+  if(!target_account) {
+    PyErr_SetString(PyExc_TypeError, "Account value broken");
+    return -1;
+  }
+
+  if(!self->compose || !self->compose->account_combo) {
+    PyErr_SetString(PyExc_RuntimeError, "ComposeWindow: Cannot access account");
+    return -1;
+  }
+
+  combobox_select_by_data(GTK_COMBO_BOX(self->compose->account_combo), target_account->account_id);
+
+  return 0;
+}
+
+
 
 static PyMethodDef ComposeWindow_methods[] = {
     {"set_subject", (PyCFunction)ComposeWindow_set_subject, METH_VARARGS,
@@ -547,7 +580,7 @@ static PyMemberDef ComposeWindow_members[] = {
 };
 
 static PyGetSetDef ComposeWindow_getset[] = {
-    {"account", (getter)get_account, (setter)NULL,
+    {"account", (getter)get_account, (setter)set_account,
       "account - the account corresponding to this compose window", NULL},
 
     {NULL}

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list