diff options
author | guidog <guidog@517b70f8-ed25-0410-8bf6-f5db08f7b76e> | 2009-01-10 13:25:30 +0000 |
---|---|---|
committer | guidog <guidog@517b70f8-ed25-0410-8bf6-f5db08f7b76e> | 2009-01-10 13:25:30 +0000 |
commit | c6d317a94d1857eb17617d4f85874f5139c8c8bf (patch) | |
tree | 300e5a874c932c7026f8df084a4cc0aa095a589d /src/krb5-auth-applet.c | |
parent | af9d2e62e392533987d17ada803bb6327c54afee (diff) |
don't popup the dialog if we have a tray icon
The user can happily refresh the credentials by left clicking on the
tray icon. When using libnotify we also remind him to do so every
NOTIFY_SECONDS (300).
git-svn-id: http://svn.gnome.org/svn/krb5-auth-dialog/trunk@104 517b70f8-ed25-0410-8bf6-f5db08f7b76e
Diffstat (limited to 'src/krb5-auth-applet.c')
-rw-r--r-- | src/krb5-auth-applet.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/krb5-auth-applet.c b/src/krb5-auth-applet.c index 5dc9145..4a11d09 100644 --- a/src/krb5-auth-applet.c +++ b/src/krb5-auth-applet.c @@ -28,23 +28,26 @@ #include "krb5-auth-notify.h" #endif +#define NOTIFY_SECONDS 300 /* update the tray icon's tooltip and icon */ int ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) { gchar* expiry_text; - int interval = expiry - time (0); + int now = time(0); + int remaining = expiry - now; + static int last_warn = 0; static gboolean expiry_notified = FALSE; - if (interval > 0) { + if (remaining > 0) { int hours, minutes; - if (interval >= 3600) { - hours = interval / 3600; - minutes = (interval % 3600) / 60; + if (remaining >= 3600) { + hours = remaining / 3600; + minutes = (remaining % 3600) / 60; expiry_text = g_strdup_printf (_("Your credentials expire in %.2d:%.2dh"), hours, minutes); } else { - minutes = interval / 60; + minutes = remaining / 60; expiry_text = g_strdup_printf (ngettext( "Your credentials expire in %d minute", "Your credentials expire in %d minutes", @@ -57,6 +60,11 @@ ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) _("Network credentials valid"), _("Your Kerberos credentials have been refreshed."), NULL); expiry_notified = FALSE; + } else if (remaining < applet->pw_prompt_secs && (now - last_warn) > NOTIFY_SECONDS) { + ka_send_event_notification (applet, NOTIFY_URGENCY_NORMAL, + _("Network credentials expiring"), + expiry_text, NULL); + last_warn = now; } #endif } else { @@ -68,6 +76,7 @@ ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) _("Network credentials expired"), _("Your Kerberos credentails have expired."), NULL); expiry_notified = TRUE; + last_warn = 0; } #endif } |