user-accounts: use GtkStack instead of GtkNotebook in Add user dialog

https://bugzilla.gnome.org/show_bug.cgi?id=734422
This commit is contained in:
Ondrej Holy 2014-08-14 11:58:14 +02:00
parent ed4653627b
commit 3695f858dd
2 changed files with 20 additions and 13 deletions

View file

@ -32,11 +32,10 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkNotebook" id="notebook"> <object class="GtkStack" id="stack">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="show_tabs">False</property> <property name="transition-type">none</property>
<property name="show_border">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="margin_bottom">6</property> <property name="margin_bottom">6</property>
<child> <child>
@ -367,6 +366,9 @@
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="name">_local</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkGrid" id="enterprise-area"> <object class="GtkGrid" id="enterprise-area">
@ -563,7 +565,7 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="name">_enterprise</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -634,7 +636,7 @@ enterprise login accounts.</property>
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">2</property> <property name="name">_offline</property>
</packing> </packing>
</child> </child>
</object> </object>

View file

@ -36,10 +36,15 @@
typedef enum { typedef enum {
UM_LOCAL, UM_LOCAL,
UM_ENTERPRISE, UM_ENTERPRISE,
UM_OFFLINE, UM_OFFLINE
NUM_MODES
} UmAccountMode; } UmAccountMode;
static const char * const mode_pages[] = {
"_local",
"_enterprise",
"_offline"
};
static void mode_change (UmAccountDialog *self, static void mode_change (UmAccountDialog *self,
UmAccountMode mode); UmAccountMode mode);
@ -64,7 +69,7 @@ static void um_account_dialog_response (GtkDialog *dialog,
struct _UmAccountDialog { struct _UmAccountDialog {
GtkDialog parent; GtkDialog parent;
GtkWidget *notebook; GtkWidget *stack;
GtkWidget *container_widget; GtkWidget *container_widget;
GSimpleAsyncResult *async; GSimpleAsyncResult *async;
GCancellable *cancellable; GCancellable *cancellable;
@ -147,7 +152,7 @@ begin_action (UmAccountDialog *self)
g_debug ("Beginning action, disabling dialog controls"); g_debug ("Beginning action, disabling dialog controls");
if (self->enterprise_check_credentials) { if (self->enterprise_check_credentials) {
gtk_widget_set_sensitive (self->notebook, FALSE); gtk_widget_set_sensitive (self->stack, FALSE);
} }
gtk_widget_set_sensitive (self->enterprise_button, FALSE); gtk_widget_set_sensitive (self->enterprise_button, FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE); gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE);
@ -162,7 +167,7 @@ finish_action (UmAccountDialog *self)
g_debug ("Completed domain action"); g_debug ("Completed domain action");
if (self->enterprise_check_credentials) { if (self->enterprise_check_credentials) {
gtk_widget_set_sensitive (self->notebook, TRUE); gtk_widget_set_sensitive (self->stack, TRUE);
} }
gtk_widget_set_sensitive (self->enterprise_button, TRUE); gtk_widget_set_sensitive (self->enterprise_button, TRUE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, TRUE); gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, TRUE);
@ -1395,7 +1400,7 @@ mode_change (UmAccountDialog *self,
mode = available ? UM_ENTERPRISE : UM_OFFLINE; mode = available ? UM_ENTERPRISE : UM_OFFLINE;
} }
gtk_notebook_set_current_page (GTK_NOTEBOOK (self->notebook), mode); gtk_stack_set_visible_child_name (GTK_STACK (self->stack), mode_pages[mode]);
/* The enterprise toggle state */ /* The enterprise toggle state */
active = (mode != UM_LOCAL); active = (mode != UM_LOCAL);
@ -1469,8 +1474,8 @@ um_account_dialog_init (UmAccountDialog *self)
gtk_container_add (GTK_CONTAINER (content), widget); gtk_container_add (GTK_CONTAINER (content), widget);
self->container_widget = widget; self->container_widget = widget;
widget = GTK_WIDGET (gtk_builder_get_object (builder, "notebook")); widget = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
self->notebook = widget; self->stack = widget;
local_init (self, builder); local_init (self, builder);
enterprise_init (self, builder); enterprise_init (self, builder);