[network-manager-applet/th/validation-error-bgo754832: 3/6] 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/th/validation-error-bgo754832: 3/6] c-e: fix icon and tooltip of "Save" button regarding authorization
- Date: Thu, 10 Sep 2015 16:27:37 +0000 (UTC)
commit 37d35cf807763d8818eb2f71118786931467a3c5
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.
The check in update_button() was completely wrong.
We actually need three states:
- !priv->authorized: user is anyway not authorized. Button
is disabled.
- priv->authorized && priv->authorized_asks: user can get
authorization after authenticating with polkit.
- priv->authorized && !priv->authorized_asks: user already
has permission right away.
Also drop the "authorized" signal because it isn't needed.
src/connection-editor/ce-polkit-button.c | 21 +++++++--------------
src/connection-editor/ce-polkit-button.h | 2 --
src/connection-editor/nm-connection-editor.c | 2 --
3 files changed, 7 insertions(+), 18 deletions(-)
---
diff --git a/src/connection-editor/ce-polkit-button.c b/src/connection-editor/ce-polkit-button.c
index 690ed92..50a1e9b 100644
--- a/src/connection-editor/ce-polkit-button.c
+++ b/src/connection-editor/ce-polkit-button.c
@@ -46,13 +46,13 @@ typedef struct {
* authorization.
*/
gboolean authorized;
+ gboolean authorized_asks;
guint perm_id;
} CEPolkitButtonPrivate;
enum {
ACTIONABLE,
- AUTHORIZED,
LAST_SIGNAL
};
@@ -68,7 +68,10 @@ update_button (CEPolkitButton *self)
gtk_widget_set_sensitive (GTK_WIDGET (self), actionable);
- if (priv->authorized) {
+ if (!priv->authorized) {
+ gtk_widget_set_tooltip_text (GTK_WIDGET (self), _("No polkit authorization to perform the
action"));
+ gtk_button_set_image (GTK_BUTTON (self), priv->auth);
+ } else if (priv->authorized_asks) {
gtk_widget_set_tooltip_text (GTK_WIDGET (self), priv->auth_tooltip);
gtk_button_set_image (GTK_BUTTON (self), priv->auth);
} else {
@@ -130,16 +133,13 @@ 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;
priv->authorized = (result == NM_CLIENT_PERMISSION_RESULT_YES || result ==
NM_CLIENT_PERMISSION_RESULT_AUTH);
+ priv->authorized_asks = priv->authorized_asks && (result == NM_CLIENT_PERMISSION_RESULT_AUTH);
update_and_emit (self, old_actionable);
-
- if (priv->authorized != old_authorized)
- g_signal_emit (self, signals[AUTHORIZED], 0, priv->authorized);
}
GtkWidget *
@@ -234,12 +234,5 @@ ce_polkit_button_class_init (CEPolkitButtonClass *pb_class)
G_STRUCT_OFFSET (CEPolkitButtonClass, actionable),
NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
- signals[AUTHORIZED] = g_signal_new ("authorized",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CEPolkitButtonClass, authorized),
- NULL, NULL, NULL,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}
diff --git a/src/connection-editor/ce-polkit-button.h b/src/connection-editor/ce-polkit-button.h
index da2f3e3..802aab4 100644
--- a/src/connection-editor/ce-polkit-button.h
+++ b/src/connection-editor/ce-polkit-button.h
@@ -43,8 +43,6 @@ typedef struct {
/* Signals */
void (*actionable) (CEPolkitButton *self, gboolean actionable);
-
- void (*authorized) (CEPolkitButton *self, gboolean authorized);
} CEPolkitButtonClass;
GType ce_polkit_button_get_type (void);
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index b4b0711..7b42ae4 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -403,8 +403,6 @@ nm_connection_editor_new (GtkWindow *parent_window,
g_signal_connect (editor->ok_button, "actionable",
G_CALLBACK (ok_button_actionable_cb), editor);
- g_signal_connect (editor->ok_button, "authorized",
- G_CALLBACK (ok_button_actionable_cb), editor);
hbox = GTK_WIDGET (gtk_builder_get_object (editor->builder, "action_area_hbox"));
gtk_box_pack_end (GTK_BOX (hbox), editor->ok_button, TRUE, TRUE, 0);
gtk_widget_show_all (editor->ok_button);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]