gboolean ev_attachment_open (EvAttachment *attachment, GdkScreen *screen, guint32 timestamp, GError **error) { GAppInfo *app_info; gboolean retval = FALSE; g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE); if (!attachment->priv->app) { app_info = g_app_info_get_default_for_type (attachment->priv->mime_type, FALSE); attachment->priv->app = app_info; } if (!attachment->priv->app) { g_set_error (error, EV_ATTACHMENT_ERROR, 0, _("Couldn't open attachment ā%sā"), attachment->priv->name); return FALSE; } if (attachment->priv->tmp_file) { retval = ev_attachment_launch_app (attachment, screen, timestamp, error); } else { char *basename; char *template; GFile *file; /* FIXMEchpe: convert to filename encoding first! */ basename = g_path_get_basename (ev_attachment_get_name (attachment));
0, _("Couldn't open attachment ā%sā"), attachment->priv->name); return FALSE; } if (attachment->priv->tmp_file) { retval = ev_attachment_launch_app (attachment, screen, timestamp, error); } else { char *template; GFile *file; /* FIXMEchpe: convert to filename encoding first! */ template = g_strdup_printf ("%s.XXXXXX", ev_attachment_get_name (attachment)); file = ev_mkstemp_file (template, error); g_free (template); if (file != NULL && ev_attachment_save (attachment, file, error)) { if (attachment->priv->tmp_file) g_object_unref (attachment->priv->tmp_file); attachment->priv->tmp_file = g_object_ref (file); retval = ev_attachment_launch_app (attachment, screen, timestamp, error); } g_object_unref (file); }