aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-attachment-bar.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2007-11-15 06:04:21 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2007-11-15 06:04:21 +0800
commit9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91 (patch)
tree2e1e96f33404781354c422a7e9beaf458ebeb655 /widgets/misc/e-attachment-bar.c
parent7e8f8bb9e5167b0219b48ab3e8062080d3740b0a (diff)
downloadgsoc2013-evolution-9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91.tar
gsoc2013-evolution-9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91.tar.gz
gsoc2013-evolution-9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91.tar.bz2
gsoc2013-evolution-9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91.tar.lz
gsoc2013-evolution-9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91.tar.xz
gsoc2013-evolution-9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91.tar.zst
gsoc2013-evolution-9e4fcb29cf7f05c18f7fd34e318f9e795fa32e91.zip
** Remove trailing whitespace from source code.
2007-11-14 Matthew Barnes <mbarnes@redhat.com> ** Remove trailing whitespace from source code. svn path=/trunk/; revision=34537
Diffstat (limited to 'widgets/misc/e-attachment-bar.c')
-rw-r--r--widgets/misc/e-attachment-bar.c352
1 files changed, 176 insertions, 176 deletions
diff --git a/widgets/misc/e-attachment-bar.c b/widgets/misc/e-attachment-bar.c
index 0525887cc4..192fba56e0 100644
--- a/widgets/misc/e-attachment-bar.c
+++ b/widgets/misc/e-attachment-bar.c
@@ -70,7 +70,7 @@ static GnomeIconListClass *parent_class = NULL;
struct _EAttachmentBarPrivate {
GtkWidget *attach; /* attachment file dialogue, if active */
-
+
gboolean batch_unref;
GPtrArray *attachments;
char *path;
@@ -92,7 +92,7 @@ static char *
size_to_string (gulong size)
{
char *size_string;
-
+
/* FIXME: The following should probably go into a separate module, as
we might have to do the same thing in other places as well. Also,
I am not sure this will be OK for all the languages. */
@@ -109,7 +109,7 @@ attachment_destroy (EAttachmentBar *bar, EAttachment *attachment)
{
if (bar->priv->batch_unref)
return;
-
+
if (g_ptr_array_remove (bar->priv->attachments, attachment)) {
update (bar);
g_signal_emit (bar, signals[CHANGED], 0);
@@ -127,13 +127,13 @@ static void
add_common (EAttachmentBar *bar, EAttachment *attachment)
{
g_return_if_fail (attachment != NULL);
-
+
g_ptr_array_add (bar->priv->attachments, attachment);
g_object_weak_ref ((GObject *) attachment, (GWeakNotify) attachment_destroy, bar);
g_signal_connect (attachment, "changed", G_CALLBACK (attachment_changed_cb), bar);
-
+
update (bar);
-
+
g_signal_emit (bar, signals[CHANGED], 0);
}
@@ -148,9 +148,9 @@ add_from_file (EAttachmentBar *bar, const char *file_name, const char *dispositi
{
EAttachment *attachment;
CamelException ex;
-
+
camel_exception_init (&ex);
-
+
if ((attachment = e_attachment_new (file_name, disposition, &ex))) {
add_common (bar, attachment);
} else {
@@ -170,7 +170,7 @@ calculate_height_width(EAttachmentBar *bar, int *new_width, int *new_height)
int width, height, icon_width;
PangoFontMetrics *metrics;
PangoContext *context;
-
+
context = gtk_widget_get_pango_context ((GtkWidget *) bar);
metrics = pango_context_get_metrics (context, ((GtkWidget *) bar)->style->font_desc, pango_context_get_language (context));
width = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width (metrics)) * 15;
@@ -205,20 +205,20 @@ e_attachment_bar_create_attachment_cache (EAttachment *attachment)
GdkPixbufLoader *loader;
gboolean error = TRUE;
GdkPixbuf *pixbuf;
-
+
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body));
mstream = (CamelStreamMem *) camel_stream_mem_new ();
-
+
camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) mstream);
-
+
/* Stream image into pixbuf loader */
loader = gdk_pixbuf_loader_new ();
error = !gdk_pixbuf_loader_write (loader, mstream->buffer->data, mstream->buffer->len, NULL);
gdk_pixbuf_loader_close (loader, NULL);
-
+
if (!error) {
int ratio, width, height;
-
+
/* Shrink pixbuf */
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
width = gdk_pixbuf_get_width (pixbuf);
@@ -240,7 +240,7 @@ e_attachment_bar_create_attachment_cache (EAttachment *attachment)
width = 1;
}
}
-
+
attachment->pixbuf_cache = gdk_pixbuf_scale_simple (pixbuf, width,height,GDK_INTERP_BILINEAR);
pixbuf = attachment->pixbuf_cache;
g_object_ref(pixbuf);
@@ -248,7 +248,7 @@ e_attachment_bar_create_attachment_cache (EAttachment *attachment)
attachment->pixbuf_cache = NULL;
g_warning ("GdkPixbufLoader Error");
}
-
+
/* Destroy everything */
g_object_unref (loader);
camel_object_unref (mstream);
@@ -262,14 +262,14 @@ update (EAttachmentBar *bar)
GnomeIconList *icon_list;
int bar_width, bar_height;
int i;
-
+
priv = bar->priv;
icon_list = GNOME_ICON_LIST (bar);
-
+
gnome_icon_list_freeze (icon_list);
-
+
gnome_icon_list_clear (icon_list);
-
+
/* FIXME could be faster, but we don't care. */
for (i = 0; i < priv->attachments->len; i++) {
EAttachment *attachment;
@@ -277,9 +277,9 @@ update (EAttachmentBar *bar)
char *size_string, *label;
GdkPixbuf *pixbuf = NULL;
const char *desc;
-
+
attachment = priv->attachments->pdata[i];
-
+
if (!attachment->is_available_local || !attachment->body) {
if ((pixbuf = e_icon_factory_get_icon("mail-attachment", E_ICON_SIZE_DIALOG))) {
attachment->index = gnome_icon_list_append_pixbuf (icon_list, pixbuf, NULL, "");
@@ -287,9 +287,9 @@ update (EAttachmentBar *bar)
}
continue;
}
-
+
content_type = camel_mime_part_get_content_type (attachment->body);
- /* Get the image out of the attachment
+ /* Get the image out of the attachment
and create a thumbnail for it */
if ((pixbuf = attachment->pixbuf_cache)) {
g_object_ref(pixbuf);
@@ -298,20 +298,20 @@ update (EAttachmentBar *bar)
CamelStreamMem *mstream;
GdkPixbufLoader *loader;
gboolean error = TRUE;
-
+
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body));
mstream = (CamelStreamMem *) camel_stream_mem_new ();
-
+
camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) mstream);
-
+
/* Stream image into pixbuf loader */
loader = gdk_pixbuf_loader_new ();
error = !gdk_pixbuf_loader_write (loader, mstream->buffer->data, mstream->buffer->len, NULL);
gdk_pixbuf_loader_close (loader, NULL);
-
+
if (!error) {
int ratio, width, height;
-
+
/* Shrink pixbuf */
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
width = gdk_pixbuf_get_width (pixbuf);
@@ -333,7 +333,7 @@ update (EAttachmentBar *bar)
width = 1;
}
}
-
+
attachment->pixbuf_cache = gdk_pixbuf_scale_simple (pixbuf, width, height,
GDK_INTERP_BILINEAR);
pixbuf = attachment->pixbuf_cache;
@@ -342,32 +342,32 @@ update (EAttachmentBar *bar)
pixbuf = NULL;
g_warning ("GdkPixbufLoader Error");
}
-
+
/* Destroy everything */
g_object_unref (loader);
camel_object_unref (mstream);
}
-
+
desc = camel_mime_part_get_description (attachment->body);
if (!desc || *desc == '\0') {
if (attachment->file_name)
desc = attachment->file_name;
- else
+ else
desc = camel_mime_part_get_filename (attachment->body);
}
-
+
if (!desc)
desc = _("attachment");
-
+
if (attachment->size && (size_string = size_to_string (attachment->size))) {
label = g_strdup_printf ("%s (%s)", desc, size_string);
g_free (size_string);
} else
label = g_strdup (desc);
-
+
if (pixbuf == NULL) {
char *mime_type;
-
+
mime_type = camel_content_type_simple (content_type);
pixbuf = e_icon_for_mime_type (mime_type, 48);
if (pixbuf == NULL) {
@@ -376,60 +376,60 @@ update (EAttachmentBar *bar)
}
g_free (mime_type);
}
-
+
if (pixbuf) {
GdkPixbuf *pixbuf_orig = pixbuf;
pixbuf = gdk_pixbuf_add_alpha (pixbuf_orig, TRUE, 255, 255, 255);
-
+
/* gdk_pixbuf_add_alpha returns a newly allocated pixbuf,
- free the original one.
+ free the original one.
*/
g_object_unref (pixbuf_orig);
-
+
/* In case of a attachment bar, in a signed/encrypted part, display the status as a emblem*/
if (attachment->sign) {
/* Show the signature status at the right-bottom.*/
GdkPixbuf *sign = NULL;
int x, y;
-
+
if (attachment->sign == CAMEL_CIPHER_VALIDITY_SIGN_BAD)
sign = e_icon_factory_get_icon ("stock_signature-bad", E_ICON_SIZE_MENU);
else if (attachment->sign == CAMEL_CIPHER_VALIDITY_SIGN_GOOD)
sign = e_icon_factory_get_icon ("stock_signature-ok", E_ICON_SIZE_MENU);
else
sign = e_icon_factory_get_icon ("stock_signature", E_ICON_SIZE_MENU);
-
+
x = gdk_pixbuf_get_width (pixbuf) - 17;
y = gdk_pixbuf_get_height (pixbuf) - 17;
-
+
gdk_pixbuf_copy_area (sign, 0, 0, 16, 16, pixbuf, x, y);
g_object_unref (sign);
}
-
+
if (attachment->encrypt) {
/* Show the encryption status at the top left.*/
GdkPixbuf *encrypt = e_icon_factory_get_icon ("stock_lock-ok", E_ICON_SIZE_MENU);
-
+
gdk_pixbuf_copy_area (encrypt, 0, 0, 16, 16, pixbuf, 1, 1);
g_object_unref (encrypt);
}
-
+
gnome_icon_list_append_pixbuf (icon_list, pixbuf, NULL, label);
g_object_unref (pixbuf);
}
-
+
g_free (label);
}
-
+
gnome_icon_list_thaw (icon_list);
-
+
/* Resize */
if (bar->expand) {
gtk_widget_get_size_request ((GtkWidget *) bar, &bar_width, &bar_height);
-
+
if (bar->priv->attachments->len) {
int per_col, rows, height, width;
-
+
calculate_height_width(bar, &width, &height);
per_col = bar_width / width;
per_col = (per_col ? per_col : 1);
@@ -450,19 +450,19 @@ update_remote_file (EAttachment *attachment, EAttachmentBar *bar)
update (bar);
return;
}
-
+
base = g_path_get_basename(attachment->file_name);
msg = g_strdup_printf("%s (%d%%)", base, attachment->percentage);
g_free(base);
icon_list = GNOME_ICON_LIST (bar);
-
+
gnome_icon_list_freeze (icon_list);
item = gnome_icon_list_get_icon_text_item (icon_list, attachment->index);
if (!item->is_text_allocated)
g_free (item->text);
-
+
gnome_icon_text_item_configure (item, item->x, item->y, item->width, item->fontname, msg, item->is_editable, TRUE);
gnome_icon_list_thaw (icon_list);
@@ -478,12 +478,12 @@ e_attachment_bar_remove_selected (EAttachmentBar *bar)
GPtrArray *temp_arr;
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
-
+
priv = bar->priv;
-
+
if (!(items = gnome_icon_list_get_selection ((GnomeIconList *) bar)))
return;
-
+
temp_arr = g_ptr_array_new ();
while (items != NULL) {
if ((id = GPOINTER_TO_INT (items->data) - nrem) < priv->attachments->len) {
@@ -492,19 +492,19 @@ e_attachment_bar_remove_selected (EAttachmentBar *bar)
g_ptr_array_remove_index (priv->attachments, id);
nrem++;
}
-
+
items = items->next;
}
g_ptr_array_foreach (temp_arr, (GFunc)g_object_unref, NULL);
g_ptr_array_free (temp_arr, TRUE);
-
+
update (bar);
g_signal_emit (bar, signals[CHANGED], 0);
-
+
id++;
-
+
if ((left = gnome_icon_list_get_num_icons ((GnomeIconList *) bar)) > 0)
gnome_icon_list_focus_icon ((GnomeIconList *) bar, left > id ? id : left - 1);
}
@@ -528,18 +528,18 @@ e_attachment_bar_edit_selected (EAttachmentBar *bar)
EAttachment *attachment;
GList *items;
int id;
-
+
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
-
+
priv = bar->priv;
-
+
items = gnome_icon_list_get_selection ((GnomeIconList *) bar);
while (items != NULL) {
if ((id = GPOINTER_TO_INT (items->data)) < priv->attachments->len) {
attachment = priv->attachments->pdata[id];
e_attachment_edit (attachment, GTK_WIDGET (bar));
}
-
+
items = items->next;
}
}
@@ -548,7 +548,7 @@ GtkWidget **
e_attachment_bar_get_selector(EAttachmentBar *bar)
{
g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), NULL);
-
+
return &bar->priv->attach;
}
@@ -568,25 +568,25 @@ e_attachment_bar_get_selected (EAttachmentBar *bar)
EAttachment *attachment;
GList *items;
int id;
-
+
g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), NULL);
-
+
priv = bar->priv;
-
+
items = gnome_icon_list_get_selection ((GnomeIconList *) bar);
-
+
while (items != NULL) {
if ((id = GPOINTER_TO_INT (items->data)) < priv->attachments->len) {
attachment = priv->attachments->pdata[id];
attachments = g_slist_prepend (attachments, attachment);
g_object_ref (attachment);
}
-
+
items = items->next;
}
-
+
attachments = g_slist_reverse (attachments);
-
+
return attachments;
}
@@ -606,18 +606,18 @@ e_attachment_bar_get_attachment (EAttachmentBar *bar, int id)
struct _EAttachmentBarPrivate *priv;
EAttachment *attachment;
GSList *attachments;
-
+
g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), NULL);
-
+
priv = bar->priv;
-
+
if (id == -1 || id > priv->attachments->len)
return e_attachment_bar_get_selected (bar);
-
+
attachment = priv->attachments->pdata[id];
attachments = g_slist_prepend (NULL, attachment);
g_object_ref (attachment);
-
+
return attachments;
}
@@ -635,11 +635,11 @@ e_attachment_bar_get_all_attachments (EAttachmentBar *bar)
GSList *attachments = NULL;
EAttachment *attachment;
int i;
-
+
g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), NULL);
-
+
priv = bar->priv;
-
+
for (i = priv->attachments->len - 1; i >= 0; i--) {
attachment = priv->attachments->pdata[i];
if (attachment->is_available_local) {
@@ -647,7 +647,7 @@ e_attachment_bar_get_all_attachments (EAttachmentBar *bar)
g_object_ref (attachment);
}
}
-
+
return attachments;
}
@@ -659,17 +659,17 @@ e_attachment_bar_get_parts (EAttachmentBar *bar)
EAttachment *attachment;
GSList *parts = NULL;
int i;
-
+
g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), NULL);
-
+
priv = bar->priv;
-
+
for (i = 0; i < priv->attachments->len; i++) {
attachment = priv->attachments->pdata[i];
if (attachment->is_available_local)
parts = g_slist_prepend (parts, attachment->body);
}
-
+
return parts;
}
@@ -682,7 +682,7 @@ destroy (GtkObject *object)
struct _EAttachmentBarPrivate *priv = bar->priv;
EAttachment *attachment;
int i;
-
+
if ((priv = bar->priv)) {
priv->batch_unref = TRUE;
for (i = 0; i < priv->attachments->len; i++) {
@@ -691,17 +691,17 @@ destroy (GtkObject *object)
g_object_unref (attachment);
}
g_ptr_array_free (priv->attachments, TRUE);
-
+
if (priv->attach)
gtk_widget_destroy (priv->attach);
-
+
if (priv->path)
g_free (priv->path);
-
+
g_free (priv);
bar->priv = NULL;
}
-
+
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -713,10 +713,10 @@ temp_save_part (CamelMimePart *part, gboolean readonly)
char *tmpdir, *path, *mfilename = NULL, *utf8_mfilename = NULL;
CamelStream *stream;
CamelDataWrapper *wrapper;
-
+
if (!(tmpdir = e_mkdtemp ("evolution-tmp-XXXXXX")))
return NULL;
-
+
if (!(filename = camel_mime_part_get_filename (part))) {
/* This is the default filename used for temporary file creation */
filename = _("Unknown");
@@ -727,17 +727,17 @@ temp_save_part (CamelMimePart *part, gboolean readonly)
g_free (utf8_mfilename);
filename = (const char *) mfilename;
}
-
+
path = g_build_filename (tmpdir, filename, NULL);
g_free (tmpdir);
g_free (mfilename);
-
+
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
if (readonly)
stream = camel_stream_fs_new_with_name (path, O_RDWR|O_CREAT|O_TRUNC, 0444);
- else
+ else
stream = camel_stream_fs_new_with_name (path, O_RDWR|O_CREAT|O_TRUNC, 0644);
-
+
if (!stream) {
/* TODO handle error conditions */
g_message ("DEBUG: could not open the file to write\n");
@@ -768,48 +768,48 @@ eab_drag_data_get(EAttachmentBar *bar, GdkDragContext *drag, GtkSelectionData *d
int len, n, i = 0;
CamelURL *url;
GList *items;
-
+
if (info)
return;
-
+
items = gnome_icon_list_get_selection (GNOME_ICON_LIST (bar));
len = g_list_length (items);
-
+
uris = g_malloc0 (sizeof (char *) * (len + 1));
-
+
for ( ; items != NULL; items = items->next) {
if (!((n = GPOINTER_TO_INT (items->data)) < priv->attachments->len))
continue;
-
+
attachment = priv->attachments->pdata[n];
-
+
if (!attachment->is_available_local)
continue;
-
+
if (attachment->store_uri) {
uris[i++] = attachment->store_uri;
continue;
}
-
+
/* If we are not able to save, ignore it */
if (!(path = temp_save_part (attachment->body, FALSE)))
continue;
-
+
url = camel_url_new ("file://", NULL);
camel_url_set_path (url, path);
attachment->store_uri = camel_url_to_string (url, 0);
camel_url_free (url);
g_free (path);
-
+
uris[i++] = attachment->store_uri;
}
-
+
uris[i] = NULL;
-
+
gtk_selection_data_set_uris (data, uris);
-
+
g_free (uris);
-
+
return;
}
@@ -821,7 +821,7 @@ eab_button_release_event(EAttachmentBar *bar, GdkEventButton *event, gpointer du
int length;
GtkTargetEntry drag_types[] = {
{ "text/uri-list", 0, 0 },
- };
+ };
if (event && event->button == 1) {
selected = gnome_icon_list_get_selection(icon_list);
@@ -844,20 +844,20 @@ eab_button_press_event(EAttachmentBar *bar, GdkEventButton *event, gpointer dumm
gboolean take_selected = FALSE;
GtkTargetEntry drag_types[] = {
{ "text/uri-list", 0, 0 },
- };
+ };
selected = gnome_icon_list_get_selection(icon_list);
length = g_list_length (selected);
if (event) {
icon_number = gnome_icon_list_get_icon_at(icon_list, event->x, event->y);
- if (icon_number < 0) {
+ if (icon_number < 0) {
/* When nothing is selected, deselect all */
gnome_icon_list_unselect_all (icon_list);
length = 0;
selected = NULL;
}
-
+
if (event->button == 1) {
/* If something is selected, then allow drag or else help to select */
if (length)
@@ -866,27 +866,27 @@ eab_button_press_event(EAttachmentBar *bar, GdkEventButton *event, gpointer dumm
gtk_drag_source_unset((GtkWidget *)bar);
return FALSE;
}
-
+
/* If not r-click dont progress any more.*/
if (event->button != 3)
return FALSE;
-
+
/* When a r-click on something, if it is in the already selected list, consider a r-click of multiple things
- * or deselect all and select only this for r-click
+ * or deselect all and select only this for r-click
*/
if (icon_number >= 0) {
for (tmp = selected; tmp; tmp = tmp->next) {
if (GPOINTER_TO_INT(tmp->data) == icon_number)
take_selected = TRUE;
}
-
+
if (!take_selected) {
gnome_icon_list_unselect_all(icon_list);
gnome_icon_list_select_icon(icon_list, icon_number);
}
}
}
-
+
return FALSE;
}
@@ -899,15 +899,15 @@ eab_icon_clicked_cb (EAttachmentBar *bar, GdkEvent *event, gpointer *dummy)
CamelURL *url;
char *path;
GSList *p;
-
+
if (E_IS_ATTACHMENT_BAR (bar) && event->type == GDK_2BUTTON_PRESS) {
p = e_attachment_bar_get_selected (bar);
if (p && p->next == NULL) {
attachment = p->data;
-
+
/* Check if the file is stored already */
if (!attachment->store_uri) {
- path = temp_save_part (attachment->body, TRUE);
+ path = temp_save_part (attachment->body, TRUE);
url = camel_url_new ("file://", NULL);
camel_url_set_path (url, path);
attachment->store_uri = camel_url_to_string (url, 0);
@@ -922,10 +922,10 @@ eab_icon_clicked_cb (EAttachmentBar *bar, GdkEvent *event, gpointer *dummy)
g_error_free (error);
error = NULL;
}
-
+
ret = TRUE;
}
-
+
if (p) {
g_slist_foreach (p, (GFunc) g_object_unref, NULL);
g_slist_free (p);
@@ -941,15 +941,15 @@ static void
class_init (EAttachmentBarClass *klass)
{
GtkObjectClass *object_class;
-
+
object_class = GTK_OBJECT_CLASS (klass);
-
+
parent_class = g_type_class_ref (gnome_icon_list_get_type ());
-
+
object_class->destroy = destroy;
-
+
/* Setup signals. */
-
+
signals[CHANGED] =
g_signal_new ("changed",
E_TYPE_ATTACHMENT_BAR,
@@ -964,14 +964,14 @@ static void
init (EAttachmentBar *bar)
{
struct _EAttachmentBarPrivate *priv;
-
+
priv = g_new (struct _EAttachmentBarPrivate, 1);
-
+
priv->attach = NULL;
priv->batch_unref = FALSE;
priv->attachments = g_ptr_array_new ();
priv->path = NULL;
-
+
bar->priv = priv;
bar->expand = FALSE;
}
@@ -981,7 +981,7 @@ GType
e_attachment_bar_get_type (void)
{
static GType type = 0;
-
+
if (type == 0) {
static const GTypeInfo info = {
sizeof (EAttachmentBarClass),
@@ -992,10 +992,10 @@ e_attachment_bar_get_type (void)
0,
(GInstanceInitFunc) init,
};
-
+
type = g_type_register_static (GNOME_TYPE_ICON_LIST, "EAttachmentBar", &info, 0);
}
-
+
return type;
}
@@ -1005,19 +1005,19 @@ e_attachment_bar_new (GtkAdjustment *adj)
EAttachmentBar *new;
GnomeIconList *icon_list;
int icon_width, window_height;
-
+
new = g_object_new (e_attachment_bar_get_type (), NULL);
-
+
icon_list = GNOME_ICON_LIST (new);
-
+
calculate_height_width (new, &icon_width, &window_height);
-
+
gnome_icon_list_construct (icon_list, icon_width, adj, 0);
-
+
gtk_widget_set_size_request (GTK_WIDGET (new), icon_width * 4, window_height);
GTK_WIDGET_SET_FLAGS (new, GTK_CAN_FOCUS);
-
+
gnome_icon_list_set_separators (icon_list, ICON_SEPARATORS);
gnome_icon_list_set_row_spacing (icon_list, ICON_ROW_SPACING);
gnome_icon_list_set_col_spacing (icon_list, ICON_COL_SPACING);
@@ -1025,14 +1025,14 @@ e_attachment_bar_new (GtkAdjustment *adj)
gnome_icon_list_set_text_spacing (icon_list, ICON_TEXT_SPACING);
gnome_icon_list_set_selection_mode (icon_list, GTK_SELECTION_MULTIPLE);
- atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (new)),
+ atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (new)),
_("Attachment Bar"));
-
+
g_signal_connect (new, "button_release_event", G_CALLBACK(eab_button_release_event), NULL);
g_signal_connect (new, "button_press_event", G_CALLBACK(eab_button_press_event), NULL);
g_signal_connect (new, "drag-data-get", G_CALLBACK(eab_drag_data_get), NULL);
g_signal_connect (icon_list, "event", G_CALLBACK (eab_icon_clicked_cb), NULL);
-
+
return GTK_WIDGET (new);
}
@@ -1042,10 +1042,10 @@ get_default_charset (void)
GConfClient *gconf;
const char *locale;
char *charset;
-
+
gconf = gconf_client_get_default ();
charset = gconf_client_get_string (gconf, "/apps/evolution/mail/composer/charset", NULL);
-
+
if (!charset || charset[0] == '\0') {
g_free (charset);
charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL);
@@ -1054,12 +1054,12 @@ get_default_charset (void)
charset = NULL;
}
}
-
+
g_object_unref (gconf);
-
+
if (!charset && (locale = e_iconv_locale_charset ()))
charset = g_strdup (locale);
-
+
return charset ? charset : g_strdup ("us-ascii");
}
@@ -1070,13 +1070,13 @@ attach_to_multipart (CamelMultipart *multipart,
{
CamelContentType *content_type;
CamelDataWrapper *content;
-
+
if (!attachment->body)
return;
content_type = camel_mime_part_get_content_type (attachment->body);
content = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body));
-
+
if (!CAMEL_IS_MULTIPART (content)) {
if (camel_content_type_is (content_type, "text", "*")) {
CamelTransferEncoding encoding;
@@ -1086,21 +1086,21 @@ attach_to_multipart (CamelMultipart *multipart,
const char *charset;
char *buf = NULL;
char *type;
-
+
charset = camel_content_type_param (content_type, "charset");
-
+
stream = camel_stream_null_new ();
filter_stream = camel_stream_filter_new_with_stream (stream);
bestenc = camel_mime_filter_bestenc_new (CAMEL_BESTENC_GET_ENCODING);
camel_stream_filter_add (filter_stream, CAMEL_MIME_FILTER (bestenc));
camel_object_unref (stream);
-
+
camel_data_wrapper_decode_to_stream (content, CAMEL_STREAM (filter_stream));
camel_object_unref (filter_stream);
-
+
encoding = camel_mime_filter_bestenc_get_best_encoding (bestenc, CAMEL_BESTENC_8BIT);
camel_mime_part_set_encoding (attachment->body, encoding);
-
+
if (encoding == CAMEL_TRANSFER_ENCODING_7BIT) {
/* the text fits within us-ascii so this is safe */
/* FIXME: check that this isn't iso-2022-jp? */
@@ -1108,12 +1108,12 @@ attach_to_multipart (CamelMultipart *multipart,
} else if (!charset) {
if (!default_charset)
default_charset = buf = get_default_charset ();
-
+
/* FIXME: We should really check that this fits within the
default_charset and if not find one that does and/or
allow the user to specify? */
}
-
+
if (!charset) {
/* looks kinda nasty, but this is how ya have to do it */
camel_content_type_set_param (content_type, "charset", default_charset);
@@ -1122,13 +1122,13 @@ attach_to_multipart (CamelMultipart *multipart,
g_free (type);
g_free (buf);
}
-
+
camel_object_unref (bestenc);
} else if (!CAMEL_IS_MIME_MESSAGE (content)) {
camel_mime_part_set_encoding (attachment->body, CAMEL_TRANSFER_ENCODING_BASE64);
}
}
-
+
camel_multipart_add_part (multipart, attachment->body);
}
@@ -1138,12 +1138,12 @@ e_attachment_bar_to_multipart (EAttachmentBar *bar, CamelMultipart *multipart, c
struct _EAttachmentBarPrivate *priv;
EAttachment *attachment;
int i;
-
+
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
-
+
priv = bar->priv;
-
+
for (i = 0; i < priv->attachments->len; i++) {
attachment = priv->attachments->pdata[i];
if (attachment->is_available_local)
@@ -1156,7 +1156,7 @@ guint
e_attachment_bar_get_num_attachments (EAttachmentBar *bar)
{
g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), 0);
-
+
return bar->priv->attachments->len;
}
@@ -1166,7 +1166,7 @@ e_attachment_bar_attach (EAttachmentBar *bar, const char *file_name, const char
{
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
g_return_if_fail (file_name != NULL && disposition != NULL);
-
+
add_from_file (bar, file_name, disposition);
}
@@ -1174,27 +1174,27 @@ void
e_attachment_bar_add_attachment (EAttachmentBar *bar, EAttachment *attachment)
{
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
-
+
add_common (bar, attachment);
}
-int
+int
e_attachment_bar_get_download_count (EAttachmentBar *bar)
{
struct _EAttachmentBarPrivate *priv;
EAttachment *attachment;
int i, n = 0;
-
+
g_return_val_if_fail (E_IS_ATTACHMENT_BAR (bar), 0);
-
+
priv = bar->priv;
-
+
for (i = 0; i < priv->attachments->len; i++) {
attachment = priv->attachments->pdata[i];
if (!attachment->is_available_local)
n++;
}
-
+
return n;
}
@@ -1204,9 +1204,9 @@ e_attachment_bar_attach_remote_file (EAttachmentBar *bar, const char *url, const
EAttachment *attachment;
CamelException ex;
GtkWindow *parent;
-
+
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
-
+
if (!bar->priv->path)
bar->priv->path = e_mkdtemp ("attach-XXXXXX");
@@ -1226,6 +1226,6 @@ void
e_attachment_bar_attach_mime_part (EAttachmentBar *bar, CamelMimePart *part)
{
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
-
+
add_from_mime_part (bar, part);
}