From 20b2bf609b1f818abeb936250f0a729178a243be Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sat, 17 Dec 2005 13:48:18 +0000 Subject: When building against GTK+ 2.9.0 or later, and always on Win32, use the 2005-12-17 Tor Lillqvist * 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 --- calendar/ChangeLog | 4 ++ calendar/gui/alarm-notify/alarm-queue.c | 101 +++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 3 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index d5d8f4d0c1..3d0b233c21 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -18,6 +18,10 @@ dirent. Use g_filename_{to,from}_uri(). Open files in binary mode. Use e_xml_parse_file() instead of xmlParseFile(). + * 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. + 2005-12-15 Srinivasa Ragavan ** Fixes bug #324094 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 #include #include +#include #include #include #include #include #include + +#if GTK_CHECK_VERSION (2, 9, 0) +#include +#else #include +#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 #include #include @@ -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;iinstance->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"); -- cgit v1.2.3