aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-10-03 12:43:40 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-10-03 12:43:40 +0800
commit086a96050b16f6dabd99a391b5a4faf0411963a1 (patch)
tree73a4c2efb11f255ff1685114a051d731a6a12e13 /calendar/gui
parent791c982c456fca453978358d2e919082419b7808 (diff)
downloadgsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar
gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.gz
gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.bz2
gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.lz
gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.xz
gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.zst
gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.zip
Tasks progress. Merge EMemoPreview back into ECalComponentPreview.
svn path=/branches/kill-bonobo/; revision=36538
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am2
-rw-r--r--calendar/gui/e-cal-component-preview.c322
-rw-r--r--calendar/gui/e-cal-component-preview.h63
-rw-r--r--calendar/gui/e-memo-preview.c356
-rw-r--r--calendar/gui/e-memo-preview.h84
5 files changed, 179 insertions, 648 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 7cf356add8..1edc28d0a7 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -135,8 +135,6 @@ libcal_gui_la_SOURCES = \
e-meeting-types.h \
e-meeting-utils.c \
e-meeting-utils.h \
- e-memo-preview.c \
- e-memo-preview.h \
e-memo-table.c \
e-memo-table.h \
e-memo-table-config.c \
diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c
index 853183bf53..8d3a903119 100644
--- a/calendar/gui/e-cal-component-preview.c
+++ b/calendar/gui/e-cal-component-preview.c
@@ -22,48 +22,48 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "e-cal-component-preview.h"
#include <string.h>
-#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-url.h>
-#include <libedataserver/e-categories.h>
#include <libecal/e-cal-time-util.h>
-#include <gtkhtml/gtkhtml.h>
+#include <libedataserver/e-categories.h>
#include <gtkhtml/gtkhtml-stream.h>
#include <libedataserver/e-time-utils.h>
#include <e-util/e-categories-config.h>
#include "calendar-config.h"
-#include "e-cal-component-preview.h"
#include <camel/camel-mime-filter-tohtml.h>
-struct _ECalComponentPreviewPrivate {
- GtkWidget *html;
+#define E_CAL_COMPONENT_PREVIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewPrivate))
+struct _ECalComponentPreviewPrivate {
icaltimezone *zone;
};
-G_DEFINE_TYPE (ECalComponentPreview, e_cal_component_preview, GTK_TYPE_TABLE)
+static gpointer parent_class;
static void
-on_link_clicked (GtkHTML *html, const char *url, gpointer data)
+cal_component_preview_link_clicked (GtkHTML *html,
+ const gchar *url)
{
- GError *err = NULL;
+ GdkScreen *screen;
+ GError *error = NULL;
- gnome_url_show (url, &err);
+ screen = gtk_widget_get_screen (GTK_WIDGET (html));
+ gtk_show_uri (screen, url, GDK_CURRENT_TIME, &error);
- if (err) {
- g_warning ("gnome_url_show: %s", err->message);
- g_error_free (err);
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
}
static void
-on_url_cb (GtkHTML *html, const char *url, gpointer data)
+cal_component_preview_on_url (GtkHTML *html,
+ const gchar *url)
{
#if 0
char *msg;
@@ -78,51 +78,11 @@ on_url_cb (GtkHTML *html, const char *url, gpointer data)
#endif
}
-/* Callback used when the user selects a URL in the HTML widget */
-void
-e_cal_comp_preview_url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *html_stream, gpointer data)
-{
- int len = strlen ("file:///");
-
- if (!strncmp ("file:///", url, len)) {
- GFile *file;
- const char *path = url + len - 1;
-
- g_return_if_fail (html_stream != NULL);
- g_return_if_fail (path != NULL);
-
- file = g_file_new_for_path (path);
- if (file) {
- char buffer[4096];
- GInputStream *stream;
-
- /* ignore errors here */
- stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
-
- if (stream) {
- gssize bread;
-
- do {
- /* ignore errors here as well */
- bread = g_input_stream_read (stream, buffer, sizeof (buffer), NULL, NULL);
- if (bread > 0)
- gtk_html_stream_write (html_stream, buffer, bread);
- } while (bread > 0);
-
- g_input_stream_close (stream, NULL, NULL);
- g_object_unref (stream);
-
- gtk_html_stream_close (html_stream, GTK_HTML_STREAM_OK);
- }
-
- g_object_unref (file);
- }
- }
-}
-
/* Converts a time_t to a string, relative to the specified timezone */
static char *
-timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *default_zone)
+timet_to_str_with_zone (ECalComponentDateTime *dt,
+ ECal *ecal,
+ icaltimezone *default_zone)
{
struct icaltimetype itt;
icaltimezone *zone;
@@ -152,12 +112,18 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, icaltimezone *def
}
static void
-write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone *default_zone)
+cal_component_preview_write_html (GtkHTMLStream *stream,
+ ECal *ecal,
+ ECalComponent *comp,
+ icaltimezone *default_zone)
{
ECalComponentText text;
ECalComponentDateTime dt;
gchar *str;
- GSList *l;
+ GString *string;
+ GSList *list, *iter;
+ icalcomponent *icalcomp;
+ icalproperty *icalprop;
icalproperty_status status;
const char *location;
int *priority_value;
@@ -176,28 +142,34 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
"<HTML><BODY><H1><I>%s</I></H1>",
_("Untitled"));
-
/* write icons for the categories */
- e_cal_component_get_categories_list (comp, &l);
- if (l) {
- GSList *node;
-
- for (node = l; node != NULL; node = node->next) {
- const char *icon_file;
-
- icon_file = e_categories_get_icon_file_for ((const char *) node->data);
- if (icon_file) {
- gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL);
- gtk_html_stream_printf (stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
- (const char *) node->data, icon_file_uri);
- g_free (icon_file_uri);
- }
+ string = g_string_new (NULL);
+ e_cal_component_get_categories_list (comp, &list);
+ if (list != NULL)
+ gtk_html_stream_printf (stream, "<H3>%s ", _("Categories:"));
+ for (iter = list; iter != NULL; iter = iter->next) {
+ const gchar *category = iter->data;
+ const gchar *icon_file;
+
+ icon_file = e_categories_get_icon_file_for (category);
+ if (icon_file && g_file_test (icon_file, G_FILE_TEST_EXISTS)) {
+ gchar *uri;
+
+ uri = g_filename_to_uri (icon_file, NULL, NULL);
+ gtk_html_stream_printf (
+ stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
+ category, uri);
+ g_free (uri);
+ } else {
+ if (iter != list)
+ g_string_append_len (string, ", ", 2);
+ g_string_append (string, category);
}
-
- e_cal_component_free_categories_list (l);
-
- gtk_html_stream_printf (stream, "<BR><BR><BR>");
}
+ if (string->len > 0)
+ gtk_html_stream_printf (stream, "%s</H3>", string->str);
+ e_cal_component_free_categories_list (list);
+ g_string_free (string, TRUE);
/* Start table */
gtk_html_stream_printf (stream, "<TABLE BORDER=\"0\" WIDTH=\"80%%\">"
@@ -243,26 +215,31 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
e_cal_component_free_datetime (&dt);
/* write status */
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:"));
- e_cal_component_get_status (comp, &status);
- switch (status) {
- case ICAL_STATUS_INPROCESS :
- str = g_strdup (_("In Progress"));
- break;
- case ICAL_STATUS_COMPLETED :
- str = g_strdup (_("Completed"));
- break;
- case ICAL_STATUS_CANCELLED :
- str = g_strdup (_("Canceled"));
- break;
- case ICAL_STATUS_NONE :
- default :
- str = g_strdup (_("Not Started"));
- break;
- }
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalprop = icalcomponent_get_first_property (
+ icalcomp, ICAL_STATUS_PROPERTY);
+ if (icalprop != NULL) {
+ gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:"));
+ e_cal_component_get_status (comp, &status);
+ switch (status) {
+ case ICAL_STATUS_INPROCESS :
+ str = g_strdup (_("In Progress"));
+ break;
+ case ICAL_STATUS_COMPLETED :
+ str = g_strdup (_("Completed"));
+ break;
+ case ICAL_STATUS_CANCELLED :
+ str = g_strdup (_("Canceled"));
+ break;
+ case ICAL_STATUS_NONE :
+ default :
+ str = g_strdup (_("Not Started"));
+ break;
+ }
- gtk_html_stream_printf (stream, "<TD>%s</TD></TR>", str);
- g_free (str);
+ gtk_html_stream_printf (stream, "<TD>%s</TD></TR>", str);
+ g_free (str);
+ }
/* write priority */
e_cal_component_get_priority (comp, &priority_value);
@@ -284,15 +261,15 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
/* write description and URL */
gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>");
- e_cal_component_get_description_list (comp, &l);
- if (l) {
+ e_cal_component_get_description_list (comp, &list);
+ if (list) {
GSList *node;
gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Description:"));
gtk_html_stream_printf (stream, "<TD><TT>");
- for (node = l; node != NULL; node = node->next) {
+ for (node = list; node != NULL; node = node->next) {
char *html;
text = * (ECalComponentText *) node->data;
@@ -306,7 +283,7 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
gtk_html_stream_printf (stream, "</TT></TD></TR>");
- e_cal_component_free_text_list (l);
+ e_cal_component_free_text_list (list);
}
/* URL */
@@ -323,135 +300,120 @@ write_html (GtkHTMLStream *stream, ECal *ecal, ECalComponent *comp, icaltimezone
}
static void
-e_cal_component_preview_init (ECalComponentPreview *preview)
+cal_component_preview_finalize (GObject *object)
{
ECalComponentPreviewPrivate *priv;
- GtkWidget *scroll;
- priv = g_new0 (ECalComponentPreviewPrivate, 1);
- preview->priv = priv;
+ priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (object);
+
+ /* XXX Nothing to do? */
- priv->html = gtk_html_new ();
- gtk_html_set_default_content_type (GTK_HTML (priv->html), "charset=utf-8");
- gtk_html_load_empty (GTK_HTML (priv->html));
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
- g_signal_connect (G_OBJECT (priv->html), "url_requested",
- G_CALLBACK (e_cal_comp_preview_url_requested_cb), NULL);
- g_signal_connect (G_OBJECT (priv->html), "link_clicked",
- G_CALLBACK (on_link_clicked), preview);
- g_signal_connect (G_OBJECT (priv->html), "on_url",
- G_CALLBACK (on_url_cb), preview);
+static void
+cal_component_preview_class_init (ECalComponentPreviewClass *class)
+{
+ GObjectClass *object_class;
+ GtkHTMLClass *gtkhtml_class;
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ECalComponentPreviewPrivate));
- gtk_container_add (GTK_CONTAINER (scroll), priv->html);
- gtk_container_add (GTK_CONTAINER (preview), scroll);
- gtk_widget_show_all (scroll);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = cal_component_preview_finalize;
- priv->zone = icaltimezone_get_utc_timezone ();
+ gtkhtml_class = GTK_HTML_CLASS (class);
+ gtkhtml_class->link_clicked = cal_component_preview_link_clicked;
+ gtkhtml_class->on_url = cal_component_preview_on_url;
}
static void
-e_cal_component_preview_destroy (GtkObject *object)
+cal_component_preview_init (ECalComponentPreview *preview)
{
- ECalComponentPreview *preview;
ECalComponentPreviewPrivate *priv;
+ GtkHTML *html;
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (object));
+ preview->priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (preview);
- preview = E_CAL_COMPONENT_PREVIEW (object);
- priv = preview->priv;
+ html = GTK_HTML (preview);
+ gtk_html_set_default_content_type (html, "charset=utf-8");
+ gtk_html_load_empty (html);
- if (priv) {
-
- g_free (priv);
- preview->priv = NULL;
- }
-
- if (GTK_OBJECT_CLASS (e_cal_component_preview_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (e_cal_component_preview_parent_class)->destroy) (object);
+ priv->zone = icaltimezone_get_utc_timezone ();
}
-static void
-e_cal_component_preview_class_init (ECalComponentPreviewClass *klass)
+GType
+e_cal_component_preview_get_type (void)
{
- GtkObjectClass *object_class;
-
- object_class = (GtkObjectClass *) klass;
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (ECalComponentPreviewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) cal_component_preview_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (ECalComponentPreview),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) cal_component_preview_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_HTML, "ECalComponentPreview", &type_info, 0);
+ }
- object_class->destroy = e_cal_component_preview_destroy;
+ return type;
}
GtkWidget *
e_cal_component_preview_new (void)
{
- ECalComponentPreview *preview;
-
- preview = g_object_new (e_cal_component_preview_get_type (), NULL);
-
- return GTK_WIDGET (preview);
+ return g_object_new (E_TYPE_CAL_COMPONENT_PREVIEW, NULL);
}
icaltimezone *
e_cal_component_preview_get_default_timezone (ECalComponentPreview *preview)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_val_if_fail (preview != NULL, NULL);
g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), NULL);
- priv = preview->priv;
-
- return priv->zone;
+ return preview->priv->zone;
}
void
-e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview, icaltimezone *zone)
+e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview,
+ icaltimezone *zone)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
g_return_if_fail (zone != NULL);
- priv = preview->priv;
-
- priv->zone = zone;
+ preview->priv->zone = zone;
}
void
-e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp)
+e_cal_component_preview_display (ECalComponentPreview *preview,
+ ECal *ecal,
+ ECalComponent *comp)
{
- ECalComponentPreviewPrivate *priv;
GtkHTMLStream *stream;
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
- g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
- priv = preview->priv;
-
- stream = gtk_html_begin (GTK_HTML (priv->html));
- write_html (stream, ecal, comp, priv->zone);
+ stream = gtk_html_begin (GTK_HTML (preview));
+ cal_component_preview_write_html (
+ stream, ecal, comp, preview->priv->zone);
gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
}
void
e_cal_component_preview_clear (ECalComponentPreview *preview)
{
- ECalComponentPreviewPrivate *priv;
-
- g_return_if_fail (preview != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
- priv = preview->priv;
-
- gtk_html_load_empty (GTK_HTML (priv->html));
+ gtk_html_load_empty (GTK_HTML (preview));
}
-
diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h
index e5cc98109c..dd04019e44 100644
--- a/calendar/gui/e-cal-component-preview.h
+++ b/calendar/gui/e-cal-component-preview.h
@@ -1,5 +1,4 @@
/*
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -22,51 +21,63 @@
*
*/
-#ifndef _E_CAL_COMPONENT_PREVIEW_H_
-#define _E_CAL_COMPONENT_PREVIEW_H_
+#ifndef E_CAL_COMPONENT_PREVIEW_H
+#define E_CAL_COMPONENT_PREVIEW_H
#include <gtk/gtk.h>
#include <libecal/e-cal.h>
#include <gtkhtml/gtkhtml.h>
-#include <gtkhtml/gtkhtml-stream.h>
-#define E_TYPE_CAL_COMPONENT_PREVIEW (e_cal_component_preview_get_type ())
-#define E_CAL_COMPONENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreview))
-#define E_CAL_COMPONENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_INSTANCE_CAST_CLASS ((klass), E_TYPE_CAL_COMPONENT_PREVIEW, \
- ECalComponentPreviewClass))
-#define E_IS_CAL_COMPONENT_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_COMPONENT_PREVIEW))
-#define E_IS_CAL_COMPONENT_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_COMPONENT_PREVIEW))
+/* Standard GObject macros */
+#define E_TYPE_CAL_COMPONENT_PREVIEW \
+ (e_cal_component_preview_get_type ())
+#define E_CAL_COMPONENT_PREVIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreview))
+#define E_CAL_COMPONENT_PREVIEW_CLASS(cls) \
+ (G_TYPE_CHECK_INSTANCE_CAST_CLASS \
+ ((cls), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewClass))
+#define E_IS_CAL_COMPONENT_PREVIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW))
+#define E_IS_CAL_COMPONENT_PREVIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_COMPONENT_PREVIEW))
+#define E_CAL_COMPONENT_PREVIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewClass))
+
+G_BEGIN_DECLS
typedef struct _ECalComponentPreview ECalComponentPreview;
typedef struct _ECalComponentPreviewClass ECalComponentPreviewClass;
typedef struct _ECalComponentPreviewPrivate ECalComponentPreviewPrivate;
struct _ECalComponentPreview {
- GtkTable table;
-
- /* Private data */
+ GtkHTML parent;
ECalComponentPreviewPrivate *priv;
};
struct _ECalComponentPreviewClass {
- GtkTableClass parent_class;
+ GtkHTMLClass parent_class;
/* Notification signals */
void (* selection_changed) (ECalComponentPreview *preview, int n_selected);
};
-GType e_cal_component_preview_get_type (void);
-GtkWidget *e_cal_component_preview_new (void);
-
-icaltimezone *e_cal_component_preview_get_default_timezone (ECalComponentPreview *preview);
-void e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview, icaltimezone *zone);
-
-void e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, ECalComponent *comp);
-void e_cal_component_preview_clear (ECalComponentPreview *preview);
-
-/* Callback used when GtkHTML widget requests URL */
-void e_cal_comp_preview_url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *html_stream, gpointer data);
+GType e_cal_component_preview_get_type(void);
+GtkWidget * e_cal_component_preview_new (void);
+icaltimezone * e_cal_component_preview_get_default_timezone
+ (ECalComponentPreview *preview);
+void e_cal_component_preview_set_default_timezone
+ (ECalComponentPreview *preview,
+ icaltimezone *zone);
+void e_cal_component_preview_display (ECalComponentPreview *preview,
+ ECal *ecal,
+ ECalComponent *comp);
+void e_cal_component_preview_clear (ECalComponentPreview *preview);
+G_END_DECLS
-#endif /* _E_CAL_COMPONENT_PREVIEW_H_ */
+#endif /* E_CAL_COMPONENT_PREVIEW_H */
diff --git a/calendar/gui/e-memo-preview.c b/calendar/gui/e-memo-preview.c
deleted file mode 100644
index f5b725c02f..0000000000
--- a/calendar/gui/e-memo-preview.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-tasks.c
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors: Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- * Rodrigo Moya <rodrigo@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- */
-
-#include "e-memo-preview.h"
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <libecal/e-cal-time-util.h>
-#include <libedataserver/e-categories.h>
-#include <gtkhtml/gtkhtml-stream.h>
-#include <libedataserver/e-time-utils.h>
-#include <e-util/e-categories-config.h>
-#include "calendar-config.h"
-#include "e-cal-component-preview.h"
-#include <camel/camel-mime-filter-tohtml.h>
-
-#define E_MEMO_PREVIEW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreviewPrivate))
-
-struct _EMemoPreviewPrivate {
- icaltimezone *zone;
-};
-
-static gpointer parent_class;
-
-static void
-memo_preview_link_clicked (GtkHTML *html,
- const gchar *url)
-{
- GdkScreen *screen;
- GError *error = NULL;
-
- screen = gtk_widget_get_screen (GTK_WIDGET (html));
- gtk_show_uri (screen, url, GDK_CURRENT_TIME, &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-memo_preview_on_url (GtkHTML *html,
- const gchar *url)
-{
-#if 0
- char *msg;
- EMemoPreview *preview = data;
-
- if (url && *url) {
- msg = g_strdup_printf (_("Click to open %s"), url);
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), msg);
- g_free (msg);
- } else
- e_calendar_table_set_status_message (e_tasks_get_calendar_table (tasks), NULL);
-#endif
-}
-
-/* Converts a time_t to a string, relative to the specified timezone */
-static char *
-timet_to_str_with_zone (ECalComponentDateTime *dt,
- ECal *ecal,
- icaltimezone *default_zone)
-{
- struct icaltimetype itt;
- icaltimezone *zone;
- struct tm tm;
- char buf[256];
-
- if (dt->tzid) {
- /* If we can't find the zone, we'll guess its "local" */
- if (!e_cal_get_timezone (ecal, dt->tzid, &zone, NULL))
- zone = NULL;
- } else if (dt->value->is_utc) {
- zone = icaltimezone_get_utc_timezone ();
- } else {
- zone = NULL;
- }
-
-
- itt = *dt->value;
- if (zone)
- icaltimezone_convert_time (&itt, zone, default_zone);
- tm = icaltimetype_to_tm (&itt);
-
- e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (),
- FALSE, FALSE, buf, sizeof (buf));
-
- return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
-}
-
-static void
-memo_preview_write_html (GtkHTMLStream *stream,
- ECal *ecal,
- ECalComponent *comp,
- icaltimezone *default_zone)
-{
- ECalComponentText text;
- ECalComponentDateTime dt;
- gchar *str;
- GSList *l;
- gboolean one_added = FALSE;
-
- g_return_if_fail (E_IS_CAL_COMPONENT (comp));
-
- /* write document header */
- e_cal_component_get_summary (comp, &text);
-
- if (text.value)
- gtk_html_stream_printf (stream,
- "<HTML><BODY><H1>%s</H1>",
- text.value);
- else
- gtk_html_stream_printf (stream,
- "<HTML><BODY><H1><I>%s</I></H1>",
- _("Untitled"));
-
- /* write icons for the categories */
- e_cal_component_get_categories_list (comp, &l);
- if (l) {
- GSList *node;
- GString *string = g_string_new (NULL);
-
-
- gtk_html_stream_printf(stream, "<H3>%s: ", _("Categories"));
-
- for (node = l; node != NULL; node = node->next) {
- const char *icon_file;
-
- icon_file = e_categories_get_icon_file_for ((const char *) node->data);
- if (icon_file && g_file_test(icon_file, G_FILE_TEST_EXISTS)) {
- gchar *icon_file_uri = g_filename_to_uri (icon_file, NULL, NULL);
- gtk_html_stream_printf (stream, "<IMG ALT=\"%s\" SRC=\"%s\">",
- (const char *) node->data, icon_file_uri);
- g_free (icon_file_uri);
- one_added = TRUE;
- }
- else{
- if(one_added == FALSE){
- g_string_append_printf (string, "%s", (const char *) node->data);
- one_added = TRUE;
- }
- else{
- g_string_append_printf (string, ", %s", (const char *) node->data);
- }
- }
- }
-
- if (string->len > 0)
- gtk_html_stream_printf(stream, "%s", string->str);
-
- g_string_free (string, TRUE);
-
- gtk_html_stream_printf(stream, "</H3>");
-
- e_cal_component_free_categories_list (l);
- }
-
- /* Start table */
- gtk_html_stream_printf (stream, "<TABLE BORDER=\"0\" WIDTH=\"80%%\">"
- "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\" WIDTH=\"15%%\"></TD></TR>");
-
- /* write start date */
- e_cal_component_get_dtstart (comp, &dt);
- if (dt.value != NULL) {
- str = timet_to_str_with_zone (&dt, ecal, default_zone);
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>",
- _("Start Date:"), str);
-
- g_free (str);
- }
- e_cal_component_free_datetime (&dt);
-
- /* write description and URL */
- gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>");
-
- e_cal_component_get_description_list (comp, &l);
- if (l) {
- GSList *node;
-
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Description:"));
-
- gtk_html_stream_printf (stream, "<TD><TT>");
-
- for (node = l; node != NULL; node = node->next) {
- char *html;
-
- text = * (ECalComponentText *) node->data;
- html = camel_text_to_html (text.value ? text.value : "", CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES, 0);
-
- if (html)
- gtk_html_stream_printf (stream, "%s", html);
-
- g_free (html);
- }
-
- gtk_html_stream_printf (stream, "</TT></TD></TR>");
-
- e_cal_component_free_text_list (l);
- }
-
- /* URL */
- e_cal_component_get_url (comp, (const char **) &str);
- if (str) {
- gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Web Page:"));
- gtk_html_stream_printf (stream, "<TD><A HREF=\"%s\">%s</A></TD></TR>", str, str);
- }
-
- gtk_html_stream_printf (stream, "</TABLE>");
-
- /* close document */
- gtk_html_stream_printf (stream, "</BODY></HTML>");
-}
-
-static void
-memo_preview_finalize (GObject *object)
-{
- EMemoPreviewPrivate *priv;
-
- priv = E_MEMO_PREVIEW_GET_PRIVATE (object);
-
- /* XXX Nothing to do? */
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-memo_preview_class_init (EMemoPreviewClass *class)
-{
- GObjectClass *object_class;
- GtkHTMLClass *gtkhtml_class;
-
- parent_class = g_type_class_peek_parent (class);
- g_type_class_add_private (class, sizeof (EMemoPreviewPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = memo_preview_finalize;
-
- gtkhtml_class = GTK_HTML_CLASS (class);
- gtkhtml_class->link_clicked = memo_preview_link_clicked;
- gtkhtml_class->on_url = memo_preview_on_url;
-}
-
-static void
-memo_preview_init (EMemoPreview *preview)
-{
- EMemoPreviewPrivate *priv;
- GtkHTML *html;
-
- preview->priv = E_MEMO_PREVIEW_GET_PRIVATE (preview);
-
- html = GTK_HTML (preview);
- gtk_html_set_default_content_type (html, "charset=utf-8");
- gtk_html_load_empty (html);
-
- priv->zone = icaltimezone_get_utc_timezone ();
-}
-
-GType
-e_memo_preview_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EMemoPreviewClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) memo_preview_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EMemoPreview),
- 0, /* n_preallocs */
- (GInstanceInitFunc) memo_preview_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- GTK_TYPE_HTML, "EMemoPreview", &type_info, 0);
- }
-
- return type;
-}
-
-GtkWidget *
-e_memo_preview_new (void)
-{
- return g_object_new (E_TYPE_MEMO_PREVIEW, NULL);
-}
-
-icaltimezone *
-e_memo_preview_get_default_timezone (EMemoPreview *preview)
-{
- g_return_val_if_fail (E_IS_MEMO_PREVIEW (preview), NULL);
-
- return preview->priv->zone;
-}
-
-void
-e_memo_preview_set_default_timezone (EMemoPreview *preview,
- icaltimezone *zone)
-{
- g_return_if_fail (E_IS_MEMO_PREVIEW (preview));
- g_return_if_fail (zone != NULL);
-
- preview->priv->zone = zone;
-}
-
-void
-e_memo_preview_display (EMemoPreview *preview,
- ECal *ecal,
- ECalComponent *comp)
-{
- GtkHTMLStream *stream;
-
- g_return_if_fail (E_IS_MEMO_PREVIEW (preview));
- g_return_if_fail (E_IS_CAL_COMPONENT (comp));
-
- stream = gtk_html_begin (GTK_HTML (preview));
- memo_preview_write_html (stream, ecal, comp, preview->priv->zone);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
-}
-
-void
-e_memo_preview_clear (EMemoPreview *preview)
-{
- g_return_if_fail (E_IS_MEMO_PREVIEW (preview));
-
- gtk_html_load_empty (GTK_HTML (preview));
-}
-
diff --git a/calendar/gui/e-memo-preview.h b/calendar/gui/e-memo-preview.h
deleted file mode 100644
index 50d509e705..0000000000
--- a/calendar/gui/e-memo-preview.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Federico Mena Quintero <federico@ximian.com>
- * Damon Chaplin <damon@ximian.com>
- * Nathan Owens <pianocomp81@yahoo.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_MEMO_PREVIEW_H
-#define E_MEMO_PREVIEW_H
-
-#include <gtk/gtk.h>
-#include <libecal/e-cal.h>
-#include <gtkhtml/gtkhtml.h>
-
-/* Standard GObject macros */
-#define E_TYPE_MEMO_PREVIEW \
- (e_memo_preview_get_type ())
-#define E_MEMO_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreview))
-#define E_MEMO_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_INSTANCE_CAST_CLASS \
- ((cls), E_TYPE_MEMO_PREVIEW, EMemoPreviewClass))
-#define E_IS_MEMO_PREVIEW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MEMO_PREVIEW))
-#define E_IS_MEMO_PREVIEW_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_MEMO_PREVIEW))
-#define E_MEMO_PREVIEW_GET_CLASS \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_MEMO_PREVIEW, EMemoPreviewClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EMemoPreview EMemoPreview;
-typedef struct _EMemoPreviewClass EMemoPreviewClass;
-typedef struct _EMemoPreviewPrivate EMemoPreviewPrivate;
-
-struct _EMemoPreview {
- GtkHTML parent;
- EMemoPreviewPrivate *priv;
-};
-
-struct _EMemoPreviewClass {
- GtkHTMLClass parent_class;
-
- /* Notification signals */
- void (*selection_changed) (EMemoPreview *preview, int n_selected);
-};
-
-
-GType e_memo_preview_get_type (void);
-GtkWidget * e_memo_preview_new (void);
-icaltimezone * e_memo_preview_get_default_timezone
- (EMemoPreview *preview);
-void e_memo_preview_set_default_timezone
- (EMemoPreview *preview,
- icaltimezone *zone);
-void e_memo_preview_display (EMemoPreview *preview,
- ECal *ecal,
- ECalComponent *comp);
-void e_memo_preview_clear (EMemoPreview *preview);
-
-G_END_DECLS
-
-#endif /* E_MEMO_PREVIEW_H */