~ubuntu-branches/ubuntu/raring/almanah/raring

« back to all changes in this revision

Viewing changes to .pc/git_support_latest_eds.patch/src/events/calendar-task.c

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2012-09-12 16:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20120912161719-02jiv1sjurchyl0v
Tags: 0.9.0-1ubuntu1
* debian/patches/git_support_latest_eds.patch:
  - upstream patch to build with latest libecal/libedataserver

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/*
 
3
 * Almanah
 
4
 * Copyright (C) Philip Withnall 2008-2009 <philip@tecnocode.co.uk>
 
5
 * 
 
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.
 
10
 *
 
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.
 
15
 *
 
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/>.
 
18
 */
 
19
 
 
20
#include <glib.h>
 
21
#include <glib/gi18n.h>
 
22
 
 
23
#include "event.h"
 
24
#include "calendar-task.h"
 
25
#include "interface.h"
 
26
 
 
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);
 
30
 
 
31
struct _AlmanahCalendarTaskEventPrivate {
 
32
        gchar *uid;
 
33
        gchar *summary;
 
34
};
 
35
 
 
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))
 
38
 
 
39
static void
 
40
almanah_calendar_task_event_class_init (AlmanahCalendarTaskEventClass *klass)
 
41
{
 
42
        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
43
        AlmanahEventClass *event_class = ALMANAH_EVENT_CLASS (klass);
 
44
 
 
45
        g_type_class_add_private (klass, sizeof (AlmanahCalendarTaskEventPrivate));
 
46
 
 
47
        gobject_class->finalize = almanah_calendar_task_event_finalize;
 
48
 
 
49
        event_class->name = _("Calendar Task");
 
50
        event_class->description = _("A task on an Evolution calendar.");
 
51
        event_class->icon_name = "stock_task";
 
52
 
 
53
        event_class->format_value = almanah_calendar_task_event_format_value;
 
54
        event_class->view = almanah_calendar_task_event_view;
 
55
}
 
56
 
 
57
static void
 
58
almanah_calendar_task_event_init (AlmanahCalendarTaskEvent *self)
 
59
{
 
60
        self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ALMANAH_TYPE_CALENDAR_TASK_EVENT, AlmanahCalendarTaskEventPrivate);
 
61
}
 
62
 
 
63
static void
 
64
almanah_calendar_task_event_finalize (GObject *object)
 
65
{
 
66
        AlmanahCalendarTaskEventPrivate *priv = ALMANAH_CALENDAR_TASK_EVENT_GET_PRIVATE (object);
 
67
 
 
68
        g_free (priv->uid);
 
69
        g_free (priv->summary);
 
70
 
 
71
        /* Chain up to the parent class */
 
72
        G_OBJECT_CLASS (almanah_calendar_task_event_parent_class)->finalize (object);
 
73
}
 
74
 
 
75
AlmanahCalendarTaskEvent *
 
76
almanah_calendar_task_event_new (const gchar *uid, const gchar *summary)
 
77
{
 
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);
 
81
        return event;
 
82
}
 
83
 
 
84
static const gchar *
 
85
almanah_calendar_task_event_format_value (AlmanahEvent *event)
 
86
{
 
87
        return ALMANAH_CALENDAR_TASK_EVENT (event)->priv->summary;
 
88
}
 
89
 
 
90
static gboolean
 
91
almanah_calendar_task_event_view (AlmanahEvent *event, GtkWindow *parent_window)
 
92
{
 
93
        AlmanahCalendarTaskEventPrivate *priv = ALMANAH_CALENDAR_TASK_EVENT (event)->priv;
 
94
        gchar *command_line;
 
95
        gboolean retval;
 
96
        GError *error = NULL;
 
97
 
 
98
        command_line = g_strdup_printf ("evolution task:%s", priv->uid);
 
99
 
 
100
        g_debug ("Executing \"%s\".", command_line);
 
101
 
 
102
        retval = almanah_run_on_screen (gtk_widget_get_screen (GTK_WIDGET (parent_window)), command_line, &error);
 
103
        g_free (command_line);
 
104
 
 
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);
 
112
 
 
113
                g_error_free (error);
 
114
 
 
115
                return FALSE;
 
116
        }
 
117
 
 
118
        return TRUE;
 
119
}