aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2005-12-17 21:48:18 +0800
committerTor Lillqvist <tml@src.gnome.org>2005-12-17 21:48:18 +0800
commit20b2bf609b1f818abeb936250f0a729178a243be (patch)
tree6f499fc177eb585e43b5317347d55ebdbd32c5b6 /calendar/gui/alarm-notify
parent2f8bf9ec0c72dee2f2aa29e69dc5f496a202818c (diff)
downloadgsoc2013-evolution-20b2bf609b1f818abeb936250f0a729178a243be.tar.gz
gsoc2013-evolution-20b2bf609b1f818abeb936250f0a729178a243be.tar.zst
gsoc2013-evolution-20b2bf609b1f818abeb936250f0a729178a243be.zip
When building against GTK+ 2.9.0 or later, and always on Win32, use the
2005-12-17 Tor Lillqvist <tml@novell.com> * gui/alarm-notify/alarm-queue.c: When building against GTK+ 2.9.0 or later, and always on Win32, use the GtkStatusIcon API instead of EggTrayIcon. svn path=/trunk/; revision=30814
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c101
1 files changed, 98 insertions, 3 deletions
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 83372f886f..45e14d699a 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -42,12 +42,26 @@
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkstock.h>
#include <gtk/gtktooltips.h>
+#include <gtk/gtkversion.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-exec.h>
#include <libgnome/gnome-sound.h>
#include <libgnomeui/gnome-dialog-util.h>
#include <libgnomeui/gnome-uidefs.h>
+
+#if GTK_CHECK_VERSION (2, 9, 0)
+#include <gtk/gtkstatusicon.h>
+#else
#include <e-util/eggtrayicon.h>
+#endif
+
+/* Evo's copy of eggtrayicon, for Win32, contains the gtkstatusicon
+ * API.
+ */
+#if GTK_CHECK_VERSION (2, 9, 0) || defined (GDK_WINDOWING_WIN32)
+#define USE_GTK_STATUS_ICON
+#endif
+
#include <e-util/e-icon-factory.h>
#include <libecal/e-cal-time-util.h>
#include <libecal/e-cal-component.h>
@@ -87,8 +101,12 @@ static GHashTable *client_alarms_hash = NULL;
static GList *tray_icons_list = NULL;
/* Top Tray Image */
+#ifndef USE_GTK_STATUS_ICON
static GtkWidget *tray_image = NULL;
static GtkWidget *tray_event_box = NULL;
+#else
+static GtkStatusIcon *tray_icon = NULL;
+#endif
static int tray_blink_id = -1;
static int tray_blink_state = FALSE;
static AlarmNotify *an;
@@ -771,8 +789,13 @@ typedef struct {
ECalComponent *comp;
ECal *client;
ECalView *query;
+#ifndef USE_GTK_STATUS_ICON
GtkWidget *tray_icon;
GtkWidget *image;
+#else
+ GtkStatusIcon *tray_icon;
+ GdkPixbuf *image;
+#endif
GtkTreeIter iter;
} TrayIconData;
@@ -946,15 +969,22 @@ open_alarm_dialog (TrayIconData *tray_data)
pixbuf = e_icon_factory_get_icon ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR);
+#ifndef USE_GTK_STATUS_ICON
gtk_image_set_from_pixbuf (GTK_IMAGE (tray_image), pixbuf);
+#else
+ gtk_status_icon_set_from_pixbuf (tray_icon, pixbuf);
+#endif
g_object_unref (pixbuf);
if (tray_blink_id > -1)
g_source_remove (tray_blink_id);
tray_blink_id = -1;
+#ifndef USE_GTK_STATUS_ICON
gtk_tooltips_set_tip (tooltips, tray_event_box, NULL, NULL);
-
+#else
+ gtk_status_icon_set_tooltip (tray_icon, NULL);
+#endif
if (!alarm_notifications_dialog)
alarm_notifications_dialog = notified_alarms_dialog_new ();
@@ -1211,14 +1241,22 @@ tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_da
"stock_appointment-reminder",
E_ICON_SIZE_LARGE_TOOLBAR);
+#ifndef USE_GTK_STATUS_ICON
gtk_image_set_from_pixbuf (GTK_IMAGE (tray_image), pixbuf);
+#else
+ gtk_status_icon_set_from_pixbuf (tray_icon, pixbuf);
+#endif
g_object_unref (pixbuf);
if (tray_blink_id > -1)
g_source_remove (tray_blink_id);
tray_blink_id = -1;
+#ifndef USE_GTK_STATUS_ICON
gtk_tooltips_set_tip (tooltips, tray_event_box, NULL, NULL);
+#else
+ gtk_status_icon_set_tooltip (tray_icon, NULL);
+#endif
ep = e_popup_new("org.gnome.evolution.alarmNotify.popup");
for (i=0;i<sizeof(tray_items)/sizeof(tray_items[0]);i++)
@@ -1234,6 +1272,34 @@ tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_da
return FALSE;
}
+#ifdef USE_GTK_STATUS_ICON
+static void
+icon_activated (GtkStatusIcon *icon)
+{
+ GdkEventButton event;
+
+ event.type = GDK_BUTTON_PRESS;
+ event.button = 1;
+ event.time = gtk_get_current_event_time ();
+
+ tray_icon_clicked_cb (NULL, &event, NULL);
+}
+
+static void
+popup_menu (GtkStatusIcon *icon,
+ guint button,
+ guint32 activate_time)
+{
+ GdkEventButton event;
+
+ event.type = GDK_BUTTON_PRESS;
+ event.button = button;
+ event.time = activate_time;
+
+ tray_icon_clicked_cb (NULL, &event, NULL);
+}
+#endif
+
static gboolean
tray_icon_blink_cb (gpointer data)
{
@@ -1246,7 +1312,11 @@ tray_icon_blink_cb (gpointer data)
"stock_appointment-reminder",
E_ICON_SIZE_LARGE_TOOLBAR);
+#ifndef USE_GTK_STATUS_ICON
gtk_image_set_from_pixbuf (GTK_IMAGE (tray_image), pixbuf);
+#else
+ gtk_status_icon_set_from_pixbuf (tray_icon, pixbuf);
+#endif
g_object_unref (pixbuf);
return TRUE;
@@ -1260,8 +1330,10 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
QueuedAlarm *qa;
ECalComponent *comp;
const char *summary, *description, *location;
+#ifndef USE_GTK_STATUS_ICON
GtkWidget *tray_icon=NULL, *image=NULL;
GtkTooltips *tooltips;
+#endif
TrayIconData *tray_data;
ECalComponentText text;
GSList *text_list;
@@ -1303,8 +1375,9 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
location = _("No location information available.");
/* create the tray icon */
+#ifndef USE_GTK_STATUS_ICON
tooltips = gtk_tooltips_new ();
-
+#endif
current_zone = config_data_get_timezone ();
alarm_str = timet_to_str_with_zone (trigger, current_zone);
start_str = timet_to_str_with_zone (qa->instance->occur_start, current_zone);
@@ -1325,7 +1398,9 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
tray_data->comp = g_object_ref (e_cal_component_clone (comp));
tray_data->client = cqa->parent_client->client;
tray_data->query = g_object_ref (cqa->parent_client->query);
+#ifndef USE_GTK_STATUS_ICON
tray_data->image = image;
+#endif
tray_data->blink_state = FALSE;
tray_data->snooze_set = FALSE;
g_object_ref (tray_data->client);
@@ -1337,11 +1412,20 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
char *tip;
tip = g_strdup_printf (_("You have %d alarms"), g_list_length (tray_icons_list));
+#ifndef USE_GTK_STATUS_ICON
gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), tray_event_box, tip, NULL);
g_free (tip);
+#else
+ gtk_status_icon_set_tooltip (tray_icon, tip);
+#endif
}
- else
+ else {
+#ifndef USE_GTK_STATUS_ICON
gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), tray_event_box, str, NULL);
+#else
+ gtk_status_icon_set_tooltip (tray_icon, NULL);
+#endif
+ }
g_free (start_str);
g_free (end_str);
@@ -1649,7 +1733,9 @@ check_midnight_refresh (gpointer user_data)
void
alarm_queue_init (gpointer data)
{
+#ifndef USE_GTK_STATUS_ICON
GtkWidget *tray_icon;
+#endif
an = data;
g_return_if_fail (alarm_queue_inited == FALSE);
@@ -1665,6 +1751,7 @@ alarm_queue_init (gpointer data)
/* install timeout handler (every 30 mins) for not missing the midnight refresh */
g_timeout_add (1800000, (GSourceFunc) check_midnight_refresh, NULL);
+#ifndef USE_GTK_STATUS_ICON
tray_icon = GTK_WIDGET (egg_tray_icon_new ("Evolution Alarm"));
tray_image = e_icon_factory_get_image ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR);
tray_event_box = gtk_event_box_new ();
@@ -1673,6 +1760,14 @@ alarm_queue_init (gpointer data)
g_signal_connect (G_OBJECT (tray_event_box), "button_press_event",
G_CALLBACK (tray_icon_clicked_cb), NULL);
gtk_widget_show_all (tray_icon);
+#else
+ tray_icon = gtk_status_icon_new ();
+ gtk_status_icon_set_from_pixbuf (tray_icon, e_icon_factory_get_icon ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR));
+ g_signal_connect (G_OBJECT (tray_icon), "activate",
+ G_CALLBACK (icon_activated), NULL);
+ g_signal_connect (G_OBJECT (tray_icon), "popup-menu",
+ G_CALLBACK (popup_menu), NULL);
+#endif
#ifdef HAVE_LIBNOTIFY
notify_init("Evolution Alarms");