aboutsummaryrefslogtreecommitdiff
path: root/src/compose.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-05-20 04:59:52 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-05-20 04:59:52 +0000
commit1c36fc23787fd60a798a7c584db399b7cb913bb8 (patch)
tree6618f5ac5f7bb60578a3e1a4267fe1058bc63e60 /src/compose.c
parent78cadd877feffcdbf75620ac63bc8e545f73f03b (diff)
added 'Open' menu in the attach context menu.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2539 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/compose.c')
-rw-r--r--src/compose.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/compose.c b/src/compose.c
index df695b6d..c7e61c34 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -322,6 +322,8 @@ static gboolean attach_property_key_pressed (GtkWidget *widget,
GdkEventKey *event,
gboolean *cancelled);
+static void compose_attach_open (Compose *compose);
+
static void compose_exec_ext_editor (Compose *compose);
static gboolean compose_ext_editor_kill (Compose *compose);
static void compose_ext_editor_child_exit (GPid pid,
@@ -396,6 +398,9 @@ static void compose_draft_cb (gpointer data,
guint action,
GtkWidget *widget);
+static void compose_attach_open_cb (gpointer data,
+ guint action,
+ GtkWidget *widget);
static void compose_attach_cb (gpointer data,
guint action,
GtkWidget *widget);
@@ -560,6 +565,8 @@ static gboolean autosave_timeout (gpointer data);
static GtkItemFactoryEntry compose_popup_entries[] =
{
+ {N_("/_Open"), NULL, compose_attach_open_cb, 0, NULL},
+ {N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Add..."), NULL, compose_attach_cb, 0, NULL},
{N_("/_Remove"), NULL, compose_attach_remove_selected, 0, NULL},
{N_("/---"), NULL, NULL, 0, "<Separator>"},
@@ -6559,6 +6566,58 @@ static gboolean attach_property_key_pressed(GtkWidget *widget,
return FALSE;
}
+static void compose_attach_open(Compose *compose)
+{
+ GtkTreeModel *model = GTK_TREE_MODEL(compose->attach_store);
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GList *rows;
+ AttachInfo *ainfo = NULL;
+#ifdef G_OS_WIN32
+ DWORD dwtype;
+#endif
+
+ selection = gtk_tree_view_get_selection
+ (GTK_TREE_VIEW(compose->attach_treeview));
+
+ rows = gtk_tree_selection_get_selected_rows(selection, NULL);
+
+ if (!rows)
+ return;
+
+ gtk_tree_model_get_iter(model, &iter, (GtkTreePath *)rows->data);
+ gtk_tree_model_get(model, &iter, COL_ATTACH_INFO, &ainfo, -1);
+
+ g_list_foreach(rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free(rows);
+
+ if (!ainfo || !ainfo->file)
+ return;
+
+ if (!is_file_exist(ainfo->file)) {
+ alertpanel_error(_("File not exist."));
+ return;
+ }
+
+#ifdef G_OS_WIN32
+ if (g_file_test(filename, G_FILE_TEST_IS_EXECUTABLE) ||
+ str_has_suffix_case(filename, ".scr") ||
+ str_has_suffix_case(filename, ".pif") ||
+ GetBinaryType(filename, &dwtype)) {
+ alertpanel_full
+ (_("Opening executable file"),
+ _("This is an executable file. Opening executable file is restricted for security.\n"
+ "If you want to launch it, save it to somewhere and make sure it is not an virus or something like a malicious program."),
+ ALERT_WARNING, G_ALERTDEFAULT, FALSE,
+ GTK_STOCK_OK, NULL, NULL);
+ return;
+ }
+ execute_open_file(ainfo->file, ainfo->content_type);
+#else
+ procmime_execute_open_file(ainfo->file, ainfo->content_type);
+#endif
+}
+
static void compose_exec_ext_editor(Compose *compose)
{
gchar *tmp;
@@ -7204,6 +7263,14 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
}
}
+static void compose_attach_open_cb(gpointer data, guint action,
+ GtkWidget *widget)
+{
+ Compose *compose = (Compose *)data;
+
+ compose_attach_open(compose);
+}
+
static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
{
Compose *compose = (Compose *)data;