2001-04-19 14:21:46 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2011-02-16 08:16:26 +01:00
|
|
|
* Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
|
2001-04-19 14:21:46 +02:00
|
|
|
*
|
|
|
|
* 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
|
2007-07-11 18:38:12 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-04-19 14:21:46 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-11 18:38:12 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2001-04-19 14:21:46 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
2005-02-10 13:06:07 +01:00
|
|
|
#include <glib/gi18n.h>
|
2001-04-19 14:21:46 +02:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2008-07-19 16:02:31 +02:00
|
|
|
#include <gtk/gtk.h>
|
2001-04-19 14:21:46 +02:00
|
|
|
#include <stdio.h>
|
2007-10-09 18:37:50 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2003-06-07 03:01:50 +02:00
|
|
|
|
|
|
|
#ifndef HAVE_APACHE_FNMATCH
|
|
|
|
/* kludge: apache's fnmatch clashes with <regex.h>, don't include
|
|
|
|
* fnmatch.h */
|
2003-06-07 00:09:46 +02:00
|
|
|
#include <fnmatch.h>
|
|
|
|
#endif
|
2003-06-06 23:11:42 +02:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#include "main.h"
|
|
|
|
#include "mimeview.h"
|
|
|
|
#include "textview.h"
|
|
|
|
#include "procmime.h"
|
|
|
|
#include "summaryview.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "filesel.h"
|
|
|
|
#include "alertpanel.h"
|
2001-05-10 13:19:38 +02:00
|
|
|
#include "inputdialog.h"
|
2001-04-19 14:21:46 +02:00
|
|
|
#include "utils.h"
|
|
|
|
#include "gtkutils.h"
|
|
|
|
#include "prefs_common.h"
|
2006-02-04 18:17:33 +01:00
|
|
|
#include "procheader.h"
|
2003-07-05 12:45:46 +02:00
|
|
|
#include "stock_pixmap.h"
|
2003-07-19 15:50:29 +02:00
|
|
|
#include "gtk/gtkvscrollbutton.h"
|
2006-04-05 18:47:17 +02:00
|
|
|
#include "gtk/logwindow.h"
|
2006-08-23 19:21:00 +02:00
|
|
|
#include "timing.h"
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2007-07-23 18:34:59 +02:00
|
|
|
#ifdef MAEMO
|
|
|
|
#include <libosso.h>
|
2007-11-10 13:42:23 +01:00
|
|
|
#ifndef CHINOOK
|
2007-07-23 18:34:59 +02:00
|
|
|
#include <osso-mime.h>
|
2007-11-10 13:42:23 +01:00
|
|
|
#else
|
|
|
|
#include <hildon-mime.h>
|
|
|
|
#endif
|
2007-07-23 18:34:59 +02:00
|
|
|
#endif
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
COL_MIMETYPE = 0,
|
|
|
|
COL_SIZE = 1,
|
2011-11-11 18:28:07 +01:00
|
|
|
COL_NAME = 2,
|
|
|
|
COL_DATA = 3,
|
2001-04-19 14:21:46 +02:00
|
|
|
} MimeViewColumnPos;
|
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
#define N_MIMEVIEW_COLS 4
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
static void mimeview_set_multipart_tree (MimeView *mimeview,
|
|
|
|
MimeInfo *mimeinfo,
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeIter *parent);
|
2001-04-19 14:21:46 +02:00
|
|
|
static void mimeview_show_message_part (MimeView *mimeview,
|
|
|
|
MimeInfo *partinfo);
|
|
|
|
static void mimeview_change_view_type (MimeView *mimeview,
|
2001-06-30 13:40:01 +02:00
|
|
|
MimeViewType type);
|
2007-01-20 20:54:05 +01:00
|
|
|
static gchar *mimeview_get_filename_for_part (MimeInfo *partinfo,
|
2004-05-10 12:22:28 +02:00
|
|
|
const gchar *basedir,
|
|
|
|
gint number);
|
|
|
|
static gboolean mimeview_write_part (const gchar *filename,
|
|
|
|
MimeInfo *partinfo);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
static void mimeview_selected (GtkTreeSelection *selection,
|
2001-04-19 14:21:46 +02:00
|
|
|
MimeView *mimeview);
|
|
|
|
static void mimeview_start_drag (GtkWidget *widget,
|
|
|
|
gint button,
|
|
|
|
GdkEvent *event,
|
|
|
|
MimeView *mimeview);
|
2002-01-29 11:03:33 +01:00
|
|
|
static gint mimeview_button_pressed (GtkWidget *widget,
|
2001-04-19 14:21:46 +02:00
|
|
|
GdkEventButton *event,
|
|
|
|
MimeView *mimeview);
|
2002-01-29 11:03:33 +01:00
|
|
|
static gint mimeview_key_pressed (GtkWidget *widget,
|
2001-04-19 14:21:46 +02:00
|
|
|
GdkEventKey *event,
|
|
|
|
MimeView *mimeview);
|
|
|
|
|
|
|
|
static void mimeview_drag_data_get (GtkWidget *widget,
|
|
|
|
GdkDragContext *drag_context,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info,
|
|
|
|
guint time,
|
|
|
|
MimeView *mimeview);
|
|
|
|
|
2006-08-08 18:16:13 +02:00
|
|
|
static gboolean mimeview_scrolled (GtkWidget *widget,
|
|
|
|
GdkEventScroll *event,
|
|
|
|
MimeView *mimeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
static void mimeview_display_as_text (MimeView *mimeview);
|
|
|
|
static void mimeview_save_as (MimeView *mimeview);
|
2002-07-21 18:06:50 +02:00
|
|
|
static void mimeview_save_all (MimeView *mimeview);
|
2006-09-05 07:33:16 +02:00
|
|
|
static void mimeview_launch (MimeView *mimeview,
|
|
|
|
MimeInfo *partinfo);
|
2008-11-04 22:13:42 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2001-05-10 13:19:38 +02:00
|
|
|
static void mimeview_open_with (MimeView *mimeview);
|
2006-07-07 10:20:23 +02:00
|
|
|
static void mimeview_open_part_with (MimeView *mimeview,
|
2006-08-17 18:46:14 +02:00
|
|
|
MimeInfo *partinfo,
|
|
|
|
gboolean automatic);
|
2008-11-04 22:13:42 +01:00
|
|
|
#endif
|
2007-04-20 18:15:58 +02:00
|
|
|
static void mimeview_select_next_part (MimeView *mimeview);
|
2007-07-16 19:13:43 +02:00
|
|
|
static void mimeview_select_prev_part (MimeView *mimeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
static void mimeview_view_file (const gchar *filename,
|
2001-05-10 13:19:38 +02:00
|
|
|
MimeInfo *partinfo,
|
2006-08-17 18:46:14 +02:00
|
|
|
const gchar *cmd,
|
2005-10-20 18:50:46 +02:00
|
|
|
MimeView *mimeview);
|
2003-07-19 15:50:29 +02:00
|
|
|
static gboolean icon_clicked_cb (GtkWidget *button,
|
|
|
|
GdkEventButton *event,
|
|
|
|
MimeView *mimeview);
|
2003-07-24 02:40:01 +02:00
|
|
|
static void icon_selected (MimeView *mimeview,
|
|
|
|
gint num,
|
|
|
|
MimeInfo *partinfo);
|
|
|
|
static gint icon_key_pressed (GtkWidget *button,
|
|
|
|
GdkEventKey *event,
|
|
|
|
MimeView *mimeview);
|
2003-07-19 15:50:29 +02:00
|
|
|
static void icon_list_append_icon (MimeView *mimeview,
|
|
|
|
MimeInfo *mimeinfo);
|
|
|
|
static void icon_list_create (MimeView *mimeview,
|
|
|
|
MimeInfo *mimeinfo);
|
|
|
|
static void icon_list_clear (MimeView *mimeview);
|
2003-07-24 08:34:22 +02:00
|
|
|
static void icon_list_toggle_by_mime_info (MimeView *mimeview,
|
|
|
|
MimeInfo *mimeinfo);
|
2011-11-18 22:41:56 +01:00
|
|
|
static void ctree_size_allocate_cb (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
MimeView *mimeview);
|
2007-07-16 19:13:43 +02:00
|
|
|
static gint mime_toggle_button_cb(GtkWidget *button, GdkEventButton *event,
|
|
|
|
MimeView *mimeview);
|
2003-10-05 12:25:17 +02:00
|
|
|
static gboolean part_button_pressed (MimeView *mimeview,
|
2003-07-19 15:50:29 +02:00
|
|
|
GdkEventButton *event,
|
|
|
|
MimeInfo *partinfo);
|
|
|
|
static void icon_scroll_size_allocate_cb(GtkWidget *widget,
|
|
|
|
GtkAllocation *layout_size,
|
|
|
|
MimeView *mimeview);
|
2006-09-05 18:26:59 +02:00
|
|
|
static MimeInfo *mimeview_get_part_to_use(MimeView *mimeview);
|
2011-11-11 18:28:07 +01:00
|
|
|
static const gchar *get_part_name(MimeInfo *partinfo);
|
|
|
|
static const gchar *get_part_description(MimeInfo *partinfo);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2008-07-19 18:38:57 +02:00
|
|
|
static void mimeview_launch_cb(GtkAction *action, gpointer data)
|
2006-09-05 07:33:16 +02:00
|
|
|
{
|
2008-07-19 18:38:57 +02:00
|
|
|
MimeView *mimeview = (MimeView *)data;
|
2006-09-05 18:26:59 +02:00
|
|
|
mimeview_launch(mimeview, mimeview_get_part_to_use(mimeview));
|
2006-09-05 07:33:16 +02:00
|
|
|
}
|
2008-07-19 18:38:57 +02:00
|
|
|
|
2008-11-04 22:13:42 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2008-07-19 18:38:57 +02:00
|
|
|
static void mimeview_open_with_cb(GtkAction *action, gpointer data)
|
|
|
|
{
|
|
|
|
mimeview_open_with((MimeView *)data);
|
|
|
|
}
|
2008-11-04 22:13:42 +01:00
|
|
|
#endif
|
2008-07-19 18:38:57 +02:00
|
|
|
|
|
|
|
static void mimeview_display_as_text_cb(GtkAction *action, gpointer data)
|
|
|
|
{
|
|
|
|
mimeview_display_as_text((MimeView *)data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mimeview_save_as_cb(GtkAction *action, gpointer data)
|
|
|
|
{
|
|
|
|
mimeview_save_as((MimeView *)data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mimeview_save_all_cb(GtkAction *action, gpointer data)
|
|
|
|
{
|
|
|
|
mimeview_save_all((MimeView *)data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mimeview_select_next_part_cb(GtkAction *action, gpointer data)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
2008-07-19 18:38:57 +02:00
|
|
|
mimeview_select_next_part((MimeView *)data);
|
|
|
|
}
|
|
|
|
|
2011-10-31 22:46:22 +01:00
|
|
|
static void mimeview_select_prev_part_cb(GtkAction *action, gpointer data)
|
|
|
|
{
|
|
|
|
mimeview_select_prev_part((MimeView *)data);
|
|
|
|
}
|
|
|
|
|
2008-07-29 21:07:54 +02:00
|
|
|
static GtkActionEntry mimeview_menu_actions[] = {
|
2008-07-19 18:38:57 +02:00
|
|
|
{ "MimeView", NULL, "MimeView" },
|
|
|
|
{ "MimeView/Open", NULL, N_("_Open (l)"), NULL, "Open MIME part", G_CALLBACK(mimeview_launch_cb) },
|
2008-11-04 22:13:42 +01:00
|
|
|
#if (!defined MAEMO && !defined G_OS_WIN32)
|
2008-07-19 18:38:57 +02:00
|
|
|
{ "MimeView/OpenWith", NULL, N_("Open _with (o)..."), NULL, "Open MIME part with...", G_CALLBACK(mimeview_open_with_cb) },
|
2007-07-23 18:34:59 +02:00
|
|
|
#endif
|
2008-07-19 18:38:57 +02:00
|
|
|
{ "MimeView/DisplayAsText", NULL, N_("_Display as text (t)"), NULL, "Display as text", G_CALLBACK(mimeview_display_as_text_cb) },
|
|
|
|
{ "MimeView/SaveAs", NULL, N_("_Save as (y)..."), NULL, "Save as", G_CALLBACK(mimeview_save_as_cb) },
|
|
|
|
{ "MimeView/SaveAll", NULL, N_("Save _all..."), NULL, "Save all parts", G_CALLBACK(mimeview_save_all_cb) },
|
2011-10-31 22:46:22 +01:00
|
|
|
{ "MimeView/NextPart", NULL, N_("Next part (a)"), NULL, "Next part", G_CALLBACK(mimeview_select_next_part_cb) },
|
|
|
|
{ "MimeView/PrevPart", NULL, N_("Previous part (z)"), NULL, "Previous part", G_CALLBACK(mimeview_select_prev_part_cb) }
|
2001-04-19 14:21:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static GtkTargetEntry mimeview_mime_types[] =
|
|
|
|
{
|
|
|
|
{"text/uri-list", 0, 0}
|
|
|
|
};
|
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
GSList *mimeviewer_factories;
|
2003-03-16 18:11:03 +01:00
|
|
|
GSList *mimeviews;
|
2003-03-15 00:58:57 +01:00
|
|
|
|
2007-07-16 19:13:43 +02:00
|
|
|
static GdkCursor *hand_cursor = NULL;
|
|
|
|
|
|
|
|
static gboolean mimeview_visi_notify(GtkWidget *widget,
|
|
|
|
GdkEventVisibility *event,
|
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
2011-10-07 11:08:57 +02:00
|
|
|
gdk_window_set_cursor(gtk_widget_get_window(widget), hand_cursor);
|
2007-07-16 19:13:43 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean mimeview_leave_notify(GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event,
|
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
2011-10-07 11:08:57 +02:00
|
|
|
gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
|
2007-07-16 19:13:43 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean mimeview_enter_notify(GtkWidget *widget,
|
|
|
|
GdkEventCrossing *event,
|
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
2011-10-07 11:08:57 +02:00
|
|
|
gdk_window_set_cursor(gtk_widget_get_window(widget), hand_cursor);
|
2007-07-16 19:13:43 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-07-05 12:45:46 +02:00
|
|
|
MimeView *mimeview_create(MainWindow *mainwin)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
|
|
|
MimeView *mimeview;
|
|
|
|
|
|
|
|
GtkWidget *paned;
|
|
|
|
GtkWidget *scrolledwin;
|
|
|
|
GtkWidget *ctree;
|
2003-07-16 19:47:36 +02:00
|
|
|
GtkWidget *mime_notebook;
|
2001-04-19 14:21:46 +02:00
|
|
|
GtkWidget *popupmenu;
|
2003-07-19 15:50:29 +02:00
|
|
|
GtkWidget *ctree_mainbox;
|
2004-01-12 22:28:31 +01:00
|
|
|
GtkWidget *vbox;
|
2003-07-19 15:50:29 +02:00
|
|
|
GtkWidget *mime_toggle;
|
|
|
|
GtkWidget *icon_mainbox;
|
|
|
|
GtkWidget *icon_scroll;
|
|
|
|
GtkWidget *icon_vbox;
|
|
|
|
GtkWidget *arrow;
|
|
|
|
GtkWidget *scrollbutton;
|
2003-07-24 02:40:01 +02:00
|
|
|
GtkWidget *hbox;
|
2004-01-12 22:28:31 +01:00
|
|
|
NoticeView *siginfoview;
|
2008-10-04 20:24:57 +02:00
|
|
|
GtkRequisition r;
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeStore *model;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreeSelection *selection;
|
2008-10-04 20:24:57 +02:00
|
|
|
|
2002-02-08 11:07:11 +01:00
|
|
|
gchar *titles[N_MIMEVIEW_COLS];
|
2011-11-11 18:28:07 +01:00
|
|
|
gint cols;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2007-07-16 19:13:43 +02:00
|
|
|
if (!hand_cursor)
|
|
|
|
hand_cursor = gdk_cursor_new(GDK_HAND2);
|
|
|
|
|
2002-08-15 09:38:17 +02:00
|
|
|
debug_print("Creating MIME view...\n");
|
2001-04-19 14:21:46 +02:00
|
|
|
mimeview = g_new0(MimeView, 1);
|
|
|
|
|
2002-02-08 11:07:11 +01:00
|
|
|
titles[COL_MIMETYPE] = _("MIME Type");
|
|
|
|
titles[COL_SIZE] = _("Size");
|
|
|
|
titles[COL_NAME] = _("Name");
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(scrolledwin);
|
2001-04-19 14:21:46 +02:00
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
2004-08-03 10:46:10 +02:00
|
|
|
GTK_POLICY_AUTOMATIC);
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
model = gtk_tree_store_new(N_MIMEVIEW_COLS,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_POINTER);
|
|
|
|
|
|
|
|
ctree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
|
|
|
|
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(ctree), FALSE);
|
|
|
|
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(ctree),
|
|
|
|
prefs_common.use_stripes_everywhere);
|
|
|
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(ctree),
|
|
|
|
prefs_common.show_col_headers);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
cols = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(ctree),
|
|
|
|
-1, titles[COL_MIMETYPE],renderer,
|
|
|
|
"text", COL_MIMETYPE, NULL);
|
|
|
|
column = gtk_tree_view_get_column(GTK_TREE_VIEW(ctree), cols-1);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
gtk_cell_renderer_set_alignment(renderer, 1, 0.5);
|
|
|
|
cols = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(ctree),
|
|
|
|
-1, titles[COL_SIZE], renderer,
|
|
|
|
"text", COL_SIZE, NULL);
|
|
|
|
column = gtk_tree_view_get_column(GTK_TREE_VIEW(ctree), cols-1);
|
|
|
|
gtk_tree_view_column_set_alignment(GTK_TREE_VIEW_COLUMN(column), 1);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
cols = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(ctree),
|
|
|
|
-1, titles[COL_NAME], renderer,
|
|
|
|
"text", COL_NAME, NULL);
|
|
|
|
column = gtk_tree_view_get_column(GTK_TREE_VIEW(ctree), cols-1);
|
|
|
|
gtk_tree_view_column_set_expand(GTK_TREE_VIEW_COLUMN(column), TRUE);
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ctree));
|
|
|
|
gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2010-03-23 17:12:41 +01:00
|
|
|
gtk_widget_show(ctree);
|
2001-04-19 14:21:46 +02:00
|
|
|
gtk_container_add(GTK_CONTAINER(scrolledwin), ctree);
|
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
g_signal_connect(G_OBJECT(selection), "changed",
|
2003-10-05 12:10:30 +02:00
|
|
|
G_CALLBACK(mimeview_selected), mimeview);
|
2011-11-11 18:28:07 +01:00
|
|
|
g_signal_connect(G_OBJECT(ctree), "button-release-event",
|
2003-10-05 12:10:30 +02:00
|
|
|
G_CALLBACK(mimeview_button_pressed), mimeview);
|
2011-11-11 18:28:07 +01:00
|
|
|
g_signal_connect(G_OBJECT(ctree), "key-press-event",
|
2003-10-05 12:10:30 +02:00
|
|
|
G_CALLBACK(mimeview_key_pressed), mimeview);
|
2011-11-11 18:28:07 +01:00
|
|
|
g_signal_connect(G_OBJECT (ctree),"drag-begin",
|
2003-10-05 12:10:30 +02:00
|
|
|
G_CALLBACK (mimeview_start_drag), mimeview);
|
2011-11-11 18:28:07 +01:00
|
|
|
g_signal_connect(G_OBJECT(ctree), "drag-data-get",
|
2003-10-05 12:10:30 +02:00
|
|
|
G_CALLBACK(mimeview_drag_data_get), mimeview);
|
2003-07-16 19:47:36 +02:00
|
|
|
|
|
|
|
mime_notebook = gtk_notebook_new();
|
|
|
|
gtk_widget_show(mime_notebook);
|
2010-10-02 17:02:54 +02:00
|
|
|
gtkut_widget_set_can_focus(mime_notebook, FALSE);
|
2003-07-16 19:47:36 +02:00
|
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(mime_notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_border(GTK_NOTEBOOK(mime_notebook), FALSE);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2003-08-18 19:08:48 +02:00
|
|
|
icon_vbox = gtk_vbox_new(FALSE, 2);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(icon_vbox);
|
2003-07-19 15:50:29 +02:00
|
|
|
icon_scroll = gtk_layout_new(NULL, NULL);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(icon_scroll);
|
2003-07-19 15:50:29 +02:00
|
|
|
gtk_layout_put(GTK_LAYOUT(icon_scroll), icon_vbox, 0, 0);
|
|
|
|
scrollbutton = gtk_vscrollbutton_new(gtk_layout_get_vadjustment(GTK_LAYOUT(icon_scroll)));
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(scrollbutton);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2006-08-08 18:16:13 +02:00
|
|
|
g_signal_connect(G_OBJECT(icon_scroll), "scroll_event",
|
|
|
|
G_CALLBACK(mimeview_scrolled), mimeview);
|
|
|
|
|
2007-07-16 19:13:43 +02:00
|
|
|
mime_toggle = gtk_event_box_new();
|
|
|
|
gtk_event_box_set_visible_window(GTK_EVENT_BOX(mime_toggle), FALSE);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(mime_toggle), "motion-notify-event",
|
|
|
|
G_CALLBACK(mimeview_visi_notify), mimeview);
|
|
|
|
g_signal_connect(G_OBJECT(mime_toggle), "leave-notify-event",
|
|
|
|
G_CALLBACK(mimeview_leave_notify), mimeview);
|
|
|
|
g_signal_connect(G_OBJECT(mime_toggle), "enter-notify-event",
|
|
|
|
G_CALLBACK(mimeview_enter_notify), mimeview);
|
|
|
|
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(mime_toggle), 2);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(mime_toggle);
|
2007-07-16 19:13:43 +02:00
|
|
|
mimeview->ctree_mode = FALSE;
|
2003-07-19 15:50:29 +02:00
|
|
|
arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE);
|
|
|
|
gtk_widget_show(arrow);
|
2008-10-04 20:24:57 +02:00
|
|
|
gtk_widget_size_request(arrow, &r);
|
2003-07-19 15:50:29 +02:00
|
|
|
gtk_container_add(GTK_CONTAINER(mime_toggle), arrow);
|
2007-07-16 19:13:43 +02:00
|
|
|
g_signal_connect(G_OBJECT(mime_toggle), "button_release_event",
|
2003-10-05 12:10:30 +02:00
|
|
|
G_CALLBACK(mime_toggle_button_cb), mimeview);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
|
|
|
icon_mainbox = gtk_vbox_new(FALSE, 0);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(icon_mainbox);
|
2007-07-16 19:13:43 +02:00
|
|
|
gtk_widget_set_size_request(icon_mainbox, 32, -1);
|
2003-07-19 15:50:29 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(icon_mainbox), mime_toggle, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(icon_mainbox), icon_scroll, TRUE, TRUE, 3);
|
|
|
|
gtk_box_pack_end(GTK_BOX(icon_mainbox), scrollbutton, FALSE, FALSE, 0);
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_connect(G_OBJECT(icon_mainbox), "size_allocate",
|
|
|
|
G_CALLBACK(icon_scroll_size_allocate_cb), mimeview);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2003-07-24 02:40:01 +02:00
|
|
|
ctree_mainbox = gtk_hbox_new(FALSE, 0);
|
2003-07-19 15:50:29 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(ctree_mainbox), scrolledwin, TRUE, TRUE, 0);
|
2011-11-18 22:41:56 +01:00
|
|
|
g_signal_connect(G_OBJECT(ctree_mainbox), "size_allocate",
|
|
|
|
G_CALLBACK(ctree_size_allocate_cb), mimeview);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2008-10-30 18:46:46 +01:00
|
|
|
mimeview->ui_manager = gtk_ui_manager_new();
|
|
|
|
mimeview->action_group = cm_menu_create_action_group_full(mimeview->ui_manager,
|
|
|
|
"MimeView", mimeview_menu_actions,
|
2008-07-19 18:38:57 +02:00
|
|
|
G_N_ELEMENTS(mimeview_menu_actions), (gpointer)mimeview);
|
|
|
|
|
2008-10-30 18:46:46 +01:00
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, "/", "Menus", "Menus", GTK_UI_MANAGER_MENUBAR)
|
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/", "MimeView", "MimeView", GTK_UI_MANAGER_MENU);
|
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/MimeView/", "Open", "MimeView/Open",
|
2008-07-19 18:38:57 +02:00
|
|
|
GTK_UI_MANAGER_MENUITEM);
|
2008-11-04 22:13:42 +01:00
|
|
|
#if (!defined MAEMO && !defined G_OS_WIN32)
|
2008-10-30 18:46:46 +01:00
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/MimeView/", "OpenWith", "MimeView/OpenWith",
|
2008-07-19 18:38:57 +02:00
|
|
|
GTK_UI_MANAGER_MENUITEM);
|
|
|
|
#endif
|
2008-10-30 18:46:46 +01:00
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/MimeView/", "DisplayAsText", "MimeView/DisplayAsText",
|
2008-07-19 18:38:57 +02:00
|
|
|
GTK_UI_MANAGER_MENUITEM);
|
2008-10-30 18:46:46 +01:00
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/MimeView/", "SaveAs", "MimeView/SaveAs",
|
2008-07-19 18:38:57 +02:00
|
|
|
GTK_UI_MANAGER_MENUITEM);
|
2008-10-30 18:46:46 +01:00
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/MimeView/", "SaveAll", "MimeView/SaveAll",
|
2008-07-19 18:38:57 +02:00
|
|
|
GTK_UI_MANAGER_MENUITEM);
|
2008-10-30 18:46:46 +01:00
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/MimeView/", "NextPart", "MimeView/NextPart",
|
2008-07-19 18:38:57 +02:00
|
|
|
GTK_UI_MANAGER_MENUITEM);
|
2011-10-31 22:46:22 +01:00
|
|
|
MENUITEM_ADDUI_MANAGER(mimeview->ui_manager,
|
|
|
|
"/Menus/MimeView/", "PrevPart", "MimeView/PrevPart",
|
|
|
|
GTK_UI_MANAGER_MENUITEM);
|
2008-07-19 18:38:57 +02:00
|
|
|
|
|
|
|
popupmenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
|
2008-10-30 18:46:46 +01:00
|
|
|
gtk_ui_manager_get_widget(mimeview->ui_manager, "/Menus/MimeView")) );
|
2008-07-19 18:38:57 +02:00
|
|
|
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
siginfoview = noticeview_create(mainwin);
|
|
|
|
noticeview_hide(siginfoview);
|
2005-10-13 19:48:47 +02:00
|
|
|
noticeview_set_icon_clickable(siginfoview, TRUE);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), mime_notebook, TRUE, TRUE, 0);
|
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), GTK_WIDGET_PTR(siginfoview), FALSE, FALSE, 0);
|
|
|
|
|
2003-07-24 02:40:01 +02:00
|
|
|
paned = gtk_vpaned_new();
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(paned);
|
2003-07-24 02:40:01 +02:00
|
|
|
gtk_paned_pack1(GTK_PANED(paned), ctree_mainbox, FALSE, TRUE);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_paned_pack2(GTK_PANED(paned), vbox, TRUE, TRUE);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2003-07-24 02:40:01 +02:00
|
|
|
hbox = gtk_hbox_new(FALSE, 0);
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), paned, TRUE, TRUE, 0);
|
2003-07-24 02:40:01 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), icon_mainbox, FALSE, FALSE, 0);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
gtk_widget_show(hbox);
|
2003-07-24 02:40:01 +02:00
|
|
|
gtk_widget_hide(ctree_mainbox);
|
2008-05-07 10:18:24 +02:00
|
|
|
#ifdef GENERIC_UMPC
|
2008-10-04 20:24:57 +02:00
|
|
|
gtk_widget_set_size_request(mime_toggle, -1, r.height + 8);
|
2007-07-14 19:51:10 +02:00
|
|
|
#endif
|
2003-07-24 02:40:01 +02:00
|
|
|
mimeview->hbox = hbox;
|
2003-07-16 19:47:36 +02:00
|
|
|
mimeview->paned = paned;
|
|
|
|
mimeview->scrolledwin = scrolledwin;
|
|
|
|
mimeview->ctree = ctree;
|
|
|
|
mimeview->mime_notebook = mime_notebook;
|
|
|
|
mimeview->popupmenu = popupmenu;
|
|
|
|
mimeview->type = -1;
|
2003-07-19 15:50:29 +02:00
|
|
|
mimeview->ctree_mainbox = ctree_mainbox;
|
|
|
|
mimeview->icon_scroll = icon_scroll;
|
|
|
|
mimeview->icon_vbox = icon_vbox;
|
|
|
|
mimeview->icon_mainbox = icon_mainbox;
|
|
|
|
mimeview->icon_count = 0;
|
|
|
|
mimeview->mainwin = mainwin;
|
2008-07-19 16:02:31 +02:00
|
|
|
#if !(GTK_CHECK_VERSION(2,12,0))
|
|
|
|
mimeview->tooltips = tips;
|
|
|
|
#endif
|
2003-07-19 23:08:55 +02:00
|
|
|
mimeview->mime_toggle = mime_toggle;
|
2004-01-12 22:28:31 +01:00
|
|
|
mimeview->siginfoview = siginfoview;
|
2006-08-08 18:16:13 +02:00
|
|
|
mimeview->scrollbutton = scrollbutton;
|
2003-07-17 10:39:41 +02:00
|
|
|
mimeview->target_list = gtk_target_list_new(mimeview_mime_types, 1);
|
|
|
|
|
2003-03-16 18:11:03 +01:00
|
|
|
mimeviews = g_slist_prepend(mimeviews, mimeview);
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
return mimeview;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mimeview_init(MimeView *mimeview)
|
|
|
|
{
|
2003-06-30 08:21:21 +02:00
|
|
|
textview_init(mimeview->textview);
|
2003-07-16 19:47:36 +02:00
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(mimeview->mime_notebook),
|
|
|
|
GTK_WIDGET_PTR(mimeview->textview));
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2007-01-12 12:58:57 +01:00
|
|
|
static gboolean any_part_is_signed(MimeInfo *mimeinfo)
|
|
|
|
{
|
|
|
|
while (mimeinfo) {
|
|
|
|
if (privacy_mimeinfo_is_signed(mimeinfo))
|
|
|
|
return TRUE;
|
|
|
|
mimeinfo = procmime_mimeinfo_next(mimeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
|
|
|
|
const gchar *file)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeView *ctree = GTK_TREE_VIEW(mimeview->ctree);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
mimeview_clear(mimeview);
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(file != NULL);
|
|
|
|
cm_return_if_fail(mimeinfo != NULL);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
mimeview->mimeinfo = mimeinfo;
|
|
|
|
|
|
|
|
mimeview->file = g_strdup(file);
|
|
|
|
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_handlers_block_by_func(G_OBJECT(ctree), mimeview_selected,
|
|
|
|
mimeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2007-01-12 12:58:57 +01:00
|
|
|
/* check if the mail's signed - it can change the mail structure */
|
|
|
|
|
|
|
|
if (any_part_is_signed(mimeinfo))
|
|
|
|
debug_print("signed mail\n");
|
|
|
|
|
|
|
|
mimeview_set_multipart_tree(mimeview, mimeinfo, NULL);
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_view_expand_all(ctree);
|
2007-01-12 12:58:57 +01:00
|
|
|
icon_list_clear(mimeview);
|
2003-07-19 15:50:29 +02:00
|
|
|
icon_list_create(mimeview, mimeinfo);
|
2011-11-06 12:24:30 +01:00
|
|
|
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(ctree),
|
|
|
|
mimeview_selected, mimeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
#ifdef USE_PTHREAD
|
|
|
|
static void mimeview_check_sig_cancel_now(MimeView *mimeview);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void mimeview_free_mimeinfo(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
gboolean defer = FALSE;
|
|
|
|
#ifdef USE_PTHREAD
|
|
|
|
defer = (mimeview->check_data != NULL);
|
|
|
|
if (defer)
|
|
|
|
mimeview->check_data->free_after_use = TRUE;
|
|
|
|
#endif
|
2006-01-09 19:17:30 +01:00
|
|
|
if (mimeview->mimeinfo != NULL && !defer) {
|
2005-11-01 07:53:28 +01:00
|
|
|
procmime_mimeinfo_free_all(mimeview->mimeinfo);
|
2006-01-09 19:17:30 +01:00
|
|
|
mimeview->mimeinfo = NULL;
|
|
|
|
} else if (defer) {
|
2005-12-20 18:43:40 +01:00
|
|
|
#ifdef USE_PTHREAD
|
2005-11-01 07:53:28 +01:00
|
|
|
debug_print("deferring free(mimeinfo) and cancelling check\n");
|
|
|
|
mimeview_check_sig_cancel_now(mimeview);
|
2005-12-20 18:43:40 +01:00
|
|
|
#endif
|
2005-11-01 07:53:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
void mimeview_destroy(MimeView *mimeview)
|
|
|
|
{
|
2003-03-15 00:58:57 +01:00
|
|
|
GSList *cur;
|
|
|
|
|
|
|
|
for (cur = mimeview->viewers; cur != NULL; cur = g_slist_next(cur)) {
|
|
|
|
MimeViewer *viewer = (MimeViewer *) cur->data;
|
|
|
|
viewer->destroy_viewer(viewer);
|
|
|
|
}
|
|
|
|
g_slist_free(mimeview->viewers);
|
2003-07-17 10:39:41 +02:00
|
|
|
gtk_target_list_unref(mimeview->target_list);
|
2003-03-15 00:58:57 +01:00
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
#ifdef USE_PTHREAD
|
|
|
|
if (mimeview->check_data) {
|
|
|
|
mimeview->check_data->destroy_mimeview = TRUE;
|
|
|
|
debug_print("deferring destroy\n");
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2011-02-13 22:59:10 +01:00
|
|
|
mimeview_free_mimeinfo(mimeview);
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_path_free(mimeview->opened);
|
2005-11-01 07:53:28 +01:00
|
|
|
g_free(mimeview->file);
|
|
|
|
g_free(mimeview);
|
|
|
|
mimeviews = g_slist_remove(mimeviews, mimeview);
|
|
|
|
}
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2003-04-22 15:53:19 +02:00
|
|
|
MimeInfo *mimeview_get_selected_part(MimeView *mimeview)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeSelection *selection;
|
2011-11-17 17:05:50 +01:00
|
|
|
MimeInfo *partinfo = NULL;
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(mimeview->ctree));
|
2011-11-17 17:05:50 +01:00
|
|
|
if (gtk_tree_selection_get_selected(selection, NULL, &iter))
|
|
|
|
gtk_tree_model_get(model, &iter, COL_DATA, &partinfo, -1);
|
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
return partinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
MimeInfo *mimeview_get_node_part(MimeView *mimeview, GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
MimeInfo *partinfo;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
|
gtk_tree_model_get(model, &iter, COL_DATA, &partinfo, -1);
|
|
|
|
return partinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean mimeview_tree_is_empty(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
return !gtk_tree_model_get_iter_first(model, &iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean mimeview_tree_next(GtkTreeModel *model, GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter, parent;
|
|
|
|
gboolean has_parent;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
|
|
|
|
|
if (gtk_tree_model_iter_has_child(model, &iter)) {
|
|
|
|
gtk_tree_path_down(path);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
has_parent = gtk_tree_model_iter_parent(model, &parent, &iter);
|
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_next(model, &iter)) {
|
|
|
|
if (has_parent && gtk_tree_model_iter_next(model, &parent)) {
|
|
|
|
gtk_tree_path_up(path);
|
|
|
|
gtk_tree_path_next(path);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
gtk_tree_path_next(path);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean mimeview_tree_prev(MimeView *mimeview, GtkTreePath *path)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
GtkTreeIter iter, child, parent;
|
|
|
|
gboolean has_parent;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
|
has_parent = gtk_tree_model_iter_parent(model, &parent, &iter);
|
|
|
|
|
|
|
|
if (gtk_tree_path_prev(path)) {
|
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
|
|
|
|
|
if (gtk_tree_model_iter_nth_child(model, &child, &iter, 0)) {
|
|
|
|
gtk_tree_path_down(path);
|
|
|
|
|
|
|
|
while (gtk_tree_model_iter_next(model, &child))
|
|
|
|
gtk_tree_path_next(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_parent) {
|
|
|
|
gtk_tree_path_up(path);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2003-04-22 15:53:19 +02:00
|
|
|
}
|
|
|
|
|
2006-12-14 10:49:25 +01:00
|
|
|
gint mimeview_get_selected_part_num(MimeView *mimeview)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
2006-12-14 10:49:25 +01:00
|
|
|
gint i = 0;
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
gtk_tree_model_get_iter_first(model, &iter);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (!gtk_tree_path_compare(mimeview->opened, path)) {
|
|
|
|
gtk_tree_path_free(path);
|
2006-12-14 10:49:25 +01:00
|
|
|
return i;
|
2011-11-11 18:28:07 +01:00
|
|
|
}
|
|
|
|
|
2006-12-14 10:49:25 +01:00
|
|
|
i++;
|
2011-11-11 18:28:07 +01:00
|
|
|
} while (mimeview_tree_next(model, path));
|
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
|
2006-12-14 10:49:25 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mimeview_select_part_num(MimeView *mimeview, gint i)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
gint x = 0;
|
|
|
|
|
2006-12-14 10:49:25 +01:00
|
|
|
if (i < 0)
|
|
|
|
return;
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
gtk_tree_model_get_iter_first(model, &iter);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
|
|
|
|
while (x != i) {
|
|
|
|
if (!mimeview_tree_next(model, path)) {
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
gtk_tree_selection_select_path(selection, path);
|
|
|
|
gtk_tree_path_free(path);
|
2006-12-14 10:49:25 +01:00
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
static void mimeview_set_multipart_tree(MimeView *mimeview,
|
|
|
|
MimeInfo *mimeinfo,
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeIter *parent)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeStore *model = GTK_TREE_STORE(gtk_tree_view_get_model(
|
|
|
|
GTK_TREE_VIEW(mimeview->ctree)));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *content_type, *length, *name;
|
2001-12-22 17:09:08 +01:00
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(mimeinfo != NULL);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2003-05-07 09:36:15 +02:00
|
|
|
while (mimeinfo != NULL) {
|
2011-11-11 18:28:07 +01:00
|
|
|
if (mimeinfo->type != MIMETYPE_UNKNOWN && mimeinfo->subtype)
|
|
|
|
content_type = g_strdup_printf("%s/%s",
|
|
|
|
procmime_get_media_type_str(mimeinfo->type),
|
|
|
|
mimeinfo->subtype);
|
|
|
|
else
|
|
|
|
content_type = g_strdup("UNKNOWN");
|
|
|
|
|
|
|
|
length = g_strdup(to_human_readable((goffset) mimeinfo->length));
|
|
|
|
|
|
|
|
if (prefs_common.attach_desc)
|
|
|
|
name = g_strdup(get_part_description(mimeinfo));
|
|
|
|
else
|
|
|
|
name = g_strdup(get_part_name(mimeinfo));
|
|
|
|
|
|
|
|
gtk_tree_store_append(model, &iter, parent);
|
|
|
|
gtk_tree_store_set(model, &iter,
|
|
|
|
COL_MIMETYPE, content_type,
|
|
|
|
COL_SIZE, length,
|
|
|
|
COL_NAME, name,
|
|
|
|
COL_DATA, mimeinfo, -1);
|
|
|
|
g_free(content_type);
|
|
|
|
g_free(length);
|
|
|
|
g_free(name);
|
2003-05-07 09:36:15 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
if (mimeinfo->node->children)
|
2011-11-11 18:28:07 +01:00
|
|
|
mimeview_set_multipart_tree(mimeview,
|
|
|
|
(MimeInfo *) mimeinfo->node->children->data, &iter);
|
|
|
|
mimeinfo = mimeinfo->node->next != NULL ?
|
|
|
|
(MimeInfo *) mimeinfo->node->next->data : NULL;
|
2003-05-07 09:36:15 +02:00
|
|
|
}
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2006-06-28 19:28:32 +02:00
|
|
|
static const gchar *get_real_part_name(MimeInfo *partinfo)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
2006-06-28 19:28:32 +02:00
|
|
|
const gchar *name = NULL;
|
2004-01-12 22:28:31 +01:00
|
|
|
|
|
|
|
name = procmime_mimeinfo_get_parameter(partinfo, "filename");
|
|
|
|
if (name == NULL)
|
|
|
|
name = procmime_mimeinfo_get_parameter(partinfo, "name");
|
2006-06-28 19:28:32 +02:00
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar *get_part_name(MimeInfo *partinfo)
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
name = get_real_part_name(partinfo);
|
2004-01-12 22:28:31 +01:00
|
|
|
if (name == NULL)
|
|
|
|
name = "";
|
|
|
|
|
|
|
|
return name;
|
2003-02-22 13:09:38 +01:00
|
|
|
}
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
static const gchar *get_part_description(MimeInfo *partinfo)
|
2003-02-22 13:09:38 +01:00
|
|
|
{
|
|
|
|
if (partinfo->description)
|
|
|
|
return partinfo->description;
|
2001-04-19 14:21:46 +02:00
|
|
|
else
|
2004-01-12 22:28:31 +01:00
|
|
|
return get_part_name(partinfo);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mimeview_show_message_part(MimeView *mimeview, MimeInfo *partinfo)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
const gchar *fname;
|
|
|
|
|
|
|
|
if (!partinfo) return;
|
|
|
|
|
|
|
|
fname = mimeview->file;
|
|
|
|
if (!fname) return;
|
|
|
|
|
2005-08-19 11:30:30 +02:00
|
|
|
if ((fp = g_fopen(fname, "rb")) == NULL) {
|
2001-04-19 14:21:46 +02:00
|
|
|
FILE_OP_ERROR(fname, "fopen");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
if (fseek(fp, partinfo->offset, SEEK_SET) < 0) {
|
2001-04-19 14:21:46 +02:00
|
|
|
FILE_OP_ERROR(mimeview->file, "fseek");
|
|
|
|
fclose(fp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
|
|
|
|
textview_show_part(mimeview->textview, partinfo, fp);
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
static MimeViewer *get_viewer_for_content_type(MimeView *mimeview, const gchar *content_type)
|
|
|
|
{
|
|
|
|
GSList *cur;
|
|
|
|
MimeViewerFactory *factory = NULL;
|
|
|
|
MimeViewer *viewer = NULL;
|
2008-08-06 21:38:45 +02:00
|
|
|
gchar *real_contenttype = NULL;
|
2003-06-07 00:09:46 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FNM_CASEFOLD is a GNU extension
|
|
|
|
*/
|
|
|
|
#ifndef FNM_CASEFOLD
|
|
|
|
#define FNM_CASEFOLD 0
|
2008-08-06 21:38:45 +02:00
|
|
|
real_contenttype = g_utf8_strdown((gchar *)content_type, -1);
|
|
|
|
#else
|
|
|
|
real_contenttype = g_strdup(content_type);
|
2003-06-07 00:09:46 +02:00
|
|
|
#endif
|
2003-03-15 00:58:57 +01:00
|
|
|
|
|
|
|
for (cur = mimeviewer_factories; cur != NULL; cur = g_slist_next(cur)) {
|
|
|
|
MimeViewerFactory *curfactory = cur->data;
|
2003-05-18 18:15:33 +02:00
|
|
|
gint i = 0;
|
|
|
|
|
|
|
|
while (curfactory->content_types[i] != NULL) {
|
2008-08-06 21:38:45 +02:00
|
|
|
if(!fnmatch(curfactory->content_types[i], real_contenttype, FNM_CASEFOLD)) {
|
2004-01-12 22:28:31 +01:00
|
|
|
debug_print("%s\n", curfactory->content_types[i]);
|
2003-05-18 18:15:33 +02:00
|
|
|
factory = curfactory;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
2003-03-15 00:58:57 +01:00
|
|
|
}
|
2003-05-18 18:15:33 +02:00
|
|
|
if (factory != NULL)
|
|
|
|
break;
|
2003-03-15 00:58:57 +01:00
|
|
|
}
|
2008-08-06 21:38:45 +02:00
|
|
|
g_free(real_contenttype);
|
2003-03-15 00:58:57 +01:00
|
|
|
if (factory == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (cur = mimeview->viewers; cur != NULL; cur = g_slist_next(cur)) {
|
|
|
|
MimeViewer *curviewer = cur->data;
|
|
|
|
|
|
|
|
if (curviewer->factory == factory)
|
|
|
|
return curviewer;
|
|
|
|
}
|
|
|
|
viewer = factory->create_viewer();
|
2003-07-16 19:47:36 +02:00
|
|
|
gtk_container_add(GTK_CONTAINER(mimeview->mime_notebook),
|
|
|
|
GTK_WIDGET(viewer->get_widget(viewer)));
|
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
mimeview->viewers = g_slist_append(mimeview->viewers, viewer);
|
|
|
|
|
|
|
|
return viewer;
|
|
|
|
}
|
|
|
|
|
2008-02-05 08:27:07 +01:00
|
|
|
gboolean mimeview_has_viewer_for_content_type(MimeView *mimeview, const gchar *content_type)
|
|
|
|
{
|
|
|
|
return (get_viewer_for_content_type(mimeview, content_type) != NULL);
|
|
|
|
}
|
|
|
|
|
2003-03-26 00:35:47 +01:00
|
|
|
static MimeViewer *get_viewer_for_mimeinfo(MimeView *mimeview, MimeInfo *partinfo)
|
|
|
|
{
|
|
|
|
gchar *content_type = NULL;
|
2003-03-26 16:51:31 +01:00
|
|
|
MimeViewer *viewer = NULL;
|
2003-03-26 00:35:47 +01:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
if ((partinfo->type == MIMETYPE_APPLICATION) &&
|
2004-10-26 12:43:50 +02:00
|
|
|
(!g_ascii_strcasecmp(partinfo->subtype, "octet-stream"))) {
|
2004-01-12 22:28:31 +01:00
|
|
|
const gchar *filename;
|
|
|
|
|
|
|
|
filename = procmime_mimeinfo_get_parameter(partinfo, "filename");
|
|
|
|
if (filename == NULL)
|
|
|
|
filename = procmime_mimeinfo_get_parameter(partinfo, "name");
|
|
|
|
if (filename != NULL)
|
|
|
|
content_type = procmime_get_mime_type(filename);
|
2003-03-26 00:35:47 +01:00
|
|
|
} else {
|
2004-05-10 12:22:28 +02:00
|
|
|
content_type = procmime_get_content_type_str(partinfo->type, partinfo->subtype);
|
2003-03-26 00:35:47 +01:00
|
|
|
}
|
|
|
|
|
2003-03-26 16:51:31 +01:00
|
|
|
if (content_type != NULL) {
|
|
|
|
viewer = get_viewer_for_content_type(mimeview, content_type);
|
|
|
|
g_free(content_type);
|
|
|
|
}
|
2003-03-26 00:35:47 +01:00
|
|
|
|
|
|
|
return viewer;
|
|
|
|
}
|
|
|
|
|
2005-02-09 09:59:12 +01:00
|
|
|
gboolean mimeview_show_part(MimeView *mimeview, MimeInfo *partinfo)
|
2003-03-15 00:58:57 +01:00
|
|
|
{
|
|
|
|
MimeViewer *viewer;
|
|
|
|
|
2008-08-13 18:03:12 +02:00
|
|
|
if (mimeview->messageview->partial_display_shown) {
|
|
|
|
noticeview_hide(mimeview->messageview->noticeview);
|
|
|
|
mimeview->messageview->partial_display_shown = FALSE;
|
|
|
|
}
|
|
|
|
|
2003-03-26 00:35:47 +01:00
|
|
|
viewer = get_viewer_for_mimeinfo(mimeview, partinfo);
|
2003-03-15 00:58:57 +01:00
|
|
|
if (viewer == NULL) {
|
|
|
|
if (mimeview->mimeviewer != NULL)
|
|
|
|
mimeview->mimeviewer->clear_viewer(mimeview->mimeviewer);
|
|
|
|
mimeview->mimeviewer = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-20 18:51:40 +02:00
|
|
|
if (mimeview->mimeviewer != NULL)
|
|
|
|
mimeview->mimeviewer->clear_viewer(mimeview->mimeviewer);
|
|
|
|
|
2011-11-06 12:24:30 +01:00
|
|
|
if (mimeview->mimeviewer != viewer)
|
2003-03-15 00:58:57 +01:00
|
|
|
mimeview->mimeviewer = viewer;
|
2011-11-06 12:24:30 +01:00
|
|
|
|
|
|
|
mimeview_change_view_type(mimeview, MIMEVIEW_VIEWER);
|
2006-02-15 18:59:37 +01:00
|
|
|
viewer->mimeview = mimeview;
|
2003-03-15 00:58:57 +01:00
|
|
|
viewer->show_mimepart(viewer, mimeview->file, partinfo);
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
return TRUE;
|
2003-03-15 00:58:57 +01:00
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
static void mimeview_change_view_type(MimeView *mimeview, MimeViewType type)
|
|
|
|
{
|
|
|
|
TextView *textview = mimeview->textview;
|
2006-09-04 21:29:14 +02:00
|
|
|
GtkWidget *focused = NULL;
|
|
|
|
|
|
|
|
if (mainwindow_get_mainwindow())
|
2006-09-07 15:23:55 +02:00
|
|
|
focused = gtkut_get_focused_child(
|
|
|
|
GTK_CONTAINER(mainwindow_get_mainwindow()->window));
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
if ((mimeview->type != MIMEVIEW_VIEWER) &&
|
|
|
|
(mimeview->type == type)) return;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case MIMEVIEW_TEXT:
|
2004-11-18 08:11:16 +01:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(mimeview->mime_notebook),
|
2003-07-16 19:47:36 +02:00
|
|
|
gtk_notebook_page_num(GTK_NOTEBOOK(mimeview->mime_notebook),
|
|
|
|
GTK_WIDGET_PTR(textview)));
|
2001-04-19 14:21:46 +02:00
|
|
|
break;
|
2003-03-15 00:58:57 +01:00
|
|
|
case MIMEVIEW_VIEWER:
|
2004-11-18 08:11:16 +01:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(mimeview->mime_notebook),
|
2003-07-16 19:47:36 +02:00
|
|
|
gtk_notebook_page_num(GTK_NOTEBOOK(mimeview->mime_notebook),
|
|
|
|
GTK_WIDGET(mimeview->mimeviewer->get_widget(mimeview->mimeviewer))));
|
2003-03-15 00:58:57 +01:00
|
|
|
break;
|
2001-04-19 14:21:46 +02:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2006-09-04 21:29:14 +02:00
|
|
|
if (focused)
|
|
|
|
gtk_widget_grab_focus(focused);
|
2001-04-19 14:21:46 +02:00
|
|
|
mimeview->type = type;
|
|
|
|
}
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
void mimeview_clear(MimeView *mimeview)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeModel *model;
|
2006-01-09 19:17:30 +01:00
|
|
|
|
|
|
|
if (!mimeview)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (g_slist_find(mimeviews, mimeview) == NULL)
|
|
|
|
return;
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
noticeview_hide(mimeview->siginfoview);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
gtk_tree_store_clear(GTK_TREE_STORE(model));
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
textview_clear(mimeview->textview);
|
2003-03-15 00:58:57 +01:00
|
|
|
if (mimeview->mimeviewer != NULL)
|
|
|
|
mimeview->mimeviewer->clear_viewer(mimeview->mimeviewer);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
mimeview_free_mimeinfo(mimeview);
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
mimeview->mimeinfo = NULL;
|
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_path_free(mimeview->opened);
|
2001-04-19 14:21:46 +02:00
|
|
|
mimeview->opened = NULL;
|
|
|
|
|
|
|
|
g_free(mimeview->file);
|
|
|
|
mimeview->file = NULL;
|
2003-07-29 15:14:26 +02:00
|
|
|
|
2003-07-19 15:50:29 +02:00
|
|
|
icon_list_clear(mimeview);
|
2006-01-17 19:42:53 +01:00
|
|
|
mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
|
2004-01-12 22:28:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_signature_cb(GtkWidget *widget, gpointer user_data);
|
2007-10-15 19:20:02 +02:00
|
|
|
static void mimeview_check_signature(MimeView *mimeview);
|
2004-01-12 22:28:31 +01:00
|
|
|
static void display_full_info_cb(GtkWidget *widget, gpointer user_data);
|
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo,
|
|
|
|
gboolean special, SignatureStatus code)
|
2004-01-12 22:28:31 +01:00
|
|
|
{
|
|
|
|
gchar *text = NULL, *button_text = NULL;
|
2004-07-17 18:58:04 +02:00
|
|
|
void *func = NULL;
|
2004-01-12 22:28:31 +01:00
|
|
|
StockPixmap icon = STOCK_PIXMAP_PRIVACY_SIGNED;
|
2005-11-01 07:53:28 +01:00
|
|
|
SignatureStatus mycode = SIGNATURE_UNCHECKED;
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(mimeview != NULL);
|
|
|
|
cm_return_if_fail(mimeinfo != NULL);
|
2004-01-12 22:28:31 +01:00
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
if (special)
|
|
|
|
mycode = code;
|
|
|
|
else
|
|
|
|
mycode = privacy_mimeinfo_get_sig_status(mimeinfo);
|
|
|
|
|
|
|
|
switch (mycode) {
|
2004-01-12 22:28:31 +01:00
|
|
|
case SIGNATURE_UNCHECKED:
|
2005-10-13 21:56:17 +02:00
|
|
|
button_text = _("Check signature");
|
2004-01-12 22:28:31 +01:00
|
|
|
func = check_signature_cb;
|
|
|
|
icon = STOCK_PIXMAP_PRIVACY_SIGNED;
|
|
|
|
break;
|
|
|
|
case SIGNATURE_OK:
|
2005-10-13 21:56:17 +02:00
|
|
|
button_text = _("View full information");
|
2004-01-12 22:28:31 +01:00
|
|
|
func = display_full_info_cb;
|
|
|
|
icon = STOCK_PIXMAP_PRIVACY_PASSED;
|
|
|
|
break;
|
|
|
|
case SIGNATURE_WARN:
|
2005-10-13 21:56:17 +02:00
|
|
|
button_text = _("View full information");
|
2004-01-12 22:28:31 +01:00
|
|
|
func = display_full_info_cb;
|
|
|
|
icon = STOCK_PIXMAP_PRIVACY_WARN;
|
|
|
|
break;
|
2008-05-18 12:24:33 +02:00
|
|
|
case SIGNATURE_KEY_EXPIRED:
|
|
|
|
button_text = _("View full information");
|
|
|
|
func = display_full_info_cb;
|
|
|
|
icon = STOCK_PIXMAP_PRIVACY_EXPIRED;
|
|
|
|
break;
|
2004-01-12 22:28:31 +01:00
|
|
|
case SIGNATURE_INVALID:
|
2005-10-13 21:56:17 +02:00
|
|
|
button_text = _("View full information");
|
2004-01-12 22:28:31 +01:00
|
|
|
func = display_full_info_cb;
|
|
|
|
icon = STOCK_PIXMAP_PRIVACY_FAILED;
|
|
|
|
break;
|
|
|
|
case SIGNATURE_CHECK_FAILED:
|
|
|
|
button_text = _("Check again");
|
|
|
|
func = check_signature_cb;
|
|
|
|
icon = STOCK_PIXMAP_PRIVACY_UNKNOWN;
|
2005-11-01 07:53:28 +01:00
|
|
|
case SIGNATURE_CHECK_TIMEOUT:
|
|
|
|
button_text = _("Check again");
|
|
|
|
func = check_signature_cb;
|
|
|
|
icon = STOCK_PIXMAP_PRIVACY_UNKNOWN;
|
2004-01-12 22:28:31 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-11-01 07:53:28 +01:00
|
|
|
if (mycode == SIGNATURE_UNCHECKED) {
|
2005-10-16 13:08:46 +02:00
|
|
|
gchar *tmp = privacy_mimeinfo_sig_info_short(mimeinfo);
|
|
|
|
text = g_strdup_printf("%s %s",
|
2005-10-16 15:00:50 +02:00
|
|
|
tmp, _("Click the icon or hit 'C' to check it."));
|
2005-10-16 13:08:46 +02:00
|
|
|
g_free(tmp);
|
2005-11-01 07:53:28 +01:00
|
|
|
} else if (mycode != SIGNATURE_CHECK_TIMEOUT) {
|
2005-10-16 13:08:46 +02:00
|
|
|
text = privacy_mimeinfo_sig_info_short(mimeinfo);
|
2005-11-01 07:53:28 +01:00
|
|
|
} else if (mycode == SIGNATURE_CHECK_TIMEOUT) {
|
|
|
|
text = g_strdup(_("Timeout checking the signature. Click the icon or hit 'C' to try again."));
|
|
|
|
}
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
noticeview_set_text(mimeview->siginfoview, text);
|
2006-01-10 10:07:42 +01:00
|
|
|
gtk_label_set_selectable(GTK_LABEL(mimeview->siginfoview->text), TRUE);
|
2005-12-08 18:45:19 +01:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
g_free(text);
|
2005-10-13 21:56:17 +02:00
|
|
|
noticeview_set_button_text(mimeview->siginfoview, NULL);
|
2004-01-12 22:28:31 +01:00
|
|
|
noticeview_set_button_press_callback(
|
|
|
|
mimeview->siginfoview,
|
2004-12-04 12:26:52 +01:00
|
|
|
G_CALLBACK(func),
|
2004-01-12 22:28:31 +01:00
|
|
|
(gpointer) mimeview);
|
|
|
|
noticeview_set_icon(mimeview->siginfoview, icon);
|
2005-10-13 21:56:17 +02:00
|
|
|
noticeview_set_tooltip(mimeview->siginfoview, button_text);
|
2004-01-12 22:28:31 +01:00
|
|
|
}
|
2002-02-25 10:25:17 +01:00
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
#ifdef USE_PTHREAD
|
|
|
|
|
|
|
|
/* reset all thread stuff, and do the cleanups we've been left to do */
|
|
|
|
static void mimeview_check_data_reset(MimeView *mimeview)
|
|
|
|
{
|
2011-02-13 22:59:10 +01:00
|
|
|
gboolean must_free;
|
|
|
|
gboolean must_destroy;
|
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
if (!mimeview->check_data)
|
|
|
|
return;
|
|
|
|
|
2011-02-13 22:59:10 +01:00
|
|
|
must_free = mimeview->check_data->free_after_use;
|
|
|
|
must_destroy = mimeview->check_data->destroy_mimeview;
|
|
|
|
|
2011-03-04 16:50:16 +01:00
|
|
|
if (mimeview->check_data->cancel_th_init) {
|
2011-02-13 22:59:10 +01:00
|
|
|
debug_print("killing canceller thread\n");
|
2011-03-04 16:50:16 +01:00
|
|
|
mimeview->check_data->cancel_th_init = FALSE;
|
2011-02-13 22:59:10 +01:00
|
|
|
pthread_cancel(mimeview->check_data->cancel_th);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free(mimeview->check_data);
|
|
|
|
mimeview->check_data = NULL;
|
|
|
|
|
|
|
|
if (must_free) {
|
2005-11-01 07:53:28 +01:00
|
|
|
debug_print("freeing deferred mimeinfo\n");
|
|
|
|
procmime_mimeinfo_free_all(mimeview->check_data->siginfo);
|
|
|
|
}
|
2011-02-13 22:59:10 +01:00
|
|
|
if (must_destroy) {
|
2005-11-01 07:53:28 +01:00
|
|
|
debug_print("freeing deferred mimeview\n");
|
2011-02-13 22:59:10 +01:00
|
|
|
mimeview_free_mimeinfo(mimeview);
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_path_free(mimeview->opened);
|
2005-11-01 07:53:28 +01:00
|
|
|
g_free(mimeview->file);
|
|
|
|
g_free(mimeview);
|
|
|
|
mimeviews = g_slist_remove(mimeviews, mimeview);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GUI update once the checker thread is done or killed */
|
|
|
|
static gboolean mimeview_check_sig_thread_cb(void *data)
|
|
|
|
{
|
|
|
|
MimeView *mimeview = (MimeView *) data;
|
|
|
|
MimeInfo *mimeinfo = mimeview->siginfo;
|
|
|
|
|
|
|
|
debug_print("mimeview_check_sig_thread_cb\n");
|
|
|
|
|
|
|
|
if (mimeinfo == NULL) {
|
|
|
|
/* message changed !? */
|
|
|
|
g_warning("no more siginfo!\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mimeview->check_data) {
|
|
|
|
g_warning("nothing to check\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mimeview->check_data->siginfo != mimeinfo) {
|
|
|
|
/* message changed !? */
|
|
|
|
g_warning("different siginfo!\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mimeview->check_data->destroy_mimeview ||
|
|
|
|
mimeview->check_data->free_after_use) {
|
|
|
|
debug_print("not bothering, we're changing message\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update status */
|
|
|
|
if (mimeview->check_data->timeout)
|
|
|
|
update_signature_noticeview(mimeview, mimeview->siginfo,
|
|
|
|
TRUE, SIGNATURE_CHECK_TIMEOUT);
|
|
|
|
else
|
|
|
|
update_signature_noticeview(mimeview, mimeview->siginfo,
|
|
|
|
FALSE, 0);
|
|
|
|
icon_list_clear(mimeview);
|
|
|
|
icon_list_create(mimeview, mimeview->mimeinfo);
|
|
|
|
|
|
|
|
end:
|
|
|
|
mimeview_check_data_reset(mimeview);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sig checker thread */
|
|
|
|
static void *mimeview_check_sig_worker_thread(void *data)
|
|
|
|
{
|
|
|
|
MimeView *mimeview = (MimeView *)data;
|
|
|
|
MimeInfo *mimeinfo = mimeview->siginfo;
|
|
|
|
|
|
|
|
debug_print("checking...\n");
|
|
|
|
|
|
|
|
if (!mimeview->check_data)
|
|
|
|
return NULL;
|
|
|
|
|
2011-02-13 22:59:10 +01:00
|
|
|
if (mimeinfo && mimeinfo == mimeview->check_data->siginfo) {
|
2005-11-01 07:53:28 +01:00
|
|
|
privacy_mimeinfo_check_signature(mimeinfo);
|
2011-03-04 16:50:16 +01:00
|
|
|
if (mimeview->check_data && mimeview->check_data->cancel_th_init) {
|
|
|
|
mimeview->check_data->cancel_th_init = FALSE;
|
2011-02-13 22:59:10 +01:00
|
|
|
pthread_cancel(mimeview->check_data->cancel_th);
|
|
|
|
}
|
|
|
|
} else {
|
2005-11-01 07:53:28 +01:00
|
|
|
/* that's strange! we changed message without
|
|
|
|
* getting killed. */
|
|
|
|
g_warning("different siginfo!\n");
|
|
|
|
mimeview_check_data_reset(mimeview);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use g_timeout so that GUI updates is done from the
|
|
|
|
* correct thread */
|
|
|
|
g_timeout_add(0,mimeview_check_sig_thread_cb,mimeview);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* killer thread - acts when the checker didn't work fast
|
|
|
|
* enough. */
|
|
|
|
static void *mimeview_check_sig_cancel_thread(void *data)
|
|
|
|
{
|
|
|
|
MimeView *mimeview = (MimeView *)data;
|
|
|
|
|
|
|
|
if (!mimeview->check_data)
|
|
|
|
return NULL; /* nothing to kill ! */
|
|
|
|
|
|
|
|
/* wait for a few seconds... */
|
|
|
|
debug_print("waiting a while\n");
|
|
|
|
|
2011-03-04 16:50:16 +01:00
|
|
|
g_usleep(5 * 1000 * 1000);
|
2005-11-01 07:53:28 +01:00
|
|
|
|
|
|
|
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");
|
2011-03-04 16:50:16 +01:00
|
|
|
if (mimeview->check_data->th_init) {
|
|
|
|
mimeview->check_data->th_init = FALSE;
|
|
|
|
pthread_cancel(mimeview->check_data->th);
|
|
|
|
}
|
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
/* tell upstream it was a timeout */
|
|
|
|
mimeview->check_data->timeout = TRUE;
|
|
|
|
/* use g_timeout so that GUI updates is done from the
|
|
|
|
* correct thread */
|
|
|
|
g_timeout_add(0,mimeview_check_sig_thread_cb,mimeview);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get rid of the checker thread right now - used when changing the
|
|
|
|
* displayed message for example. */
|
|
|
|
static void mimeview_check_sig_cancel_now(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
if (!mimeview->check_data)
|
|
|
|
return;
|
|
|
|
debug_print("killing checker thread NOW\n");
|
2011-03-04 16:50:16 +01:00
|
|
|
if (mimeview->check_data->th_init) {
|
|
|
|
mimeview->check_data->th_init = FALSE;
|
|
|
|
pthread_cancel(mimeview->check_data->th);
|
|
|
|
}
|
2005-11-01 07:53:28 +01:00
|
|
|
|
|
|
|
/* tell upstream it was a timeout */
|
|
|
|
mimeview->check_data->timeout = TRUE;
|
|
|
|
mimeview_check_sig_thread_cb(mimeview);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* creates a thread to check the signature, and a second one
|
|
|
|
* to kill the first one after a timeout */
|
|
|
|
static void mimeview_check_sig_in_thread(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
pthread_t th, th2;
|
|
|
|
pthread_attr_t detach, detach2;
|
|
|
|
|
|
|
|
if (mimeview->check_data) {
|
|
|
|
g_warning("already checking it");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mimeview->check_data = g_new0(SigCheckData, 1);
|
|
|
|
mimeview->check_data->siginfo = mimeview->siginfo;
|
|
|
|
debug_print("creating thread\n");
|
|
|
|
|
2008-01-21 08:56:11 +01:00
|
|
|
/* init thread attributes and create the checker thread */
|
|
|
|
if (pthread_attr_init(&detach) != 0 ||
|
|
|
|
pthread_attr_setdetachstate(&detach, PTHREAD_CREATE_DETACHED) != 0 ||
|
|
|
|
pthread_attr_init(&detach2) != 0 ||
|
|
|
|
pthread_attr_setdetachstate(&detach2, PTHREAD_CREATE_DETACHED) != 0 ||
|
|
|
|
pthread_create(&th, &detach,
|
2005-11-01 07:53:28 +01:00
|
|
|
mimeview_check_sig_worker_thread,
|
|
|
|
mimeview) != 0) {
|
|
|
|
/* arh. We'll do it synchronously. */
|
|
|
|
g_warning("can't create thread");
|
|
|
|
g_free(mimeview->check_data);
|
|
|
|
mimeview->check_data = NULL;
|
|
|
|
return;
|
2011-03-04 16:50:16 +01:00
|
|
|
} else {
|
2005-11-01 07:53:28 +01:00
|
|
|
mimeview->check_data->th = th;
|
2011-03-04 16:50:16 +01:00
|
|
|
mimeview->check_data->th_init = TRUE;
|
|
|
|
}
|
2005-11-01 07:53:28 +01:00
|
|
|
|
|
|
|
/* create the killer thread */
|
|
|
|
pthread_create(&th2, &detach2,
|
|
|
|
mimeview_check_sig_cancel_thread,
|
|
|
|
mimeview);
|
2011-02-13 22:59:10 +01:00
|
|
|
|
|
|
|
mimeview->check_data->cancel_th = th2;
|
2011-03-04 16:50:16 +01:00
|
|
|
mimeview->check_data->cancel_th_init = TRUE;
|
2005-11-01 07:53:28 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
static void check_signature_cb(GtkWidget *widget, gpointer user_data)
|
|
|
|
{
|
|
|
|
MimeView *mimeview = (MimeView *) user_data;
|
|
|
|
MimeInfo *mimeinfo = mimeview->siginfo;
|
|
|
|
|
2005-10-16 13:08:46 +02:00
|
|
|
if (mimeinfo == NULL)
|
|
|
|
return;
|
2005-11-01 07:53:28 +01:00
|
|
|
#ifdef USE_PTHREAD
|
|
|
|
if (mimeview->check_data)
|
|
|
|
return;
|
|
|
|
#endif
|
2005-10-17 21:53:32 +02:00
|
|
|
noticeview_set_text(mimeview->siginfoview, _("Checking signature..."));
|
|
|
|
GTK_EVENTS_FLUSH();
|
2008-01-21 08:56:11 +01:00
|
|
|
#ifdef USE_PTHREAD
|
2005-11-01 07:53:28 +01:00
|
|
|
/* let's do it non-blocking */
|
|
|
|
mimeview_check_sig_in_thread(mimeview);
|
|
|
|
if (!mimeview->check_data) /* let's check syncronously */
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
debug_print("checking without thread\n");
|
|
|
|
privacy_mimeinfo_check_signature(mimeinfo);
|
|
|
|
update_signature_noticeview(mimeview, mimeview->siginfo, FALSE, 0);
|
|
|
|
icon_list_clear(mimeview);
|
|
|
|
icon_list_create(mimeview, mimeview->mimeinfo);
|
|
|
|
}
|
2004-01-12 22:28:31 +01:00
|
|
|
}
|
|
|
|
|
2007-10-15 19:20:02 +02:00
|
|
|
static void mimeview_check_signature(MimeView *mimeview)
|
2005-10-16 13:08:46 +02:00
|
|
|
{
|
|
|
|
check_signature_cb(NULL, mimeview);
|
|
|
|
}
|
|
|
|
|
2005-10-12 20:50:03 +02:00
|
|
|
static void redisplay_email(GtkWidget *widget, gpointer user_data)
|
|
|
|
{
|
|
|
|
MimeView *mimeview = (MimeView *) user_data;
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_path_free(mimeview->opened);
|
2005-10-12 20:50:03 +02:00
|
|
|
mimeview->opened = NULL;
|
2011-11-11 18:28:07 +01:00
|
|
|
mimeview_selected(gtk_tree_view_get_selection(
|
|
|
|
GTK_TREE_VIEW(mimeview->ctree)), mimeview);
|
2005-10-12 20:50:03 +02:00
|
|
|
}
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
static void display_full_info_cb(GtkWidget *widget, gpointer user_data)
|
|
|
|
{
|
|
|
|
MimeView *mimeview = (MimeView *) user_data;
|
|
|
|
gchar *siginfo;
|
|
|
|
|
|
|
|
siginfo = privacy_mimeinfo_sig_info_full(mimeview->siginfo);
|
|
|
|
textview_set_text(mimeview->textview, siginfo);
|
|
|
|
g_free(siginfo);
|
2005-10-13 21:56:17 +02:00
|
|
|
noticeview_set_button_text(mimeview->siginfoview, NULL);
|
2005-10-12 20:50:03 +02:00
|
|
|
noticeview_set_button_press_callback(
|
|
|
|
mimeview->siginfoview,
|
|
|
|
G_CALLBACK(redisplay_email),
|
|
|
|
(gpointer) mimeview);
|
2005-10-13 21:56:17 +02:00
|
|
|
noticeview_set_tooltip(mimeview->siginfoview, _("Go back to email"));
|
2004-01-12 22:28:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void update_signature_info(MimeView *mimeview, MimeInfo *selected)
|
|
|
|
{
|
|
|
|
MimeInfo *siginfo;
|
2005-10-12 19:22:33 +02:00
|
|
|
MimeInfo *first_text;
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(mimeview != NULL);
|
|
|
|
cm_return_if_fail(selected != NULL);
|
2004-01-12 22:28:31 +01:00
|
|
|
|
2005-10-12 19:22:33 +02:00
|
|
|
if (selected->type == MIMETYPE_MESSAGE
|
|
|
|
&& !g_ascii_strcasecmp(selected->subtype, "rfc822")) {
|
|
|
|
/* if the first text part is signed, check that */
|
|
|
|
first_text = selected;
|
|
|
|
while (first_text && first_text->type != MIMETYPE_TEXT) {
|
|
|
|
first_text = procmime_mimeinfo_next(first_text);
|
|
|
|
}
|
|
|
|
if (first_text) {
|
|
|
|
update_signature_info(mimeview, first_text);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
siginfo = selected;
|
|
|
|
while (siginfo != NULL) {
|
|
|
|
if (privacy_mimeinfo_is_signed(siginfo))
|
|
|
|
break;
|
|
|
|
siginfo = procmime_mimeinfo_parent(siginfo);
|
|
|
|
}
|
|
|
|
mimeview->siginfo = siginfo;
|
|
|
|
|
|
|
|
if (siginfo == NULL) {
|
|
|
|
noticeview_hide(mimeview->siginfoview);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-11-01 07:53:28 +01:00
|
|
|
update_signature_noticeview(mimeview, siginfo, FALSE, 0);
|
2004-01-12 22:28:31 +01:00
|
|
|
noticeview_show(mimeview->siginfoview);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
static void mimeview_selected(GtkTreeSelection *selection, MimeView *mimeview)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeView *ctree = GTK_TREE_VIEW(mimeview->ctree);
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
2001-04-19 14:21:46 +02:00
|
|
|
MimeInfo *partinfo;
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(ctree);
|
|
|
|
if (!gtk_tree_selection_get_selected(selection, &model, &iter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
|
|
|
|
if (mimeview->opened && !gtk_tree_path_compare(mimeview->opened, path)) {
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_path_free(mimeview->opened);
|
|
|
|
mimeview->opened = path;
|
2006-07-07 10:20:23 +02:00
|
|
|
mimeview->spec_part = NULL;
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_view_scroll_to_cell(ctree, path, NULL, TRUE, 0.5, 0);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
partinfo = mimeview_get_node_part(mimeview, path);
|
2001-04-19 14:21:46 +02:00
|
|
|
if (!partinfo) return;
|
|
|
|
|
2001-06-03 12:34:31 +02:00
|
|
|
/* ungrab the mouse event */
|
2011-10-22 19:09:05 +02:00
|
|
|
if (gtk_widget_has_grab(GTK_WIDGET(ctree))) {
|
2001-06-03 12:34:31 +02:00
|
|
|
gtk_grab_remove(GTK_WIDGET(ctree));
|
|
|
|
if (gdk_pointer_is_grabbed())
|
|
|
|
gdk_pointer_ungrab(GDK_CURRENT_TIME);
|
|
|
|
}
|
2002-07-16 01:56:33 +02:00
|
|
|
|
|
|
|
mimeview->textview->default_text = FALSE;
|
2004-01-12 22:28:31 +01:00
|
|
|
|
|
|
|
update_signature_info(mimeview, partinfo);
|
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
if (!mimeview_show_part(mimeview, partinfo)) {
|
2004-01-12 22:28:31 +01:00
|
|
|
switch (partinfo->type) {
|
|
|
|
case MIMETYPE_TEXT:
|
|
|
|
case MIMETYPE_MESSAGE:
|
|
|
|
case MIMETYPE_MULTIPART:
|
2003-03-15 00:58:57 +01:00
|
|
|
mimeview_show_message_part(mimeview, partinfo);
|
2002-07-16 01:56:33 +02:00
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-02-01 18:51:14 +01:00
|
|
|
mimeview->textview->default_text = TRUE;
|
2003-03-15 00:58:57 +01:00
|
|
|
mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
|
2006-02-01 18:51:14 +01:00
|
|
|
textview_clear(mimeview->textview);
|
2006-02-01 19:13:20 +01:00
|
|
|
textview_show_mime_part(mimeview->textview, partinfo);
|
2003-03-15 00:58:57 +01:00
|
|
|
break;
|
|
|
|
}
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-25 10:25:17 +01:00
|
|
|
static void mimeview_start_drag(GtkWidget *widget, gint button,
|
|
|
|
GdkEvent *event, MimeView *mimeview)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
|
|
|
GdkDragContext *context;
|
|
|
|
MimeInfo *partinfo;
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(mimeview != NULL);
|
2003-04-22 15:53:19 +02:00
|
|
|
|
|
|
|
partinfo = mimeview_get_selected_part(mimeview);
|
2011-10-25 07:41:33 +02:00
|
|
|
if (partinfo == NULL ||
|
|
|
|
partinfo->disposition == DISPOSITIONTYPE_INLINE)
|
|
|
|
return;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2003-07-17 10:39:41 +02:00
|
|
|
context = gtk_drag_begin(widget, mimeview->target_list,
|
2001-04-19 14:21:46 +02:00
|
|
|
GDK_ACTION_COPY, button, event);
|
|
|
|
gtk_drag_set_icon_default(context);
|
|
|
|
}
|
|
|
|
|
2002-01-29 11:03:33 +01:00
|
|
|
static gint mimeview_button_pressed(GtkWidget *widget, GdkEventButton *event,
|
2001-04-19 14:21:46 +02:00
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-01-29 11:03:33 +01:00
|
|
|
if (!event) return FALSE;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
if (event->button == 2 || event->button == 3) {
|
2011-11-11 18:28:07 +01:00
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
|
|
|
|
if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
|
2002-01-29 11:03:33 +01:00
|
|
|
return FALSE;
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
gtk_tree_selection_select_iter(selection, &iter);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
2003-07-19 15:50:29 +02:00
|
|
|
part_button_pressed(mimeview, event, mimeview_get_selected_part(mimeview));
|
|
|
|
|
2004-01-27 23:24:47 +01:00
|
|
|
return FALSE;
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2006-08-08 18:16:13 +02:00
|
|
|
static gboolean mimeview_scrolled(GtkWidget *widget, GdkEventScroll *event,
|
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
|
|
|
GtkVScrollbutton *scrollbutton = (GtkVScrollbutton *)mimeview->scrollbutton;
|
|
|
|
if (event->direction == GDK_SCROLL_UP) {
|
|
|
|
scrollbutton->scroll_type = GTK_SCROLL_STEP_BACKWARD;
|
|
|
|
} else {
|
|
|
|
scrollbutton->scroll_type = GTK_SCROLL_STEP_FORWARD;
|
|
|
|
}
|
|
|
|
gtk_vscrollbutton_scroll(scrollbutton);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-17 11:38:14 +02:00
|
|
|
/* from gdkevents.c */
|
|
|
|
#define DOUBLE_CLICK_TIME 250
|
|
|
|
|
2003-10-05 12:25:17 +02:00
|
|
|
static gboolean part_button_pressed(MimeView *mimeview, GdkEventButton *event,
|
|
|
|
MimeInfo *partinfo)
|
2003-07-19 15:50:29 +02:00
|
|
|
{
|
2004-07-17 11:38:14 +02:00
|
|
|
static MimeInfo *lastinfo;
|
|
|
|
static guint32 lasttime;
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
if (event->button == 2 ||
|
2004-07-17 11:38:14 +02:00
|
|
|
(event->button == 1 && (event->time - lasttime) < DOUBLE_CLICK_TIME && lastinfo == partinfo)) {
|
2001-04-19 14:21:46 +02:00
|
|
|
/* call external program for image, audio or html */
|
2006-09-05 07:33:16 +02:00
|
|
|
mimeview_launch(mimeview, partinfo);
|
2003-10-05 12:25:17 +02:00
|
|
|
return TRUE;
|
2001-04-19 14:21:46 +02:00
|
|
|
} else if (event->button == 3) {
|
2006-07-07 10:20:23 +02:00
|
|
|
if (partinfo && (partinfo->type == MIMETYPE_MESSAGE ||
|
2004-01-12 22:28:31 +01:00
|
|
|
partinfo->type == MIMETYPE_IMAGE ||
|
|
|
|
partinfo->type == MIMETYPE_MULTIPART))
|
2008-10-30 18:46:46 +01:00
|
|
|
cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/DisplayAsText", FALSE);
|
2001-04-19 14:21:46 +02:00
|
|
|
else
|
2008-10-30 18:46:46 +01:00
|
|
|
cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/DisplayAsText", TRUE);
|
2008-11-04 22:13:42 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2001-08-01 09:22:54 +02:00
|
|
|
if (partinfo &&
|
2004-01-12 22:28:31 +01:00
|
|
|
partinfo->type == MIMETYPE_APPLICATION &&
|
2004-10-26 12:43:50 +02:00
|
|
|
!g_ascii_strcasecmp(partinfo->subtype, "octet-stream"))
|
2008-10-30 18:46:46 +01:00
|
|
|
cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Open", FALSE);
|
2001-08-01 09:22:54 +02:00
|
|
|
else
|
2008-11-04 22:13:42 +01:00
|
|
|
#endif
|
2008-10-30 18:46:46 +01:00
|
|
|
cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Open", TRUE);
|
2002-04-21 13:27:07 +02:00
|
|
|
|
2004-05-25 10:39:41 +02:00
|
|
|
g_object_set_data(G_OBJECT(mimeview->popupmenu),
|
|
|
|
"pop_partinfo", partinfo);
|
2003-07-31 00:50:01 +02:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
gtk_menu_popup(GTK_MENU(mimeview->popupmenu),
|
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
event->button, event->time);
|
2003-10-05 12:25:17 +02:00
|
|
|
return TRUE;
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
2002-01-29 11:03:33 +01:00
|
|
|
|
2004-07-17 11:38:14 +02:00
|
|
|
lastinfo = partinfo;
|
|
|
|
lasttime = event->time;
|
2003-10-05 12:25:17 +02:00
|
|
|
return FALSE;
|
2002-01-29 11:03:33 +01:00
|
|
|
}
|
|
|
|
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2011-10-31 22:46:22 +01:00
|
|
|
gboolean mimeview_pass_key_press_event(MimeView *mimeview, GdkEventKey *event)
|
2002-01-29 11:03:33 +01:00
|
|
|
{
|
2011-10-31 22:46:22 +01:00
|
|
|
return mimeview_key_pressed(mimeview->ctree, event, mimeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2007-04-20 18:15:58 +02:00
|
|
|
static void mimeview_select_next_part(MimeView *mimeview)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeView *ctree = GTK_TREE_VIEW(mimeview->ctree);
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(ctree);
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
2007-07-16 19:13:43 +02:00
|
|
|
MimeInfo *partinfo = NULL;
|
2011-11-11 18:28:07 +01:00
|
|
|
gboolean has_next;
|
2007-07-16 19:13:43 +02:00
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_model_get_iter(model, &iter, mimeview->opened);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
2007-07-16 19:13:43 +02:00
|
|
|
skip:
|
2011-11-11 18:28:07 +01:00
|
|
|
has_next = mimeview_tree_next(model, path);
|
|
|
|
if (!has_next) {
|
|
|
|
has_next = gtk_tree_model_get_iter_first(model, &iter);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
}
|
2007-04-20 18:15:58 +02:00
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
if (has_next) {
|
|
|
|
partinfo = mimeview_get_node_part(mimeview, path);
|
2011-02-05 12:32:20 +01:00
|
|
|
if (partinfo->type == MIMETYPE_MULTIPART ||
|
|
|
|
(!prefs_common.show_inline_attachments && partinfo->id))
|
2007-07-16 19:13:43 +02:00
|
|
|
goto skip;
|
2011-11-11 18:28:07 +01:00
|
|
|
selection = gtk_tree_view_get_selection(ctree);
|
|
|
|
gtk_tree_selection_select_path(selection, path);
|
2007-07-16 19:13:43 +02:00
|
|
|
icon_list_toggle_by_mime_info(mimeview, partinfo);
|
2007-04-20 18:15:58 +02:00
|
|
|
}
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
2007-07-16 19:13:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mimeview_select_prev_part(MimeView *mimeview)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeView *ctree = GTK_TREE_VIEW(mimeview->ctree);
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(ctree);
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
2007-07-16 19:13:43 +02:00
|
|
|
MimeInfo *partinfo = NULL;
|
2011-11-11 18:28:07 +01:00
|
|
|
gboolean has_prev;
|
2007-07-16 19:13:43 +02:00
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
gtk_tree_model_get_iter(model, &iter, mimeview->opened);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
2007-07-16 19:13:43 +02:00
|
|
|
skip:
|
2011-11-11 18:28:07 +01:00
|
|
|
has_prev = mimeview_tree_prev(mimeview, path);
|
|
|
|
if (!has_prev) {
|
|
|
|
while (mimeview_tree_next(model, path)) {}
|
|
|
|
has_prev = TRUE;
|
|
|
|
}
|
2007-07-16 19:13:43 +02:00
|
|
|
|
2011-11-11 18:28:07 +01:00
|
|
|
if (has_prev) {
|
|
|
|
partinfo = mimeview_get_node_part(mimeview, path);
|
|
|
|
if (partinfo->type == MIMETYPE_MULTIPART ||
|
|
|
|
(!prefs_common.show_inline_attachments && partinfo->id))
|
2007-07-16 19:13:43 +02:00
|
|
|
goto skip;
|
2011-11-11 18:28:07 +01:00
|
|
|
selection = gtk_tree_view_get_selection(ctree);
|
|
|
|
gtk_tree_selection_select_path(selection, path);
|
2007-07-16 19:13:43 +02:00
|
|
|
icon_list_toggle_by_mime_info(mimeview, partinfo);
|
2007-04-20 18:15:58 +02:00
|
|
|
}
|
2011-11-11 18:28:07 +01:00
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
2007-04-20 18:15:58 +02:00
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#define BREAK_ON_MODIFIER_KEY() \
|
|
|
|
if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
|
|
|
|
|
2002-01-29 11:03:33 +01:00
|
|
|
static gint mimeview_key_pressed(GtkWidget *widget, GdkEventKey *event,
|
2001-04-19 14:21:46 +02:00
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
|
|
|
SummaryView *summaryview;
|
|
|
|
|
2002-01-29 11:03:33 +01:00
|
|
|
if (!event) return FALSE;
|
|
|
|
if (!mimeview->opened) return FALSE;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2004-07-17 23:15:07 +02:00
|
|
|
summaryview = mimeview->messageview->mainwin->summaryview;
|
|
|
|
|
|
|
|
if (summaryview && quicksearch_has_focus(summaryview->quicksearch))
|
|
|
|
return FALSE;
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
switch (event->keyval) {
|
2011-11-07 22:21:50 +01:00
|
|
|
case GDK_KEY_Home:
|
|
|
|
case GDK_KEY_End:
|
|
|
|
textview_scroll_max(mimeview->textview,
|
|
|
|
(event->keyval == GDK_KEY_Home));
|
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_Page_Down:
|
|
|
|
case GDK_KEY_space:
|
2010-01-31 15:19:44 +01:00
|
|
|
if (mimeview_scroll_page(mimeview,
|
|
|
|
(event->state & GDK_SHIFT_MASK) != 0))
|
2002-01-29 11:03:33 +01:00
|
|
|
return TRUE;
|
2010-01-31 15:19:44 +01:00
|
|
|
|
|
|
|
if (!(event->state & GDK_SHIFT_MASK))
|
|
|
|
mimeview_select_next_part(mimeview);
|
2007-07-16 19:13:43 +02:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_Page_Up:
|
|
|
|
case GDK_KEY_BackSpace:
|
2006-08-29 18:27:14 +02:00
|
|
|
mimeview_scroll_page(mimeview, TRUE);
|
2002-01-29 11:03:33 +01:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_Return:
|
|
|
|
case GDK_KEY_KP_Enter:
|
2006-08-29 18:27:14 +02:00
|
|
|
mimeview_scroll_one_line(mimeview,
|
2001-04-19 14:21:46 +02:00
|
|
|
(event->state & GDK_MOD1_MASK) != 0);
|
2002-01-29 11:03:33 +01:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_Up:
|
|
|
|
case GDK_KEY_Down:
|
|
|
|
mimeview_scroll_one_line(mimeview, (event->keyval == GDK_KEY_Up));
|
2010-01-31 15:19:44 +01:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_y:
|
2001-04-19 14:21:46 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_save_as(mimeview);
|
2002-01-29 11:03:33 +01:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_t:
|
2001-04-19 14:21:46 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_display_as_text(mimeview);
|
2002-04-21 13:27:07 +02:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_l:
|
2001-04-19 14:21:46 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
2006-09-05 07:33:16 +02:00
|
|
|
mimeview_launch(mimeview, NULL);
|
2002-01-29 11:03:33 +01:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_o:
|
2004-01-12 22:28:31 +01:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
2009-01-08 18:21:58 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2004-01-12 22:28:31 +01:00
|
|
|
mimeview_open_with(mimeview);
|
2008-11-04 22:13:42 +01:00
|
|
|
#endif
|
2009-01-08 18:21:58 +01:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_c:
|
2005-10-16 13:08:46 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_check_signature(mimeview);
|
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_a:
|
2007-04-20 18:15:58 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_select_next_part(mimeview);
|
|
|
|
return TRUE;
|
2011-10-31 22:46:22 +01:00
|
|
|
case GDK_KEY_z:
|
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_select_prev_part(mimeview);
|
|
|
|
return TRUE;
|
2001-04-19 14:21:46 +02:00
|
|
|
default:
|
2002-03-07 14:22:39 +01:00
|
|
|
break;
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2011-10-31 22:46:22 +01:00
|
|
|
if (mimeview->messageview->new_window) return FALSE;
|
2004-07-17 23:15:07 +02:00
|
|
|
|
2011-10-30 17:59:14 +01:00
|
|
|
return summary_pass_key_press_event(summaryview, event);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mimeview_drag_data_get(GtkWidget *widget,
|
|
|
|
GdkDragContext *drag_context,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info,
|
|
|
|
guint time,
|
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
2006-02-04 18:17:33 +01:00
|
|
|
gchar *filename = NULL, *uriname, *tmp;
|
2001-04-19 14:21:46 +02:00
|
|
|
MimeInfo *partinfo;
|
2007-01-16 09:13:56 +01:00
|
|
|
gint err;
|
2008-05-05 09:20:29 +02:00
|
|
|
gint count = 0;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
if (!mimeview->opened) return;
|
|
|
|
if (!mimeview->file) return;
|
|
|
|
|
2003-04-22 15:53:19 +02:00
|
|
|
partinfo = mimeview_get_selected_part(mimeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
if (!partinfo) return;
|
|
|
|
|
2006-02-04 18:17:33 +01:00
|
|
|
if (strlen(get_part_name(partinfo)) > 0) {
|
|
|
|
filename = g_path_get_basename(get_part_name(partinfo));
|
|
|
|
if (*filename == '\0') return;
|
|
|
|
} else if (partinfo->type == MIMETYPE_MESSAGE
|
|
|
|
&& !g_ascii_strcasecmp(partinfo->subtype, "rfc822")) {
|
|
|
|
gchar *name = NULL;
|
|
|
|
GPtrArray *headers = NULL;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
fp = g_fopen(partinfo->data.filename, "rb");
|
|
|
|
fseek(fp, partinfo->offset, SEEK_SET);
|
|
|
|
headers = procheader_get_header_array_asis(fp);
|
|
|
|
if (headers) {
|
|
|
|
gint i;
|
|
|
|
for (i = 0; i < headers->len; i++) {
|
|
|
|
Header *header = g_ptr_array_index(headers, i);
|
|
|
|
if (procheader_headername_equal(header->name, "Subject")) {
|
|
|
|
unfold_line(header->body);
|
|
|
|
name = g_strconcat(header->body, ".txt", NULL);
|
|
|
|
subst_for_filename(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
procheader_header_array_destroy(headers);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
if (name)
|
|
|
|
filename = g_path_get_basename(name);
|
|
|
|
g_free(name);
|
|
|
|
}
|
|
|
|
if (filename == NULL)
|
|
|
|
filename = g_path_get_basename("Unnamed part");
|
|
|
|
|
2007-04-18 10:28:32 +02:00
|
|
|
if (!g_utf8_validate(filename, -1, NULL))
|
|
|
|
tmp = conv_codeset_strdup(filename,
|
|
|
|
conv_get_locale_charset_str(),
|
|
|
|
CS_UTF_8);
|
|
|
|
else
|
|
|
|
tmp = g_strdup(filename);
|
|
|
|
|
2006-05-17 18:37:41 +02:00
|
|
|
if (tmp == NULL) {
|
|
|
|
g_warning("filename not in UTF-8");
|
|
|
|
tmp = g_strdup("Unnamed part");
|
|
|
|
}
|
2001-04-19 14:21:46 +02:00
|
|
|
filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
|
2006-02-04 20:13:38 +01:00
|
|
|
tmp, NULL);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2008-05-05 09:20:29 +02:00
|
|
|
check_new_file:
|
|
|
|
if (is_file_exist(filename)) {
|
|
|
|
gchar *ext = NULL;
|
|
|
|
gchar *prefix = NULL;
|
|
|
|
gchar *new_name = NULL;
|
|
|
|
if (strrchr(tmp, '.')) {
|
|
|
|
prefix = g_strdup(tmp);
|
|
|
|
ext = g_strdup(strrchr(tmp, '.'));
|
|
|
|
*(strrchr(prefix, '.')) = '\0';
|
|
|
|
} else {
|
|
|
|
prefix = g_strdup(tmp);
|
|
|
|
ext = g_strdup("");
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
new_name = g_strdup_printf("%s.%d%s", prefix, count, ext);
|
|
|
|
g_free(prefix);
|
|
|
|
g_free(ext);
|
|
|
|
g_free(filename);
|
|
|
|
filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
|
|
|
|
new_name, NULL);
|
|
|
|
g_free(new_name);
|
|
|
|
goto check_new_file;
|
|
|
|
}
|
|
|
|
|
2004-07-17 18:58:04 +02:00
|
|
|
g_free(tmp);
|
2006-02-04 18:17:33 +01:00
|
|
|
|
2007-01-16 09:13:56 +01:00
|
|
|
if ((err = procmime_get_part(filename, partinfo)) < 0)
|
2001-04-19 14:21:46 +02:00
|
|
|
alertpanel_error
|
2007-01-16 09:13:56 +01:00
|
|
|
(_("Couldn't save the part of multipart message: %s"),
|
|
|
|
strerror(-err));
|
|
|
|
|
2008-01-31 17:50:31 +01:00
|
|
|
tmp = g_filename_to_uri(filename, NULL, NULL);
|
|
|
|
uriname = g_strconcat(tmp, "\r\n", NULL);
|
|
|
|
g_free(tmp);
|
2006-02-04 20:13:38 +01:00
|
|
|
|
2011-10-07 11:08:57 +02:00
|
|
|
gtk_selection_data_set(selection_data,
|
|
|
|
gtk_selection_data_get_target(selection_data), 8,
|
2006-07-07 10:20:23 +02:00
|
|
|
(guchar *)uriname, strlen(uriname));
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
g_free(uriname);
|
|
|
|
g_free(filename);
|
|
|
|
}
|
|
|
|
|
2004-05-10 12:22:28 +02:00
|
|
|
/**
|
|
|
|
* Returns a filename (with path) for an attachment
|
|
|
|
* \param partinfo The attachment to save
|
|
|
|
* \param basedir The target directory
|
|
|
|
* \param number Used for dummy filename if attachment is unnamed
|
|
|
|
*/
|
2007-01-20 20:54:05 +01:00
|
|
|
static gchar *mimeview_get_filename_for_part(MimeInfo *partinfo,
|
2004-05-10 12:22:28 +02:00
|
|
|
const gchar *basedir,
|
|
|
|
gint number)
|
|
|
|
{
|
|
|
|
gchar *fullname;
|
|
|
|
gchar *filename;
|
|
|
|
|
|
|
|
filename = g_strdup(get_part_name(partinfo));
|
2009-09-28 09:06:42 +02:00
|
|
|
if (!filename || !*filename) {
|
|
|
|
g_free(filename);
|
2004-05-10 12:22:28 +02:00
|
|
|
filename = g_strdup_printf("noname.%d", number);
|
2009-09-28 09:06:42 +02:00
|
|
|
}
|
2005-02-15 16:00:28 +01:00
|
|
|
|
2005-02-17 09:54:47 +01:00
|
|
|
if (!g_utf8_validate(filename, -1, NULL)) {
|
|
|
|
gchar *tmp = conv_filename_to_utf8(filename);
|
|
|
|
g_free(filename);
|
|
|
|
filename = tmp;
|
|
|
|
}
|
|
|
|
|
2005-02-15 16:00:28 +01:00
|
|
|
subst_for_filename(filename);
|
2004-05-10 12:22:28 +02:00
|
|
|
|
|
|
|
fullname = g_strconcat
|
2008-09-22 17:49:25 +02:00
|
|
|
(basedir, G_DIR_SEPARATOR_S, (g_path_is_absolute(filename))
|
2004-05-10 12:22:28 +02:00
|
|
|
? &filename[1] : filename, NULL);
|
|
|
|
|
|
|
|
g_free(filename);
|
2005-10-25 18:14:38 +02:00
|
|
|
filename = conv_filename_from_utf8(fullname);
|
|
|
|
g_free(fullname);
|
|
|
|
return filename;
|
2004-05-10 12:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a single attachment to file
|
|
|
|
* \param filename Filename with path
|
|
|
|
* \param partinfo Attachment to save
|
|
|
|
*/
|
|
|
|
static gboolean mimeview_write_part(const gchar *filename,
|
|
|
|
MimeInfo *partinfo)
|
|
|
|
{
|
|
|
|
gchar *dir;
|
2007-01-16 09:13:56 +01:00
|
|
|
gint err;
|
|
|
|
|
2004-11-12 10:21:06 +01:00
|
|
|
dir= g_path_get_dirname(filename);
|
2004-05-10 12:22:28 +02:00
|
|
|
if (!is_dir_exist(dir))
|
|
|
|
make_dir_hier(dir);
|
|
|
|
g_free(dir);
|
|
|
|
|
|
|
|
if (is_file_exist(filename)) {
|
|
|
|
AlertValue aval;
|
|
|
|
gchar *res;
|
2005-10-25 18:14:38 +02:00
|
|
|
gchar *tmp;
|
|
|
|
|
|
|
|
if (!g_utf8_validate(filename, -1, NULL))
|
|
|
|
tmp = conv_filename_to_utf8(filename);
|
|
|
|
else
|
|
|
|
tmp = g_strdup(filename);
|
2004-05-10 12:22:28 +02:00
|
|
|
|
|
|
|
res = g_strdup_printf(_("Overwrite existing file '%s'?"),
|
2005-10-25 18:14:38 +02:00
|
|
|
tmp);
|
|
|
|
g_free(tmp);
|
2006-01-14 10:45:39 +01:00
|
|
|
aval = alertpanel(_("Overwrite"), res, GTK_STOCK_CANCEL,
|
|
|
|
GTK_STOCK_OK, NULL);
|
2004-05-10 12:22:28 +02:00
|
|
|
g_free(res);
|
2006-01-14 10:45:39 +01:00
|
|
|
if (G_ALERTALTERNATE != aval) return FALSE;
|
2004-05-10 12:22:28 +02:00
|
|
|
}
|
|
|
|
|
2007-01-16 09:13:56 +01:00
|
|
|
if ((err = procmime_get_part(filename, partinfo)) < 0) {
|
2004-05-10 12:22:28 +02:00
|
|
|
alertpanel_error
|
2007-01-16 09:13:56 +01:00
|
|
|
(_("Couldn't save the part of multipart message: %s"),
|
|
|
|
strerror(-err));
|
2004-05-10 12:22:28 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Menu callback: Save all attached files
|
|
|
|
* \param mimeview Current display
|
|
|
|
*/
|
2002-07-21 18:06:50 +02:00
|
|
|
static void mimeview_save_all(MimeView *mimeview)
|
|
|
|
{
|
2004-05-10 12:22:28 +02:00
|
|
|
MimeInfo *partinfo;
|
2002-07-21 18:06:50 +02:00
|
|
|
gchar *dirname;
|
2004-05-10 12:22:28 +02:00
|
|
|
gchar *startdir = NULL;
|
|
|
|
gint number = 1;
|
2002-07-21 18:06:50 +02:00
|
|
|
|
|
|
|
if (!mimeview->opened) return;
|
|
|
|
if (!mimeview->file) return;
|
2004-05-10 12:22:28 +02:00
|
|
|
if (!mimeview->mimeinfo) return;
|
2002-07-21 18:06:50 +02:00
|
|
|
|
2004-05-10 12:22:28 +02:00
|
|
|
partinfo = mimeview->mimeinfo;
|
2007-01-25 18:13:52 +01:00
|
|
|
if (prefs_common.attach_save_dir && *prefs_common.attach_save_dir)
|
2004-05-10 12:22:28 +02:00
|
|
|
startdir = g_strconcat(prefs_common.attach_save_dir,
|
|
|
|
G_DIR_SEPARATOR_S, NULL);
|
2007-01-25 18:13:52 +01:00
|
|
|
else
|
|
|
|
startdir = g_strdup(get_home_dir());
|
2002-07-21 18:06:50 +02:00
|
|
|
|
2005-08-30 18:49:27 +02:00
|
|
|
dirname = filesel_select_file_save_folder(_("Select destination folder"), startdir);
|
2004-05-10 12:22:28 +02:00
|
|
|
if (!dirname) {
|
2006-04-06 12:58:17 +02:00
|
|
|
g_free(startdir);
|
2004-05-10 12:22:28 +02:00
|
|
|
return;
|
|
|
|
}
|
2002-07-21 18:06:50 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
if (!is_dir_exist (dirname)) {
|
2005-07-17 09:30:07 +02:00
|
|
|
alertpanel_error(_("'%s' is not a directory."),
|
2004-01-12 22:28:31 +01:00
|
|
|
dirname);
|
2006-04-06 12:58:17 +02:00
|
|
|
g_free(startdir);
|
2008-05-26 09:43:52 +02:00
|
|
|
g_free(dirname);
|
2004-01-12 22:28:31 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-10 12:22:28 +02:00
|
|
|
if (dirname[strlen(dirname)-1] == G_DIR_SEPARATOR)
|
|
|
|
dirname[strlen(dirname)-1] = '\0';
|
|
|
|
|
2004-10-01 14:00:51 +02:00
|
|
|
/* Skip the first part, that is sometimes DISPOSITIONTYPE_UNKNOWN */
|
|
|
|
if (partinfo && partinfo->type == MIMETYPE_MESSAGE)
|
|
|
|
partinfo = procmime_mimeinfo_next(partinfo);
|
|
|
|
if (partinfo && partinfo->type == MIMETYPE_MULTIPART) {
|
|
|
|
partinfo = procmime_mimeinfo_next(partinfo);
|
|
|
|
if (partinfo && partinfo->type == MIMETYPE_TEXT)
|
|
|
|
partinfo = procmime_mimeinfo_next(partinfo);
|
|
|
|
}
|
|
|
|
|
2004-05-10 12:22:28 +02:00
|
|
|
while (partinfo != NULL) {
|
|
|
|
if (partinfo->type != MIMETYPE_MESSAGE &&
|
|
|
|
partinfo->type != MIMETYPE_MULTIPART &&
|
2006-06-28 18:22:41 +02:00
|
|
|
(partinfo->disposition != DISPOSITIONTYPE_INLINE
|
2006-06-28 19:28:32 +02:00
|
|
|
|| get_real_part_name(partinfo) != NULL)) {
|
2004-05-10 12:22:28 +02:00
|
|
|
gchar *filename = mimeview_get_filename_for_part
|
|
|
|
(partinfo, dirname, number++);
|
|
|
|
|
|
|
|
mimeview_write_part(filename, partinfo);
|
|
|
|
g_free(filename);
|
2002-07-21 18:06:50 +02:00
|
|
|
}
|
2004-05-10 12:22:28 +02:00
|
|
|
partinfo = procmime_mimeinfo_next(partinfo);
|
2002-07-21 18:06:50 +02:00
|
|
|
}
|
|
|
|
|
2006-04-06 12:58:17 +02:00
|
|
|
g_free(prefs_common.attach_save_dir);
|
|
|
|
g_free(startdir);
|
2006-12-17 14:36:22 +01:00
|
|
|
prefs_common.attach_save_dir = g_filename_to_utf8(dirname,
|
|
|
|
-1, NULL, NULL, NULL);
|
2008-05-26 09:43:52 +02:00
|
|
|
g_free(dirname);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2006-07-07 10:20:23 +02:00
|
|
|
static MimeInfo *mimeview_get_part_to_use(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
MimeInfo *partinfo = NULL;
|
|
|
|
if (mimeview->spec_part) {
|
|
|
|
partinfo = mimeview->spec_part;
|
|
|
|
mimeview->spec_part = NULL;
|
|
|
|
} else {
|
2006-09-05 18:26:59 +02:00
|
|
|
partinfo = (MimeInfo *) g_object_get_data
|
|
|
|
(G_OBJECT(mimeview->popupmenu),
|
|
|
|
"pop_partinfo");
|
|
|
|
g_object_set_data(G_OBJECT(mimeview->popupmenu),
|
|
|
|
"pop_partinfo", NULL);
|
2006-07-07 10:20:23 +02:00
|
|
|
if (!partinfo) {
|
2006-09-05 18:26:59 +02:00
|
|
|
partinfo = mimeview_get_selected_part(mimeview);
|
2006-07-07 10:20:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return partinfo;
|
|
|
|
}
|
2004-05-10 12:22:28 +02:00
|
|
|
/**
|
|
|
|
* Menu callback: Save the selected attachment
|
|
|
|
* \param mimeview Current display
|
|
|
|
*/
|
2001-04-19 14:21:46 +02:00
|
|
|
static void mimeview_save_as(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
gchar *filename;
|
2004-05-10 12:22:28 +02:00
|
|
|
gchar *filepath = NULL;
|
|
|
|
gchar *filedir = NULL;
|
2001-04-19 14:21:46 +02:00
|
|
|
MimeInfo *partinfo;
|
2005-02-15 16:00:28 +01:00
|
|
|
gchar *partname = NULL;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
if (!mimeview->opened) return;
|
|
|
|
if (!mimeview->file) return;
|
|
|
|
|
2006-07-07 10:20:23 +02:00
|
|
|
partinfo = mimeview_get_part_to_use(mimeview);
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(partinfo != NULL);
|
2004-01-12 22:28:31 +01:00
|
|
|
|
2005-02-15 16:00:28 +01:00
|
|
|
if (get_part_name(partinfo) == NULL) {
|
2004-08-30 00:56:20 +02:00
|
|
|
return;
|
2002-01-16 12:48:36 +01:00
|
|
|
}
|
2005-02-15 16:00:28 +01:00
|
|
|
partname = g_strdup(get_part_name(partinfo));
|
|
|
|
|
2005-02-17 09:54:47 +01:00
|
|
|
if (!g_utf8_validate(partname, -1, NULL)) {
|
|
|
|
gchar *tmp = conv_filename_to_utf8(partname);
|
2007-04-18 10:28:32 +02:00
|
|
|
if (!tmp) {
|
|
|
|
tmp = conv_codeset_strdup(partname,
|
|
|
|
conv_get_locale_charset_str(),
|
|
|
|
CS_UTF_8);
|
|
|
|
}
|
|
|
|
if (tmp) {
|
|
|
|
g_free(partname);
|
|
|
|
partname = tmp;
|
|
|
|
}
|
2005-02-17 09:54:47 +01:00
|
|
|
}
|
|
|
|
|
2005-02-15 16:00:28 +01:00
|
|
|
subst_for_filename(partname);
|
|
|
|
|
2009-01-06 17:45:59 +01:00
|
|
|
if (prefs_common.attach_save_dir && *prefs_common.attach_save_dir)
|
2004-05-10 12:22:28 +02:00
|
|
|
filepath = g_strconcat(prefs_common.attach_save_dir,
|
2004-08-30 00:56:20 +02:00
|
|
|
G_DIR_SEPARATOR_S, partname, NULL);
|
2004-05-10 12:22:28 +02:00
|
|
|
else
|
2004-08-30 00:56:20 +02:00
|
|
|
filepath = g_strdup(partname);
|
2004-05-10 12:22:28 +02:00
|
|
|
|
2005-02-15 16:00:28 +01:00
|
|
|
g_free(partname);
|
|
|
|
|
2004-07-21 11:39:52 +02:00
|
|
|
filename = filesel_select_file_save(_("Save as"), filepath);
|
2004-05-10 12:22:28 +02:00
|
|
|
if (!filename) {
|
|
|
|
g_free(filepath);
|
|
|
|
return;
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2004-05-10 12:22:28 +02:00
|
|
|
mimeview_write_part(filename, partinfo);
|
|
|
|
|
2004-11-12 10:21:06 +01:00
|
|
|
filedir = g_path_get_dirname(filename);
|
2004-05-10 12:22:28 +02:00
|
|
|
if (filedir && strcmp(filedir, ".")) {
|
2006-04-06 12:58:17 +02:00
|
|
|
g_free(prefs_common.attach_save_dir);
|
2006-12-17 14:36:22 +01:00
|
|
|
prefs_common.attach_save_dir = g_filename_to_utf8(filedir, -1, NULL, NULL, NULL);
|
2004-05-10 12:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free(filedir);
|
|
|
|
g_free(filepath);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mimeview_display_as_text(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
MimeInfo *partinfo;
|
|
|
|
|
|
|
|
if (!mimeview->opened) return;
|
|
|
|
|
2006-07-07 10:20:23 +02:00
|
|
|
partinfo = mimeview_get_part_to_use(mimeview);
|
2006-09-07 14:42:16 +02:00
|
|
|
mimeview_select_mimepart_icon(mimeview, partinfo);
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(partinfo != NULL);
|
2004-05-10 12:22:28 +02:00
|
|
|
mimeview_show_message_part(mimeview, partinfo);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2006-09-05 07:33:16 +02:00
|
|
|
static void mimeview_launch(MimeView *mimeview, MimeInfo *partinfo)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
|
|
|
gchar *filename;
|
2007-01-16 09:13:56 +01:00
|
|
|
gint err;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
if (!mimeview->opened) return;
|
|
|
|
if (!mimeview->file) return;
|
|
|
|
|
2006-09-05 07:33:16 +02:00
|
|
|
if (!partinfo)
|
|
|
|
partinfo = mimeview_get_part_to_use(mimeview);
|
2006-07-07 10:20:23 +02:00
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(partinfo != NULL);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
filename = procmime_get_tmp_file_name(partinfo);
|
|
|
|
|
2007-01-16 09:13:56 +01:00
|
|
|
if ((err = procmime_get_part(filename, partinfo)) < 0)
|
2001-04-19 14:21:46 +02:00
|
|
|
alertpanel_error
|
2007-01-16 09:13:56 +01:00
|
|
|
(_("Couldn't save the part of multipart message: %s"),
|
|
|
|
strerror(-err));
|
2001-04-19 14:21:46 +02:00
|
|
|
else
|
2005-10-20 18:50:46 +02:00
|
|
|
mimeview_view_file(filename, partinfo, NULL, mimeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
g_free(filename);
|
|
|
|
}
|
|
|
|
|
2008-11-04 22:13:42 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2001-05-10 13:19:38 +02:00
|
|
|
static void mimeview_open_with(MimeView *mimeview)
|
|
|
|
{
|
|
|
|
MimeInfo *partinfo;
|
|
|
|
|
2005-10-20 18:50:46 +02:00
|
|
|
if (!mimeview) return;
|
2001-05-10 13:19:38 +02:00
|
|
|
if (!mimeview->opened) return;
|
|
|
|
if (!mimeview->file) return;
|
|
|
|
|
2006-07-07 10:20:23 +02:00
|
|
|
partinfo = mimeview_get_part_to_use(mimeview);
|
|
|
|
|
2006-08-17 18:46:14 +02:00
|
|
|
mimeview_open_part_with(mimeview, partinfo, FALSE);
|
2006-07-07 10:20:23 +02:00
|
|
|
}
|
|
|
|
|
2007-07-23 18:34:59 +02:00
|
|
|
#ifdef MAEMO
|
|
|
|
osso_context_t *get_osso_context(void);
|
|
|
|
#endif
|
2006-08-17 18:46:14 +02:00
|
|
|
static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo, gboolean automatic)
|
2006-07-07 10:20:23 +02:00
|
|
|
{
|
|
|
|
gchar *filename;
|
|
|
|
gchar *cmd;
|
|
|
|
gchar *mime_command = NULL;
|
|
|
|
gchar *content_type = NULL;
|
2007-01-16 09:13:56 +01:00
|
|
|
gint err;
|
2007-07-23 18:34:59 +02:00
|
|
|
#ifdef MAEMO
|
|
|
|
DBusConnection *dbusconn;
|
|
|
|
gchar *uri;
|
|
|
|
int r = 0;
|
|
|
|
#endif
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(partinfo != NULL);
|
2001-05-10 13:19:38 +02:00
|
|
|
|
|
|
|
filename = procmime_get_tmp_file_name(partinfo);
|
|
|
|
|
2007-01-16 09:13:56 +01:00
|
|
|
if ((err = procmime_get_part(filename, partinfo)) < 0) {
|
2001-05-10 13:19:38 +02:00
|
|
|
alertpanel_error
|
2007-01-16 09:13:56 +01:00
|
|
|
(_("Couldn't save the part of multipart message: %s"),
|
|
|
|
strerror(-err));
|
2001-11-07 11:29:45 +01:00
|
|
|
g_free(filename);
|
|
|
|
return;
|
|
|
|
}
|
2007-07-23 18:34:59 +02:00
|
|
|
|
2001-11-07 11:29:45 +01:00
|
|
|
if (!prefs_common.mime_open_cmd_history)
|
|
|
|
prefs_common.mime_open_cmd_history =
|
|
|
|
add_history(NULL, prefs_common.mime_open_cmd);
|
|
|
|
|
2006-02-01 18:51:14 +01:00
|
|
|
if ((partinfo->type == MIMETYPE_APPLICATION) &&
|
|
|
|
(!g_ascii_strcasecmp(partinfo->subtype, "octet-stream"))) {
|
|
|
|
/* guess content-type from filename */
|
|
|
|
content_type = procmime_get_mime_type(filename);
|
|
|
|
}
|
|
|
|
if (content_type == NULL) {
|
|
|
|
content_type = procmime_get_content_type_str(partinfo->type,
|
2005-09-07 08:41:01 +02:00
|
|
|
partinfo->subtype);
|
2006-02-01 18:51:14 +01:00
|
|
|
}
|
2006-08-17 18:46:14 +02:00
|
|
|
|
2007-07-23 18:34:59 +02:00
|
|
|
#ifdef MAEMO
|
|
|
|
if (content_type != NULL) {
|
2008-01-31 17:50:31 +01:00
|
|
|
uri = g_filename_to_uri(filename, NULL, NULL);
|
2007-07-23 18:34:59 +02:00
|
|
|
dbusconn = osso_get_dbus_connection (get_osso_context());
|
2007-11-10 13:42:23 +01:00
|
|
|
#ifdef CHINOOK
|
|
|
|
r = hildon_mime_open_file_with_mime_type (dbusconn, uri, content_type);
|
|
|
|
#else
|
2007-07-23 18:34:59 +02:00
|
|
|
r = osso_mime_open_file_with_mime_type (dbusconn, uri, content_type);
|
2007-11-10 13:42:23 +01:00
|
|
|
#endif
|
2007-07-23 18:34:59 +02:00
|
|
|
g_free(uri);
|
|
|
|
}
|
|
|
|
if (r != 1) {
|
|
|
|
alertpanel_error(_("No registered viewer for this file type."));
|
|
|
|
}
|
|
|
|
goto out;
|
|
|
|
#endif
|
|
|
|
|
2006-08-17 21:07:36 +02:00
|
|
|
if ((partinfo->type == MIMETYPE_TEXT && !strcmp(partinfo->subtype, "html"))
|
2007-11-21 19:58:18 +01:00
|
|
|
&& prefs_common_get_uri_cmd() && prefs_common.uri_cmd[0]) {
|
|
|
|
mime_command = g_strdup(prefs_common_get_uri_cmd());
|
2006-08-21 08:12:40 +02:00
|
|
|
g_free(content_type);
|
|
|
|
content_type = NULL;
|
2007-11-21 19:58:18 +01:00
|
|
|
} else if (partinfo->type != MIMETYPE_TEXT || !prefs_common_get_ext_editor_cmd()
|
|
|
|
|| !prefs_common_get_ext_editor_cmd()[0]) {
|
2006-08-17 18:46:14 +02:00
|
|
|
mime_command = mailcap_get_command_for_type(content_type, filename);
|
2006-08-21 08:12:40 +02:00
|
|
|
} else {
|
2007-11-21 19:58:18 +01:00
|
|
|
mime_command = g_strdup(prefs_common_get_ext_editor_cmd());
|
2006-08-21 08:12:40 +02:00
|
|
|
g_free(content_type);
|
|
|
|
content_type = NULL;
|
|
|
|
}
|
2006-07-04 18:19:39 +02:00
|
|
|
if (mime_command == NULL) {
|
|
|
|
/* try with extension this time */
|
|
|
|
g_free(content_type);
|
|
|
|
content_type = procmime_get_mime_type(filename);
|
2006-08-17 18:46:14 +02:00
|
|
|
mime_command = mailcap_get_command_for_type(content_type, filename);
|
2006-07-04 18:19:39 +02:00
|
|
|
}
|
|
|
|
|
2006-08-17 18:46:14 +02:00
|
|
|
if (mime_command == NULL)
|
|
|
|
automatic = FALSE;
|
|
|
|
|
|
|
|
if (!automatic) {
|
|
|
|
gboolean remember = FALSE;
|
|
|
|
if (content_type != NULL)
|
|
|
|
cmd = input_dialog_combo_remember
|
|
|
|
(_("Open with"),
|
2008-11-19 18:04:46 +01:00
|
|
|
_("Enter the command-line to open file:\n"
|
2006-08-17 18:46:14 +02:00
|
|
|
"('%s' will be replaced with file name)"),
|
|
|
|
mime_command ? mime_command : prefs_common.mime_open_cmd,
|
2007-10-19 08:50:41 +02:00
|
|
|
prefs_common.mime_open_cmd_history, &remember);
|
2006-08-17 18:46:14 +02:00
|
|
|
else
|
|
|
|
cmd = input_dialog_combo
|
|
|
|
(_("Open with"),
|
2008-11-19 18:04:46 +01:00
|
|
|
_("Enter the command-line to open file:\n"
|
2006-08-17 18:46:14 +02:00
|
|
|
"('%s' will be replaced with file name)"),
|
|
|
|
mime_command ? mime_command : prefs_common.mime_open_cmd,
|
2007-10-19 08:50:41 +02:00
|
|
|
prefs_common.mime_open_cmd_history);
|
2006-08-17 18:46:14 +02:00
|
|
|
if (cmd && remember) {
|
|
|
|
mailcap_update_default(content_type, cmd);
|
|
|
|
}
|
|
|
|
g_free(mime_command);
|
|
|
|
} else {
|
|
|
|
cmd = mime_command;
|
|
|
|
}
|
2001-11-07 11:29:45 +01:00
|
|
|
if (cmd) {
|
2005-10-20 18:50:46 +02:00
|
|
|
mimeview_view_file(filename, partinfo, cmd, mimeview);
|
2001-11-07 11:29:45 +01:00
|
|
|
g_free(prefs_common.mime_open_cmd);
|
|
|
|
prefs_common.mime_open_cmd = cmd;
|
|
|
|
prefs_common.mime_open_cmd_history =
|
|
|
|
add_history(prefs_common.mime_open_cmd_history, cmd);
|
2001-05-10 13:19:38 +02:00
|
|
|
}
|
2007-09-28 20:56:48 +02:00
|
|
|
#ifdef MAEMO
|
|
|
|
out:
|
|
|
|
#endif
|
2006-08-17 18:46:14 +02:00
|
|
|
g_free(content_type);
|
2001-05-10 13:19:38 +02:00
|
|
|
g_free(filename);
|
|
|
|
}
|
2008-11-04 22:13:42 +01:00
|
|
|
#endif
|
2001-05-10 13:19:38 +02:00
|
|
|
|
|
|
|
static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
|
2006-08-17 18:46:14 +02:00
|
|
|
const gchar *cmd, MimeView *mimeview)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
2008-11-04 22:13:42 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2006-08-17 18:46:14 +02:00
|
|
|
gchar *p;
|
|
|
|
gchar buf[BUFFSIZE];
|
|
|
|
if (cmd == NULL)
|
|
|
|
mimeview_open_part_with(mimeview, partinfo, TRUE);
|
2001-04-19 14:21:46 +02:00
|
|
|
else {
|
2006-08-17 18:46:14 +02:00
|
|
|
if ((p = strchr(cmd, '%')) && *(p + 1) == 's' &&
|
2007-10-08 15:19:20 +02:00
|
|
|
!strchr(p + 2, '%')) {
|
2006-08-17 18:46:14 +02:00
|
|
|
g_snprintf(buf, sizeof(buf), cmd, filename);
|
2007-11-07 18:26:29 +01:00
|
|
|
if (!prefs_common.save_parts_readwrite)
|
|
|
|
g_chmod(filename, S_IRUSR);
|
|
|
|
else
|
|
|
|
g_chmod(filename, S_IRUSR|S_IWUSR);
|
2007-10-08 15:19:20 +02:00
|
|
|
} else {
|
2008-11-19 18:04:46 +01:00
|
|
|
g_warning("MIME viewer command-line is invalid: '%s'", cmd);
|
2006-08-17 18:46:14 +02:00
|
|
|
mimeview_open_part_with(mimeview, partinfo, FALSE);
|
|
|
|
}
|
2007-10-08 15:19:20 +02:00
|
|
|
if (execute_command_line(buf, TRUE) != 0) {
|
2007-11-07 18:26:29 +01:00
|
|
|
if (!prefs_common.save_parts_readwrite)
|
|
|
|
g_chmod(filename, S_IRUSR|S_IWUSR);
|
2006-08-17 18:46:14 +02:00
|
|
|
mimeview_open_part_with(mimeview, partinfo, FALSE);
|
2007-10-08 15:19:20 +02:00
|
|
|
}
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
2008-11-04 22:13:42 +01:00
|
|
|
#else
|
|
|
|
SHFILEINFO file_info;
|
|
|
|
if ((SHGetFileInfo(filename, 0, &file_info, sizeof(SHFILEINFO), SHGFI_EXETYPE)) != 0) {
|
|
|
|
AlertValue val = alertpanel_full(_("Execute untrusted binary?"),
|
|
|
|
_("This attachment is an executable file. Executing "
|
|
|
|
"untrusted binaries is dangerous and could probably "
|
|
|
|
"lead to compromission of your computer.\n\n"
|
|
|
|
"Do you want to run this file?"), GTK_STOCK_CANCEL,
|
|
|
|
_("Run binary"),
|
|
|
|
NULL, FALSE, NULL, ALERT_WARNING, G_ALERTDEFAULT);
|
|
|
|
if (val == G_ALERTALTERNATE) {
|
|
|
|
debug_print("executing binary\n");
|
|
|
|
ShellExecute(NULL, "open", filename, NULL, NULL, SW_SHOW);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ShellExecute(NULL, "open", filename, NULL, NULL, SW_SHOW);
|
|
|
|
|
|
|
|
#endif
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
void mimeview_register_viewer_factory(MimeViewerFactory *factory)
|
|
|
|
{
|
|
|
|
mimeviewer_factories = g_slist_append(mimeviewer_factories, factory);
|
|
|
|
}
|
|
|
|
|
2003-03-16 18:11:03 +01:00
|
|
|
static gint cmp_viewer_by_factroy(gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
return ((MimeViewer *) a)->factory == (MimeViewerFactory *) b ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
void mimeview_unregister_viewer_factory(MimeViewerFactory *factory)
|
|
|
|
{
|
2003-03-16 18:11:03 +01:00
|
|
|
GSList *mimeview_list, *viewer_list;
|
|
|
|
|
|
|
|
for (mimeview_list = mimeviews; mimeview_list != NULL; mimeview_list = g_slist_next(mimeview_list)) {
|
|
|
|
MimeView *mimeview = (MimeView *) mimeview_list->data;
|
|
|
|
|
|
|
|
if (mimeview->mimeviewer && mimeview->mimeviewer->factory == factory) {
|
|
|
|
mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
|
|
|
|
mimeview->mimeviewer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((viewer_list = g_slist_find_custom(mimeview->viewers, factory, cmp_viewer_by_factroy)) != NULL) {
|
|
|
|
MimeViewer *mimeviewer = (MimeViewer *) viewer_list->data;
|
|
|
|
|
|
|
|
mimeviewer->destroy_viewer(mimeviewer);
|
|
|
|
mimeview->viewers = g_slist_remove(mimeview->viewers, mimeviewer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-15 00:58:57 +01:00
|
|
|
mimeviewer_factories = g_slist_remove(mimeviewer_factories, factory);
|
|
|
|
}
|
2003-07-19 15:50:29 +02:00
|
|
|
|
|
|
|
static gboolean icon_clicked_cb (GtkWidget *button, GdkEventButton *event, MimeView *mimeview)
|
|
|
|
{
|
2003-07-24 02:40:01 +02:00
|
|
|
gint num;
|
2003-07-19 15:50:29 +02:00
|
|
|
MimeInfo *partinfo;
|
2003-07-24 02:40:01 +02:00
|
|
|
|
2004-05-25 10:39:41 +02:00
|
|
|
num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "icon_number"));
|
|
|
|
partinfo = g_object_get_data(G_OBJECT(button), "partinfo");
|
2004-01-12 22:28:31 +01:00
|
|
|
|
2006-09-05 18:26:59 +02:00
|
|
|
if (event->button == 1) {
|
2006-09-05 07:33:16 +02:00
|
|
|
icon_selected(mimeview, num, partinfo);
|
|
|
|
gtk_widget_grab_focus(button);
|
2004-01-12 22:28:31 +01:00
|
|
|
}
|
2003-07-19 15:50:29 +02:00
|
|
|
part_button_pressed(mimeview, event, partinfo);
|
2011-11-19 22:15:13 +01:00
|
|
|
|
|
|
|
if (event->button != 3)
|
|
|
|
icon_list_toggle_by_mime_info(mimeview, partinfo);
|
2003-07-27 21:04:30 +02:00
|
|
|
|
2003-10-05 12:25:17 +02:00
|
|
|
return FALSE;
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
|
|
|
|
2003-07-24 02:40:01 +02:00
|
|
|
static void icon_selected (MimeView *mimeview, gint num, MimeInfo *partinfo)
|
|
|
|
{
|
2011-11-11 18:28:07 +01:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
MimeInfo *curr = NULL;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter_first(model, &iter);
|
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
|
|
|
|
|
do {
|
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
|
gtk_tree_model_get(model, &iter, COL_DATA, &curr, -1);
|
|
|
|
if (curr == partinfo) {
|
|
|
|
GtkTreeSelection *sel = gtk_tree_view_get_selection(
|
|
|
|
GTK_TREE_VIEW(mimeview->ctree));
|
|
|
|
gtk_tree_selection_select_iter(sel, &iter);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} while (mimeview_tree_next(model, path));
|
|
|
|
|
|
|
|
gtk_tree_path_free(path);
|
2003-07-24 02:40:01 +02:00
|
|
|
}
|
|
|
|
|
2006-08-09 18:25:35 +02:00
|
|
|
void mimeview_select_mimepart_icon(MimeView *mimeview, MimeInfo *partinfo)
|
|
|
|
{
|
|
|
|
icon_list_toggle_by_mime_info(mimeview, partinfo);
|
|
|
|
icon_selected(mimeview, -1, partinfo);
|
|
|
|
}
|
|
|
|
|
2003-07-24 02:40:01 +02:00
|
|
|
static gint icon_key_pressed(GtkWidget *button, GdkEventKey *event,
|
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
2003-08-02 20:27:04 +02:00
|
|
|
gint num;
|
|
|
|
MimeInfo *partinfo;
|
|
|
|
SummaryView *summaryview;
|
|
|
|
TextView *textview;
|
2003-07-24 02:40:01 +02:00
|
|
|
|
2004-05-25 10:39:41 +02:00
|
|
|
num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "icon_number"));
|
|
|
|
partinfo = g_object_get_data(G_OBJECT(button), "partinfo");
|
2003-07-24 02:40:01 +02:00
|
|
|
|
|
|
|
if (!event) return FALSE;
|
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
textview = mimeview->textview;
|
2003-08-02 20:27:04 +02:00
|
|
|
|
2003-07-24 02:40:01 +02:00
|
|
|
switch (event->keyval) {
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_space:
|
2007-07-16 19:13:43 +02:00
|
|
|
if (mimeview_scroll_page(mimeview, FALSE))
|
2003-08-02 20:27:04 +02:00
|
|
|
return TRUE;
|
2007-07-16 19:13:43 +02:00
|
|
|
|
|
|
|
mimeview_select_next_part(mimeview);
|
|
|
|
return TRUE;
|
2003-08-02 20:27:04 +02:00
|
|
|
|
|
|
|
break;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_BackSpace:
|
2006-08-29 18:27:14 +02:00
|
|
|
mimeview_scroll_page(mimeview, TRUE);
|
2003-07-24 02:40:01 +02:00
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_Return:
|
|
|
|
case GDK_KEY_KP_Enter:
|
2007-07-16 19:13:43 +02:00
|
|
|
mimeview_scroll_one_line(mimeview,
|
|
|
|
(event->state & GDK_MOD1_MASK) != 0);
|
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_y:
|
2003-08-02 20:27:04 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_save_as(mimeview);
|
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_t:
|
2003-08-02 20:27:04 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_display_as_text(mimeview);
|
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_l:
|
2003-08-02 20:27:04 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
2006-09-05 07:33:16 +02:00
|
|
|
mimeview_launch(mimeview, NULL);
|
2003-08-02 20:27:04 +02:00
|
|
|
return TRUE;
|
2008-11-04 22:13:42 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_o:
|
2004-01-12 22:28:31 +01:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_open_with(mimeview);
|
|
|
|
return TRUE;
|
2008-11-04 22:13:42 +01:00
|
|
|
#endif
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_c:
|
2005-10-16 13:08:46 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_check_signature(mimeview);
|
|
|
|
return TRUE;
|
2011-10-07 11:17:51 +02:00
|
|
|
case GDK_KEY_a:
|
2007-04-20 18:15:58 +02:00
|
|
|
BREAK_ON_MODIFIER_KEY();
|
|
|
|
mimeview_select_next_part(mimeview);
|
|
|
|
return TRUE;
|
2003-07-24 02:40:01 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-08-02 20:27:04 +02:00
|
|
|
|
|
|
|
if (!mimeview->messageview->mainwin) return FALSE;
|
|
|
|
summaryview = mimeview->messageview->mainwin->summaryview;
|
2006-04-25 08:33:15 +02:00
|
|
|
return summary_pass_key_press_event(summaryview, event);
|
2003-07-24 02:40:01 +02:00
|
|
|
}
|
|
|
|
|
2007-03-28 21:46:10 +02:00
|
|
|
static gboolean icon_popup_menu(GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
MimeView *mimeview = (MimeView *)data;
|
|
|
|
MimeInfo *partinfo = g_object_get_data(G_OBJECT(widget), "partinfo");
|
|
|
|
|
|
|
|
g_object_set_data(G_OBJECT(mimeview->popupmenu),
|
|
|
|
"pop_partinfo", partinfo);
|
|
|
|
gtk_menu_popup(GTK_MENU(mimeview->popupmenu),
|
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
0, gtk_get_current_event_time());
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-07-19 15:50:29 +02:00
|
|
|
static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo)
|
|
|
|
{
|
2005-05-31 21:00:21 +02:00
|
|
|
GtkWidget *pixmap = NULL;
|
2003-07-19 15:50:29 +02:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
gchar *tip;
|
2004-06-25 10:05:09 +02:00
|
|
|
gchar *tiptmp;
|
2004-05-10 12:22:28 +02:00
|
|
|
const gchar *desc = NULL;
|
2004-06-25 10:05:09 +02:00
|
|
|
gchar *sigshort = NULL;
|
2004-05-10 12:22:28 +02:00
|
|
|
gchar *content_type;
|
2003-07-19 15:50:29 +02:00
|
|
|
StockPixmap stockp;
|
2004-06-25 10:05:09 +02:00
|
|
|
MimeInfo *partinfo;
|
|
|
|
MimeInfo *siginfo = NULL;
|
|
|
|
MimeInfo *encrypted = NULL;
|
2008-10-04 20:24:57 +02:00
|
|
|
#ifdef GENERIC_UMPC
|
|
|
|
GtkRequisition r;
|
|
|
|
#endif
|
2008-07-19 16:02:31 +02:00
|
|
|
#if !(GTK_CHECK_VERSION(2,12,0))
|
|
|
|
GtkTooltips *tips = mimeview->tooltips;
|
|
|
|
#endif
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2011-02-05 12:32:20 +01:00
|
|
|
if (!prefs_common.show_inline_attachments && mimeinfo->id)
|
|
|
|
return;
|
|
|
|
|
2003-07-19 15:50:29 +02:00
|
|
|
vbox = mimeview->icon_vbox;
|
|
|
|
mimeview->icon_count++;
|
2007-07-16 19:13:43 +02:00
|
|
|
button = gtk_event_box_new();
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(button), "motion-notify-event",
|
|
|
|
G_CALLBACK(mimeview_visi_notify), mimeview);
|
|
|
|
g_signal_connect(G_OBJECT(button), "leave-notify-event",
|
|
|
|
G_CALLBACK(mimeview_leave_notify), mimeview);
|
|
|
|
g_signal_connect(G_OBJECT(button), "enter-notify-event",
|
|
|
|
G_CALLBACK(mimeview_enter_notify), mimeview);
|
|
|
|
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(button), 2);
|
2004-05-25 10:39:41 +02:00
|
|
|
g_object_set_data(G_OBJECT(button), "icon_number",
|
|
|
|
GINT_TO_POINTER(mimeview->icon_count));
|
|
|
|
g_object_set_data(G_OBJECT(button), "partinfo",
|
|
|
|
mimeinfo);
|
2007-01-11 17:36:17 +01:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
switch (mimeinfo->type) {
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2004-01-12 22:28:31 +01:00
|
|
|
case MIMETYPE_TEXT:
|
2004-10-26 12:43:50 +02:00
|
|
|
if (mimeinfo->subtype && !g_ascii_strcasecmp(mimeinfo->subtype, "html"))
|
2004-01-12 22:28:31 +01:00
|
|
|
stockp = STOCK_PIXMAP_MIME_TEXT_HTML;
|
2004-10-26 12:43:50 +02:00
|
|
|
else if (mimeinfo->subtype && !g_ascii_strcasecmp(mimeinfo->subtype, "enriched"))
|
2004-01-12 22:28:31 +01:00
|
|
|
stockp = STOCK_PIXMAP_MIME_TEXT_ENRICHED;
|
2007-02-20 18:49:16 +01:00
|
|
|
else if (mimeinfo->subtype && !g_ascii_strcasecmp(mimeinfo->subtype, "calendar"))
|
|
|
|
stockp = STOCK_PIXMAP_MIME_TEXT_CALENDAR;
|
2008-02-10 12:54:44 +01:00
|
|
|
else if (mimeinfo->subtype && (!g_ascii_strcasecmp(mimeinfo->subtype, "x-patch")
|
|
|
|
|| !g_ascii_strcasecmp(mimeinfo->subtype, "x-diff")))
|
|
|
|
stockp = STOCK_PIXMAP_MIME_TEXT_PATCH;
|
2004-01-12 22:28:31 +01:00
|
|
|
else
|
|
|
|
stockp = STOCK_PIXMAP_MIME_TEXT_PLAIN;
|
2003-07-19 15:50:29 +02:00
|
|
|
break;
|
2004-01-12 22:28:31 +01:00
|
|
|
case MIMETYPE_MESSAGE:
|
|
|
|
stockp = STOCK_PIXMAP_MIME_MESSAGE;
|
2003-07-19 15:50:29 +02:00
|
|
|
break;
|
2004-01-12 22:28:31 +01:00
|
|
|
case MIMETYPE_APPLICATION:
|
2009-05-06 08:46:58 +02:00
|
|
|
if (mimeinfo->subtype && (!g_ascii_strcasecmp(mimeinfo->subtype, "pgp-signature")
|
|
|
|
|| !g_ascii_strcasecmp(mimeinfo->subtype, "x-pkcs7-signature")
|
|
|
|
|| !g_ascii_strcasecmp(mimeinfo->subtype, "pkcs7-signature")))
|
2007-02-20 19:45:33 +01:00
|
|
|
stockp = STOCK_PIXMAP_MIME_PGP_SIG;
|
|
|
|
else if (mimeinfo->subtype && !g_ascii_strcasecmp(mimeinfo->subtype, "pdf"))
|
2007-02-20 18:49:16 +01:00
|
|
|
stockp = STOCK_PIXMAP_MIME_PDF;
|
|
|
|
else if (mimeinfo->subtype && !g_ascii_strcasecmp(mimeinfo->subtype, "postscript"))
|
|
|
|
stockp = STOCK_PIXMAP_MIME_PS;
|
|
|
|
else
|
|
|
|
stockp = STOCK_PIXMAP_MIME_APPLICATION;
|
2003-07-19 15:50:29 +02:00
|
|
|
break;
|
2004-01-12 22:28:31 +01:00
|
|
|
case MIMETYPE_IMAGE:
|
2003-07-19 15:50:29 +02:00
|
|
|
stockp = STOCK_PIXMAP_MIME_IMAGE;
|
|
|
|
break;
|
2004-01-12 22:28:31 +01:00
|
|
|
case MIMETYPE_AUDIO:
|
2003-07-19 15:50:29 +02:00
|
|
|
stockp = STOCK_PIXMAP_MIME_AUDIO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stockp = STOCK_PIXMAP_MIME_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-25 10:05:09 +02:00
|
|
|
partinfo = mimeinfo;
|
|
|
|
while (partinfo != NULL) {
|
|
|
|
if (privacy_mimeinfo_is_signed(partinfo)) {
|
|
|
|
siginfo = partinfo;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (privacy_mimeinfo_is_encrypted(partinfo)) {
|
|
|
|
encrypted = partinfo;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
partinfo = procmime_mimeinfo_parent(partinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (siginfo != NULL) {
|
|
|
|
switch (privacy_mimeinfo_get_sig_status(siginfo)) {
|
|
|
|
case SIGNATURE_UNCHECKED:
|
|
|
|
case SIGNATURE_CHECK_FAILED:
|
2005-11-01 07:53:28 +01:00
|
|
|
case SIGNATURE_CHECK_TIMEOUT:
|
2004-06-25 10:05:09 +02:00
|
|
|
pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_SIGNED, OVERLAY_BOTTOM_RIGHT, 6, 3);
|
|
|
|
break;
|
|
|
|
case SIGNATURE_OK:
|
|
|
|
pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_PASSED, OVERLAY_BOTTOM_RIGHT, 6, 3);
|
|
|
|
break;
|
|
|
|
case SIGNATURE_WARN:
|
2008-05-18 12:24:33 +02:00
|
|
|
case SIGNATURE_KEY_EXPIRED:
|
2004-06-25 10:05:09 +02:00
|
|
|
pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_WARN, OVERLAY_BOTTOM_RIGHT, 6, 3);
|
|
|
|
break;
|
|
|
|
case SIGNATURE_INVALID:
|
|
|
|
pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_FAILED, OVERLAY_BOTTOM_RIGHT, 6, 3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sigshort = privacy_mimeinfo_sig_info_short(siginfo);
|
|
|
|
} else if (encrypted != NULL) {
|
|
|
|
pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp,
|
|
|
|
STOCK_PIXMAP_PRIVACY_EMBLEM_ENCRYPTED, OVERLAY_BOTTOM_RIGHT, 6, 3);
|
|
|
|
} else {
|
|
|
|
pixmap = stock_pixmap_widget_with_overlay(mimeview->mainwin->window, stockp, 0,
|
|
|
|
OVERLAY_NONE, 6, 3);
|
|
|
|
}
|
2003-07-19 15:50:29 +02:00
|
|
|
gtk_container_add(GTK_CONTAINER(button), pixmap);
|
|
|
|
if (!desc) {
|
|
|
|
if (prefs_common.attach_desc)
|
|
|
|
desc = get_part_description(mimeinfo);
|
|
|
|
else
|
|
|
|
desc = get_part_name(mimeinfo);
|
|
|
|
}
|
2004-01-12 22:28:31 +01:00
|
|
|
|
2004-05-10 12:22:28 +02:00
|
|
|
content_type = procmime_get_content_type_str(mimeinfo->type,
|
|
|
|
mimeinfo->subtype);
|
|
|
|
|
2010-02-08 19:43:06 +01:00
|
|
|
tip = g_strconcat("<b>", _("Type:"), " </b>", content_type,
|
|
|
|
"\n<b>", _("Size:"), " </b>",
|
|
|
|
to_human_readable((goffset)mimeinfo->length), NULL);
|
2004-05-10 12:22:28 +02:00
|
|
|
g_free(content_type);
|
2004-06-25 10:05:09 +02:00
|
|
|
if (desc && *desc) {
|
2005-02-17 09:54:47 +01:00
|
|
|
gchar *tmp = NULL;
|
|
|
|
if (!g_utf8_validate(desc, -1, NULL)) {
|
|
|
|
tmp = conv_filename_to_utf8(desc);
|
|
|
|
} else {
|
|
|
|
tmp = g_strdup(desc);
|
|
|
|
}
|
2010-02-08 19:43:06 +01:00
|
|
|
tiptmp = g_strconcat(tip, "\n<b>",
|
|
|
|
prefs_common.attach_desc && mimeinfo->description ?
|
2010-03-21 19:46:31 +01:00
|
|
|
_("Description:") : _("Filename:"),
|
2010-02-08 19:43:06 +01:00
|
|
|
" </b>", tmp, NULL);
|
2004-06-25 10:05:09 +02:00
|
|
|
g_free(tip);
|
|
|
|
tip = tiptmp;
|
2005-02-17 09:54:47 +01:00
|
|
|
g_free(tmp);
|
2004-06-25 10:05:09 +02:00
|
|
|
}
|
|
|
|
if (sigshort && *sigshort) {
|
2011-08-12 15:57:41 +02:00
|
|
|
tiptmp = g_strjoin("\n", tip, g_markup_escape_text(sigshort, -1), NULL);
|
2004-06-25 10:05:09 +02:00
|
|
|
g_free(tip);
|
|
|
|
tip = tiptmp;
|
|
|
|
}
|
|
|
|
g_free(sigshort);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2010-02-08 19:43:06 +01:00
|
|
|
gtk_widget_set_tooltip_markup(button, tip);
|
2003-07-19 15:50:29 +02:00
|
|
|
g_free(tip);
|
|
|
|
gtk_widget_show_all(button);
|
2006-02-04 18:17:33 +01:00
|
|
|
gtk_drag_source_set(button, GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
|
|
|
|
mimeview_mime_types, 1, GDK_ACTION_COPY);
|
2007-03-28 21:46:10 +02:00
|
|
|
#ifndef MAEMO
|
|
|
|
g_signal_connect(G_OBJECT(button), "popup-menu",
|
|
|
|
G_CALLBACK(icon_popup_menu), mimeview);
|
|
|
|
#else
|
|
|
|
gtk_widget_tap_and_hold_setup(GTK_WIDGET(button), NULL, NULL,
|
|
|
|
GTK_TAP_AND_HOLD_NONE | GTK_TAP_AND_HOLD_NO_INTERNALS);
|
|
|
|
g_signal_connect(G_OBJECT(button), "tap-and-hold",
|
|
|
|
G_CALLBACK(icon_popup_menu), mimeview);
|
|
|
|
#endif
|
2004-07-16 13:12:46 +02:00
|
|
|
g_signal_connect(G_OBJECT(button), "button_release_event",
|
2003-10-05 12:10:30 +02:00
|
|
|
G_CALLBACK(icon_clicked_cb), mimeview);
|
|
|
|
g_signal_connect(G_OBJECT(button), "key_press_event",
|
|
|
|
G_CALLBACK(icon_key_pressed), mimeview);
|
2006-02-04 18:17:33 +01:00
|
|
|
g_signal_connect(G_OBJECT(button), "drag_data_get",
|
|
|
|
G_CALLBACK(mimeview_drag_data_get), mimeview);
|
2003-07-19 15:50:29 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
|
2008-05-07 10:18:24 +02:00
|
|
|
#ifdef GENERIC_UMPC
|
2008-10-04 20:24:57 +02:00
|
|
|
gtk_widget_size_request(pixmap, &r);
|
|
|
|
gtk_widget_set_size_request(button, -1, r.height + 4);
|
2007-07-14 19:51:10 +02:00
|
|
|
#endif
|
2003-07-24 02:40:01 +02:00
|
|
|
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void icon_list_clear (MimeView *mimeview)
|
|
|
|
{
|
2008-11-28 23:35:51 +01:00
|
|
|
GList *child, *orig;
|
2003-07-19 15:50:29 +02:00
|
|
|
GtkAdjustment *adj;
|
2007-01-12 12:58:57 +01:00
|
|
|
|
2008-11-28 23:35:51 +01:00
|
|
|
orig = gtk_container_get_children(GTK_CONTAINER(mimeview->icon_vbox));
|
|
|
|
for (child = orig; child != NULL; child = g_list_next(child)) {
|
2003-07-19 15:50:29 +02:00
|
|
|
gtkut_container_remove(GTK_CONTAINER(mimeview->icon_vbox),
|
|
|
|
GTK_WIDGET(child->data));
|
|
|
|
}
|
2008-11-28 23:35:51 +01:00
|
|
|
g_list_free(orig);
|
2003-07-19 15:50:29 +02:00
|
|
|
mimeview->icon_count = 0;
|
|
|
|
adj = gtk_layout_get_vadjustment(GTK_LAYOUT(mimeview->icon_scroll));
|
2011-10-07 11:08:57 +02:00
|
|
|
gtk_adjustment_set_value(adj, gtk_adjustment_get_lower(adj));
|
2007-08-31 19:03:45 +02:00
|
|
|
gtk_adjustment_changed(adj);
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
|
|
|
|
2003-08-02 20:27:04 +02:00
|
|
|
/*!
|
|
|
|
*\brief Used to 'click' the next or previous icon.
|
|
|
|
*
|
|
|
|
*\return true if the icon 'number' exists and was selected.
|
|
|
|
*/
|
2003-07-19 15:50:29 +02:00
|
|
|
static void icon_scroll_size_allocate_cb(GtkWidget *widget,
|
2003-10-05 12:25:17 +02:00
|
|
|
GtkAllocation *size, MimeView *mimeview)
|
2003-07-19 15:50:29 +02:00
|
|
|
{
|
2011-10-07 11:08:57 +02:00
|
|
|
GtkAllocation vbox_size;
|
|
|
|
GtkAllocation layout_size;
|
2003-07-19 15:50:29 +02:00
|
|
|
GtkAdjustment *adj;
|
2011-10-07 11:08:57 +02:00
|
|
|
guint width;
|
|
|
|
guint height;
|
2008-10-04 20:24:57 +02:00
|
|
|
|
2003-07-19 15:50:29 +02:00
|
|
|
adj = gtk_layout_get_vadjustment(GTK_LAYOUT(mimeview->icon_scroll));
|
|
|
|
|
2011-10-07 11:08:57 +02:00
|
|
|
gtk_widget_get_allocation(mimeview->icon_vbox, &vbox_size);
|
|
|
|
gtk_widget_get_allocation(mimeview->icon_scroll, &layout_size);
|
2004-07-03 18:31:08 +02:00
|
|
|
|
2011-10-07 11:08:57 +02:00
|
|
|
gtk_layout_get_size(GTK_LAYOUT(mimeview->icon_scroll), &width, &height);
|
2003-07-20 00:24:05 +02:00
|
|
|
gtk_layout_set_size(GTK_LAYOUT(mimeview->icon_scroll),
|
2011-10-07 11:08:57 +02:00
|
|
|
width,
|
|
|
|
MAX(vbox_size.height, layout_size.height));
|
|
|
|
gtk_adjustment_set_step_increment(adj, 10);
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void icon_list_create(MimeView *mimeview, MimeInfo *mimeinfo)
|
|
|
|
{
|
2003-07-24 02:40:01 +02:00
|
|
|
GtkRequisition size;
|
2011-10-07 11:08:57 +02:00
|
|
|
GtkRequisition requisition;
|
2004-07-27 10:52:20 +02:00
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(mimeinfo != NULL);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
|
|
|
while (mimeinfo != NULL) {
|
2004-01-12 22:28:31 +01:00
|
|
|
if (mimeinfo->type != MIMETYPE_MULTIPART)
|
2003-07-19 15:50:29 +02:00
|
|
|
icon_list_append_icon(mimeview, mimeinfo);
|
2004-01-12 22:28:31 +01:00
|
|
|
if (mimeinfo->node->children != NULL)
|
2004-07-27 10:52:20 +02:00
|
|
|
icon_list_create(mimeview,
|
|
|
|
(MimeInfo *) mimeinfo->node->children->data);
|
|
|
|
mimeinfo = mimeinfo->node->next != NULL
|
|
|
|
? (MimeInfo *) mimeinfo->node->next->data
|
|
|
|
: NULL;
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
2003-07-24 02:40:01 +02:00
|
|
|
gtk_widget_size_request(mimeview->icon_vbox, &size);
|
2011-10-07 11:08:57 +02:00
|
|
|
gtk_widget_get_requisition(mimeview->icon_mainbox, &requisition);
|
|
|
|
if (size.width > requisition.width) {
|
2003-10-05 12:10:30 +02:00
|
|
|
gtk_widget_set_size_request(mimeview->icon_mainbox,
|
2004-07-27 10:52:20 +02:00
|
|
|
size.width, -1);
|
2003-07-24 02:40:01 +02:00
|
|
|
}
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
|
|
|
|
2007-07-16 19:13:43 +02:00
|
|
|
static void icon_list_toggle_by_mime_info (MimeView *mimeview,
|
|
|
|
MimeInfo *mimeinfo)
|
|
|
|
{
|
|
|
|
GList *child;
|
|
|
|
|
2008-08-05 03:36:42 +02:00
|
|
|
child = gtk_container_get_children(GTK_CONTAINER(mimeview->icon_vbox));
|
2007-07-16 19:13:43 +02:00
|
|
|
for (; child != NULL; child = g_list_next(child)) {
|
|
|
|
if (!GTK_IS_EVENT_BOX(child->data))
|
|
|
|
continue;
|
|
|
|
if(g_object_get_data(G_OBJECT(child->data),
|
|
|
|
"partinfo") == (gpointer)mimeinfo) {
|
2007-07-20 16:03:27 +02:00
|
|
|
gboolean *highlight = NULL;
|
2007-07-16 19:13:43 +02:00
|
|
|
GtkWidget *icon = gtk_bin_get_child(GTK_BIN(child->data));
|
2007-07-20 16:03:27 +02:00
|
|
|
highlight = g_object_get_data(G_OBJECT(icon), "highlight");
|
|
|
|
*highlight = TRUE;
|
2007-07-16 19:13:43 +02:00
|
|
|
gtk_widget_queue_draw(icon);
|
|
|
|
} else {
|
2007-07-20 16:03:27 +02:00
|
|
|
gint *highlight = NULL;
|
2007-07-16 19:13:43 +02:00
|
|
|
GtkWidget *icon = gtk_bin_get_child(GTK_BIN(child->data));
|
2007-07-20 16:03:27 +02:00
|
|
|
highlight = g_object_get_data(G_OBJECT(icon), "highlight");
|
|
|
|
*highlight = FALSE;
|
2007-07-16 19:13:43 +02:00
|
|
|
gtk_widget_queue_draw(icon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-18 22:41:56 +01:00
|
|
|
static void ctree_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation,
|
|
|
|
MimeView *mimeview)
|
|
|
|
{
|
|
|
|
prefs_common.mimeview_tree_height = allocation->height;
|
|
|
|
}
|
|
|
|
|
2007-07-16 19:13:43 +02:00
|
|
|
static gint mime_toggle_button_cb(GtkWidget *button, GdkEventButton *event,
|
|
|
|
MimeView *mimeview)
|
2003-07-19 15:50:29 +02:00
|
|
|
{
|
2008-08-05 03:36:42 +02:00
|
|
|
g_object_ref(button);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2007-07-16 19:13:43 +02:00
|
|
|
mimeview_leave_notify(button, NULL, NULL);
|
|
|
|
|
|
|
|
mimeview->ctree_mode = !mimeview->ctree_mode;
|
|
|
|
if (mimeview->ctree_mode) {
|
2008-08-07 18:39:17 +02:00
|
|
|
gtk_arrow_set(GTK_ARROW(gtk_bin_get_child(GTK_BIN((button)))), GTK_ARROW_RIGHT,
|
2003-07-19 15:50:29 +02:00
|
|
|
GTK_SHADOW_NONE);
|
2003-07-24 02:40:01 +02:00
|
|
|
gtk_widget_hide(mimeview->icon_mainbox);
|
|
|
|
gtk_widget_show(mimeview->ctree_mainbox);
|
2011-11-18 22:41:56 +01:00
|
|
|
gtk_paned_set_position(GTK_PANED(mimeview->paned),
|
|
|
|
prefs_common.mimeview_tree_height);
|
2003-07-24 02:40:01 +02:00
|
|
|
|
2003-07-19 15:50:29 +02:00
|
|
|
gtkut_container_remove(GTK_CONTAINER(mimeview->icon_mainbox),
|
|
|
|
button);
|
2003-07-24 02:40:01 +02:00
|
|
|
gtk_box_pack_end(GTK_BOX(mimeview->ctree_mainbox),
|
2003-07-19 15:50:29 +02:00
|
|
|
button, FALSE, FALSE, 0);
|
|
|
|
} else {
|
2008-08-07 18:39:17 +02:00
|
|
|
gtk_arrow_set(GTK_ARROW(gtk_bin_get_child(GTK_BIN((button)))), GTK_ARROW_LEFT,
|
2003-07-19 15:50:29 +02:00
|
|
|
GTK_SHADOW_NONE);
|
2003-07-24 02:40:01 +02:00
|
|
|
gtk_widget_hide(mimeview->ctree_mainbox);
|
|
|
|
gtk_widget_show(mimeview->icon_mainbox);
|
|
|
|
gtk_paned_set_position(GTK_PANED(mimeview->paned), 0);
|
2003-07-19 15:50:29 +02:00
|
|
|
|
|
|
|
gtkut_container_remove(GTK_CONTAINER(mimeview->ctree_mainbox),
|
|
|
|
button);
|
|
|
|
gtk_box_pack_start(GTK_BOX(mimeview->icon_mainbox),
|
|
|
|
button, FALSE, FALSE, 0);
|
2011-10-07 11:08:57 +02:00
|
|
|
gtk_box_reorder_child(GTK_BOX(gtk_widget_get_parent(button)), button, 0);
|
2003-07-25 14:39:29 +02:00
|
|
|
if (mimeview->opened)
|
2011-11-11 18:28:07 +01:00
|
|
|
icon_list_toggle_by_mime_info(mimeview,
|
|
|
|
mimeview_get_node_part(mimeview, mimeview->opened));
|
|
|
|
summary_grab_focus(mimeview->mainwin->summaryview);
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
2008-08-05 03:36:42 +02:00
|
|
|
g_object_unref(button);
|
2007-07-16 19:13:43 +02:00
|
|
|
return TRUE;
|
2003-07-19 15:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void mimeview_update (MimeView *mimeview) {
|
|
|
|
if (mimeview && mimeview->mimeinfo) {
|
|
|
|
icon_list_clear(mimeview);
|
|
|
|
icon_list_create(mimeview, mimeview->mimeinfo);
|
|
|
|
}
|
|
|
|
}
|
2006-04-05 18:47:17 +02:00
|
|
|
|
2006-07-07 10:20:23 +02:00
|
|
|
void mimeview_handle_cmd(MimeView *mimeview, const gchar *cmd, GdkEventButton *event, gpointer data)
|
2006-04-05 18:47:17 +02:00
|
|
|
{
|
|
|
|
MessageView *msgview = NULL;
|
|
|
|
MainWindow *mainwin = NULL;
|
|
|
|
|
|
|
|
if (!cmd)
|
|
|
|
return;
|
|
|
|
|
|
|
|
msgview = mimeview->messageview;
|
|
|
|
if (!msgview)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mainwin = msgview->mainwin;
|
|
|
|
if (!mainwin)
|
|
|
|
return;
|
|
|
|
|
2006-09-05 18:26:59 +02:00
|
|
|
g_object_set_data(G_OBJECT(mimeview->popupmenu),
|
|
|
|
"pop_partinfo", NULL);
|
|
|
|
|
|
|
|
if (!strcmp(cmd, "sc://view_log"))
|
2006-04-05 18:47:17 +02:00
|
|
|
log_window_show(mainwin->logwin);
|
|
|
|
else if (!strcmp(cmd, "sc://save_as"))
|
|
|
|
mimeview_save_as(mimeview);
|
|
|
|
else if (!strcmp(cmd, "sc://display_as_text"))
|
|
|
|
mimeview_display_as_text(mimeview);
|
2008-11-04 22:13:42 +01:00
|
|
|
#ifndef G_OS_WIN32
|
2006-04-05 18:47:17 +02:00
|
|
|
else if (!strcmp(cmd, "sc://open_with"))
|
|
|
|
mimeview_open_with(mimeview);
|
2008-11-04 22:13:42 +01:00
|
|
|
#endif
|
2006-04-05 18:47:17 +02:00
|
|
|
else if (!strcmp(cmd, "sc://open"))
|
2006-09-05 07:33:16 +02:00
|
|
|
mimeview_launch(mimeview, NULL);
|
2006-07-04 18:53:47 +02:00
|
|
|
else if (!strcmp(cmd, "sc://select_attachment") && data != NULL) {
|
2006-07-04 18:19:39 +02:00
|
|
|
icon_list_toggle_by_mime_info(mimeview, (MimeInfo *)data);
|
|
|
|
icon_selected(mimeview, -1, (MimeInfo *)data);
|
2006-07-04 18:53:47 +02:00
|
|
|
} else if (!strcmp(cmd, "sc://open_attachment") && data != NULL) {
|
2006-09-05 09:45:14 +02:00
|
|
|
mimeview_launch(mimeview, (MimeInfo *)data);
|
2006-07-07 10:20:23 +02:00
|
|
|
} else if (!strcmp(cmd, "sc://menu_attachment") && data != NULL) {
|
|
|
|
mimeview->spec_part = (MimeInfo *)data;
|
|
|
|
part_button_pressed(mimeview, event, (MimeInfo *)data);
|
2007-07-02 18:35:40 +02:00
|
|
|
} else if (!strncmp(cmd, "sc://search_tags:", strlen("sc://search_tags:"))) {
|
|
|
|
const gchar *tagname = cmd + strlen("sc://search_tags:");
|
|
|
|
gchar *buf = g_strdup_printf("tag matchcase \"%s\"", tagname);
|
|
|
|
gtk_toggle_button_set_active(
|
|
|
|
GTK_TOGGLE_BUTTON(mimeview->messageview->mainwin->summaryview->toggle_search),
|
|
|
|
TRUE);
|
|
|
|
quicksearch_set(mimeview->messageview->mainwin->summaryview->quicksearch,
|
|
|
|
QUICK_SEARCH_EXTENDED, buf);
|
|
|
|
g_free(buf);
|
2006-07-04 18:19:39 +02:00
|
|
|
}
|
2006-04-05 18:47:17 +02:00
|
|
|
}
|
|
|
|
|
2006-08-29 18:27:14 +02:00
|
|
|
gboolean mimeview_scroll_page(MimeView *mimeview, gboolean up)
|
|
|
|
{
|
|
|
|
if (mimeview->type == MIMEVIEW_TEXT)
|
|
|
|
return textview_scroll_page(mimeview->textview, up);
|
|
|
|
else if (mimeview->mimeviewer) {
|
|
|
|
MimeViewer *mimeviewer = mimeview->mimeviewer;
|
|
|
|
if (mimeviewer->scroll_page)
|
|
|
|
return mimeviewer->scroll_page(mimeviewer, up);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mimeview_scroll_one_line(MimeView *mimeview, gboolean up)
|
|
|
|
{
|
|
|
|
if (mimeview->type == MIMEVIEW_TEXT)
|
|
|
|
textview_scroll_one_line(mimeview->textview, up);
|
|
|
|
else if (mimeview->mimeviewer) {
|
|
|
|
MimeViewer *mimeviewer = mimeview->mimeviewer;
|
|
|
|
if (mimeviewer->scroll_one_line)
|
|
|
|
mimeviewer->scroll_one_line(mimeviewer, up);
|
|
|
|
}
|
|
|
|
}
|