[accounts-dialog/control-center-panel: 15/15] Some cleanups
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [accounts-dialog/control-center-panel: 15/15] Some cleanups
- Date: Mon, 14 Jun 2010 05:06:38 +0000 (UTC)
commit 1d89164cfd1433855b855c89630bd9ca98a667dc
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 14 01:00:06 2010 -0400
Some cleanups
src/um-user-panel.c | 170 +++++++++++++++++++++++++--------------------------
1 files changed, 83 insertions(+), 87 deletions(-)
---
diff --git a/src/um-user-panel.c b/src/um-user-panel.c
index 263661c..c99fc68 100644
--- a/src/um-user-panel.c
+++ b/src/um-user-panel.c
@@ -454,6 +454,34 @@ delete_user (GtkButton *button, UmUserPanelPrivate *d)
}
+static const gchar *
+get_password_mode_text (UmUser *user)
+{
+ const gchar *text;
+
+ if (um_user_get_locked (user)) {
+ text = C_("Password mode", "Account disabled");
+ }
+ else {
+ switch (um_user_get_password_mode (user)) {
+ case UM_PASSWORD_MODE_REGULAR:
+ /* five bullets */
+ text = "\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2";
+ break;
+ case UM_PASSWORD_MODE_SET_AT_LOGIN:
+ text = C_("Password mode", "To be set at next login");
+ break;
+ case UM_PASSWORD_MODE_NONE:
+ text = C_("Password mode", "None");
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ return text;
+}
+
static void
show_user (UmUser *user, UmUserPanelPrivate *d)
{
@@ -462,7 +490,6 @@ show_user (UmUser *user, UmUserPanelPrivate *d)
GtkWidget *label2;
GtkWidget *label3;
GdkPixbuf *pixbuf;
- const gchar *text;
gchar *lang;
GtkWidget *widget;
GtkTreeModel *model;
@@ -477,37 +504,18 @@ show_user (UmUser *user, UmUserPanelPrivate *d)
um_photo_dialog_set_user (d->photo_dialog, user);
- label = get_widget (d, "full-name-entry");
- um_editable_entry_set_text (UM_EDITABLE_ENTRY (label), um_user_get_real_name (user));
- gtk_widget_set_tooltip_text (label, um_user_get_user_name (user));
+ widget = get_widget (d, "full-name-entry");
+ um_editable_entry_set_text (UM_EDITABLE_ENTRY (widget), um_user_get_real_name (user));
+ gtk_widget_set_tooltip_text (widget, um_user_get_user_name (user));
- label = get_widget (d, "account-type-combo");
- um_editable_combo_set_active (UM_EDITABLE_COMBO (label), um_user_get_account_type (user));
+ widget = get_widget (d, "account-type-combo");
+ um_editable_combo_set_active (UM_EDITABLE_COMBO (widget), um_user_get_account_type (user));
- if (um_user_get_locked (user)) {
- text = C_("Password mode", "Account disabled");
- }
- else {
- switch (um_user_get_password_mode (user)) {
- case UM_PASSWORD_MODE_REGULAR:
- text = "\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2";
- break;
- case UM_PASSWORD_MODE_SET_AT_LOGIN:
- text = C_("Password mode", "To be set at next login");
- break;
- case UM_PASSWORD_MODE_NONE:
- text = C_("Password mode", "None");
- break;
- default:
- g_assert_not_reached ();
- }
- }
widget = get_widget (d, "account-password-button");
- um_editable_button_set_text (UM_EDITABLE_BUTTON (widget), text);
+ um_editable_button_set_text (UM_EDITABLE_BUTTON (widget), get_password_mode_text (user));
- text = um_user_get_email (user);
widget = get_widget (d, "account-email-entry");
- um_editable_entry_set_text (UM_EDITABLE_ENTRY (widget), text);
+ um_editable_entry_set_text (UM_EDITABLE_ENTRY (widget), um_user_get_email (user));
widget = get_widget (d, "account-language-combo");
model = um_editable_combo_get_model (UM_EDITABLE_COMBO (widget));
@@ -520,9 +528,8 @@ show_user (UmUser *user, UmUserPanelPrivate *d)
um_editable_combo_set_active_iter (UM_EDITABLE_COMBO (widget), &iter);
g_free (lang);
- text = um_user_get_location (user);
label = get_widget (d, "account-location-entry");
- um_editable_entry_set_text (UM_EDITABLE_ENTRY (label), text);
+ um_editable_entry_set_text (UM_EDITABLE_ENTRY (label), um_user_get_location (user));
widget = get_widget (d, "account-fingerprint-notebook");
label = get_widget (d, "account-fingerprint-label");
@@ -550,9 +557,7 @@ selected_user_changed (GtkTreeSelection *selection, UmUserPanelPrivate *d)
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
gtk_tree_model_get (model, &iter, USER_COL, &user, -1);
show_user (user, d);
-
lockbutton_changed (POLKIT_LOCK_BUTTON (d->lock_button), d);
-
g_object_unref (user);
}
}
@@ -567,6 +572,7 @@ change_name_done (GtkWidget *entry,
user = get_selected_user (d);
text = um_editable_entry_get_text (UM_EDITABLE_ENTRY (entry));
+
if (g_strcmp0 (text, um_user_get_location (user)) != 0) {
um_user_set_real_name (user, text);
}
@@ -707,6 +713,7 @@ change_email_done (UmEditableEntry *e,
user = get_selected_user (d);
text = um_editable_entry_get_text (e);
+
if (g_strcmp0 (text, um_user_get_email (user)) != 0) {
um_user_set_email (user, text);
}
@@ -722,6 +729,7 @@ change_location_done (GtkWidget *entry,
user = get_selected_user (d);
text = um_editable_entry_get_text (UM_EDITABLE_ENTRY (entry));
+
if (g_strcmp0 (text, um_user_get_location (user)) != 0) {
um_user_set_location (user, text);
}
@@ -975,11 +983,12 @@ match_user (GtkTreeModel *model,
case_normalized_key = g_utf8_casefold (normalized_key, -1);
for (i = 0; i < 2; i++) {
- if (i == 0)
+ if (i == 0) {
name = um_user_get_real_name (user);
- else
+ }
+ else {
name = um_user_get_user_name (user);
-
+ }
g_free (normalized_name);
normalized_name = g_utf8_normalize (name, -1, G_NORMALIZE_ALL);
if (normalized_name) {
@@ -1166,8 +1175,9 @@ um_user_panel_init (UmUserPanel *self)
d->authority = polkit_authority_get ();
filename = UIDIR "/user-accounts-dialog.ui";
- if (!g_file_test (filename, G_FILE_TEST_EXISTS))
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
filename = "../data/user-accounts-dialog.ui";
+ }
error = NULL;
if (!gtk_builder_add_from_file (d->builder, filename, &error)) {
g_error ("%s", error->message);
@@ -1188,61 +1198,48 @@ um_user_panel_init (UmUserPanel *self)
static void
um_user_panel_dispose (GObject *object)
{
- UmUserPanelPrivate *priv = UM_USER_PANEL (object)->priv;
-
- if (priv->um)
- {
- g_object_unref (priv->um);
- priv->um = NULL;
- }
-
- if (priv->builder)
- {
- g_object_unref (priv->builder);
- priv->builder = NULL;
- }
-
- if (priv->account_dialog)
- {
- um_account_dialog_free (priv->account_dialog);
- priv->account_dialog = NULL;
- }
-
- if (priv->password_dialog)
- {
- um_password_dialog_free (priv->password_dialog);
- priv->password_dialog = NULL;
- }
-
- if (priv->photo_dialog)
- {
- um_photo_dialog_free (priv->photo_dialog);
- priv->photo_dialog = NULL;
- }
-
- if (priv->login_options)
- {
- um_login_options_free (priv->login_options);
- priv->login_options = NULL;
- }
-
- if (priv->authority)
- {
- g_object_unref (priv->authority);
- priv->authority = NULL;
- }
-
- G_OBJECT_CLASS (um_user_panel_parent_class)->dispose (object);
+ UmUserPanelPrivate *priv = UM_USER_PANEL (object)->priv;
+
+ if (priv->um) {
+ g_object_unref (priv->um);
+ priv->um = NULL;
+ }
+ if (priv->builder) {
+ g_object_unref (priv->builder);
+ priv->builder = NULL;
+ }
+ if (priv->account_dialog) {
+ um_account_dialog_free (priv->account_dialog);
+ priv->account_dialog = NULL;
+ }
+ if (priv->password_dialog) {
+ um_password_dialog_free (priv->password_dialog);
+ priv->password_dialog = NULL;
+ }
+ if (priv->photo_dialog) {
+ um_photo_dialog_free (priv->photo_dialog);
+ priv->photo_dialog = NULL;
+ }
+ if (priv->login_options) {
+ um_login_options_free (priv->login_options);
+ priv->login_options = NULL;
+ }
+ if (priv->authority) {
+ g_object_unref (priv->authority);
+ priv->authority = NULL;
+ }
+
+ G_OBJECT_CLASS (um_user_panel_parent_class)->dispose (object);
}
static void
um_user_panel_class_init (UmUserPanelClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (UmUserPanelPrivate));
+ object_class->dispose = um_user_panel_dispose;
- object_class->dispose = um_user_panel_dispose;
+ g_type_class_add_private (klass, sizeof (UmUserPanelPrivate));
}
static void
@@ -1253,8 +1250,7 @@ um_user_panel_class_finalize (UmUserPanelClass *klass)
void
um_user_panel_register (GIOModule *module)
{
- um_user_panel_register_type (G_TYPE_MODULE (module));
- g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
- UM_TYPE_USER_PANEL,
- "users", 0);
+ um_user_panel_register_type (G_TYPE_MODULE (module));
+ g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
+ UM_TYPE_USER_PANEL, "users", 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]