Mercurial > projects > pk-update-icon
changeset 1:483f5fe9d2b2
change icon and tooltip of the tray icon
author | Pavol Rusnak <stick@gk2.sk> |
---|---|
date | Mon, 26 Sep 2011 18:59:14 +0200 |
parents | f5e03fc667f8 |
children | 847ae02bc13b |
files | main.c |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Mon Sep 26 18:52:04 2011 +0200 +++ b/main.c Mon Sep 26 18:59:14 2011 +0200 @@ -7,6 +7,8 @@ int critical; } UpdatesInfo; +GtkStatusIcon *tray_icon; + void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data) { char *argv[2] = { "gpk-update-viewer", NULL }; @@ -37,8 +39,6 @@ static GtkStatusIcon *create_tray_icon() { - GtkStatusIcon *tray_icon; - tray_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL); g_signal_connect(G_OBJECT(tray_icon), "popup-menu", G_CALLBACK(tray_icon_on_menu), NULL); @@ -54,7 +54,15 @@ struct UpdatesInfo info; query_packagekit(&info); send_notify(info.normal, info.critical); - return FALSE; + if (info.critical > 0) { + gtk_status_icon_set_from_icon_name(tray_icon, "software-update-urgent"); + gtk_status_icon_set_tooltip_text(tray_icon, "Critical updates available."); + } else + if (info.normal > 0) { + gtk_status_icon_set_from_icon_name(tray_icon, "software-update-available"); + gtk_status_icon_set_tooltip_text(tray_icon, "Updates available."); + } + return TRUE; } int main(int argc, char **argv) @@ -65,7 +73,8 @@ tray_icon = create_tray_icon(); init_notify(); - g_timeout_add(3000, periodic_check, NULL); + periodic_check(NULL); + g_timeout_add(15 * 60 * 1000, periodic_check, NULL); gtk_main();