[gnome-initial-setup] assistant: Make apply cancellable by the user
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] assistant: Make apply cancellable by the user
- Date: Mon, 27 May 2013 16:29:43 +0000 (UTC)
commit 73824e5dd0e9f501f3f83ceeca200ce83c4911b7
Author: Stef Walter <stefw redhat com>
Date: Sun May 26 13:57:38 2013 +0200
assistant: Make apply cancellable by the user
Some of the actual operations are not yet cancellable, but that will
come shortly.
https://bugzilla.gnome.org/show_bug.cgi?id=701039
gnome-initial-setup/gis-assistant.c | 19 ++++++++++++++++++
.../pages/account/gis-account-page.c | 21 +++++++++++++------
2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index c45723f..b96725b 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -57,6 +57,7 @@ struct _GisAssistantPrivate
GtkWidget *frame;
GtkWidget *forward;
GtkWidget *back;
+ GtkWidget *cancel;
GtkWidget *progress_indicator;
GtkWidget *main_layout;
GtkWidget *action_area;
@@ -258,6 +259,8 @@ update_applying_state (GisAssistant *assistant)
applying = gis_page_get_applying (assistant->priv->current_page);
gtk_widget_set_sensitive (assistant->priv->frame, !applying);
gtk_widget_set_sensitive (assistant->priv->forward, !applying);
+ gtk_widget_set_visible (assistant->priv->back, !applying);
+ gtk_widget_set_visible (assistant->priv->cancel, applying);
}
static void
@@ -337,6 +340,14 @@ go_backward (GtkWidget *button,
gis_assistant_previous_page (assistant);
}
+static void
+do_cancel (GtkWidget *button,
+ GisAssistant *assistant)
+{
+ if (assistant->priv->current_page)
+ gis_page_apply_cancel (assistant->priv->current_page);
+}
+
gchar *
gis_assistant_get_title (GisAssistant *assistant)
{
@@ -375,6 +386,7 @@ gis_assistant_locale_changed (GisAssistant *assistant)
gtk_button_set_label (GTK_BUTTON (priv->forward), _("_Next"));
gtk_button_set_label (GTK_BUTTON (priv->back), _("_Back"));
+ gtk_button_set_label (GTK_BUTTON (priv->cancel), _("_Cancel"));
for (l = priv->pages; l != NULL; l = l->next)
gis_page_locale_changed (l->data);
@@ -412,11 +424,18 @@ gis_assistant_init (GisAssistant *assistant)
gtk_image_new_from_stock (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
gtk_button_set_use_underline (GTK_BUTTON (priv->back), TRUE);
+ priv->cancel = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (priv->cancel),
+ gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
+ gtk_button_set_use_underline (GTK_BUTTON (priv->cancel), TRUE);
+
+ gtk_box_pack_start (GTK_BOX (navigation), priv->cancel, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (navigation), priv->back, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (navigation), priv->forward, FALSE, FALSE, 0);
g_signal_connect (priv->forward, "clicked", G_CALLBACK (go_forward), assistant);
g_signal_connect (priv->back, "clicked", G_CALLBACK (go_backward), assistant);
+ g_signal_connect (priv->cancel, "clicked", G_CALLBACK (do_cancel), assistant);
priv->progress_indicator = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (priv->progress_indicator, GTK_ALIGN_CENTER);
diff --git a/gnome-initial-setup/pages/account/gis-account-page.c
b/gnome-initial-setup/pages/account/gis-account-page.c
index b352960..662652f 100644
--- a/gnome-initial-setup/pages/account/gis-account-page.c
+++ b/gnome-initial-setup/pages/account/gis-account-page.c
@@ -72,6 +72,7 @@ struct _GisAccountPagePrivate
guint realmd_watch;
UmRealmManager *realm_manager;
gboolean domain_chosen;
+ GCancellable *cancellable;
GtkWidget *action;
};
@@ -86,6 +87,9 @@ show_error_dialog (GisAccountPage *page,
{
GtkWidget *dialog;
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ return;
+
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page))),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
@@ -590,7 +594,7 @@ enterprise_permit_user_login (GisAccountPage *page, UmRealmObject *realm)
um_realm_common_call_change_login_policy (common, "",
add, remove, options,
- NULL,
+ page->priv->cancellable,
on_permit_user_login,
page);
@@ -666,7 +670,7 @@ on_realm_login (GObject *source,
!um_realm_join_as_user (realm,
gtk_entry_get_text (OBJ (GtkEntry *, "enterprise-login")),
gtk_entry_get_text (OBJ (GtkEntry *, "enterprise-password")),
- creds, NULL,
+ creds, page->priv->cancellable,
on_realm_joined,
page)) {
@@ -711,7 +715,7 @@ enterprise_check_login (GisAccountPage *page, UmRealmObject *realm)
um_realm_login (realm,
gtk_entry_get_text (OBJ (GtkEntry *, "enterprise-login")),
gtk_entry_get_text (OBJ (GtkEntry *, "enterprise-password")),
- NULL,
+ page->priv->cancellable,
on_realm_login,
page);
}
@@ -766,7 +770,7 @@ enterprise_add_user (GisAccountPage *page)
} else {
um_realm_manager_discover (priv->realm_manager,
gtk_entry_get_text (OBJ (GtkEntry*, "enterprise-domain-entry")),
- NULL,
+ priv->cancellable,
on_realm_discover_input,
page);
}
@@ -963,10 +967,13 @@ toggle_mode (GtkToggleButton *button,
}
static void
-gis_account_page_apply (GisPage *page,
- GCancellable *cancellable)
+gis_account_page_apply (GisPage *gis_page,
+ GCancellable *cancellable)
{
- save_account_data (GIS_ACCOUNT_PAGE (page));
+ GisAccountPage *page = GIS_ACCOUNT_PAGE (gis_page);
+ g_clear_object (&page->priv->cancellable);
+ page->priv->cancellable = g_object_ref (cancellable);
+ save_account_data (page);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]