[patch] more stetic, broken up, 2/2
- From: Robert Love <rml novell com>
- To: networkmanager-list gnome org
- Subject: [patch] more stetic, broken up, 2/2
- Date: Thu, 16 Jun 2005 21:32:41 -0400
On Thu, 2005-06-16 at 21:30 -0400, Robert Love wrote:
> Let's break these up into two patches, since I think some of these
> changes are not contentious whatsoever.
Meanwhile, this patch includes the following changes:
- Don't center the "Wireless Networks" menu item.
- Actually make the "Wireless Networks" menu item inactive.
I realize this was done deliberately (with the nasty signal
hack), but the thing /is/ insensitive, unselectable, and a
label, not a menu item. The greyed-out look is in.
- Use gtk_menu_new_with_label(), not the previous complications.
- Consolidate a few seemingly related functions, all called from
the same place once, into one.
- Draw a horizontal separator above the "Wireless Networks"
label.
- Misc. cleanup: net patch change is -36 lines!
If needed, we can spur debate, bring in experts, vote, draw straws, or
consult the tea leaves on this one. I think it is the right way to go.
Best,
Robert Love
Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.12
diff -u -u -r1.12 applet.c
--- gnome/applet/applet.c 12 Jun 2005 14:35:58 -0000 1.12
+++ gnome/applet/applet.c 16 Jun 2005 20:12:00 -0000
@@ -1298,16 +1298,17 @@
case DEVICE_TYPE_WIRELESS_ETHERNET:
{
- NMWirelessMenuItem *item = wireless_menu_item_new ();
- GtkMenuItem *gtk_item = wireless_menu_item_get_item (item);
- wireless_menu_item_update (item, device, n_devices);
-
- g_object_set_data (G_OBJECT (gtk_item), "device", g_strdup (network_device_get_nm_path (device)));
- g_object_set_data (G_OBJECT (gtk_item), "nm-item-data", item);
- g_signal_connect(G_OBJECT (gtk_item), "activate", G_CALLBACK (nmwa_menu_item_activate), applet);
+ NMWirelessMenuItem *item = wireless_menu_item_new (device, n_devices);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (gtk_item));
- gtk_widget_show (GTK_WIDGET (gtk_item));
+ g_object_set_data (G_OBJECT (item->menu_item), "device", g_strdup (network_device_get_nm_path (device)));
+ g_object_set_data (G_OBJECT (item->menu_item), "nm-item-data", item);
+ g_signal_connect (G_OBJECT (item->menu_item), "activate", G_CALLBACK (nmwa_menu_item_activate), applet);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item->separator));
+ gtk_widget_show (GTK_WIDGET (item->separator));
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item->menu_item));
+ gtk_widget_show (GTK_WIDGET (item->menu_item));
break;
}
Index: gnome/applet/menu-items.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/menu-items.c,v
retrieving revision 1.2
diff -u -u -r1.2 menu-items.c
--- gnome/applet/menu-items.c 6 May 2005 02:58:05 -0000 1.2
+++ gnome/applet/menu-items.c 16 Jun 2005 20:12:00 -0000
@@ -101,76 +101,34 @@
gtk_widget_set_sensitive (GTK_WIDGET (item->check_item), network_device_get_link (dev));
}
-
-/****************************************************************
- * Wireless menu item
- ****************************************************************/
-
-struct NMWirelessMenuItem
-{
- GtkMenuItem *menu_item;
- GtkLabel *label;
-};
-
-
-static gboolean label_expose (GtkWidget *widget)
+NMWirelessMenuItem *wireless_menu_item_new (NetworkDevice *dev, const gint n_devices)
{
- /* Bad hack to make the label draw normally, instead of insensitive. */
- widget->state = GTK_STATE_NORMAL;
-
- return FALSE;
-}
-
-NMWirelessMenuItem *wireless_menu_item_new (void)
-{
- NMWirelessMenuItem *item = g_malloc0 (sizeof (NMWirelessMenuItem));
-
- g_return_val_if_fail (item != NULL, NULL);
-
- item->menu_item = GTK_MENU_ITEM (gtk_menu_item_new ());
-
- /* Make sure it looks slightly different if the label determines the width of the widget */
- item->label = GTK_LABEL (gtk_label_new (NULL));
- gtk_misc_set_padding (GTK_MISC (item->label), 6, 0);
- g_signal_connect (G_OBJECT (item->label), "expose-event", G_CALLBACK (label_expose), NULL);
-
- gtk_container_add (GTK_CONTAINER (item->menu_item), GTK_WIDGET (item->label));
- gtk_widget_show (GTK_WIDGET (item->label));
-
- gtk_widget_set_sensitive (GTK_WIDGET (item->menu_item), FALSE);
-
- return item;
-}
-
-GtkMenuItem *wireless_menu_item_get_item (NMWirelessMenuItem *item)
-{
- g_return_val_if_fail (item != NULL, NULL);
-
- return item->menu_item;
-}
-
-void wireless_menu_item_update (NMWirelessMenuItem *item, NetworkDevice *dev, const gint n_devices)
-{
- char *text;
- const char *dev_name;
+ NMWirelessMenuItem *item = g_malloc0 (sizeof (NMWirelessMenuItem));
gint n_essids;
+ char *text;
- g_return_if_fail (dev != NULL);
- g_return_if_fail (item != NULL);
+ g_return_val_if_fail (dev != NULL, NULL);
+ g_return_val_if_fail (item != NULL, NULL);
g_assert (network_device_is_wireless (dev));
- n_essids = network_device_get_num_wireless_networks (dev);
- dev_name = network_device_get_desc (dev) ? network_device_get_desc (dev) : network_device_get_iface (dev);
+ item->separator = gtk_separator_menu_item_new ();
+ n_essids = network_device_get_num_wireless_networks (dev);
if (n_devices > 1)
+ {
+ const char *dev_name = network_device_get_desc (dev) ? network_device_get_desc (dev) : network_device_get_iface (dev);
text = g_strdup_printf (ngettext ("Wireless Network (%s)", "Wireless Networks (%s)", n_essids), dev_name);
+ }
else
text = g_strdup (ngettext ("Wireless Network", "Wireless Networks", n_essids));
- gtk_label_set_markup (GTK_LABEL (item->label), text);
+ item->menu_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (text));
+ gtk_widget_set_sensitive (GTK_WIDGET (item->menu_item), FALSE);
+
g_free (text);
-}
+ return item;
+}
/****************************************************************
* Wireless Network menu item
Index: gnome/applet/menu-items.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/menu-items.h,v
retrieving revision 1.1
diff -u -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 16 Jun 2005 20:12:00 -0000
@@ -27,15 +27,20 @@
typedef struct NMWiredMenuItem NMWiredMenuItem;
-typedef struct NMWirelessMenuItem NMWirelessMenuItem;
typedef struct NMNetworkMenuItem NMNetworkMenuItem;
+typedef struct NMWirelessMenuItem
+{
+ GtkWidget *separator;
+ GtkMenuItem *menu_item;
+ GtkLabel *label;
+} NMWirelessMenuItem;
NMWiredMenuItem *wired_menu_item_new (void);
GtkCheckMenuItem *wired_menu_item_get_check_item (NMWiredMenuItem *item);
void wired_menu_item_update (NMWiredMenuItem *item, NetworkDevice *dev, const gint n_devices);
-NMWirelessMenuItem *wireless_menu_item_new (void);
+NMWirelessMenuItem *wireless_menu_item_new (NetworkDevice *dev, const gint nr_devices);
GtkMenuItem *wireless_menu_item_get_item (NMWirelessMenuItem *item);
void wireless_menu_item_update (NMWirelessMenuItem *item, NetworkDevice *dev, const gint n_devices);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]