1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
4
* Copyright (C) Philip Withnall 2008 <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-appointment.h"
27
static void almanah_calendar_appointment_event_init (AlmanahCalendarAppointmentEvent *self);
28
static void almanah_calendar_appointment_event_finalize (GObject *object);
29
static const gchar *almanah_calendar_appointment_event_format_value (AlmanahEvent *event);
30
static gboolean almanah_calendar_appointment_event_view (AlmanahEvent *event);
32
struct _AlmanahCalendarAppointmentEventPrivate {
37
G_DEFINE_TYPE (AlmanahCalendarAppointmentEvent, almanah_calendar_appointment_event, ALMANAH_TYPE_EVENT)
38
#define ALMANAH_CALENDAR_APPOINTMENT_EVENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, AlmanahCalendarAppointmentEventPrivate))
41
almanah_calendar_appointment_event_class_init (AlmanahCalendarAppointmentEventClass *klass)
43
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
44
AlmanahEventClass *event_class = ALMANAH_EVENT_CLASS (klass);
46
g_type_class_add_private (klass, sizeof (AlmanahCalendarAppointmentEventPrivate));
48
gobject_class->finalize = almanah_calendar_appointment_event_finalize;
50
event_class->name = _("Calendar Appointment");
51
event_class->description = _("An appointment on an Evolution calendar.");
52
event_class->icon_name = "appointment-new";
54
event_class->format_value = almanah_calendar_appointment_event_format_value;
55
event_class->view = almanah_calendar_appointment_event_view;
59
almanah_calendar_appointment_event_init (AlmanahCalendarAppointmentEvent *self)
61
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, AlmanahCalendarAppointmentEventPrivate);
65
almanah_calendar_appointment_event_finalize (GObject *object)
67
AlmanahCalendarAppointmentEventPrivate *priv = ALMANAH_CALENDAR_APPOINTMENT_EVENT_GET_PRIVATE (object);
69
g_free (priv->summary);
71
/* Chain up to the parent class */
72
G_OBJECT_CLASS (almanah_calendar_appointment_event_parent_class)->finalize (object);
75
AlmanahCalendarAppointmentEvent *
76
almanah_calendar_appointment_event_new (const gchar *summary, GTime start_time)
78
AlmanahCalendarAppointmentEvent *event = g_object_new (ALMANAH_TYPE_CALENDAR_APPOINTMENT_EVENT, NULL);
79
event->priv->summary = g_strdup (summary);
80
event->priv->start_time = start_time;
86
almanah_calendar_appointment_event_format_value (AlmanahEvent *event)
88
return ALMANAH_CALENDAR_APPOINTMENT_EVENT (event)->priv->summary;
92
almanah_calendar_appointment_event_view (AlmanahEvent *event)
94
AlmanahCalendarAppointmentEventPrivate *priv = ALMANAH_CALENDAR_APPOINTMENT_EVENT (event)->priv;
95
struct tm utc_date_tm;
100
gmtime_r ((const time_t*) &(priv->start_time), &utc_date_tm);
102
/* FIXME: once bug 409200 is fixed, we'll have to make this hh:mm:ss
103
* instead of hhmmss */
104
command_line = g_strdup_printf ("evolution calendar:///?startdate=%.4d%.2d%.2dT%.2d%.2d%.2dZ",
105
utc_date_tm.tm_year + 1900,
106
utc_date_tm.tm_mon + 1,
112
if (almanah->debug == TRUE)
113
g_debug ("Executing \"%s\".", command_line);
115
retval = gdk_spawn_command_line_on_screen (gtk_widget_get_screen (almanah->main_window), command_line, &error);
116
g_free (command_line);
118
if (retval == FALSE) {
119
GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (almanah->main_window),
120
GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
121
_("Error launching Evolution"));
122
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
123
gtk_dialog_run (GTK_DIALOG (dialog));
124
gtk_widget_destroy (dialog);
126
g_error_free (error);