[network-manager-applet/menu-rework: 3/18] Convert main menu to use GtkCheckMenuItem instead GtkImageMenuItem.
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-applet/menu-rework: 3/18] Convert main menu to use GtkCheckMenuItem instead GtkImageMenuItem.
- Date: Fri, 25 Sep 2009 05:48:09 +0000 (UTC)
commit 4da7e3f6a72d038d39786ed03b93566e0b981fef
Author: Tony Espy <espy ubuntu com>
Date: Thu Sep 10 12:34:33 2009 -0400
Convert main menu to use GtkCheckMenuItem instead GtkImageMenuItem.
Convert the main menu to use GtkImageMenuItem and the Gnome
STOCK_CONNECT image to denote "Connected".
src/ap-menu-item.c | 3 +--
src/ap-menu-item.h | 4 ++--
src/applet-device-bt.c | 12 +++++++-----
src/applet-device-cdma.c | 13 +++++++------
src/applet-device-gsm.c | 13 +++++++------
src/applet-device-wifi.c | 8 ++++++--
src/applet-device-wired.c | 12 +++++++-----
src/applet.c | 11 +++++++----
8 files changed, 44 insertions(+), 32 deletions(-)
---
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 27abd76..dc61fde 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -35,12 +35,11 @@
#include "utils.h"
-G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_CHECK_MENU_ITEM);
+G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_IMAGE_MENU_ITEM);
static void
nm_network_menu_item_init (NMNetworkMenuItem * item)
{
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
item->hbox = gtk_hbox_new (FALSE, 6);
item->ssid = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (item->ssid), 0.0, 0.5);
diff --git a/src/ap-menu-item.h b/src/ap-menu-item.h
index 9a96f37..470d25f 100644
--- a/src/ap-menu-item.h
+++ b/src/ap-menu-item.h
@@ -41,7 +41,7 @@ typedef struct _NMNetworkMenuItemClass NMNetworkMenuItemClass;
struct _NMNetworkMenuItem
{
- GtkCheckMenuItem check_item;
+ GtkImageMenuItem image_item;
/*< private >*/
GtkWidget * ssid;
@@ -57,7 +57,7 @@ struct _NMNetworkMenuItem
struct _NMNetworkMenuItemClass
{
- GtkCheckMenuItemClass parent_class;
+ GtkImageMenuItemClass parent_class;
};
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 47287fd..a84aaad 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -95,15 +95,17 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item;
+ GtkWidget *item, *image;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+ item = gtk_image_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
- if (connection == active)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+ if (connection == active) {
+ image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
info = g_slice_new0 (BtMenuItemInfo);
info->applet = applet;
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index cf73890..d50c1c3 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -179,14 +179,16 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item;
+ GtkWidget *item, *image;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
+ item = gtk_image_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
- if (connection == active)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+ if (connection == active) {
+ image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
info = g_slice_new0 (CdmaMenuItemInfo);
info->applet = applet;
@@ -211,7 +213,6 @@ add_default_connection_item (NMDevice *device,
GtkWidget *item;
item = gtk_check_menu_item_new_with_label (_("New Mobile Broadband (CDMA) connection..."));
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
info = g_slice_new0 (CdmaMenuItemInfo);
info->applet = applet;
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 90bf31f..661f5e1 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -181,14 +181,16 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item;
+ GtkWidget *item, *image;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
+ item = gtk_image_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
- if (connection == active)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+ if (connection == active) {
+ image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
info = g_slice_new0 (GSMMenuItemInfo);
info->applet = applet;
@@ -213,7 +215,6 @@ add_default_connection_item (NMDevice *device,
GtkWidget *item;
item = gtk_check_menu_item_new_with_label (_("New Mobile Broadband (GSM) connection..."));
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
info = g_slice_new0 (GSMMenuItemInfo);
info->applet = applet;
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index e23db3f..5db1ed4 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -480,6 +480,7 @@ add_new_ap_item (NMDeviceWifi *device,
foo = nm_network_menu_item_new (applet->encryption_size_group,
dup_data->hash, AP_HASH_LEN);
item = NM_NETWORK_MENU_ITEM (foo);
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
ssid = nm_access_point_get_ssid (ap);
nm_network_menu_item_set_ssid (item, (GByteArray *) ssid);
@@ -561,6 +562,7 @@ add_one_ap_menu_item (NMDeviceWifi *device,
const GByteArray *ssid;
struct dup_data dup_data = { NULL, NULL };
NMNetworkMenuItem *item = NULL;
+ GtkWidget *image;
/* Don't add BSSs that hide their SSID */
ssid = nm_access_point_get_ssid (ap);
@@ -597,8 +599,10 @@ add_one_ap_menu_item (NMDeviceWifi *device,
g_signal_handlers_block_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
G_CALLBACK (wireless_menu_item_activate), NULL);
- if (nm_network_menu_item_find_dupe (item, active_ap))
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+ if (nm_network_menu_item_find_dupe (item, active_ap)) {
+ image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
g_signal_handlers_unblock_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
G_CALLBACK (wireless_menu_item_activate), NULL);
diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c
index e12f99f..6cccc71 100644
--- a/src/applet-device-wired.c
+++ b/src/applet-device-wired.c
@@ -120,15 +120,17 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item;
+ GtkWidget *item, *image;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+ item = gtk_image_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
- if (connection == active)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+ if (connection == active) {
+ image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
info = g_slice_new0 (WiredMenuItemInfo);
info->applet = applet;
diff --git a/src/applet.c b/src/applet.c
index 708b6b5..9460122 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -1317,11 +1317,12 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
NMConnection *connection = NM_CONNECTION (iter->data);
NMActiveConnection *active;
const char *name;
+ GtkWidget *image;
name = get_connection_id (connection);
- item = GTK_MENU_ITEM (gtk_check_menu_item_new_with_label (name));
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
+ item = GTK_MENU_ITEM (gtk_image_menu_item_new_with_label (name));
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
/* If no VPN connections are active, draw all menu items enabled. If
* >= 1 VPN connections are active, only the active VPN menu item is
@@ -1336,8 +1337,10 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
else
gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
- if (active)
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+ if (active) {
+ image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
g_object_set_data_full (G_OBJECT (item), "connection",
g_object_ref (connection),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]