# include "claws-features.h"
#endif
-#include <glib.h>
-#include <glib/gi18n.h>
-
#include "composewindowtype.h"
+#include "accounttype.h"
#include "clawsmailmodule.h"
#include "foldertype.h"
#include "mainwindow.h"
#include "account.h"
#include "summaryview.h"
+#include "gtk/combobox.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
#include <structmember.h>
return Py_None;
}
-/* this is pretty ugly, as the compose struct does not maintain a pointer to the account selection combo */
static PyObject* ComposeWindow_get_account_selection(clawsmail_ComposeWindowObject *self, PyObject *args)
{
- GList *children, *walk;
-
- children = gtk_container_get_children(GTK_CONTAINER(self->compose->header_table));
- for(walk = children; walk; walk = walk->next) {
- if(GTK_IS_HBOX(walk->data)) {
- GList *children2, *walk2;
- children2 = gtk_container_get_children(GTK_CONTAINER(walk->data));
- for(walk2 = children2; walk2; walk2 = walk2->next) {
- if(GTK_IS_EVENT_BOX(walk2->data)) {
- return get_gobj_from_address(gtk_container_get_children(GTK_CONTAINER(walk2->data))->data);
- }
- }
- }
- }
+ if(GTK_IS_COMBO_BOX(self->compose->account_combo))
+ return get_gobj_from_address(self->compose->account_combo);
+
Py_INCREF(Py_None);
return Py_None;
}
return Py_None;
}
+static PyObject* get_account(clawsmail_ComposeWindowObject *self, void *closure)
+{
+ if(self->compose->account) {
+ return clawsmail_account_new(self->compose->account);
+ }
+ 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,
"set_subject(text) - set subject to text\n"
{NULL}
};
+static PyGetSetDef ComposeWindow_getset[] = {
+ {"account", (getter)get_account, (setter)set_account,
+ "account - the account corresponding to this compose window", NULL},
+
+ {NULL}
+};
+
static PyTypeObject clawsmail_ComposeWindowType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
0, /* tp_iternext */
ComposeWindow_methods, /* tp_methods */
ComposeWindow_members, /* tp_members */
- 0, /* tp_getset */
+ ComposeWindow_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */