diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-05-15 21:17:58 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-05-20 01:07:22 +0800 |
commit | f9ffe647231a7ba2bd5347d92d560b6a57fee786 (patch) | |
tree | 6c1245d91a399647fc25521bc1f38cf564210979 /em-format/e-mail-part-attachment-bar.c | |
parent | 0b4e7ec091c8bbe65dc2f2afd7da78b04da7c274 (diff) | |
download | gsoc2013-evolution-f9ffe647231a7ba2bd5347d92d560b6a57fee786.tar.gz gsoc2013-evolution-f9ffe647231a7ba2bd5347d92d560b6a57fee786.tar.zst gsoc2013-evolution-f9ffe647231a7ba2bd5347d92d560b6a57fee786.zip |
Convert EMailPart to a GObject.
EMailPart is reference-counted, subclassed, and allows a custom
finalize function. There's no excuse for it not to use GObject.
Diffstat (limited to 'em-format/e-mail-part-attachment-bar.c')
-rw-r--r-- | em-format/e-mail-part-attachment-bar.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/em-format/e-mail-part-attachment-bar.c b/em-format/e-mail-part-attachment-bar.c new file mode 100644 index 0000000000..5cebd9b8dc --- /dev/null +++ b/em-format/e-mail-part-attachment-bar.c @@ -0,0 +1,89 @@ +/* + * e-mail-part-attachment-bar.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + */ + +#include "e-mail-part-attachment-bar.h" + +#define E_MAIL_PART_ATTACHMENT_BAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_PART_ATTACHMENT_BAR, EMailPartAttachmentBarPrivate)) + +struct _EMailPartAttachmentBarPrivate { + EAttachmentStore *store; +}; + +G_DEFINE_TYPE ( + EMailPartAttachmentBar, + e_mail_part_attachment_bar, + E_TYPE_MAIL_PART) + +static void +mail_part_attachment_bar_dispose (GObject *object) +{ + EMailPartAttachmentBarPrivate *priv; + + priv = E_MAIL_PART_ATTACHMENT_BAR_GET_PRIVATE (object); + + g_clear_object (&priv->store); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (e_mail_part_attachment_bar_parent_class)-> + dispose (object); +} + +static void +e_mail_part_attachment_bar_class_init (EMailPartAttachmentBarClass *class) +{ + GObjectClass *object_class; + + g_type_class_add_private ( + class, sizeof (EMailPartAttachmentBarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->dispose = mail_part_attachment_bar_dispose; +} + +static void +e_mail_part_attachment_bar_init (EMailPartAttachmentBar *part) +{ + GtkTreeModel *tree_model; + + part->priv = E_MAIL_PART_ATTACHMENT_BAR_GET_PRIVATE (part); + + tree_model = e_attachment_store_new (); + part->priv->store = E_ATTACHMENT_STORE (tree_model); +} + +EMailPart * +e_mail_part_attachment_bar_new (CamelMimePart *mime_part, + const gchar *id) +{ + g_return_val_if_fail (id != NULL, NULL); + + return g_object_new ( + E_TYPE_MAIL_PART_ATTACHMENT_BAR, + "id", id, "mime-part", mime_part, NULL); +} + +EAttachmentStore * +e_mail_part_attachment_bar_get_store (EMailPartAttachmentBar *part) +{ + g_return_val_if_fail (E_IS_MAIL_PART_ATTACHMENT_BAR (part), NULL); + + return part->priv->store; +} + |