mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 06:10:11 +01:00
Fri Oct 1 18:26:03 2004 Jonathan Blandford <jrb@redhat.com>
* panel-applet/menu-info.c (nm_menu_wired_class_init): update look
and feel. We should be back to working, and have a good, clean
look.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@183 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
999ee47b63
commit
b46b359554
5 changed files with 124 additions and 63 deletions
|
|
@ -1,3 +1,9 @@
|
|||
Fri Oct 1 18:26:03 2004 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* panel-applet/menu-info.c (nm_menu_wired_class_init): update look
|
||||
and feel. We should be back to working, and have a good, clean
|
||||
look.
|
||||
|
||||
2004-09-30 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* info-daemon/NetworkManagerInfo.c
|
||||
|
|
|
|||
|
|
@ -560,10 +560,18 @@ static void nmwa_menu_add_device_item (GtkWidget *menu, NetworkDevice *device, g
|
|||
|
||||
g_return_if_fail (menu != NULL);
|
||||
|
||||
menu_item = nm_menu_network_new (applet->image_size_group);
|
||||
nm_menu_network_update (NM_MENU_NETWORK (menu_item), device, n_devices);
|
||||
if (applet->active_device == device && device->type == DEVICE_TYPE_WIRED_ETHERNET)
|
||||
if (device->type == DEVICE_TYPE_WIRED_ETHERNET)
|
||||
{
|
||||
menu_item = nm_menu_wired_new ();
|
||||
nm_menu_wired_update (NM_MENU_WIRED (menu_item), device, n_devices);
|
||||
if (applet->active_device == device)
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_item = nm_menu_network_new ();
|
||||
nm_menu_network_update (NM_MENU_NETWORK (menu_item), device, n_devices);
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (menu_item), "device", g_strdup (device->nm_device));
|
||||
g_signal_connect(G_OBJECT (menu_item), "activate", G_CALLBACK(nmwa_menu_item_activate), applet);
|
||||
|
|
@ -575,21 +583,12 @@ static void nmwa_menu_add_device_item (GtkWidget *menu, NetworkDevice *device, g
|
|||
static void nmwa_menu_add_custom_essid_item (GtkWidget *menu, NMWirelessApplet *applet)
|
||||
{
|
||||
GtkWidget *menu_item;
|
||||
GtkWidget *spacer;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
|
||||
menu_item = gtk_menu_item_new ();
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
spacer = gtk_frame_new (NULL);
|
||||
gtk_size_group_add_widget (applet->image_size_group, spacer);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (spacer), GTK_SHADOW_NONE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), spacer, FALSE, FALSE, 0);
|
||||
label = gtk_label_new (_("Other Wireless Network..."));
|
||||
label = gtk_label_new (_("Other Wireless Networks..."));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (menu_item), hbox);
|
||||
gtk_container_add (GTK_CONTAINER (menu_item), label);
|
||||
gtk_widget_show_all (menu_item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
||||
}
|
||||
|
|
@ -875,7 +874,6 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
|
|||
gtk_menu_item_set_submenu (GTK_MENU_ITEM(applet->toplevel_menu), applet->menu);
|
||||
g_signal_connect (menu_bar, "button_press_event", G_CALLBACK (do_not_eat_button_press), NULL);
|
||||
|
||||
applet->image_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
applet->encryption_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
gtk_widget_show (menu_bar);
|
||||
gtk_widget_show (applet->toplevel_menu);
|
||||
|
|
|
|||
|
|
@ -144,7 +144,6 @@ typedef struct
|
|||
GtkWidget *about_dialog;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *toplevel_menu;
|
||||
GtkSizeGroup *image_size_group;
|
||||
GtkSizeGroup *encryption_size_group;
|
||||
} NMWirelessApplet;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,47 +32,95 @@
|
|||
#include "NMWirelessAppletDbus.h"
|
||||
#include <config.h>
|
||||
|
||||
|
||||
|
||||
G_DEFINE_TYPE (NMMenuWired, nm_menu_wired, GTK_TYPE_CHECK_MENU_ITEM);
|
||||
|
||||
|
||||
static void
|
||||
nm_menu_wired_init (NMMenuWired *menu_wired)
|
||||
{
|
||||
menu_wired->label = gtk_label_new (NULL);
|
||||
gtk_misc_set_alignment (GTK_MISC (menu_wired->label), 0.0, 0.5);
|
||||
gtk_container_add (GTK_CONTAINER (menu_wired), menu_wired->label);
|
||||
gtk_widget_show (menu_wired->label);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nm_menu_wired_class_init (NMMenuWiredClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
nm_menu_wired_new (void)
|
||||
{
|
||||
GtkWidget *retval = g_object_new (nm_menu_wired_get_type (), NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nm_menu_wired_update (NMMenuWired *menu_wired,
|
||||
NetworkDevice *network,
|
||||
gint n_devices)
|
||||
{
|
||||
gchar *text;
|
||||
gchar *network_name;
|
||||
|
||||
g_assert (network->type == DEVICE_TYPE_WIRED_ETHERNET);
|
||||
|
||||
network_name = network->hal_name ? network->hal_name : network->nm_name;
|
||||
|
||||
if (n_devices > 1)
|
||||
text = g_strdup_printf (_("Wired Network (%s)"), network_name);
|
||||
else
|
||||
text = g_strdup (_("Wired Network"));
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (menu_wired->label), text);
|
||||
}
|
||||
|
||||
|
||||
/* NMMenuNetwork */
|
||||
G_DEFINE_TYPE (NMMenuNetwork, nm_menu_network, GTK_TYPE_MENU_ITEM);
|
||||
|
||||
|
||||
static gboolean
|
||||
label_expose (GtkWidget *widget)
|
||||
{
|
||||
/* Bad hack to make the label draw normally, instead of insensitive. */
|
||||
widget->state = GTK_STATE_NORMAL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_menu_network_init (NMMenuNetwork *menu_network)
|
||||
{
|
||||
GtkWidget *eb;
|
||||
|
||||
eb = gtk_event_box_new ();
|
||||
menu_network->label = gtk_label_new (NULL);
|
||||
gtk_container_add (GTK_CONTAINER (eb), menu_network->label);
|
||||
gtk_container_add (GTK_CONTAINER (menu_network), eb);
|
||||
gtk_widget_show_all (eb);
|
||||
|
||||
/* Make sure it looks slightly different if the label determines the width of the widget */
|
||||
gtk_misc_set_padding (GTK_MISC (menu_network->label), 6, 0);
|
||||
g_signal_connect (menu_network->label, "expose-event", G_CALLBACK (label_expose), NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (menu_network), menu_network->label);
|
||||
gtk_widget_show (menu_network->label);
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (menu_network), FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nm_menu_network_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous_style)
|
||||
{
|
||||
GTK_WIDGET_CLASS (nm_menu_network_parent_class)->style_set (widget, previous_style);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_menu_network_class_init (NMMenuNetworkClass *menu_network)
|
||||
{
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
widget_class = GTK_WIDGET_CLASS (menu_network);
|
||||
|
||||
widget_class->style_set = nm_menu_network_style_set;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
nm_menu_network_new (GtkSizeGroup *image_size_group)
|
||||
nm_menu_network_new (void)
|
||||
{
|
||||
GtkWidget *retval = g_object_new (nm_menu_network_get_type (), NULL);
|
||||
|
||||
gtk_size_group_add_widget (image_size_group,
|
||||
NM_MENU_NETWORK (retval)->image);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
@ -82,33 +130,23 @@ nm_menu_network_update (NMMenuNetwork *menu_network,
|
|||
NetworkDevice *network,
|
||||
gint n_devices)
|
||||
{
|
||||
char *text;
|
||||
char *text, *markup;
|
||||
const char *network_name;
|
||||
gint n_essids;
|
||||
|
||||
menu_network->type = network->type;
|
||||
n_essids = g_slist_length (network->networks);
|
||||
network_name = network->hal_name ? network->hal_name : network->nm_name;
|
||||
|
||||
switch (menu_network->type)
|
||||
{
|
||||
case DEVICE_TYPE_WIRED_ETHERNET:
|
||||
if (n_devices > 1)
|
||||
text = g_strdup_printf (_("Wired Network (%s)"), network_name);
|
||||
else
|
||||
text = g_strdup (_("Wired Network"));
|
||||
break;
|
||||
case DEVICE_TYPE_WIRELESS_ETHERNET:
|
||||
if (n_devices > 1)
|
||||
text = g_strdup_printf (ngettext ("Wireless Network (%s)", "Wireless Networks (%s)", n_essids), network_name);
|
||||
else
|
||||
text = g_strdup (ngettext ("Wireless Network", "Wireless Networks", n_essids));
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
gtk_label_set_text (GTK_LABEL (menu_network->label), text);
|
||||
g_assert (network->type == DEVICE_TYPE_WIRELESS_ETHERNET);
|
||||
|
||||
if (n_devices > 1)
|
||||
text = g_strdup_printf (ngettext ("Wireless Network (%s)", "Wireless Networks (%s)", n_essids), network_name);
|
||||
else
|
||||
text = g_strdup (ngettext ("Wireless Network", "Wireless Networks", n_essids));
|
||||
|
||||
markup = g_markup_printf_escaped ("<b>%s</b>", text);
|
||||
gtk_label_set_markup (GTK_LABEL (menu_network->label), markup);
|
||||
g_free (markup);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,28 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include "NMWirelessApplet.h"
|
||||
|
||||
#define NM_TYPE_MENU_WIRED (nm_menu_wired_get_type ())
|
||||
#define NM_MENU_WIRED(widget) (G_TYPE_CHECK_INSTANCE_CAST ((widget), NM_TYPE_MENU_WIRED, NMMenuWired))
|
||||
|
||||
#define NM_TYPE_MENU_NETWORK (nm_menu_network_get_type ())
|
||||
#define NM_MENU_NETWORK(widget) (G_TYPE_CHECK_INSTANCE_CAST ((widget), NM_TYPE_MENU_NETWORK, NMMenuNetwork))
|
||||
|
||||
#define NM_TYPE_MENU_WIRELESS (nm_menu_wireless_get_type ())
|
||||
#define NM_MENU_WIRELESS(widget) (G_TYPE_CHECK_INSTANCE_CAST ((widget), NM_TYPE_MENU_WIRELESS, NMMenuWireless))
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkCheckMenuItemClass parent_class;
|
||||
} NMMenuWiredClass;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkCheckMenuItem parent;
|
||||
GtkWidget *label;
|
||||
} NMMenuWired;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkMenuItemClass parent_class;
|
||||
|
|
@ -42,9 +58,8 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
GtkMenuItem parent;
|
||||
GtkWidget *image;
|
||||
GtkWidget *event_box;
|
||||
GtkWidget *label;
|
||||
int type;
|
||||
} NMMenuNetwork;
|
||||
|
||||
|
||||
|
|
@ -64,12 +79,17 @@ typedef struct
|
|||
|
||||
|
||||
|
||||
GType nm_menu_wired_get_type (void);
|
||||
GtkWidget *nm_menu_wired_new (void);
|
||||
void nm_menu_wired_update (NMMenuWired *menu_wired,
|
||||
NetworkDevice *network,
|
||||
gint n_devices);
|
||||
|
||||
GType nm_menu_network_get_type (void);
|
||||
GtkWidget *nm_menu_network_new (GtkSizeGroup *image_size_group);
|
||||
GtkWidget *nm_menu_network_new (void);
|
||||
void nm_menu_network_update (NMMenuNetwork *menu_network,
|
||||
NetworkDevice *network,
|
||||
gboolean multiple_devices);
|
||||
gint n_devices);
|
||||
|
||||
GType nm_menu_wireless_get_type (void);
|
||||
GtkWidget *nm_menu_wireless_new (GtkSizeGroup *encryption_size_group);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue