diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-08-18 00:41:19 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-08-20 02:21:22 +0800 |
commit | 2167e37071957121275915b658e2350d3eeaf091 (patch) | |
tree | 3e43c9ab55b792f4685aedfd92fbd581481e2999 /widgets | |
parent | c85109fc322137596bf34cffc5445d568223c60d (diff) | |
download | gsoc2013-evolution-2167e37071957121275915b658e2350d3eeaf091.tar gsoc2013-evolution-2167e37071957121275915b658e2350d3eeaf091.tar.gz gsoc2013-evolution-2167e37071957121275915b658e2350d3eeaf091.tar.bz2 gsoc2013-evolution-2167e37071957121275915b658e2350d3eeaf091.tar.lz gsoc2013-evolution-2167e37071957121275915b658e2350d3eeaf091.tar.xz gsoc2013-evolution-2167e37071957121275915b658e2350d3eeaf091.tar.zst gsoc2013-evolution-2167e37071957121275915b658e2350d3eeaf091.zip |
EAttachment: Minor code rearrangement.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-attachment.c | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index b79ebc81b4..b83bf1ce41 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -405,40 +405,6 @@ attachment_update_progress_columns (EAttachment *attachment) -1); } -void -e_attachment_set_file_info (EAttachment *attachment, - GFileInfo *file_info) -{ - GtkTreeRowReference *reference; - GIcon *icon; - - reference = e_attachment_get_reference (attachment); - - if (file_info != NULL) - g_object_ref (file_info); - - if (attachment->priv->file_info != NULL) - g_object_unref (attachment->priv->file_info); - - attachment->priv->file_info = file_info; - - /* If the GFileInfo contains a GThemedIcon, append a - * fallback icon name to ensure we display something. */ - icon = g_file_info_get_icon (file_info); - if (G_IS_THEMED_ICON (icon)) - g_themed_icon_append_name ( - G_THEMED_ICON (icon), DEFAULT_ICON_NAME); - - g_object_notify (G_OBJECT (attachment), "file-info"); - - /* Tell the EAttachmentStore its total size changed. */ - if (gtk_tree_row_reference_valid (reference)) { - GtkTreeModel *model; - model = gtk_tree_row_reference_get_model (reference); - g_object_notify (G_OBJECT (model), "total-size"); - } -} - static void attachment_set_loading (EAttachment *attachment, gboolean loading) @@ -1184,6 +1150,73 @@ e_attachment_get_file_info (EAttachment *attachment) return attachment->priv->file_info; } +void +e_attachment_set_file_info (EAttachment *attachment, + GFileInfo *file_info) +{ + GtkTreeRowReference *reference; + GIcon *icon; + + reference = e_attachment_get_reference (attachment); + + if (file_info != NULL) + g_object_ref (file_info); + + if (attachment->priv->file_info != NULL) + g_object_unref (attachment->priv->file_info); + + attachment->priv->file_info = file_info; + + /* If the GFileInfo contains a GThemedIcon, append a + * fallback icon name to ensure we display something. */ + icon = g_file_info_get_icon (file_info); + if (G_IS_THEMED_ICON (icon)) + g_themed_icon_append_name ( + G_THEMED_ICON (icon), DEFAULT_ICON_NAME); + + g_object_notify (G_OBJECT (attachment), "file-info"); + + /* Tell the EAttachmentStore its total size changed. */ + if (gtk_tree_row_reference_valid (reference)) { + GtkTreeModel *model; + model = gtk_tree_row_reference_get_model (reference); + g_object_notify (G_OBJECT (model), "total-size"); + } +} + +/** + * e_attachment_get_mime_type: + * + * Returns mime_type part of the file_info as a newly allocated string, + * which should be freed with g_free(). + * Returns NULL, if mime_type not found or set on the attachment. + **/ +gchar * +e_attachment_get_mime_type (EAttachment *attachment) +{ + GFileInfo *file_info; + const gchar *content_type; + gchar *mime_type; + + g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL); + + file_info = e_attachment_get_file_info (attachment); + if (file_info == NULL) + return NULL; + + content_type = g_file_info_get_content_type (file_info); + if (content_type == NULL) + return NULL; + + mime_type = g_content_type_get_mime_type (content_type); + if (!mime_type) + return NULL; + + camel_strdown (mime_type); + + return mime_type; +} + GIcon * e_attachment_get_icon (EAttachment *attachment) { @@ -1361,39 +1394,6 @@ e_attachment_get_thumbnail_path (EAttachment *attachment) return g_file_info_get_attribute_byte_string (file_info, attribute); } -/** - * e_attachment_get_mime_type: - * - * Returns mime_type part of the file_info as a newly allocated string, - * which should be freed with g_free(). - * Returns NULL, if mime_type not found or set on the attachment. - **/ -gchar * -e_attachment_get_mime_type (EAttachment *attachment) -{ - GFileInfo *file_info; - const gchar *content_type; - gchar *mime_type; - - g_return_val_if_fail (E_IS_ATTACHMENT (attachment), NULL); - - file_info = e_attachment_get_file_info (attachment); - if (file_info == NULL) - return NULL; - - content_type = g_file_info_get_content_type (file_info); - if (content_type == NULL) - return NULL; - - mime_type = g_content_type_get_mime_type (content_type); - if (!mime_type) - return NULL; - - camel_strdown (mime_type); - - return mime_type; -} - gboolean e_attachment_is_rfc822 (EAttachment *attachment) { |