aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/stats/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/stats/functions.c')
-rw-r--r--src/plugins/stats/functions.c87
1 files changed, 59 insertions, 28 deletions
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c
index 937f7f61..a7d2134c 100644
--- a/src/plugins/stats/functions.c
+++ b/src/plugins/stats/functions.c
@@ -491,9 +491,7 @@ updateDaemonStatus (void *delta)
491 static GtkWidget *statusConnexionsLabel; 491 static GtkWidget *statusConnexionsLabel;
492 static GtkWidget *statusConnexionsPic; 492 static GtkWidget *statusConnexionsPic;
493#if GTK_CHECK_VERSION (2,10,0) 493#if GTK_CHECK_VERSION (2,10,0)
494 static GdkPixbuf *iconNoDaemon; 494 static GtkStatusIcon *trayIcon;
495 static GdkPixbuf *iconDisconnected;
496 static GdkPixbuf *iconConnected;
497#endif 495#endif
498 496
499 if (once) 497 if (once)
@@ -505,11 +503,15 @@ updateDaemonStatus (void *delta)
505 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 503 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
506 "statusConnexionsPic"); 504 "statusConnexionsPic");
507#if GTK_CHECK_VERSION (2,10,0) 505#if GTK_CHECK_VERSION (2,10,0)
508 char *iconFile; 506 GtkIconSet *iconSet;
507 GtkIconSource *iconSource;
508 char *iconPath;
509 char *finalPath; 509 char *finalPath;
510 char *instDir; 510 char *instDir;
511 char *dataDir; 511 char *dataDir;
512 512
513 trayIcon = GNUNET_GTK_get_trayIcon ();
514
513 instDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); 515 instDir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
514 dataDir = g_strconcat (instDir, "/../gnunet-gtk/", NULL); 516 dataDir = g_strconcat (instDir, "/../gnunet-gtk/", NULL);
515#if MINGW 517#if MINGW
@@ -520,18 +522,48 @@ updateDaemonStatus (void *delta)
520#endif 522#endif
521 GNUNET_free (instDir); 523 GNUNET_free (instDir);
522 g_free (dataDir); 524 g_free (dataDir);
523 iconFile = 525 iconSource = gtk_icon_source_new ();
526
527 iconSet = gtk_icon_set_new ();
528 iconPath =
524 g_strconcat (finalPath, "gnunet-gtk-status-nodaemon.svg", NULL); 529 g_strconcat (finalPath, "gnunet-gtk-status-nodaemon.svg", NULL);
525 iconNoDaemon = gdk_pixbuf_new_from_file (iconFile, NULL); 530 gtk_icon_source_set_filename (iconSource, iconPath);
526 g_free (iconFile); 531 g_free (iconPath);
527 iconFile = 532 gtk_icon_source_set_size_wildcarded (iconSource, TRUE);
533 gtk_icon_set_add_source (iconSet, iconSource);
534 iconPath =
535 g_strconcat (finalPath, "gnunet-gtk-status-nodaemon.png", NULL);
536 gtk_icon_source_set_filename (iconSource, iconPath);
537 g_free (iconPath);
538 gtk_icon_source_set_size_wildcarded (iconSource, FALSE);
539 gtk_icon_set_add_source (iconSet, iconSource);
540
541 gtk_icon_factory_add (GNUNET_GTK_get_iconFactory(),
542 "gnunet-gtk-status-nodaemon",
543 iconSet);
544 gtk_icon_set_unref (iconSet);
545
546 iconSet = gtk_icon_set_new ();
547 iconPath =
528 g_strconcat (finalPath, "gnunet-gtk-status-disconnected.svg", NULL); 548 g_strconcat (finalPath, "gnunet-gtk-status-disconnected.svg", NULL);
529 iconDisconnected = gdk_pixbuf_new_from_file (iconFile, NULL); 549 gtk_icon_source_set_filename (iconSource, iconPath);
530 g_free (iconFile); 550 g_free (iconPath);
531 iconFile = 551 gtk_icon_source_set_size_wildcarded (iconSource, TRUE);
532 g_strconcat (finalPath, "gnunet-gtk-status-connected.svg", NULL); 552 gtk_icon_set_add_source (iconSet, iconSource);
533 iconConnected = gdk_pixbuf_new_from_file (iconFile, NULL); 553 iconPath =
534 g_free (iconFile); 554 g_strconcat (finalPath, "gnunet-gtk-status-disconnected.png", NULL);
555 gtk_icon_source_set_filename (iconSource, iconPath);
556 g_free (iconPath);
557 gtk_icon_source_set_size_wildcarded (iconSource, FALSE);
558 gtk_icon_set_add_source (iconSet, iconSource);
559
560 gtk_icon_factory_add (GNUNET_GTK_get_iconFactory(),
561 "gnunet-gtk-status-disconnected",
562 iconSet);
563 gtk_icon_set_unref (iconSet);
564
565
566 gtk_icon_source_free (iconSource);
535 GNUNET_free (finalPath); 567 GNUNET_free (finalPath);
536#endif 568#endif
537 569
@@ -552,10 +584,10 @@ updateDaemonStatus (void *delta)
552 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic), 584 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
553 GTK_STOCK_DIALOG_ERROR, 1); 585 GTK_STOCK_DIALOG_ERROR, 1);
554#if GTK_CHECK_VERSION (2,10,0) 586#if GTK_CHECK_VERSION (2,10,0)
555 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 587 gtk_status_icon_set_tooltip (trayIcon,
556 _("Unknown status")); 588 _("Unknown status"));
557 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (), 589 gtk_status_icon_set_from_stock (trayIcon,
558 iconNoDaemon); 590 "gnunet-gtk-status-nodaemon");
559#endif 591#endif
560 last_status = -1; 592 last_status = -1;
561 } 593 }
@@ -569,7 +601,7 @@ updateDaemonStatus (void *delta)
569 gtk_label_set_text (GTK_LABEL (statusConnexionsLabel), 601 gtk_label_set_text (GTK_LABEL (statusConnexionsLabel),
570 _("Connected to 1 peer")); 602 _("Connected to 1 peer"));
571#if GTK_CHECK_VERSION (2,10,0) 603#if GTK_CHECK_VERSION (2,10,0)
572 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 604 gtk_status_icon_set_tooltip (trayIcon,
573 _ 605 _
574 ("GNUnet - Connected to 1 peer")); 606 ("GNUnet - Connected to 1 peer"));
575#endif 607#endif
@@ -585,14 +617,13 @@ updateDaemonStatus (void *delta)
585 label = 617 label =
586 g_strdup_printf (_("GNUnet - Connected to %Lu peers"), 618 g_strdup_printf (_("GNUnet - Connected to %Lu peers"),
587 connected_peers); 619 connected_peers);
588 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 620 gtk_status_icon_set_tooltip (trayIcon, label);
589 label);
590 g_free (label); 621 g_free (label);
591#endif 622#endif
592 } 623 }
593#if GTK_CHECK_VERSION (2,10,0) 624#if GTK_CHECK_VERSION (2,10,0)
594 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (), 625 gtk_status_icon_set_from_stock (trayIcon,
595 iconConnected); 626 "gnunet-gtk-status-connected");
596#endif 627#endif
597 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic), 628 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
598 GTK_STOCK_NETWORK, 1); 629 GTK_STOCK_NETWORK, 1);
@@ -606,10 +637,10 @@ updateDaemonStatus (void *delta)
606 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic), 637 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
607 GTK_STOCK_DISCONNECT, 1); 638 GTK_STOCK_DISCONNECT, 1);
608#if GTK_CHECK_VERSION (2,10,0) 639#if GTK_CHECK_VERSION (2,10,0)
609 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 640 gtk_status_icon_set_tooltip (trayIcon,
610 _("GNUnet - Disconnected")); 641 _("GNUnet - Disconnected"));
611 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (), 642 gtk_status_icon_set_from_stock (trayIcon,
612 iconDisconnected); 643 "gnunet-gtk-status-disconnected");
613#endif 644#endif
614 last_status = 0; 645 last_status = 0;
615 } 646 }
@@ -621,10 +652,10 @@ updateDaemonStatus (void *delta)
621 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic), 652 gtk_image_set_from_stock (GTK_IMAGE (statusConnexionsPic),
622 GTK_STOCK_NO, 1); 653 GTK_STOCK_NO, 1);
623#if GTK_CHECK_VERSION (2,10,0) 654#if GTK_CHECK_VERSION (2,10,0)
624 gtk_status_icon_set_tooltip (GNUNET_GTK_get_trayIcon (), 655 gtk_status_icon_set_tooltip (trayIcon,
625 _("GNUnet - Daemon not running")); 656 _("GNUnet - Daemon not running"));
626 gtk_status_icon_set_from_pixbuf (GNUNET_GTK_get_trayIcon (), 657 gtk_status_icon_set_from_stock (trayIcon,
627 iconNoDaemon); 658 "gnunet-gtk-status-nodaemon");
628#endif 659#endif
629 last_status = -2; 660 last_status = -2;
630 } 661 }