34
notify_action_cb (NotifyNotification *notification,
38
g_autoptr(GDesktopAppInfo) info = NULL;
39
g_autoptr(GdkAppLaunchContext) context = NULL;
40
g_autoptr(GError) error = NULL;
42
info = g_desktop_app_info_new (LIVEPATCH_DESKTOP_FILE);
44
g_warning ("Could not find application '%s'", LIVEPATCH_DESKTOP_FILE);
48
context = gdk_display_get_app_launch_context (gdk_display_get_default ());
49
if (!g_app_info_launch (G_APP_INFO (info), NULL, G_APP_LAUNCH_CONTEXT (context), &error)) {
50
g_warning ("Could not launch application '%s'", LIVEPATCH_DESKTOP_FILE);
32
55
show_notification (const char *summary, const char *body, const char *icon)
34
NotifyNotification *n = notify_notification_new (summary, body, icon);
57
NotifyNotification *n;
58
g_autoptr(GDesktopAppInfo) info = NULL;
59
g_autoptr(GError) error = NULL;
61
n = notify_notification_new (summary, body, icon);
35
62
notify_notification_set_timeout (n, 60000);
36
notify_notification_show (n, NULL);
64
info = g_desktop_app_info_new (LIVEPATCH_DESKTOP_FILE);
66
notify_notification_add_action (n, "settings", _("Show Settings…"),
67
notify_action_cb, NULL, NULL);
68
notify_notification_add_action (n, "default", _("Show Settings…"),
69
notify_action_cb, NULL, NULL);
71
g_warning ("Could not find application '%s'. The notification will not "
72
"have a 'Show Settings…' button.", LIVEPATCH_DESKTOP_FILE);
75
g_signal_connect (n, "closed", G_CALLBACK (gtk_main_quit), NULL);
77
if (!notify_notification_show (n, &error)) {
78
g_warning ("Could not show notification: '%s", error->message);
94
139
return difftime (status_stat.st_mtim.tv_sec, boot_timestamp) >= 0;
98
143
show_status_notification ()
100
145
g_autofree gchar *event = NULL;
101
146
g_autofree gchar *description = NULL;
103
148
if (!g_file_test (STATUS_PATH, G_FILE_TEST_EXISTS))
106
151
if (!file_modified_after_boot (STATUS_PATH))
109
154
get_event_from_file (STATUS_PATH, &event, &description);
130
show_notification (_("Canonical Livepatch"), body, NULL);
176
return show_notification (_("Canonical Livepatch"), body, NULL);
136
184
main (int argc, char **argv)
186
gtk_init (&argc, &argv);
138
187
init_notification ();
141
show_status_notification ();
190
if (show_status_notification ())
143
193
return EXIT_SUCCESS;