[gnome-software/gnome-3-10] Show a modal dialog when installing or removing fails
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-10] Show a modal dialog when installing or removing fails
- Date: Mon, 11 Nov 2013 20:49:14 +0000 (UTC)
commit 506e2c2ec9de06bc21ff9f8ac10d8da5c85b20b9
Author: Richard Hughes <richard hughsie com>
Date: Mon Nov 11 20:49:02 2013 +0000
Show a modal dialog when installing or removing fails
src/gs-shell-details.c | 8 +++++++
src/gs-shell-installed.c | 5 ++++
src/gs-shell-search.c | 9 ++++++++
src/gs-utils.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
src/gs-utils.h | 4 +++
5 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 78a08cf..c29f46a 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -269,6 +269,9 @@ gs_shell_details_installed_func (GsPluginLoader *plugin_loader, GsApp *app, gpoi
if (app) {
gs_app_notify_installed (app);
+ } else {
+ gs_app_notify_failed_modal (shell_details->priv->builder,
+ app, TRUE, NULL);
}
}
@@ -277,6 +280,11 @@ gs_shell_details_removed_func (GsPluginLoader *plugin_loader, GsApp *app, gpoint
{
GsShellDetails *shell_details = GS_SHELL_DETAILS (user_data);
gs_shell_details_refresh (shell_details);
+
+ if (app == NULL) {
+ gs_app_notify_failed_modal (shell_details->priv->builder,
+ app, FALSE, NULL);
+ }
}
/**
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 0542490..c0d44ec 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -120,7 +120,12 @@ gs_shell_installed_finished_func (GsPluginLoader *plugin_loader, GsApp *app, gpo
if (app != NULL) {
remove_row (GTK_LIST_BOX (priv->list_box_installed),
GTK_WIDGET (helper->app_widget));
+ } else {
+ gs_app_notify_failed_modal (priv->builder,
+ gs_app_widget_get_app (helper->app_widget),
+ FALSE, NULL);
}
+
g_object_unref (helper->app_widget);
g_object_unref (helper->shell_installed);
g_free (helper);
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index a1575bd..1298ed5 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -65,8 +65,12 @@ gs_shell_search_app_widget_activated_cb (GtkListBox *list_box,
static void
gs_shell_search_installed_func (GsPluginLoader *plugin_loader, GsApp *app, gpointer user_data)
{
+ GsShellSearch *shell_search = GS_SHELL_SEARCH (user_data);
if (app) {
gs_app_notify_installed (app);
+ } else {
+ gs_app_notify_failed_modal (shell_search->priv->builder,
+ app, TRUE, NULL);
}
}
@@ -76,6 +80,11 @@ gs_shell_search_installed_func (GsPluginLoader *plugin_loader, GsApp *app, gpoin
static void
gs_shell_search_removed_func (GsPluginLoader *plugin_loader, GsApp *app, gpointer user_data)
{
+ GsShellSearch *shell_search = GS_SHELL_SEARCH (user_data);
+ if (app == NULL) {
+ gs_app_notify_failed_modal (shell_search->priv->builder,
+ app, FALSE, NULL);
+ }
}
/**
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 4764760..6bcf524 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -174,6 +174,53 @@ gs_app_notify_installed (GsApp *app)
g_free (summary);
}
+/**
+ * gs_app_notify_failed_modal_response_cb:
+ **/
+static void
+gs_app_notify_failed_modal_response_cb (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+/**
+ * gs_app_notify_failed_modal:
+ **/
+void
+gs_app_notify_failed_modal (GtkBuilder *builder,
+ GsApp *app,
+ gboolean is_install,
+ const GError *error)
+{
+ GtkWidget *dialog;
+ GtkWindow *window;
+ const gchar *title;
+ const gchar *tmp;
+ gchar *msg;
+
+ title = "Sorry, this did not work";
+ tmp = app != NULL ? gs_app_get_name (app) : "the application";
+ if (is_install) {
+ msg = g_strdup_printf ("Installation of %s failed.", tmp);
+ } else {
+ msg = g_strdup_printf ("Removal of %s failed.", tmp);
+ }
+ window = GTK_WINDOW (gtk_builder_get_object (builder, "window_software"));
+ dialog = gtk_message_dialog_new (window,
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", msg);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gs_app_notify_failed_modal_response_cb), NULL);
+ gtk_window_present (GTK_WINDOW (dialog));
+}
+
guint
gs_string_replace (GString *string, const gchar *search, const gchar *replace)
{
diff --git a/src/gs-utils.h b/src/gs-utils.h
index c139454..5bbc949 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -34,6 +34,10 @@ void gs_container_remove_all (GtkContainer *container);
void gs_grab_focus_when_mapped (GtkWidget *widget);
void gs_app_notify_installed (GsApp *app);
+void gs_app_notify_failed_modal (GtkBuilder *builder,
+ GsApp *app,
+ gboolean is_install,
+ const GError *error);
guint gs_string_replace (GString *string,
const gchar *search,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]