Add tooltip showing BSSID and flags.
[dhcpcd-ui] / menu.c
diff --git a/menu.c b/menu.c
index 22b2aead67f81bcd44e330e16cac6956b9dc98db..fe5ce9637603cfa431aec9abeb88cc440acb94af 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -26,6 +26,7 @@
 
 #include "dhcpcd-gtk.h"
 #include "menu.h"
+#include "wpa.h"
 
 static const char *copyright = "Copyright (c) 2009 Roy Marples";
 
@@ -71,6 +72,12 @@ url_hook(GtkAboutDialog *dialog, const char *url, _unused gpointer p)
 }
 
 static void
+ssid_hook(_unused GtkMenuItem *item, gpointer data)
+{
+       wpa_configure((const struct if_ap *)data);
+}
+
+static void
 on_about(_unused GtkMenuItem *item, _unused gpointer data)
 {
        gtk_window_set_default_icon_name(GTK_STOCK_NETWORK);
@@ -95,6 +102,7 @@ add_scan_results(GtkMenu *menu, const struct if_msg *ifm)
        double perc;
        int strength;
        const char *icon;
+       char *tip;
 
        for (gl = ifm->scan_results; gl; gl = gl->next) {
                ifa = (const struct if_ap *)gl->data;
@@ -122,10 +130,16 @@ add_scan_results(GtkMenu *menu, const struct if_msg *ifm)
                perc = strength / 100.0;
                gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(bar), perc);
 
+               tip = g_strconcat(ifa->bssid, " ", ifa->flags, NULL);
+               gtk_widget_set_tooltip_text(item, tip);
+               g_free(tip);
+
                gtk_widget_show(label);
                gtk_widget_show(bar);
                gtk_widget_show(image);
                gtk_widget_show(box);
+               g_signal_connect(G_OBJECT(item), "activate",
+                               G_CALLBACK(ssid_hook), gl->data);
                gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
        }
 }