user-accounts: Move "Add User" button to header bar
This also introduces a change to the Lock/Unlock logic. From now on, Unlocking the panel causes the "Lock" button to turn into the "Add User" button. https://bugzilla.gnome.org/show_bug.cgi?id=767065
This commit is contained in:
parent
e18c0014f1
commit
eb9c110646
2 changed files with 53 additions and 37 deletions
|
@ -1,6 +1,33 @@
|
|||
<interface>
|
||||
<!-- interface-requires gtk+ 3.8 -->
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<object class="GtkStack" id="headerbar-buttons">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLockButton" id="lock-button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">_lock</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="add-user-toolbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Add User…</property>
|
||||
<property name="use_underline">True</property>
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">_adduser</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="shortname-model">
|
||||
<columns>
|
||||
<!-- column-name gchararray -->
|
||||
|
@ -52,34 +79,6 @@
|
|||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolbar" id="add-remove-toolbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon_size">1</property>
|
||||
<property name="icon_size_set">True</property>
|
||||
<property name="toolbar_style">icons</property>
|
||||
<style>
|
||||
<class name="inline-toolbar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="add-user-toolbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">list-add-symbolic</property>
|
||||
<property name="label" translatable="yes">Add User Account</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
|
|
@ -73,6 +73,7 @@ struct _CcUserPanelPrivate {
|
|||
GtkWidget *notification;
|
||||
GSettings *login_screen_settings;
|
||||
|
||||
GtkWidget *headerbar_buttons;
|
||||
GtkWidget *main_box;
|
||||
GPermission *permission;
|
||||
GtkWidget *language_chooser;
|
||||
|
@ -93,6 +94,9 @@ get_widget (CcUserPanelPrivate *d, const char *name)
|
|||
return (GtkWidget *)gtk_builder_get_object (d->builder, name);
|
||||
}
|
||||
|
||||
#define PAGE_LOCK "_lock"
|
||||
#define PAGE_ADDUSER "_adduser"
|
||||
|
||||
enum {
|
||||
USER_COL,
|
||||
NAME_COL,
|
||||
|
@ -1357,6 +1361,8 @@ on_permission_changed (GPermission *permission,
|
|||
is_authorized = g_permission_get_allowed (G_PERMISSION (d->permission));
|
||||
self_selected = act_user_get_uid (user) == geteuid ();
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (d->headerbar_buttons), is_authorized ? PAGE_ADDUSER : PAGE_LOCK);
|
||||
|
||||
widget = get_widget (d, "add-user-toolbutton");
|
||||
gtk_widget_set_sensitive (widget, is_authorized);
|
||||
if (is_authorized) {
|
||||
|
@ -1723,6 +1729,24 @@ settings_or_null (const gchar *schema)
|
|||
return settings;
|
||||
}
|
||||
|
||||
static void
|
||||
cc_user_panel_constructed (GObject *object)
|
||||
{
|
||||
CcUserPanelPrivate *d;
|
||||
CcUserPanel *self = UM_USER_PANEL (object);
|
||||
GtkWidget *button;
|
||||
CcShell *shell;
|
||||
|
||||
G_OBJECT_CLASS (cc_user_panel_parent_class)->constructed (object);
|
||||
d = self->priv;
|
||||
|
||||
shell = cc_panel_get_shell (CC_PANEL (self));
|
||||
cc_shell_embed_widget_in_header (shell, d->headerbar_buttons);
|
||||
|
||||
button = get_widget (d, "lock-button");
|
||||
gtk_lock_button_set_permission (GTK_LOCK_BUTTON (button), d->permission);
|
||||
}
|
||||
|
||||
static void
|
||||
cc_user_panel_init (CcUserPanel *self)
|
||||
{
|
||||
|
@ -1756,6 +1780,7 @@ cc_user_panel_init (CcUserPanel *self)
|
|||
return;
|
||||
}
|
||||
|
||||
d->headerbar_buttons = get_widget (d, "headerbar-buttons");
|
||||
d->login_screen_settings = settings_or_null ("org.gnome.login-screen");
|
||||
|
||||
d->password_dialog = um_password_dialog_new ();
|
||||
|
@ -1821,14 +1846,6 @@ cc_user_panel_dispose (GObject *object)
|
|||
G_OBJECT_CLASS (cc_user_panel_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static GPermission *
|
||||
cc_user_panel_get_permission (CcPanel *panel)
|
||||
{
|
||||
CcUserPanelPrivate *priv = UM_USER_PANEL (panel)->priv;
|
||||
|
||||
return priv->permission;
|
||||
}
|
||||
|
||||
static const char *
|
||||
cc_user_panel_get_help_uri (CcPanel *panel)
|
||||
{
|
||||
|
@ -1842,8 +1859,8 @@ cc_user_panel_class_init (CcUserPanelClass *klass)
|
|||
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
||||
|
||||
object_class->dispose = cc_user_panel_dispose;
|
||||
object_class->constructed = cc_user_panel_constructed;
|
||||
|
||||
panel_class->get_permission = cc_user_panel_get_permission;
|
||||
panel_class->get_help_uri = cc_user_panel_get_help_uri;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (CcUserPanelPrivate));
|
||||
|
|
Loading…
Add table
Reference in a new issue