[gnome-software] Remove the just-removed application from the installed view
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Remove the just-removed application from the installed view
- Date: Thu, 22 Aug 2013 17:41:12 +0000 (UTC)
commit aa7ae81c6fde8159bd2f4ad5f2918dbbc0988e60
Author: Richard Hughes <richard hughsie com>
Date: Thu Aug 22 18:41:03 2013 +0100
Remove the just-removed application from the installed view
src/gs-plugin-loader.c | 21 +++++++++++++++++++--
src/gs-plugin-loader.h | 12 ++++++++++--
src/gs-shell-installed.c | 33 ++++++++++++++++++++++++++++++++-
3 files changed, 61 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index ec6fef6..e02b18c 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -924,6 +924,8 @@ typedef struct {
GsAppState state_progress;
GsAppState state_success;
GsAppState state_failure;
+ GsPluginLoaderFinishedFunc func;
+ gpointer func_user_data;
} GsPluginLoaderThreadHelper;
/**
@@ -959,6 +961,13 @@ gs_plugin_loader_thread_func (gpointer user_data)
g_ptr_array_remove (helper->plugin_loader->priv->pending_apps, helper->app);
g_signal_emit (helper->plugin_loader, signals[SIGNAL_PENDING_APPS_CHANGED], 0);
+ /* fire finished func */
+ if (helper->func != NULL) {
+ helper->func (helper->plugin_loader,
+ ret ? helper->app : NULL,
+ helper->func_user_data);
+ }
+
g_object_unref (helper->plugin_loader);
g_object_unref (helper->app);
if (helper->cancellable != NULL)
@@ -973,12 +982,16 @@ gs_plugin_loader_thread_func (gpointer user_data)
void
gs_plugin_loader_app_install (GsPluginLoader *plugin_loader,
GsApp *app,
- GCancellable *cancellable)
+ GCancellable *cancellable,
+ GsPluginLoaderFinishedFunc func,
+ gpointer user_data)
{
GsPluginLoaderThreadHelper *helper;
helper = g_new0 (GsPluginLoaderThreadHelper, 1);
helper->plugin_loader = g_object_ref (plugin_loader);
helper->app = g_object_ref (app);
+ helper->func = func;
+ helper->func_user_data = user_data;
if (cancellable != NULL)
helper->cancellable = g_object_ref (cancellable);
helper->function_name = "gs_plugin_app_install";
@@ -996,12 +1009,16 @@ gs_plugin_loader_app_install (GsPluginLoader *plugin_loader,
void
gs_plugin_loader_app_remove (GsPluginLoader *plugin_loader,
GsApp *app,
- GCancellable *cancellable)
+ GCancellable *cancellable,
+ GsPluginLoaderFinishedFunc func,
+ gpointer user_data)
{
GsPluginLoaderThreadHelper *helper;
helper = g_new0 (GsPluginLoaderThreadHelper, 1);
helper->plugin_loader = g_object_ref (plugin_loader);
helper->app = g_object_ref (app);
+ helper->func = func;
+ helper->func_user_data = user_data;
if (cancellable != NULL)
helper->cancellable = g_object_ref (cancellable);
helper->function_name = "gs_plugin_app_remove";
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index 3528f99..b37b462 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -60,6 +60,10 @@ typedef enum
GS_PLUGIN_LOADER_ERROR_LAST
} GsPluginLoaderError;
+typedef void (*GsPluginLoaderFinishedFunc) (GsPluginLoader *plugin_loader,
+ GsApp *app,
+ gpointer user_data);
+
GQuark gs_plugin_loader_error_quark (void);
GType gs_plugin_loader_get_type (void);
@@ -109,10 +113,14 @@ gboolean gs_plugin_loader_app_refine (GsPluginLoader *plugin_loader,
GError **error);
void gs_plugin_loader_app_install (GsPluginLoader *plugin_loader,
GsApp *app,
- GCancellable *cancellable);
+ GCancellable *cancellable,
+ GsPluginLoaderFinishedFunc func,
+ gpointer user_data);
void gs_plugin_loader_app_remove (GsPluginLoader *plugin_loader,
GsApp *app,
- GCancellable *cancellable);
+ GCancellable *cancellable,
+ GsPluginLoaderFinishedFunc func,
+ gpointer user_data);
gboolean gs_plugin_loader_app_set_rating (GsPluginLoader *plugin_loader,
GsApp *app,
GCancellable *cancellable,
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 8620e55..a42038f 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -149,6 +149,31 @@ gs_shell_installed_app_widget_read_more_clicked_cb (GsAppWidget *app_widget,
gtk_window_present (GTK_WINDOW (details));
}
+
+typedef struct {
+ GsAppWidget *app_widget;
+ GsShellInstalled *shell_installed;
+} GsShellInstalledHelper;
+
+/**
+ * gs_shell_installed_finished_func:
+ **/
+static void
+gs_shell_installed_finished_func (GsPluginLoader *plugin_loader, GsApp *app, gpointer user_data)
+{
+ GsShellInstalledHelper *helper = (GsShellInstalledHelper *) user_data;
+ GsShellInstalledPrivate *priv = helper->shell_installed->priv;
+
+ /* remove from the list */
+ if (app != NULL) {
+ gtk_container_remove (GTK_CONTAINER (priv->list_box_installed),
+ gtk_widget_get_parent (GTK_WIDGET (helper->app_widget)));
+ }
+ g_object_unref (helper->app_widget);
+ g_object_unref (helper->shell_installed);
+ g_free (helper);
+}
+
/**
* gs_shell_installed_app_remove_cb:
**/
@@ -162,6 +187,7 @@ gs_shell_installed_app_remove_cb (GsAppWidget *app_widget,
GtkResponseType response;
GtkWidget *dialog;
GtkWindow *window;
+ GsShellInstalledHelper *helper;
window = GTK_WINDOW (gtk_builder_get_object (priv->builder, "window_software"));
markup = g_string_new ("");
@@ -184,9 +210,14 @@ gs_shell_installed_app_remove_cb (GsAppWidget *app_widget,
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_OK) {
g_debug ("remove %s", gs_app_get_id (app));
+ helper = g_new0 (GsShellInstalledHelper, 1);
+ helper->shell_installed = g_object_ref (shell_installed);
+ helper->app_widget = g_object_ref (app_widget);
gs_plugin_loader_app_remove (priv->plugin_loader,
app,
- NULL); /* cancellable */
+ NULL, /* cancellable */
+ gs_shell_installed_finished_func,
+ helper);
}
g_string_free (markup, TRUE);
gtk_widget_destroy (dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]