aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/Makefile.am8
-rw-r--r--calendar/gui/alarm-notify/alarm-notify-dialog.c189
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.glade14
3 files changed, 154 insertions, 57 deletions
diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am
index 8cf9b749fc..26965fffea 100644
--- a/calendar/gui/alarm-notify/Makefile.am
+++ b/calendar/gui/alarm-notify/Makefile.am
@@ -28,13 +28,18 @@ INCLUDES = \
-I$(top_builddir)/libical/src/libical \
-I$(top_srcdir)/widgets \
-I$(includedir) \
+ $(GAL_CFLAGS) \
$(BONOBO_VFS_GNOME_CFLAGS) \
$(BONOBO_CONF_CFLAGS) \
+ $(BONOBO_HTML_GNOME_LIBS) \
$(EXTRA_GNOME_CFLAGS) \
-DEVOLUTION_DATADIR=\""$(datadir)"\" \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
+ -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \
-DEVOLUTION_LOCALEDIR=\""$(localedir)"\"
+iconsdir = $(datadir)/images/evolution
+
gladedir = $(datadir)/evolution/glade
glade_DATA = \
@@ -58,9 +63,12 @@ evolution_alarm_notify_LDADD = \
$(top_builddir)/calendar/cal-util/libcal-util.la \
$(top_builddir)/libical/src/libical/libical.la \
$(top_builddir)/libwombat/libwombat.la \
+ $(top_builddir)/e-util/libeutil.la \
$(BONOBO_CONF_LIBS) \
$(BONOBO_VFS_GNOME_LIBS) \
+ $(BONOBO_HTML_GNOME_LIBS) \
$(EXTRA_GNOME_LIBS) \
+ $(GAL_LIBS) \
$(INTLLIBS)
oafdir = $(datadir)/oaf
diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c
index 665419241f..c6644264c6 100644
--- a/calendar/gui/alarm-notify/alarm-notify-dialog.c
+++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c
@@ -1,7 +1,7 @@
/* Evolution calendar - alarm notification dialog
*
* Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
+ * Copyright (C) 2001 Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@ximian.com>
*
@@ -21,6 +21,8 @@
*/
#include <config.h>
+#include <stdio.h>
+#include <string.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkspinbutton.h>
#include <gtk/gtksignal.h>
@@ -28,11 +30,18 @@
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-winhints.h>
+#include <libgnomeui/gnome-window-icon.h>
#include <glade/glade.h>
+#include <e-util/e-time-utils.h>
+#include <e-util/e-unicode-i18n.h>
#include <gal/widgets/e-unicode.h>
+#include <gal/widgets/e-scroll-frame.h>
+#include <gtkhtml/gtkhtml.h>
+#include <gtkhtml/gtkhtml-stream.h>
#include "alarm-notify-dialog.h"
+GtkWidget *make_html_display (gchar *widget_name, char *s1, char *s2, int scroll, int shadow);
/* The useful contents of the alarm notify dialog */
typedef struct {
@@ -45,6 +54,7 @@ typedef struct {
GtkWidget *heading;
GtkWidget *message;
GtkWidget *snooze_time;
+ GtkWidget *html;
AlarmNotifyFunc func;
gpointer func_data;
@@ -122,18 +132,108 @@ edit_clicked_cb (GtkWidget *widget, gpointer data)
gtk_widget_destroy (an->dialog);
}
+static void
+url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *stream, gpointer data)
+{
+
+ if (!strncmp ("file:///", url, strlen ("file:///"))) {
+ FILE *fp;
+ const char *filename = url + strlen ("file://");
+ char buf[4096];
+ size_t len;
+
+ fp = fopen (filename, "r");
+
+ if (fp == NULL) {
+ g_warning ("Error opening image: %s\n", url);
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
+ return;
+ }
+
+ while ((len = fread (buf, 1, sizeof(buf), fp)) > 0)
+ gtk_html_stream_write (stream, buf, len);
+
+ if (feof (fp)) {
+ fclose (fp);
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
+ return;
+ }
+
+ fclose (fp);
+ }
+
+ g_warning ("Error loading image");
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
+ return;
+}
+
+GtkWidget *
+make_html_display (gchar *widget_name, char *s1, char *s2, int scroll, int shadow)
+{
+ GtkWidget *html, *frame;
+
+ gtk_widget_push_visual(gdk_rgb_get_visual());
+ gtk_widget_push_colormap(gdk_rgb_get_cmap());
+
+ html = gtk_html_new();
+
+ gtk_html_set_default_content_type (GTK_HTML (html),
+ "charset=utf-8");
+ gtk_html_load_empty (GTK_HTML (html));
+
+ gtk_signal_connect (GTK_OBJECT (html), "url_requested",
+ GTK_SIGNAL_FUNC (url_requested_cb),
+ NULL);
+
+ gtk_widget_pop_colormap();
+ gtk_widget_pop_visual();
+
+ frame = e_scroll_frame_new(NULL, NULL);
+
+ e_scroll_frame_set_policy(E_SCROLL_FRAME(frame),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+
+ e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (frame),
+ GTK_SHADOW_IN);
+
+ gtk_widget_set_usize (frame, 300, 200);
+
+ gtk_container_add(GTK_CONTAINER (frame), html);
+
+ gtk_widget_show_all(frame);
+
+ gtk_object_set_user_data(GTK_OBJECT (frame), html);
+ return frame;
+}
+
+static void
+write_times (GtkHTMLStream *stream, char *start, char *end)
+{
+ if (start)
+ gtk_html_stream_printf (stream, "<b>%s</b> %s<br>", U_("Starting:"), start);
+ if (end)
+ gtk_html_stream_printf (stream, "<b>%s</b> %s<br>", U_("Ending:"), end);
+
+}
+
/* Creates a heading for the alarm notification dialog */
-static char *
-make_heading (CalComponentVType vtype, time_t occur_start, time_t occur_end)
+static void
+write_html_heading (GtkHTMLStream *stream, const char *message, CalComponentVType vtype, time_t occur_start, time_t occur_end)
{
char *buf;
char s[128], e[128];
+ char *start = NULL, *end = NULL;
+ char *bg_path = "file://" EVOLUTION_ICONSDIR "/bcg.png";
+ char *image_path = "file://" EVOLUTION_ICONSDIR "/alarm.png";
if (occur_start != -1) {
struct tm tm;
tm = *localtime (&occur_start);
strftime (s, sizeof (s), "%A %b %d %Y %H:%M", &tm);
+ start = e_utf8_from_locale_string (s);
}
if (occur_end != -1) {
@@ -141,51 +241,33 @@ make_heading (CalComponentVType vtype, time_t occur_start, time_t occur_end)
tm = *localtime (&occur_end);
strftime (e, sizeof (e), "%A %b %d %Y %H:%M", &tm);
+ end = e_utf8_from_locale_string (e);
}
/* I love combinatorial explosion */
+ gtk_html_stream_printf (stream,
+ "<HTML><BODY background=\"%s\">"
+ "<TABLE WIDTH=\"100%%\">"
+ "<TR>"
+ "<TD><IMG SRC=\"%s\" ALIGN=\"top\" BORDER=\"0\"></TD>"
+ "<TD><H1>%s</H1></TD>"
+ "</TR>"
+ "</TABLE>",
+ bg_path,
+ image_path,
+ U_("Evolution Alarm"));
+
+ gtk_html_stream_printf (stream, "<br><br><font size=\"+2\">%s</font><br><br>", message);
switch (vtype) {
case CAL_COMPONENT_EVENT:
- if (occur_start != -1) {
- if (occur_end != -1)
- buf = g_strdup_printf (_("Notification about your appointment "
- "starting on %s and ending on %s"),
- s, e);
- else
- buf = g_strdup_printf (_("Notification about your appointment "
- "starting on %s"),
- s);
- } else {
- if (occur_end != -1)
- buf = g_strdup_printf (_("Notification about your appointment "
- "ending on %s"),
- e);
- else
- buf = g_strdup_printf (_("Notification about your appointment"));
- }
+ /* gtk_html_stream_printf (stream, "%s<br>", U_("Notification about your appointment")); */
+ write_times (stream, start, end);
break;
-
case CAL_COMPONENT_TODO:
- if (occur_start != -1) {
- if (occur_end != -1)
- buf = g_strdup_printf (_("Notification about your task "
- "starting on %s and ending on %s"),
- s, e);
- else
- buf = g_strdup_printf (_("Notification about your task "
- "starting on %s"),
- s);
- } else {
- if (occur_end != -1)
- buf = g_strdup_printf (_("Notification about your task "
- "ending on %s"),
- e);
- else
- buf = g_strdup_printf (_("Notification about your task"));
- }
+ /* gtk_html_stream_printf (stream, "%s<br>", U_("Notification about your task")); */
+ write_times (stream, start, end);
break;
-
default:
/* Only VEVENTs and VTODOs can have alarms */
g_assert_not_reached ();
@@ -193,7 +275,9 @@ make_heading (CalComponentVType vtype, time_t occur_start, time_t occur_end)
break;
}
- return buf;
+ g_free (start);
+ g_free (end);
+ return;
}
/**
@@ -218,9 +302,8 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
{
AlarmNotify *an;
char buf[256];
- char *heading;
- char *msg;
struct tm tm_trigger;
+ GtkHTMLStream *stream;
g_return_val_if_fail (trigger != -1, FALSE);
@@ -248,6 +331,7 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
an->heading = glade_xml_get_widget (an->xml, "heading");
an->message = glade_xml_get_widget (an->xml, "message");
an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time");
+ an->html = gtk_object_get_user_data (GTK_OBJECT (glade_xml_get_widget (an->xml, "frame")));
if (!(an->dialog && an->close && an->snooze && an->edit && an->heading && an->message
&& an->snooze_time)) {
@@ -262,25 +346,14 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
GTK_SIGNAL_FUNC (dialog_destroy_cb), an);
/* Title */
-
tm_trigger = *localtime (&trigger);
strftime (buf, sizeof (buf), _("Alarm on %A %b %d %Y %H:%M"), &tm_trigger);
gtk_window_set_title (GTK_WINDOW (an->dialog), buf);
- /* Heading */
-
- heading = make_heading (vtype, occur_start, occur_end);
- gtk_label_set_text (GTK_LABEL (an->heading), heading);
- g_free (heading);
-
- /* Message */
-
- msg = e_utf8_to_gtk_string (an->message, message);
- if (msg) {
- gtk_label_set_text (GTK_LABEL (an->message), msg);
- g_free (msg);
- } else
- g_message ("Could not convert the alarm message from UTF8");
+ /* html heading */
+ stream = gtk_html_begin (GTK_HTML (an->html));
+ write_html_heading (stream, message, vtype, occur_start, occur_end);
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
/* Connect actions */
@@ -306,7 +379,9 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
gtk_widget_realize (an->dialog);
gnome_win_hints_set_state (an->dialog, WIN_STATE_STICKY);
+ gnome_window_icon_set_from_file (GTK_WINDOW (an->dialog), EVOLUTION_ICONSDIR "/alarm.png");
gtk_widget_show (an->dialog);
return TRUE;
}
+
diff --git a/calendar/gui/alarm-notify/alarm-notify.glade b/calendar/gui/alarm-notify/alarm-notify.glade
index 19af18f010..e71828ca53 100644
--- a/calendar/gui/alarm-notify/alarm-notify.glade
+++ b/calendar/gui/alarm-notify/alarm-notify.glade
@@ -85,6 +85,20 @@
<fill>False</fill>
</child>
</widget>
+
+ <widget>
+ <class>Custom</class>
+ <name>frame</name>
+ <creation_function>make_html_display</creation_function>
+ <int1>0</int1>
+ <int2>0</int2>
+ <last_modification_time>Thu, 11 Oct 2001 08:19:04 GMT</last_modification_time>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
</widget>
<widget>