#include <config.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "ev-file-helpers.h"
#include "ev-attachment.h"
Go to the source code of this file.
|
GQuark | ev_attachment_error_quark (void) |
|
static void | ev_attachment_finalize (GObject *object) |
|
static void | ev_attachment_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *param_spec) |
|
static void | ev_attachment_class_init (EvAttachmentClass *klass) |
|
static void | ev_attachment_init (EvAttachment *attachment) |
|
EvAttachment * | ev_attachment_new (const gchar *name, const gchar *description, GTime mtime, GTime ctime, gsize size, gpointer data) |
|
const gchar * | ev_attachment_get_name (EvAttachment *attachment) |
|
const gchar * | ev_attachment_get_description (EvAttachment *attachment) |
|
GTime | ev_attachment_get_modification_date (EvAttachment *attachment) |
|
GTime | ev_attachment_get_creation_date (EvAttachment *attachment) |
|
const gchar * | ev_attachment_get_mime_type (EvAttachment *attachment) |
|
gboolean | ev_attachment_save (EvAttachment *attachment, GFile *file, GError **error) |
|
static gboolean | ev_attachment_launch_app (EvAttachment *attachment, GdkScreen *screen, guint32 timestamp, GError **error) |
|
gboolean | ev_attachment_open (EvAttachment *attachment, GdkScreen *screen, guint32 timestamp, GError **error) |
|
Enumerator |
---|
PROP_0 |
|
PROP_NAME |
|
PROP_DESCRIPTION |
|
PROP_MTIME |
|
PROP_CTIME |
|
PROP_SIZE |
|
PROP_DATA |
|
Definition at line 27 of file ev-attachment.c.
Definition at line 147 of file ev-attachment.c.
149 GObjectClass *g_object_class;
151 g_object_class = G_OBJECT_CLASS (klass);
158 g_object_class_install_property (g_object_class,
160 g_param_spec_string (
"name",
162 "The attachment name",
165 G_PARAM_CONSTRUCT_ONLY |
166 G_PARAM_STATIC_STRINGS));
167 g_object_class_install_property (g_object_class,
169 g_param_spec_string (
"description",
171 "The attachment description",
174 G_PARAM_CONSTRUCT_ONLY |
175 G_PARAM_STATIC_STRINGS));
176 g_object_class_install_property (g_object_class,
178 g_param_spec_ulong (
"mtime",
180 "The attachment modification date",
183 G_PARAM_CONSTRUCT_ONLY |
184 G_PARAM_STATIC_STRINGS));
185 g_object_class_install_property (g_object_class,
187 g_param_spec_ulong (
"ctime",
189 "The attachment creation date",
192 G_PARAM_CONSTRUCT_ONLY |
193 G_PARAM_STATIC_STRINGS));
194 g_object_class_install_property (g_object_class,
196 g_param_spec_uint (
"size",
198 "The attachment size",
201 G_PARAM_CONSTRUCT_ONLY |
202 G_PARAM_STATIC_STRINGS));
203 g_object_class_install_property (g_object_class,
205 g_param_spec_pointer (
"data",
207 "The attachment data",
209 G_PARAM_CONSTRUCT_ONLY |
210 G_PARAM_STATIC_STRINGS));
GQuark ev_attachment_error_quark |
( |
void |
) | |
|
Definition at line 57 of file ev-attachment.c.
59 static GQuark error_quark = 0;
63 g_quark_from_static_string (
"ev-attachment-error-quark");
static void ev_attachment_finalize |
( |
GObject * |
object) | |
|
|
static |
Definition at line 69 of file ev-attachment.c.
73 if (attachment->priv->name) {
74 g_free (attachment->priv->name);
75 attachment->priv->name = NULL;
78 if (attachment->priv->description) {
79 g_free (attachment->priv->description);
80 attachment->priv->description = NULL;
83 if (attachment->priv->data) {
84 g_free (attachment->priv->data);
85 attachment->priv->data = NULL;
88 if (attachment->priv->mime_type) {
89 g_free (attachment->priv->mime_type);
90 attachment->priv->mime_type = NULL;
93 if (attachment->priv->app) {
94 g_object_unref (attachment->priv->app);
95 attachment->priv->app = NULL;
98 if (attachment->priv->tmp_file) {
100 g_object_unref (attachment->priv->tmp_file);
101 attachment->priv->tmp_file = NULL;
104 G_OBJECT_CLASS (ev_attachment_parent_class)->finalize (
object);
GTime ev_attachment_get_creation_date |
( |
EvAttachment * |
attachment) | |
|
const gchar* ev_attachment_get_description |
( |
EvAttachment * |
attachment) | |
|
const gchar* ev_attachment_get_mime_type |
( |
EvAttachment * |
attachment) | |
|
GTime ev_attachment_get_modification_date |
( |
EvAttachment * |
attachment) | |
|
const gchar* ev_attachment_get_name |
( |
EvAttachment * |
attachment) | |
|
Definition at line 216 of file ev-attachment.c.
220 attachment->priv->name = NULL;
221 attachment->priv->description = NULL;
222 attachment->priv->data = NULL;
223 attachment->priv->mime_type = NULL;
225 attachment->priv->tmp_file = NULL;
static gboolean ev_attachment_launch_app |
( |
EvAttachment * |
attachment, |
|
|
GdkScreen * |
screen, |
|
|
guint32 |
timestamp, |
|
|
GError ** |
error |
|
) |
| |
|
static |
Definition at line 349 of file ev-attachment.c.
356 GdkAppLaunchContext *context;
358 GError *ioerror = NULL;
360 g_assert (G_IS_FILE (attachment->priv->tmp_file));
361 g_assert (G_IS_APP_INFO (attachment->priv->app));
363 files = g_list_prepend (files, attachment->priv->tmp_file);
365 display = screen ? gdk_screen_get_display (screen) : gdk_display_get_default ();
366 context = gdk_display_get_app_launch_context (display);
367 gdk_app_launch_context_set_screen (context, screen);
368 gdk_app_launch_context_set_timestamp (context, timestamp);
370 result = g_app_info_launch (attachment->priv->app, files,
371 G_APP_LAUNCH_CONTEXT (context),
373 g_object_unref (context);
379 _(
"Couldn’t open attachment “%s”: %s"),
380 attachment->priv->name,
384 g_error_free (ioerror);
EvAttachment* ev_attachment_new |
( |
const gchar * |
name, |
|
|
const gchar * |
description, |
|
|
GTime |
mtime, |
|
|
GTime |
ctime, |
|
|
gsize |
size, |
|
|
gpointer |
data |
|
) |
| |
gboolean ev_attachment_open |
( |
EvAttachment * |
attachment, |
|
|
GdkScreen * |
screen, |
|
|
guint32 |
timestamp, |
|
|
GError ** |
error |
|
) |
| |
Definition at line 395 of file ev-attachment.c.
401 gboolean retval =
FALSE;
405 if (!attachment->priv->app) {
406 app_info = g_app_info_get_default_for_type (attachment->priv->mime_type,
FALSE);
407 attachment->priv->app = app_info;
410 if (!attachment->priv->app) {
414 _(
"Couldn’t open attachment “%s”"),
415 attachment->priv->name);
420 if (attachment->priv->tmp_file) {
430 template = g_strdup_printf (
"%s.XXXXXX", basename);
436 if (attachment->priv->tmp_file)
437 g_object_unref (attachment->priv->tmp_file);
438 attachment->priv->tmp_file = g_object_ref (file);
444 g_object_unref (file);
gboolean ev_attachment_save |
( |
EvAttachment * |
attachment, |
|
|
GFile * |
file, |
|
|
GError ** |
error |
|
) |
| |
Definition at line 291 of file ev-attachment.c.
295 GFileOutputStream *output_stream;
296 GError *ioerror = NULL;
297 gssize written_bytes;
300 g_return_val_if_fail (G_IS_FILE (file),
FALSE);
302 output_stream = g_file_replace (file, NULL,
FALSE, 0, NULL, &ioerror);
303 if (output_stream == NULL) {
306 uri = g_file_get_uri (file);
310 _(
"Couldn’t save attachment “%s”: %s"),
314 g_error_free (ioerror);
320 written_bytes = g_output_stream_write (G_OUTPUT_STREAM (output_stream),
321 attachment->priv->data,
322 attachment->priv->size,
324 if (written_bytes == -1) {
327 uri = g_file_get_uri (file);
331 _(
"Couldn’t save attachment “%s”: %s"),
335 g_output_stream_close (G_OUTPUT_STREAM (output_stream), NULL, NULL);
336 g_error_free (ioerror);
342 g_output_stream_close (G_OUTPUT_STREAM (output_stream), NULL, NULL);
static void ev_attachment_set_property |
( |
GObject * |
object, |
|
|
guint |
prop_id, |
|
|
const GValue * |
value, |
|
|
GParamSpec * |
param_spec |
|
) |
| |
|
static |
Definition at line 108 of file ev-attachment.c.
117 attachment->priv->name = g_value_dup_string (value);
120 attachment->priv->description = g_value_dup_string (value);
123 attachment->priv->mtime = g_value_get_ulong (value);
126 attachment->priv->ctime = g_value_get_ulong (value);
129 attachment->priv->size = g_value_get_uint (value);
132 attachment->priv->data = g_value_get_pointer (value);
133 attachment->priv->mime_type = g_content_type_guess (attachment->priv->name,
134 (guchar *) attachment->priv->data,
135 attachment->priv->size,
139 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object,