File bnc#881245-update-test-affects-package-manager-should-restart-gpk-update-viewer.patch of Package gnome-packagekit.6609

diff -urp gnome-packagekit-3.20.0.orig/src/gpk-update-viewer.c gnome-packagekit-3.20.0/src/gpk-update-viewer.c
--- gnome-packagekit-3.20.0.orig/src/gpk-update-viewer.c	2015-08-19 07:49:32.000000000 -0500
+++ gnome-packagekit-3.20.0/src/gpk-update-viewer.c	2016-04-13 15:42:44.669318353 -0500
@@ -220,7 +220,17 @@ gpk_update_viewer_check_restart (void)
 		message = _("Some of the updates that were installed require you to log out and back in before the changes will be applied.");
 		/* TRANSLATORS: the button text for the log out */
 		button = _("Log Out");
-
+	} else if (restart_update == PK_RESTART_ENUM_APPLICATION) {
+        	/* TRANSLATORS: the message text for the application restart */
+              	message = _("Some of the updates that were installed require you to restart this application before the changes will be applied.");
+              	/* TRANSLATORS: the button text for the application restart */
+              	button = _("Restart Application");
+
+                ret = pk_control_suggest_daemon_quit (control, cancellable, &error);
+                if (!ret) {
+                    gpk_update_viewer_error_dialog (_("Could not terminate PackageKit"), NULL, error->message);
+                    g_error_free (error);
+                }
 	} else if (restart_update == PK_RESTART_ENUM_SECURITY_SESSION) {
 		/* TRANSLATORS: the message text for the log out */
 		message = _("Some of the updates that were installed require you to log out and back in to remain secure.");
@@ -273,6 +283,21 @@ gpk_update_viewer_check_restart (void)
 			g_error_free (error);
 		}
 #endif
+	} else if (restart_update == PK_RESTART_ENUM_APPLICATION) {
+		char cmd[256] = {0};
+		/* need to wait for PackageKit to finish too */
+		sprintf(cmd, "/bin/bash -c 'while ps -p %d > /dev/null; do sleep 1; done; while pgrep packagekitd > /dev/null; do sleep 1; done;/usr/bin/gpk-update-viewer'", getpid());
+
+		/* restart asynchronously after gpk-update-viewer was quit */
+		ret = g_spawn_command_line_async (cmd, &error);
+
+		if (!ret) {
+			gpk_update_viewer_error_dialog (_("Could not restart application"), NULL, error->message);
+			g_error_free (error);
+		}
+
+		/* needed to force gpk-update-viewer to quit */
+		ret = FALSE;
 	}
 out:
 	return ret;
@@ -461,6 +486,7 @@ gpk_update_viewer_update_packages_cb (Pk
 	/* check restart */
 	if (restart_update == PK_RESTART_ENUM_SYSTEM ||
 	    restart_update == PK_RESTART_ENUM_SESSION ||
+	    restart_update == PK_RESTART_ENUM_APPLICATION ||
 	    restart_update == PK_RESTART_ENUM_SECURITY_SESSION ||
 	    restart_update == PK_RESTART_ENUM_SECURITY_SYSTEM) {
 		gpk_update_viewer_check_restart ();
@@ -2066,6 +2092,10 @@ gpk_update_viewer_populate_details (PkUp
 		/* TRANSLATORS: reboot required */
 		gtk_text_buffer_insert_with_tags_by_name (text_buffer, &iter, _("The computer will have to be restarted after the update for the changes to take effect."), -1, "para", NULL);
 		gtk_text_buffer_insert (text_buffer, &iter, "\n", -1);
+	} else if (restart == PK_RESTART_ENUM_APPLICATION) {
+        /* TRANSLATORS: application restart required */
+        gtk_text_buffer_insert_with_tags_by_name (text_buffer, &iter, _("This application will have to be restarted after the update for the changes to take effect."), -1, "para", NULL);
+        gtk_text_buffer_insert (text_buffer, &iter, "\n", -1);
 	} else if (restart == PK_RESTART_ENUM_SESSION) {
 		/* TRANSLATORS: log out required */
 		gtk_text_buffer_insert_with_tags_by_name (text_buffer, &iter, _("You will need to log out and back in after the update for the changes to take effect."), -1, "para", NULL);
openSUSE Build Service is sponsored by