9
#include <glade/glade.h>
10
#include <libnotify/notify.h>
12
#include "update-notifier.h"
17
show_notification (TrayApplet *ta)
19
NotifyNotification *n;
22
// only show once the icon is realy availabe
23
if(!GTK_WIDGET_REALIZED(ta->tray_icon))
26
/* Get the location of the icon. If there's no location, come back
27
* in a few seconds. */
28
gdk_window_get_origin (GTK_WIDGET(ta->tray_icon)->window, &x, &y);
29
if ((x <= 0) || (y <= 0))
32
/* Check whether the icon is still visible, may have gone away */
33
if (!GTK_WIDGET_VISIBLE (ta->tray_icon))
36
/* Create and show the notification */
37
n = notify_notification_new (_("Crashreport detected"),
38
_("A application has crashed on your "
39
"system (now or in the past). "
40
"Click on the notification icon to "
43
GTK_STOCK_DIALOG_INFO,
44
GTK_WIDGET(ta->tray_icon));
45
notify_notification_set_timeout (n, 60000);
46
notify_notification_show (n, NULL);
47
g_object_set_data (G_OBJECT(ta->tray_icon), "notification", n);
53
crashreport_check (TrayApplet *ta)
55
NotifyNotification *n;
57
const gchar *crashreport;
58
int crashreports_found = 0;
60
g_debug("crashreport_check\n");
62
// check for (new) reports
63
dir=g_dir_open(CRASHREPORT_DIR, 0, NULL);
65
g_warning("can't read %s directory\n",HOOKS_DIR);
67
g_debug("reading '%s' dir", CRASHREPORT_DIR);
68
while((crashreport=g_dir_read_name(dir)) != NULL) {
69
g_debug("investigating file '%s' ", crashreport);
76
if(crashreports_found) {
77
if (GTK_WIDGET_VISIBLE(GTK_WIDGET(ta->tray_icon)))
80
gtk_tooltips_set_tip (GTK_TOOLTIPS(ta->tooltip),
81
GTK_WIDGET (ta->eventbox),
82
_("Crashreport detected"),
83
_("Click on the notification icon to "
84
"display details. "));
86
gtk_widget_show (GTK_WIDGET(ta->tray_icon));
88
/* Check whether the user doesn't like notifications */
89
if (gconf_client_get_bool ((GConfClient*) ta->user_data,
90
GCONF_KEY_NO_UPDATE_NOTIFICATIONS, NULL))
93
/* Show the notification, after a delay so it doesn't look ugly
94
* if we've just logged in */
95
g_timeout_add(5000, (GSourceFunc)(show_notification), ta);
98
gtk_widget_hide (GTK_WIDGET(ta->tray_icon));
99
gtk_widget_unrealize (GTK_WIDGET(ta->tray_icon));
101
/* Hide any notification popup */
102
n = g_object_get_data (G_OBJECT(ta->tray_icon), "notification");
104
notify_notification_close (n, NULL);
105
g_object_set_data (G_OBJECT(ta->tray_icon), "notification", NULL);
113
button_release_cb (GtkWidget *widget,
114
GdkEventButton *event,
117
if ((event->button == 1) && (event->type == GDK_BUTTON_RELEASE)) {
118
// fire up the crashreport tool
119
g_debug("fire up the crashreport tool\n");
120
g_spawn_command_line_async("/usr/bin/bug-reporting-tool",
129
crashreport_tray_icon_init (TrayApplet *ta)
133
ta->user_data = gconf_client_get_default();
134
g_signal_connect (G_OBJECT(ta->tray_icon),
135
"button-release-event",
136
G_CALLBACK (button_release_cb),
139
/* Check for crashes for the first time */
140
crashreport_check (ta);