projects/pk-update-icon

changeset 1:483f5fe9d2b2

change icon and tooltip of the tray icon
author Pavol Rusnak <stick@gk2.sk>
date Mon Sep 26 18:59:14 2011 +0200 (2011-09-26)
parents f5e03fc667f8
children 847ae02bc13b
files main.c
line diff
     1.1 --- a/main.c	Mon Sep 26 18:52:04 2011 +0200
     1.2 +++ b/main.c	Mon Sep 26 18:59:14 2011 +0200
     1.3 @@ -7,6 +7,8 @@
     1.4  	int critical;
     1.5  } UpdatesInfo;
     1.6  
     1.7 +GtkStatusIcon *tray_icon;
     1.8 +
     1.9  void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data)
    1.10  {
    1.11  	char *argv[2] = { "gpk-update-viewer", NULL };
    1.12 @@ -37,8 +39,6 @@
    1.13  
    1.14  static GtkStatusIcon *create_tray_icon()
    1.15  {
    1.16 -	GtkStatusIcon *tray_icon;
    1.17 -
    1.18  	tray_icon = gtk_status_icon_new();
    1.19  	g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL);
    1.20  	g_signal_connect(G_OBJECT(tray_icon), "popup-menu", G_CALLBACK(tray_icon_on_menu), NULL);
    1.21 @@ -54,7 +54,15 @@
    1.22  	struct UpdatesInfo info;
    1.23  	query_packagekit(&info);
    1.24  	send_notify(info.normal, info.critical);
    1.25 -	return FALSE;
    1.26 +	if (info.critical > 0) {
    1.27 +		gtk_status_icon_set_from_icon_name(tray_icon, "software-update-urgent");
    1.28 +		gtk_status_icon_set_tooltip_text(tray_icon, "Critical updates available.");
    1.29 +	} else
    1.30 +	if (info.normal > 0) {
    1.31 +		gtk_status_icon_set_from_icon_name(tray_icon, "software-update-available");
    1.32 +		gtk_status_icon_set_tooltip_text(tray_icon, "Updates available.");
    1.33 +	}
    1.34 +	return TRUE;
    1.35  }
    1.36  
    1.37  int main(int argc, char **argv)
    1.38 @@ -65,7 +73,8 @@
    1.39  	tray_icon = create_tray_icon();
    1.40  	init_notify();
    1.41  
    1.42 -	g_timeout_add(3000, periodic_check, NULL);
    1.43 +	periodic_check(NULL);
    1.44 +	g_timeout_add(15 * 60 * 1000, periodic_check, NULL);
    1.45  
    1.46  	gtk_main();
    1.47