[network-manager-applet/nma-1-0: 4/8] c-e: fix icon and tooltip of "Save" button regarding authorization
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/nma-1-0: 4/8] c-e: fix icon and tooltip of "Save" button regarding authorization
- Date: Sat, 12 Sep 2015 11:59:09 +0000 (UTC)
commit 1165714dd79c7819f59eb37ade539bf0716d35f2
Author: Thomas Haller <thaller redhat com>
Date: Thu Sep 10 17:59:38 2015 +0200
c-e: fix icon and tooltip of "Save" button regarding authorization
CEPolkitButton has two different icons/tooltips, depending
on whether you can perform the action right away or are asked
for further polkit authorization.
We need three states regarding the icon/tooltip:
- NO authorization: Button is disabled
- NM_CLIENT_PERMISSION_RESULT_AUTH: user can get
authorization after authenticating with polkit.
- NM_CLIENT_PERMISSION_RESULT_YES: user has
permission right away.
Regardless of that, the check in update_button() was very wrong.
It would set priv->auth_tooltip when priv->authorized while it should
set priv->tooltip (if it doesn't consider the three states above).
(cherry picked from commit 05a1b8e9b47842978313a259c0ae161f0a1da4f1)
src/connection-editor/ce-polkit-button.c | 41 +++++++++++++++++------------
1 files changed, 24 insertions(+), 17 deletions(-)
---
diff --git a/src/connection-editor/ce-polkit-button.c b/src/connection-editor/ce-polkit-button.c
index 4744356..348e8cc 100644
--- a/src/connection-editor/ce-polkit-button.c
+++ b/src/connection-editor/ce-polkit-button.c
@@ -41,11 +41,8 @@ typedef struct {
NMClient *client;
NMClientPermission permission;
- /* authorized = TRUE if either explicitly authorized or if the action
- * could be performed if the user successfully authenticated to gain the
- * authorization.
- */
- gboolean authorized;
+
+ NMClientPermissionResult permission_result;
guint perm_id;
} CEPolkitButtonPrivate;
@@ -68,13 +65,17 @@ update_button (CEPolkitButton *self)
gtk_widget_set_sensitive (GTK_WIDGET (self), actionable);
- if (priv->authorized) {
+ if (priv->permission_result == NM_CLIENT_PERMISSION_RESULT_AUTH)
gtk_widget_set_tooltip_text (GTK_WIDGET (self), priv->auth_tooltip);
- gtk_button_set_image (GTK_BUTTON (self), priv->auth);
- } else {
+ else if (priv->permission_result == NM_CLIENT_PERMISSION_RESULT_YES)
gtk_widget_set_tooltip_text (GTK_WIDGET (self), priv->tooltip);
+ else
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("No polkit authorization to perform the
action"));
+
+ if (priv->permission_result == NM_CLIENT_PERMISSION_RESULT_YES)
gtk_button_set_image (GTK_BUTTON (self), priv->stock);
- }
+ else
+ gtk_button_set_image (GTK_BUTTON (self), priv->auth);
}
static void
@@ -111,16 +112,22 @@ ce_polkit_button_get_actionable (CEPolkitButton *self)
priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);
- return priv->master_sensitive && priv->authorized;
+ return priv->master_sensitive
+ && ce_polkit_button_get_authorized (self);
}
gboolean
ce_polkit_button_get_authorized (CEPolkitButton *self)
{
+ CEPolkitButtonPrivate *priv;
+
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (CE_IS_POLKIT_BUTTON (self), FALSE);
- return CE_POLKIT_BUTTON_GET_PRIVATE (self)->authorized;
+ priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);
+
+ return priv->permission_result == NM_CLIENT_PERMISSION_RESULT_YES
+ || priv->permission_result == NM_CLIENT_PERMISSION_RESULT_AUTH;
}
static void
@@ -130,16 +137,16 @@ permission_changed_cb (NMClient *client,
CEPolkitButton *self)
{
CEPolkitButtonPrivate *priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);
- gboolean old_actionable, old_authorized;
+ gboolean old_actionable;
- old_actionable = ce_polkit_button_get_actionable (self);
- old_authorized = priv->authorized;
+ if (priv->permission_result == result)
+ return;
- priv->authorized = (result == NM_CLIENT_PERMISSION_RESULT_YES || result ==
NM_CLIENT_PERMISSION_RESULT_AUTH);
+ old_actionable = ce_polkit_button_get_actionable (self);
+ priv->permission_result = result;
update_and_emit (self, old_actionable);
- if (priv->authorized != old_authorized)
- g_signal_emit (self, signals[AUTHORIZED], 0, priv->authorized);
+ g_signal_emit (self, signals[AUTHORIZED], 0, ce_polkit_button_get_authorized (self));
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]