user-accounts: replace fingerprint widgets by the UmEditableButton

The patch fixes also a wrong padding and replaces GtkNotebook.

https://bugzilla.gnome.org/show_bug.cgi?id=736009
This commit is contained in:
Ondrej Holy 2014-08-28 09:47:41 +02:00
parent 6ce59765dc
commit c218a2198e
4 changed files with 27 additions and 68 deletions

View file

@ -129,34 +129,9 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="column_spacing">10</property> <property name="column_spacing">10</property>
<child> <child>
<object class="GtkNotebook" id="account-fingerprint-notebook"> <object class="UmEditableButton" id="account-fingerprint-button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<child>
<object class="GtkLabel" id="account-fingerprint-value-label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkButton" id="account-fingerprint-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<child>
<object class="GtkLabel" id="account-fingerprint-button-label">
<property name="visible">True</property>
<property name="xalign">0</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>

View file

@ -22,6 +22,8 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "um-editable-button.h"
#include "um-fingerprint-dialog.h" #include "um-fingerprint-dialog.h"
#include "fingerprint-strings.h" #include "fingerprint-strings.h"
@ -46,8 +48,7 @@ enum {
}; };
typedef struct { typedef struct {
GtkWidget *label1; GtkWidget *editable_button;
GtkWidget *label2;
GtkWidget *ass; GtkWidget *ass;
GtkBuilder *dialog; GtkBuilder *dialog;
@ -175,8 +176,7 @@ get_error_dialog (const char *title,
} }
gboolean gboolean
set_fingerprint_label (GtkWidget *label1, set_fingerprint_label (GtkWidget *editable_button)
GtkWidget *label2)
{ {
GDBusProxy *device; GDBusProxy *device;
GVariant *result; GVariant *result;
@ -210,12 +210,10 @@ set_fingerprint_label (GtkWidget *label1,
if (fingers == NULL || g_variant_iter_n_children (fingers) == 0) { if (fingers == NULL || g_variant_iter_n_children (fingers) == 0) {
is_disable = FALSE; is_disable = FALSE;
gtk_label_set_text (GTK_LABEL (label1), _("Disabled")); um_editable_button_set_text (UM_EDITABLE_BUTTON (editable_button), _("Disabled"));
gtk_label_set_text (GTK_LABEL (label2), _("Disabled"));
} else { } else {
is_disable = TRUE; is_disable = TRUE;
gtk_label_set_text (GTK_LABEL (label1), _("Enabled")); um_editable_button_set_text (UM_EDITABLE_BUTTON (editable_button), _("Enabled"));
gtk_label_set_text (GTK_LABEL (label2), _("Enabled"));
} }
if (result != NULL) if (result != NULL)
@ -252,8 +250,7 @@ delete_fingerprints (void)
static void static void
delete_fingerprints_question (GtkWindow *parent, delete_fingerprints_question (GtkWindow *parent,
GtkWidget *label1, GtkWidget *editable_button,
GtkWidget *label2,
ActUser *user) ActUser *user)
{ {
GtkWidget *question; GtkWidget *question;
@ -281,7 +278,7 @@ delete_fingerprints_question (GtkWindow *parent,
if (gtk_dialog_run (GTK_DIALOG (question)) == GTK_RESPONSE_OK) { if (gtk_dialog_run (GTK_DIALOG (question)) == GTK_RESPONSE_OK) {
delete_fingerprints (); delete_fingerprints ();
set_fingerprint_label (label1, label2); set_fingerprint_label (editable_button);
} }
gtk_widget_destroy (question); gtk_widget_destroy (question);
@ -423,13 +420,8 @@ finger_combobox_changed (GtkComboBox *combobox, EnrollData *data)
static void static void
assistant_cancelled (GtkAssistant *ass, EnrollData *data) assistant_cancelled (GtkAssistant *ass, EnrollData *data)
{ {
GtkWidget *label1, *label2;
label1 = data->label1;
label2 = data->label2;
enroll_data_destroy (data); enroll_data_destroy (data);
set_fingerprint_label (label1, label2); set_fingerprint_label (data->editable_button);
} }
static void static void
@ -619,8 +611,7 @@ assistant_prepare (GtkAssistant *ass, GtkWidget *page, EnrollData *data)
static void static void
enroll_fingerprints (GtkWindow *parent, enroll_fingerprints (GtkWindow *parent,
GtkWidget *label1, GtkWidget *editable_button,
GtkWidget *label2,
ActUser *user) ActUser *user)
{ {
GDBusProxy *device; GDBusProxy *device;
@ -654,8 +645,7 @@ enroll_fingerprints (GtkWindow *parent,
data = g_new0 (EnrollData, 1); data = g_new0 (EnrollData, 1);
data->device = device; data->device = device;
data->label1 = label1; data->editable_button = editable_button;
data->label2 = label2;
/* Get some details about the device */ /* Get some details about the device */
result = g_dbus_connection_call_sync (connection, result = g_dbus_connection_call_sync (connection,
@ -755,17 +745,16 @@ enroll_fingerprints (GtkWindow *parent,
void void
fingerprint_button_clicked (GtkWindow *parent, fingerprint_button_clicked (GtkWindow *parent,
GtkWidget *label1, GtkWidget *editable_button,
GtkWidget *label2,
ActUser *user) ActUser *user)
{ {
bindtextdomain ("fprintd", GNOMELOCALEDIR); bindtextdomain ("fprintd", GNOMELOCALEDIR);
bind_textdomain_codeset ("fprintd", "UTF-8"); bind_textdomain_codeset ("fprintd", "UTF-8");
if (is_disable != FALSE) { if (is_disable != FALSE) {
delete_fingerprints_question (parent, label1, label2, user); delete_fingerprints_question (parent, editable_button, user);
} else { } else {
enroll_fingerprints (parent, label1, label2, user); enroll_fingerprints (parent, editable_button, user);
} }
} }

View file

@ -18,9 +18,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <act/act.h> #include <act/act.h>
gboolean set_fingerprint_label (GtkWidget *label1, gboolean set_fingerprint_label (GtkWidget *editable_button);
GtkWidget *label2);
void fingerprint_button_clicked (GtkWindow *parent, void fingerprint_button_clicked (GtkWindow *parent,
GtkWidget *label1, GtkWidget *editable_button,
GtkWidget *label2,
ActUser *user); ActUser *user);

View file

@ -664,8 +664,6 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
{ {
GtkWidget *image; GtkWidget *image;
GtkWidget *label; GtkWidget *label;
GtkWidget *label2;
GtkWidget *label3;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
gchar *lang, *text; gchar *lang, *text;
GtkWidget *widget; GtkWidget *widget;
@ -717,13 +715,11 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
g_free (lang); g_free (lang);
/* Fingerprint: show when self, possible, and local account */ /* Fingerprint: show when self, possible, and local account */
widget = get_widget (d, "account-fingerprint-notebook"); widget = get_widget (d, "account-fingerprint-button");
label = get_widget (d, "account-fingerprint-label"); label = get_widget (d, "account-fingerprint-label");
label2 = get_widget (d, "account-fingerprint-value-label");
label3 = get_widget (d, "account-fingerprint-button-label");
show = (act_user_get_uid (user) == getuid() && show = (act_user_get_uid (user) == getuid() &&
act_user_is_local_account (user) && act_user_is_local_account (user) &&
set_fingerprint_label (label2, label3)); set_fingerprint_label (widget));
gtk_widget_set_visible (label, show); gtk_widget_set_visible (label, show);
gtk_widget_set_visible (widget, show); gtk_widget_set_visible (widget, show);
@ -979,16 +975,15 @@ change_password (GtkButton *button, CcUserPanelPrivate *d)
static void static void
change_fingerprint (GtkButton *button, CcUserPanelPrivate *d) change_fingerprint (GtkButton *button, CcUserPanelPrivate *d)
{ {
GtkWidget *label, *label2; GtkWidget *widget;
ActUser *user; ActUser *user;
user = get_selected_user (d); user = get_selected_user (d);
g_assert (g_strcmp0 (g_get_user_name (), act_user_get_user_name (user)) == 0); g_assert (g_strcmp0 (g_get_user_name (), act_user_get_user_name (user)) == 0);
label = get_widget (d, "account-fingerprint-value-label"); widget = get_widget (d, "account-fingerprint-button");
label2 = get_widget (d, "account-fingerprint-button-label"); fingerprint_button_clicked (GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)), widget, user);
fingerprint_button_clicked (GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)), label, label2, user);
g_object_unref (user); g_object_unref (user);
} }
@ -1242,7 +1237,8 @@ on_permission_changed (GPermission *permission,
um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), TRUE); um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), TRUE);
remove_unlock_tooltip (get_widget (d, "account-password-button")); remove_unlock_tooltip (get_widget (d, "account-password-button"));
gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "account-fingerprint-notebook")), 1); um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-fingerprint-button")), TRUE);
remove_unlock_tooltip (get_widget (d, "account-fingerprint-button"));
} }
else { else {
gtk_widget_hide (get_widget (d, "user-icon-button")); gtk_widget_hide (get_widget (d, "user-icon-button"));
@ -1254,7 +1250,8 @@ on_permission_changed (GPermission *permission,
um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), FALSE); um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), FALSE);
add_unlock_tooltip (get_widget (d, "account-password-button")); add_unlock_tooltip (get_widget (d, "account-password-button"));
gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "account-fingerprint-notebook")), 0); um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-fingerprint-button")), FALSE);
add_unlock_tooltip (get_widget (d, "account-fingerprint-button"));
} }
um_password_dialog_set_user (d->password_dialog, user); um_password_dialog_set_user (d->password_dialog, user);
@ -1447,7 +1444,7 @@ setup_main_window (CcUserPanelPrivate *d)
g_signal_connect (button, "notify::active", G_CALLBACK (autologin_changed), d); g_signal_connect (button, "notify::active", G_CALLBACK (autologin_changed), d);
button = get_widget (d, "account-fingerprint-button"); button = get_widget (d, "account-fingerprint-button");
g_signal_connect (button, "clicked", g_signal_connect (button, "start-editing",
G_CALLBACK (change_fingerprint), d); G_CALLBACK (change_fingerprint), d);
button = get_widget (d, "last-login-history-button"); button = get_widget (d, "last-login-history-button");