[Users] Help with Python compose_any script
Holger Berndt
berndth at gmx.de
Thu Aug 14 23:46:09 CEST 2014
On Do, 10.07.2014 21:27, Holger Berndt wrote:
>The plugin doesn't provide account selection. It does however provide
>access to the GTK+ combo box selection widget, so what you can do is
>access the widget, iterate over the entries, search the one you want,
>and when you found the correct entry, select it:
>
>#================================================================
>account_combo = clawsmail.compose_window.get_account_selection()
>for row in account_combo.get_model():
> if "MyAccountName" in row[0]:
> account_combo.set_active_iter(row.iter)
> break
>#================================================================
>
>This obviously relies on Claws Mail internals (that the widget is a
>GtkComboBox, that the underlying model has a string of the display in
>the first column of that model, ...), and thus you are not guaranteed
>that it will work forever.
I just made the "account" property of a ComposeWindow read/write, so
the roundtrip through GTK+ and relying on internals is no longer
necessary. The alternative is not exactly shorter, but more
straight-forward:
#==================================================================
# look for wanted account
target_account = None
for ac in clawsmail.get_accounts():
if "MyAccountName" in ac.account_name:
target_account = ac
break
# select this account
if target_account:
clawsmail.compose_window.account = target_account
#==================================================================
Holger
More information about the Users
mailing list