/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
GTK_POLICY_AUTOMATIC);
ctree = gtk_sctree_new_with_titles(N_MIMEVIEW_COLS, 0, titles);
- gtk_widget_show(ctree);
+
+ if (prefs_common.show_col_headers == FALSE)
+ gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree));
+
gtk_cmclist_set_selection_mode(GTK_CMCLIST(ctree), GTK_SELECTION_BROWSE);
gtk_cmctree_set_line_style(GTK_CMCTREE(ctree), GTK_CMCTREE_LINES_NONE);
gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree), COL_SIZE,
GTK_JUSTIFY_RIGHT);
gtk_cmclist_set_column_width(GTK_CMCLIST(ctree), COL_MIMETYPE, 240);
gtk_cmclist_set_column_width(GTK_CMCLIST(ctree), COL_SIZE, 90);
+ gtk_cmclist_set_column_auto_resize(GTK_CMCLIST(ctree), COL_MIMETYPE, TRUE);
+ gtk_cmclist_set_column_auto_resize(GTK_CMCLIST(ctree), COL_NAME, TRUE);
for (i = 0; i < N_MIMEVIEW_COLS; i++)
- GTK_WIDGET_UNSET_FLAGS(GTK_CMCLIST(ctree)->column[i].button,
- GTK_CAN_FOCUS);
+ gtkut_widget_set_can_focus(GTK_CMCLIST(ctree)->column[i].button,
+ FALSE);
+ gtk_widget_show(ctree);
gtk_container_add(GTK_CONTAINER(scrolledwin), ctree);
g_signal_connect(G_OBJECT(ctree), "tree_select_row",
mime_notebook = gtk_notebook_new();
gtk_widget_show(mime_notebook);
- GTK_WIDGET_UNSET_FLAGS(mime_notebook, GTK_CAN_FOCUS);
+ gtkut_widget_set_can_focus(mime_notebook, FALSE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(mime_notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(mime_notebook), FALSE);
g_slist_free(mimeview->viewers);
gtk_target_list_unref(mimeview->target_list);
- mimeview_free_mimeinfo(mimeview);
#ifdef USE_PTHREAD
if (mimeview->check_data) {
mimeview->check_data->destroy_mimeview = TRUE;
} else
#endif
{
+ mimeview_free_mimeinfo(mimeview);
g_free(mimeview->file);
g_free(mimeview);
mimeviews = g_slist_remove(mimeviews, mimeview);
/* reset all thread stuff, and do the cleanups we've been left to do */
static void mimeview_check_data_reset(MimeView *mimeview)
{
+ gboolean must_free;
+ gboolean must_destroy;
+
if (!mimeview->check_data)
return;
- if (mimeview->check_data->free_after_use) {
+ must_free = mimeview->check_data->free_after_use;
+ must_destroy = mimeview->check_data->destroy_mimeview;
+
+ if (mimeview->check_data->cancel_th_init) {
+ debug_print("killing canceller thread\n");
+ mimeview->check_data->cancel_th_init = FALSE;
+ pthread_cancel(mimeview->check_data->cancel_th);
+ }
+
+ g_free(mimeview->check_data);
+ mimeview->check_data = NULL;
+
+ if (must_free) {
debug_print("freeing deferred mimeinfo\n");
procmime_mimeinfo_free_all(mimeview->check_data->siginfo);
}
- if (mimeview->check_data->destroy_mimeview) {
+ if (must_destroy) {
debug_print("freeing deferred mimeview\n");
+ mimeview_free_mimeinfo(mimeview);
g_free(mimeview->file);
g_free(mimeview);
mimeviews = g_slist_remove(mimeviews, mimeview);
}
- g_free(mimeview->check_data);
- mimeview->check_data = NULL;
}
/* GUI update once the checker thread is done or killed */
if (!mimeview->check_data)
return NULL;
- if (mimeinfo && mimeinfo == mimeview->check_data->siginfo)
+ if (mimeinfo && mimeinfo == mimeview->check_data->siginfo) {
privacy_mimeinfo_check_signature(mimeinfo);
- else {
+ if (mimeview->check_data && mimeview->check_data->cancel_th_init) {
+ mimeview->check_data->cancel_th_init = FALSE;
+ pthread_cancel(mimeview->check_data->cancel_th);
+ }
+ } else {
/* that's strange! we changed message without
* getting killed. */
g_warning("different siginfo!\n");
/* wait for a few seconds... */
debug_print("waiting a while\n");
- sleep(5);
+ g_usleep(5 * 1000 * 1000);
if (!mimeview->check_data)
return NULL; /* nothing to kill, it's done in time :) */
/* too late, go away checker thread */
debug_print("killing checker thread\n");
- pthread_cancel(mimeview->check_data->th);
-
+ if (mimeview->check_data->th_init) {
+ mimeview->check_data->th_init = FALSE;
+ pthread_cancel(mimeview->check_data->th);
+ }
+
/* tell upstream it was a timeout */
mimeview->check_data->timeout = TRUE;
/* use g_timeout so that GUI updates is done from the
if (!mimeview->check_data)
return;
debug_print("killing checker thread NOW\n");
- pthread_cancel(mimeview->check_data->th);
+ if (mimeview->check_data->th_init) {
+ mimeview->check_data->th_init = FALSE;
+ pthread_cancel(mimeview->check_data->th);
+ }
/* tell upstream it was a timeout */
mimeview->check_data->timeout = TRUE;
g_free(mimeview->check_data);
mimeview->check_data = NULL;
return;
- } else
+ } else {
mimeview->check_data->th = th;
+ mimeview->check_data->th_init = TRUE;
+ }
/* create the killer thread */
pthread_create(&th2, &detach2,
mimeview_check_sig_cancel_thread,
mimeview);
+
+ mimeview->check_data->cancel_th = th2;
+ mimeview->check_data->cancel_th_init = TRUE;
}
#endif
if (!partinfo) return;
/* ungrab the mouse event */
- if (GTK_WIDGET_HAS_GRAB(ctree)) {
+ if (gtkut_widget_has_grab(GTK_WIDGET(ctree))) {
gtk_grab_remove(GTK_WIDGET(ctree));
if (gdk_pointer_is_grabbed())
gdk_pointer_ungrab(GDK_CURRENT_TIME);
if (node) {
partinfo = gtk_cmctree_node_get_row_data(ctree, node);
- if (partinfo->type == MIMETYPE_MULTIPART)
+ if (partinfo->type == MIMETYPE_MULTIPART ||
+ (!prefs_common.show_inline_attachments && partinfo->id))
goto skip;
gtk_sctree_unselect_all(GTK_SCTREE(ctree));
gtk_sctree_select(GTK_SCTREE(ctree), node);
GtkTooltips *tips = mimeview->tooltips;
#endif
+ if (!prefs_common.show_inline_attachments && mimeinfo->id)
+ return;
+
vbox = mimeview->icon_vbox;
mimeview->icon_count++;
button = gtk_event_box_new();
content_type = procmime_get_content_type_str(mimeinfo->type,
mimeinfo->subtype);
+#if GTK_CHECK_VERSION(2,12,0)
tip = g_strconcat("<b>", _("Type:"), " </b>", content_type,
"\n<b>", _("Size:"), " </b>",
to_human_readable((goffset)mimeinfo->length), NULL);
+#else
+ tip = g_strconcat(_("Type:"), " ", content_type,
+ "\n", _("Size:"), " ",
+ to_human_readable((goffset)mimeinfo->length), NULL);
+#endif
g_free(content_type);
if (desc && *desc) {
gchar *tmp = NULL;
} else {
tmp = g_strdup(desc);
}
+#if GTK_CHECK_VERSION(2,12,0)
tiptmp = g_strconcat(tip, "\n<b>",
prefs_common.attach_desc && mimeinfo->description ?
- _("Description") : _("Filename:"),
+ _("Description:") : _("Filename:"),
" </b>", tmp, NULL);
+#else
+ tiptmp = g_strconcat(tip, "\n",
+ prefs_common.attach_desc && mimeinfo->description ?
+ _("Description:") : _("Filename:"),
+ " ", tmp, NULL);
+#endif
g_free(tip);
tip = tiptmp;
g_free(tmp);
}
if (sigshort && *sigshort) {
- tiptmp = g_strjoin("\n", tip, sigshort, NULL);
+ tiptmp = g_markup_escape_text(sigshort, -1);
g_free(tip);
tip = tiptmp;
}
g_free(sigshort);
+#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_markup(button, tip);
+#else
+ CLAWS_SET_TIP(button, tip);
+#endif
g_free(tip);
gtk_widget_show_all(button);
gtk_drag_source_set(button, GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,