[network-manager-netbook] Fix the "remove connection" button visibility issues
- From: Tambet Ingo <tambeti src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-netbook] Fix the "remove connection" button visibility issues
- Date: Thu, 21 Jan 2010 14:24:47 +0000 (UTC)
commit c2126b2b1c2b1d429f6f8bac4e40c34b951b2d3d
Author: Tambet Ingo <tambet gmail com>
Date: Thu Jan 21 09:46:55 2010 -0400
Fix the "remove connection" button visibility issues
It should never be visible for wired connections (bnc #570583).
libnm-gtk/nm-connection-item.c | 30 ++++++++++++++++++++++++++++--
libnm-gtk/nm-connection-item.h | 1 +
libnm-gtk/nm-ethernet-item.c | 1 +
src/nmn-item-renderer.c | 9 +--------
4 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/libnm-gtk/nm-connection-item.c b/libnm-gtk/nm-connection-item.c
index 3c123ad..46f8898 100644
--- a/libnm-gtk/nm-connection-item.c
+++ b/libnm-gtk/nm-connection-item.c
@@ -30,6 +30,7 @@ enum {
PROP_0,
PROP_CLIENT,
PROP_CONNECTION,
+ PROP_DELETE_ALLOWED,
LAST_PROP
};
@@ -40,6 +41,7 @@ typedef struct {
NMClient *client;
NMSettingsConnectionInterface *connection;
NMActiveConnection *ac;
+ gboolean delete_allowed;
gboolean connect_pending;
gulong removed_id;
@@ -201,6 +203,7 @@ nm_connection_item_set_connection (NMConnectionItem *self,
NMSettingsConnectionInterface *connection)
{
NMConnectionItemPrivate *priv;
+ gboolean show_delete;
g_return_if_fail (NM_IS_CONNECTION_ITEM (self));
@@ -232,7 +235,13 @@ nm_connection_item_set_connection (NMConnectionItem *self,
}
g_object_notify (G_OBJECT (self), NM_CONNECTION_ITEM_CONNECTION);
- g_object_set (G_OBJECT (self), NM_LIST_ITEM_SHOW_DELETE, connection != NULL, NULL);
+
+ if (priv->delete_allowed && connection != NULL)
+ show_delete = TRUE;
+ else
+ show_delete = FALSE;
+
+ g_object_set (G_OBJECT (self), NM_LIST_ITEM_SHOW_DELETE, show_delete, NULL);
if (priv->connect_pending) {
priv->connect_pending = FALSE;
@@ -270,7 +279,7 @@ do_delete (NMListItem *item)
{
NMConnectionItemPrivate *priv = GET_PRIVATE (item);
- if (priv->connection)
+ if (priv->connection && priv->delete_allowed)
nm_settings_connection_interface_delete (priv->connection, delete_cb, item);
}
@@ -300,6 +309,9 @@ priority (NMListItem *item)
static void
nm_connection_item_init (NMConnectionItem *self)
{
+ NMConnectionItemPrivate *priv = GET_PRIVATE (self);
+
+ priv->delete_allowed = TRUE;
}
static void
@@ -316,6 +328,9 @@ set_property (GObject *object, guint prop_id,
case PROP_CONNECTION:
nm_connection_item_set_connection (NM_CONNECTION_ITEM (object), g_value_get_object (value));
break;
+ case PROP_DELETE_ALLOWED:
+ priv->delete_allowed = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -335,6 +350,9 @@ get_property (GObject *object, guint prop_id,
case PROP_CONNECTION:
g_value_set_object (value, nm_connection_item_get_connection (self));
break;
+ case PROP_DELETE_ALLOWED:
+ g_value_set_boolean (value, GET_PRIVATE (self)->delete_allowed);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -387,4 +405,12 @@ nm_connection_item_class_init (NMConnectionItemClass *klass)
"Connection",
NM_TYPE_SETTINGS_CONNECTION_INTERFACE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (object_class, PROP_DELETE_ALLOWED,
+ g_param_spec_boolean (NM_CONNECTION_ITEM_DELETE_ALLOWED,
+ "delete allowed",
+ "delete allowed",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
diff --git a/libnm-gtk/nm-connection-item.h b/libnm-gtk/nm-connection-item.h
index d9fc599..4693915 100644
--- a/libnm-gtk/nm-connection-item.h
+++ b/libnm-gtk/nm-connection-item.h
@@ -36,6 +36,7 @@ G_BEGIN_DECLS
#define NM_CONNECTION_ITEM_CLIENT "client"
#define NM_CONNECTION_ITEM_CONNECTION "connection"
+#define NM_CONNECTION_ITEM_DELETE_ALLOWED "delete-allowed"
typedef struct {
NMListItem parent;
diff --git a/libnm-gtk/nm-ethernet-item.c b/libnm-gtk/nm-ethernet-item.c
index cd2a244..a31af28 100644
--- a/libnm-gtk/nm-ethernet-item.c
+++ b/libnm-gtk/nm-ethernet-item.c
@@ -36,6 +36,7 @@ nm_ethernet_item_new (NMClient *client,
return (NMListItem *) g_object_new (NM_TYPE_ETHERNET_ITEM,
NM_LIST_ITEM_TYPE_NAME, _("wired"),
+ NM_CONNECTION_ITEM_DELETE_ALLOWED, FALSE,
NM_CONNECTION_ITEM_CLIENT, client,
NM_CONNECTION_ITEM_CONNECTION, connection,
NM_DEVICE_ITEM_DEVICE, device,
diff --git a/src/nmn-item-renderer.c b/src/nmn-item-renderer.c
index 95b71b3..8f2a692 100644
--- a/src/nmn-item-renderer.c
+++ b/src/nmn-item-renderer.c
@@ -92,7 +92,7 @@ update_background (NmnItemRenderer *self)
gtk_widget_modify_bg (GTK_WIDGET (self), GTK_STATE_NORMAL, color);
g_object_set (priv->connect_button, "visible", priv->prelight, NULL);
- g_object_set (priv->remove_button, "visible", priv->prelight, NULL);
+ g_object_set (priv->remove_button, "visible", priv->prelight && nm_list_item_get_show_delete (priv->item), NULL);
g_object_set (priv->expander, "visible", priv->prelight, NULL);
}
@@ -180,13 +180,6 @@ item_changed (NMListItem *item,
if (!property || !strcmp (property, NM_LIST_ITEM_SECURITY))
gtk_label_set_text (priv->security_label, nm_list_item_get_security (item));
- if (!property || !strcmp (property, NM_LIST_ITEM_SHOW_DELETE)) {
- if (nm_list_item_get_show_delete (item))
- gtk_widget_show (priv->remove_button);
- else
- gtk_widget_hide (priv->remove_button);
- }
-
if (!property || !strcmp (property, NM_CONNECTION_ITEM_CONNECTION)) {
update_background (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]