189
190
case AS_APP_STATE_INSTALLED:
190
191
case AS_APP_STATE_REMOVING:
191
192
case AS_APP_STATE_UPDATABLE:
193
gtk_widget_set_visible (priv->button_install, FALSE);
192
195
case AS_APP_STATE_UNAVAILABLE:
193
gtk_widget_set_visible (priv->button_install, FALSE);
196
if (gs_app_get_url (priv->app, AS_URL_KIND_MISSING) != NULL) {
197
gtk_widget_set_visible (priv->button_install, FALSE);
199
gtk_widget_set_visible (priv->button_install, TRUE);
200
/* TRANSLATORS: this is a button that allows the apps to
202
* The ellipsis indicates that further steps are required,
203
* e.g. enabling software sources or the like */
204
gtk_button_set_label (GTK_BUTTON (priv->button_install), _("_Install…"));
196
208
g_warning ("App unexpectedly in state %s",
558
548
if (pixbuf == NULL)
559
549
pixbuf = gs_app_get_pixbuf (priv->app);
560
if (pixbuf == NULL && gs_app_get_state (priv->app) == AS_APP_STATE_AVAILABLE_LOCAL) {
561
if (gs_app_get_kind (priv->app) == GS_APP_KIND_SOURCE)
562
pixbuf = gs_pixbuf_load ("x-package-repository", NULL, 96, NULL);
563
else if (gs_shell_details_is_addon_id_kind (priv->app))
564
pixbuf = gs_pixbuf_load ("application-x-addon", NULL, 96, NULL);
566
pixbuf = gs_pixbuf_load ("application-x-executable", NULL, 96, NULL);
568
550
if (pixbuf != NULL) {
569
551
gs_image_set_from_pixbuf (GTK_IMAGE (priv->application_details_icon), pixbuf);
570
552
gtk_widget_set_visible (priv->application_details_icon, TRUE);
836
addon = g_ptr_array_index (addons, i);
817
addon = g_ptr_array_index (addons, i);
837
818
if (gs_app_get_state (addon) == AS_APP_STATE_UNAVAILABLE)
840
row = gs_app_addon_row_new ();
842
gs_app_addon_row_set_addon (GS_APP_ADDON_ROW (row), addon);
843
gtk_container_add (GTK_CONTAINER (priv->list_box_addons), row);
844
gtk_widget_show (row);
846
g_signal_connect (row, "notify::selected",
847
G_CALLBACK (gs_shell_details_addon_selected_cb),
821
row = gs_app_addon_row_new ();
823
gs_app_addon_row_set_addon (GS_APP_ADDON_ROW (row), addon);
824
gtk_container_add (GTK_CONTAINER (priv->list_box_addons), row);
825
gtk_widget_show (row);
827
g_signal_connect (row, "notify::selected",
828
G_CALLBACK (gs_shell_details_addon_selected_cb),
908
887
if (priv->app == NULL) {
890
dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell),
892
GTK_DIALOG_DESTROY_WITH_PARENT,
895
_("Sorry, this did not work"));
896
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
897
"%s", error->message);
898
g_signal_connect (dialog, "response",
899
G_CALLBACK (gtk_widget_destroy), NULL);
900
gtk_window_present (GTK_WINDOW (dialog));
909
902
g_warning ("failed to convert to GsApp: %s", error->message);
910
g_error_free (error);
904
/* Switch away from the details view that failed to load */
905
gs_shell_set_mode (priv->shell, GS_SHELL_MODE_OVERVIEW);
1022
1016
return shell_details->priv->app;
1026
GsShellDetails *shell_details;
1028
} GsShellDetailsHelper;
1031
* gs_shell_details_app_installed_cb:
1034
gs_shell_details_app_installed_cb (GObject *source,
1038
GError *error = NULL;
1039
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source);
1040
GsShellDetailsHelper *helper = (GsShellDetailsHelper *) user_data;
1043
ret = gs_plugin_loader_app_action_finish (plugin_loader,
1047
g_warning ("failed to install %s: %s",
1048
gs_app_get_id (helper->app),
1050
gs_app_notify_failed_modal (helper->app,
1051
gs_shell_get_window (helper->shell_details->priv->shell),
1052
GS_PLUGIN_LOADER_ACTION_INSTALL,
1054
g_error_free (error);
1058
/* only show this if the window is not active */
1059
if (gs_app_get_state (helper->app) != AS_APP_STATE_QUEUED_FOR_INSTALL &&
1060
!gs_shell_is_active (helper->shell_details->priv->shell))
1061
gs_app_notify_installed (helper->app);
1062
gs_shell_details_reload (helper->shell_details);
1063
g_object_unref (helper->shell_details);
1064
g_object_unref (helper->app);
1069
* gs_shell_details_app_removed_cb:
1072
gs_shell_details_app_removed_cb (GObject *source,
1076
GError *error = NULL;
1077
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source);
1078
GsShellDetailsHelper *helper = (GsShellDetailsHelper *) user_data;
1081
ret = gs_plugin_loader_app_action_finish (plugin_loader,
1085
g_warning ("failed to remove %s: %s",
1086
gs_app_get_id (helper->app),
1088
gs_app_notify_failed_modal (helper->app,
1089
gs_shell_get_window (helper->shell_details->priv->shell),
1090
GS_PLUGIN_LOADER_ACTION_REMOVE,
1092
g_error_free (error);
1096
gs_shell_details_reload (helper->shell_details);
1097
g_object_unref (helper->shell_details);
1098
g_object_unref (helper->app);
1103
* gs_shell_details_app_remove
1106
gs_shell_details_app_remove (GsShellDetails *shell_details, GsApp *app)
1108
GsShellDetailsHelper *helper;
1109
GsShellDetailsPrivate *priv = shell_details->priv;
1111
GtkResponseType response;
1114
markup = g_string_new ("");
1115
g_string_append_printf (markup,
1116
/* TRANSLATORS: this is a prompt message, and
1117
* '%s' is an application summary, e.g. 'GNOME Clocks' */
1118
_("Are you sure you want to remove %s?"),
1119
gs_app_get_name (app));
1120
g_string_prepend (markup, "<b>");
1121
g_string_append (markup, "</b>");
1122
dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell),
1124
GTK_MESSAGE_QUESTION,
1127
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup->str);
1128
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
1129
/* TRANSLATORS: longer dialog text */
1130
_("%s will be removed, and you will have to install it to use it again."),
1131
gs_app_get_name (app));
1132
/* TRANSLATORS: this is button text to remove the application */
1133
gtk_dialog_add_button (GTK_DIALOG (dialog), _("Remove"), GTK_RESPONSE_OK);
1134
if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED)
1135
response = gtk_dialog_run (GTK_DIALOG (dialog));
1137
response = GTK_RESPONSE_OK; /* pending install */
1138
if (response == GTK_RESPONSE_OK) {
1139
g_debug ("remove %s", gs_app_get_id (app));
1140
helper = g_new0 (GsShellDetailsHelper, 1);
1141
helper->shell_details = g_object_ref (shell_details);
1142
helper->app = g_object_ref (app);
1143
gs_plugin_loader_app_action_async (priv->plugin_loader,
1145
GS_PLUGIN_LOADER_ACTION_REMOVE,
1147
gs_shell_details_app_removed_cb,
1150
g_string_free (markup, TRUE);
1151
gtk_widget_destroy (dialog);
1153
gs_shell_details_refresh_addons (shell_details);
1154
gs_shell_details_refresh_all (shell_details);
1158
1020
* gs_shell_details_app_remove_button_cb:
1163
1025
GsShellDetailsPrivate *priv = shell_details->priv;
1165
gs_shell_details_app_remove (shell_details, priv->app);
1169
* gs_shell_details_app_install:
1172
gs_shell_details_app_install (GsShellDetails *shell_details, GsApp *app)
1174
GsShellDetailsPrivate *priv = shell_details->priv;
1175
GsShellDetailsHelper *helper;
1177
helper = g_new0 (GsShellDetailsHelper, 1);
1178
helper->shell_details = g_object_ref (shell_details);
1179
helper->app = g_object_ref (app);
1180
gs_plugin_loader_app_action_async (priv->plugin_loader,
1182
GS_PLUGIN_LOADER_ACTION_INSTALL,
1184
gs_shell_details_app_installed_cb,
1027
gs_page_remove_app (GS_PAGE (shell_details), priv->app);
1228
1070
switch (gs_app_get_state (priv->app)) {
1229
1071
case AS_APP_STATE_INSTALLED:
1230
1072
case AS_APP_STATE_UPDATABLE:
1231
if (gs_app_addon_row_get_selected (row))
1232
gs_shell_details_app_install (shell_details, addon);
1234
gs_shell_details_app_remove (shell_details, addon);
1073
if (gs_app_addon_row_get_selected (row)) {
1074
gs_page_install_app (GS_PAGE (shell_details), addon);
1076
gs_page_remove_app (GS_PAGE (shell_details), addon);
1077
/* make sure the addon checkboxes are synced if the
1078
* user clicks cancel in the remove confirmation dialog */
1079
gs_shell_details_refresh_addons (shell_details);
1080
gs_shell_details_refresh_all (shell_details);