Re: [patch] special icon for ad-hoc networks.
- From: Robert Love <rml novell com>
- To: networkmanager-list <networkmanager-list gnome org>
- Subject: Re: [patch] special icon for ad-hoc networks.
- Date: Wed, 17 May 2006 16:08:14 -0400
On Thu, 2006-05-11 at 17:34 -0400, Robert Love wrote:
> I grabbed my own gauntlet.
>
> Attached patch gives Ad-Hoc networks a special icon.
>
> I just used some gtk stock icon of a computer. We can -- we must -- do
> better.
>
> Also, a TODO item: putting both the encrypted and an ad-hoc network icon
> would be ugly and take up too much room. So we should have a comingling
> of the two icons that says "encrypted and ad-hoc". Right now I ignore
> that case and show all encrypted networks with the current encrypted
> icon, Ad-hoc or not.
I went ahead and committed an updated and tested version of this patch
(attached) to CVS. Please bang on it.
Two fundamental changes:
- I used our existing nm-adhoc icon instead of the stock
thing I was using before.
- Instead of showing all encrypted networks with the encrypted
icon, ad-hoc or infrastructure, I now show all ad-hoc
networks, encrypted or not, with the ad-hoc icon. In other
words, I think communicating "this is ad-hoc" is most
important.
A TODO item is still to draw up an "nm-encrypted-adhoc" icon so we can
use that for the missing "adhoc + encrypted" case.
Enjoy,
Robert Love
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/NetworkManager/ChangeLog,v
retrieving revision 1.866.2.65
diff -u -r1.866.2.65 ChangeLog
--- ChangeLog 17 May 2006 15:03:27 -0000 1.866.2.65
+++ ChangeLog 17 May 2006 20:02:43 -0000
@@ -1,5 +1,19 @@
2006-05-17 Robert Love <rml novell com>
+ Functionality to differentiate Ad-Hoc networks from infrastructure
+ networks in the applet, by displaying a special icon:
+ * gnome/applet/applet-dbus-devices.c: Set the mode for new networks.
+ * gnome/applet/applet.c: Pass 'applet' to network_menu_item_update().
+ * gnome/applet/menu-items.c: Set a special icon in the scan list for
+ ad-hoc networks. TODO: Add a third icon representing "encrypted and
+ Ad-Hoc". Right now, we display the same icon for all Ad-Hoc wireless
+ networks, encrypted or not.
+ * gnome/applet/wireless-network.c, gnome/applet/wireless-network.h: New
+ accessor functions to get and set the mode of a given network,
+ wireless_network_get_mode() and wireless_network_set_mode().
+
+2006-05-17 Robert Love <rml novell com>
+
Functionality to automatically add BSSIDs to the allowed-MAC list as
one roams from access point to access point on a given network:
* src/NetworkManagerUtils.c: Add nm_ethernet_addresses_are_equal(),
Index: gnome/applet/applet-dbus-devices.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-devices.c,v
retrieving revision 1.51.2.3
diff -u -r1.51.2.3 applet-dbus-devices.c
--- gnome/applet/applet-dbus-devices.c 20 Apr 2006 20:39:51 -0000 1.51.2.3
+++ gnome/applet/applet-dbus-devices.c 17 May 2006 20:02:44 -0000
@@ -106,7 +106,7 @@
typedef struct DriverCBData
{
- NMApplet * applet;
+ NMApplet * applet;
NetworkDevice * dev;
} DriverCBData;
@@ -120,7 +120,7 @@
static void nma_dbus_device_get_driver_cb (DBusPendingCall *pcall, void *user_data)
{
DBusMessage * reply;
- NMApplet * applet = (NMApplet *) user_data;
+ NMApplet * applet = (NMApplet *) user_data;
DriverCBData * data = (DriverCBData *) user_data;
const char * driver;
@@ -164,7 +164,7 @@
/*
* nma_dbus_device_get_driver
*
- * Get the a device's driver name
+ * Get the device's driver name
*
*/
static void nma_dbus_device_get_driver (NetworkDevice *dev, NMApplet *applet)
@@ -581,6 +581,7 @@
network_device_remove_wireless_network (dev, tmp_net);
}
+ wireless_network_set_mode (net, mode);
wireless_network_set_capabilities (net, capabilities);
wireless_network_set_strength (net, strength);
if (act_net && strlen (act_net) && (strcmp (act_net, op) == 0))
Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.112.2.5
diff -u -r1.112.2.5 applet.c
--- gnome/applet/applet.c 4 Apr 2006 19:36:55 -0000 1.112.2.5
+++ gnome/applet/applet.c 17 May 2006 20:02:44 -0000
@@ -1585,6 +1585,7 @@
AddNetworksCB * cb_data = (AddNetworksCB *)user_data;
NMNetworkMenuItem * item;
GtkCheckMenuItem * gtk_item;
+ NMApplet * applet;
g_return_if_fail (dev != NULL);
g_return_if_fail (net != NULL);
@@ -1592,22 +1593,23 @@
g_return_if_fail (cb_data->menu != NULL);
g_return_if_fail (cb_data->applet != NULL);
- item = network_menu_item_new (cb_data->applet->encryption_size_group);
+ applet = cb_data->applet;
+ item = network_menu_item_new (applet->encryption_size_group);
gtk_item = network_menu_item_get_check_item (item);
gtk_menu_shell_append (GTK_MENU_SHELL (cb_data->menu), GTK_WIDGET (gtk_item));
- if ( (cb_data->applet->nm_state == NM_STATE_CONNECTED)
- || (cb_data->applet->nm_state == NM_STATE_CONNECTING))
+ if ( (applet->nm_state == NM_STATE_CONNECTED)
+ || (applet->nm_state == NM_STATE_CONNECTING))
{
if (network_device_get_active (dev) && wireless_network_get_active (net))
gtk_check_menu_item_set_active (gtk_item, TRUE);
}
- network_menu_item_update (item, net, cb_data->has_encrypted);
+ network_menu_item_update (applet, item, net, cb_data->has_encrypted);
g_object_set_data (G_OBJECT (gtk_item), "network", g_strdup (wireless_network_get_essid (net)));
g_object_set_data (G_OBJECT (gtk_item), "device", g_strdup (network_device_get_nm_path (dev)));
g_object_set_data (G_OBJECT (gtk_item), "nm-item-data", item);
- g_signal_connect (G_OBJECT (gtk_item), "activate", G_CALLBACK (nma_menu_item_activate), cb_data->applet);
+ g_signal_connect (G_OBJECT (gtk_item), "activate", G_CALLBACK (nma_menu_item_activate), applet);
gtk_widget_show (GTK_WIDGET (gtk_item));
}
Index: gnome/applet/menu-items.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/menu-items.c,v
retrieving revision 1.12
diff -u -r1.12 menu-items.c
--- gnome/applet/menu-items.c 29 Dec 2005 16:54:34 -0000 1.12
+++ gnome/applet/menu-items.c 17 May 2006 20:02:44 -0000
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <glib/gi18n.h>
#include <string.h>
+#include <iwlib.h>
#include "menu-items.h"
#include "applet-dbus.h"
@@ -234,14 +235,16 @@
}
-/* has_encrypted means that the wireless network has an encrypted
+/* is_encrypted means that the wireless network has an encrypted
* area, and thus we need to allow for spacing.
*/
-void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted)
+void network_menu_item_update (NMApplet *applet, NMNetworkMenuItem *item,
+ WirelessNetwork *network, const gboolean is_encrypted)
{
char * display_essid;
gdouble percent;
- int capabilities;
+ gboolean encrypted = FALSE;
+ gboolean adhoc = FALSE;
g_return_if_fail (item != NULL);
g_return_if_fail (network != NULL);
@@ -256,10 +259,22 @@
/* Deal with the encrypted icon */
g_object_set (item->security_image, "visible", is_encrypted, NULL);
- capabilities = wireless_network_get_capabilities (network);
- if ( (capabilities & NM_802_11_CAP_PROTO_WEP)
- || (capabilities & NM_802_11_CAP_PROTO_WPA)
- || (capabilities & NM_802_11_CAP_PROTO_WPA2))
+ if (wireless_network_get_capabilities (network) & (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_PROTO_WPA2))
+ encrypted = TRUE;
+
+ if (wireless_network_get_mode (network) == IW_MODE_ADHOC)
+ adhoc = TRUE;
+
+ /*
+ * Set a special icon for special circumstances: encrypted or ad-hoc.
+ *
+ * FIXME: We do not currently differentiate between encrypted and non-encrypted Ad-Hoc
+ * networks; they all receive the same icon. Ideally, we should have a third icon
+ * type for encrypted Ad-Hoc networks.
+ */
+ if (adhoc)
+ gtk_image_set_from_pixbuf (GTK_IMAGE (item->security_image), applet->adhoc_icon);
+ else if (encrypted)
{
/*
* We want to use "network-wireless-encrypted," which was recently added to the icon spec,
@@ -267,7 +282,12 @@
*
* XXX: Would be nice to require gtk-2.6. For now, we have an ugly and a simple version.
*/
-#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
+#if GTK_CHECK_VERSION(2,6,0)
+ if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), "network-wireless-encrypted"))
+ gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "network-wireless-encrypted", GTK_ICON_SIZE_MENU);
+ else
+ gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "gnome-lockscreen", GTK_ICON_SIZE_MENU);
+# else
GdkPixbuf *pixbuf;
GtkIconTheme *icon_theme;
@@ -276,20 +296,13 @@
if (!pixbuf)
pixbuf = gtk_icon_theme_load_icon (icon_theme, "gnome-lockscreen", GTK_ICON_SIZE_MENU, 0, NULL);
gtk_image_set_from_pixbuf (GTK_IMAGE (item->security_image), pixbuf);
-# else
- if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), "network-wireless-encrypted"))
- gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "network-wireless-encrypted", GTK_ICON_SIZE_MENU);
- else
- gtk_image_set_from_icon_name (GTK_IMAGE (item->security_image), "gnome-lockscreen", GTK_ICON_SIZE_MENU);
#endif
}
- else
+ else /* neither encrypted nor Ad-Hoc */
gtk_image_set_from_stock (GTK_IMAGE (item->security_image), NULL, GTK_ICON_SIZE_MENU);
}
-
-
/****************************************************************
* Utility stuff
****************************************************************/
@@ -299,34 +312,34 @@
static char *eel_make_valid_utf8 (const char *name)
{
GString *string;
- const char *remainder, *invalid;
+ const char *rem, *invalid;
int remaining_bytes, valid_bytes;
string = NULL;
- remainder = name;
+ rem = name;
remaining_bytes = strlen (name);
while (remaining_bytes != 0) {
- if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
+ if (g_utf8_validate (rem, remaining_bytes, &invalid)) {
break;
}
- valid_bytes = invalid - remainder;
+ valid_bytes = invalid - rem;
if (string == NULL) {
string = g_string_sized_new (remaining_bytes);
}
- g_string_append_len (string, remainder, valid_bytes);
+ g_string_append_len (string, rem, valid_bytes);
g_string_append_c (string, '?');
remaining_bytes -= valid_bytes + 1;
- remainder = invalid + 1;
+ rem = invalid + 1;
}
if (string == NULL) {
return g_strdup (name);
}
- g_string_append (string, remainder);
+ g_string_append (string, rem);
g_string_append (string, _(" (invalid Unicode)"));
g_assert (g_utf8_validate (string->str, -1, NULL));
Index: gnome/applet/menu-items.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/menu-items.h,v
retrieving revision 1.1
diff -u -r1.1 menu-items.h
--- gnome/applet/menu-items.h 27 Apr 2005 18:05:02 -0000 1.1
+++ gnome/applet/menu-items.h 17 May 2006 20:02:44 -0000
@@ -41,7 +41,7 @@
NMNetworkMenuItem *network_menu_item_new (GtkSizeGroup *encryption_size_group);
GtkCheckMenuItem *network_menu_item_get_check_item (NMNetworkMenuItem *item);
-void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted);
+void network_menu_item_update (NMApplet *applet, NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted);
/* Helper function; escapes an essid for human readable display. */
char *nm_menu_network_escape_essid_for_display (const char *essid);
Index: gnome/applet/wireless-network.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/wireless-network.c,v
retrieving revision 1.3
diff -u -r1.3 wireless-network.c
--- gnome/applet/wireless-network.c 29 Dec 2005 16:54:34 -0000 1.3
+++ gnome/applet/wireless-network.c 17 May 2006 20:02:45 -0000
@@ -22,6 +22,8 @@
#include <glib.h>
+#include <iwlib.h>
+
#include "wireless-network.h"
/*
@@ -35,6 +37,7 @@
char * essid;
gboolean active;
gint8 strength;
+ int mode;
int capabilities;
};
@@ -170,6 +173,24 @@
g_return_if_fail (net != NULL);
net->capabilities = capabilities;
+}
+
+/*
+ * Accessors for mode
+ */
+int wireless_network_get_mode (WirelessNetwork *net)
+{
+ g_return_val_if_fail (net != NULL, FALSE);
+
+ return net->mode;
+}
+
+void wireless_network_set_mode (WirelessNetwork *net, int mode)
+{
+ g_return_if_fail (net != NULL);
+ g_return_if_fail ((mode == IW_MODE_ADHOC) || (mode == IW_MODE_INFRA));
+
+ net->mode = mode;
}
/*
Index: gnome/applet/wireless-network.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/wireless-network.h,v
retrieving revision 1.2
diff -u -r1.2 wireless-network.h
--- gnome/applet/wireless-network.h 29 Dec 2005 16:54:34 -0000 1.2
+++ gnome/applet/wireless-network.h 17 May 2006 20:02:45 -0000
@@ -41,6 +41,9 @@
int wireless_network_get_capabilities (WirelessNetwork *net);
void wireless_network_set_capabilities (WirelessNetwork *net, int capabilities);
+int wireless_network_get_mode (WirelessNetwork *net);
+void wireless_network_set_mode (WirelessNetwork *net, int mode);
+
gint8 wireless_network_get_strength (WirelessNetwork *net);
void wireless_network_set_strength (WirelessNetwork *net, gint8 strength);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]