[gnome-system-tools] Preliminary support for disabled accounts
- From: Milan Bouchet-Valat <milanbv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-system-tools] Preliminary support for disabled accounts
- Date: Thu, 28 Jan 2010 12:36:32 +0000 (UTC)
commit bcc93cc635a0b1c64bcbe0c82345784f071704aa
Author: Milan Bouchet-Valat <nalimilan club fr>
Date: Thu Jan 28 13:23:43 2010 +0100
Preliminary support for disabled accounts
If you create an account and close the password dialog without choosing one, new account will be disabled. To avoid confusion, show a warning with a button to enable it. Also add a check box in the Advanced dialog to Enable/Disabled accounts. All these options are hidden for now, waiting for actual support from the backends.
interfaces/users.ui | 130 +++++++++++++++++++++++++++++++++------------
src/users/user-settings.c | 57 ++++++++++++++++++++
2 files changed, 153 insertions(+), 34 deletions(-)
---
diff --git a/interfaces/users.ui b/interfaces/users.ui
index 5a142f4..e70a802 100644
--- a/interfaces/users.ui
+++ b/interfaces/users.ui
@@ -151,7 +151,7 @@
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">4</property>
<property name="column_spacing">12</property>
<property name="row_spacing">12</property>
@@ -305,16 +305,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="right_attach">4</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
- <child>
<object class="GtkButton" id="edit_user_advanced_button">
<property name="label" translatable="yes">_Advanced Settings</property>
<property name="visible">True</property>
@@ -326,8 +316,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">4</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
@@ -344,13 +334,67 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options">GTK_EXPAND</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="right_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
- <property name="x_options">GTK_EXPAND</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="user_settings_disabled_account">
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">This account is disabled.</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
+ <object class="GtkButton" id="user_settings_enable_account">
+ <property name="label" translatable="yes">_Enable Account</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_user_settings_enable_account"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ <property name="y_padding">12</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="user_settings_disabled_account_image">
+ <property name="xalign">1</property>
+ <property name="stock">gtk-dialog-warning</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
</object>
@@ -2780,7 +2824,7 @@
<child>
<object class="GtkTable" id="table53">
<property name="visible">True</property>
- <property name="n_rows">6</property>
+ <property name="n_rows">7</property>
<property name="n_columns">3</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -2807,8 +2851,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -2820,8 +2864,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -2837,8 +2881,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -2854,8 +2898,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -2867,8 +2911,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
@@ -2879,8 +2923,8 @@
<property name="xalign">0</property>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -2894,8 +2938,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@@ -2912,8 +2956,8 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
@@ -2953,8 +2997,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
</packing>
</child>
<child>
@@ -2967,14 +3011,32 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="user_settings_locked_account">
+ <property name="label" translatable="yes">Disable _account</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
- <property name="y_options"></property>
</packing>
</child>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index c527e6c..f4ab547 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -49,6 +49,9 @@ extern GstTool *tool;
void on_edit_user_passwd (GtkButton *button,
gpointer user_data);
+void on_user_settings_enable_account (GtkButton *button,
+ gpointer user_data);
+
static gboolean
check_user_delete (OobsUser *user)
@@ -290,6 +293,9 @@ user_settings_show (OobsUser *user)
GtkWidget *profile_label;
GtkWidget *profile_button;
GtkWidget *passwd_label;
+ GtkWidget *disabled_image;
+ GtkWidget *disabled_label;
+ GtkWidget *enable_button;
GdkPixbuf *face;
GstUserProfile *profile;
OobsGroupsConfig *groups_config;
@@ -329,6 +335,26 @@ user_settings_show (OobsUser *user)
gtk_label_set_text (GTK_LABEL (passwd_label), _("Not asked on login"));
else
gtk_label_set_text (GTK_LABEL (passwd_label), _("Asked on login"));
+
+ /* Show notice if account is locked, this is really useful for new accounts
+ * where user did not choose a password. */
+ disabled_image = gst_dialog_get_widget (tool->main_dialog,
+ "user_settings_disabled_account_image");
+ disabled_label = gst_dialog_get_widget (tool->main_dialog,
+ "user_settings_disabled_account");
+ enable_button = gst_dialog_get_widget (tool->main_dialog,
+ "user_settings_enable_account");
+
+ if (oobs_user_get_password_disabled (user)) {
+ gtk_widget_show (disabled_image);
+ gtk_widget_show (disabled_label);
+ gtk_widget_show (enable_button);
+ }
+ else {
+ gtk_widget_hide (disabled_image);
+ gtk_widget_hide (disabled_label);
+ gtk_widget_hide (enable_button);
+ }
}
static void
@@ -557,6 +583,37 @@ check_profile (OobsUser *user, GstUserProfile *profile)
}
/*
+ * Callback for user_settings_enable_account: unlock account and commit changes.
+ */
+void
+on_user_settings_enable_account (GtkButton *enable_button,
+ gpointer user_data)
+{
+ GtkWidget *disabled_image;
+ GtkWidget *disabled_label;
+ OobsUser *user;
+
+ if (!gst_tool_authenticate (tool, GST_USERS_TOOL (tool)->users_config))
+ return;
+
+ user = users_table_get_current ();
+ oobs_user_set_password_disabled (user, FALSE);
+
+ if (gst_tool_commit (tool, OOBS_OBJECT (user)) == OOBS_RESULT_OK) {
+ disabled_image = gst_dialog_get_widget (tool->main_dialog,
+ "user_settings_disabled_account_image");
+ disabled_label = gst_dialog_get_widget (tool->main_dialog,
+ "user_settings_disabled_account");
+
+ gtk_widget_hide (disabled_image);
+ gtk_widget_hide (disabled_label);
+ gtk_widget_hide (GTK_WIDGET (enable_button));
+ }
+
+ g_object_unref (user);
+}
+
+/*
* Callback for user_new_name entry: on every change, fill the combo entry
* with proposed logins. Also update validate button's sensitivity if name is empty.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]