1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
4
* Copyright (C) Philip Withnall 2008-2009 <philip@tecnocode.co.uk>
6
* Almanah is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Almanah is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Almanah. If not, see <http://www.gnu.org/licenses/>.
21
#include <glib/gi18n.h>
24
#include "calendar-task.h"
25
#include "interface.h"
27
static void almanah_calendar_task_event_finalize (GObject *object);
28
static const gchar *almanah_calendar_task_event_format_value (AlmanahEvent *event);
29
static gboolean almanah_calendar_task_event_view (AlmanahEvent *event, GtkWindow *parent_window);
31
struct _AlmanahCalendarTaskEventPrivate {
36
G_DEFINE_TYPE (AlmanahCalendarTaskEvent, almanah_calendar_task_event, ALMANAH_TYPE_EVENT)
37
#define ALMANAH_CALENDAR_TASK_EVENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ALMANAH_TYPE_CALENDAR_TASK_EVENT, AlmanahCalendarTaskEventPrivate))
40
almanah_calendar_task_event_class_init (AlmanahCalendarTaskEventClass *klass)
42
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
43
AlmanahEventClass *event_class = ALMANAH_EVENT_CLASS (klass);
45
g_type_class_add_private (klass, sizeof (AlmanahCalendarTaskEventPrivate));
47
gobject_class->finalize = almanah_calendar_task_event_finalize;
49
event_class->name = _("Calendar Task");
50
event_class->description = _("A task on an Evolution calendar.");
51
event_class->icon_name = "stock_task";
53
event_class->format_value = almanah_calendar_task_event_format_value;
54
event_class->view = almanah_calendar_task_event_view;
58
almanah_calendar_task_event_init (AlmanahCalendarTaskEvent *self)
60
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR_TASK_EVENT, AlmanahCalendarTaskEventPrivate);
64
almanah_calendar_task_event_finalize (GObject *object)
66
AlmanahCalendarTaskEventPrivate *priv = ALMANAH_CALENDAR_TASK_EVENT_GET_PRIVATE (object);
69
g_free (priv->summary);
71
/* Chain up to the parent class */
72
G_OBJECT_CLASS (almanah_calendar_task_event_parent_class)->finalize (object);
75
AlmanahCalendarTaskEvent *
76
almanah_calendar_task_event_new (const gchar *uid, const gchar *summary)
78
AlmanahCalendarTaskEvent *event = g_object_new (ALMANAH_TYPE_CALENDAR_TASK_EVENT, NULL);
79
event->priv->uid = g_strdup (uid);
80
event->priv->summary = g_strdup (summary);
85
almanah_calendar_task_event_format_value (AlmanahEvent *event)
87
return ALMANAH_CALENDAR_TASK_EVENT (event)->priv->summary;
91
almanah_calendar_task_event_view (AlmanahEvent *event, GtkWindow *parent_window)
93
AlmanahCalendarTaskEventPrivate *priv = ALMANAH_CALENDAR_TASK_EVENT (event)->priv;
98
command_line = g_strdup_printf ("evolution task:%s", priv->uid);
100
g_debug ("Executing \"%s\".", command_line);
102
retval = almanah_run_on_screen (gtk_widget_get_screen (GTK_WIDGET (parent_window)), command_line, &error);
103
g_free (command_line);
105
if (retval == FALSE) {
106
GtkWidget *dialog = gtk_message_dialog_new (parent_window,
107
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
108
_("Error launching Evolution"));
109
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
110
gtk_dialog_run (GTK_DIALOG (dialog));
111
gtk_widget_destroy (dialog);
113
g_error_free (error);