diff options
author | Zhang Xianwei <[email protected]> | 2018-01-24 16:49:59 +0800 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-03-11 14:32:13 +0100 |
commit | 8adccf37fe94b15cc3c44591ec5f89ce8448f2b8 (patch) | |
tree | 87c97f8ea430d2d7a93d7825677273b823c90e09 /capplets/appearance | |
parent | 598b1878627ddbf2484706c6afd4aa5d05976660 (diff) | |
download | mate-control-center-8adccf37fe94b15cc3c44591ec5f89ce8448f2b8.tar.bz2 mate-control-center-8adccf37fe94b15cc3c44591ec5f89ce8448f2b8.tar.xz |
theme-installer.c: add tips when reinstall a existed theme
When ~/.themes/theme-name is existed, reinstalling the same theme will
be failed. Add tips when reinstall a existed theme to fix it.
Signed-off-by: Zhang Xianwei <[email protected]>
Diffstat (limited to 'capplets/appearance')
-rw-r--r-- | capplets/appearance/theme-installer.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/capplets/appearance/theme-installer.c b/capplets/appearance/theme-installer.c index 4d261aff..2030325b 100644 --- a/capplets/appearance/theme-installer.c +++ b/capplets/appearance/theme-installer.c @@ -370,6 +370,56 @@ mate_theme_install_real (GtkWindow *parent, theme_source_dir = g_file_new_for_path (tmp_dir); theme_dest_dir = g_file_new_for_path (target_dir); + if (g_file_test (target_dir, G_FILE_TEST_EXISTS)) { + gchar *str; + + str = g_strdup_printf (_("The theme \"%s\" is already existed."), theme_name); + dialog = gtk_message_dialog_new (parent, + GTK_DIALOG_MODAL, + GTK_MESSAGE_INFO, + GTK_BUTTONS_NONE, + "%s", + str); + g_free (str); + + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("Do you want to install it again?")); + + gtk_dialog_add_button (GTK_DIALOG (dialog), + _("Cancel"), + GTK_RESPONSE_CLOSE); + + apply_button = gtk_button_new_with_label (_("Install")); + gtk_button_set_image (GTK_BUTTON (apply_button), + gtk_image_new_from_icon_name ("gtk-apply", + GTK_ICON_SIZE_BUTTON)); + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), apply_button, GTK_RESPONSE_APPLY); + gtk_widget_set_can_default (apply_button, TRUE); + gtk_widget_show (apply_button); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_APPLY) { + gtk_widget_destroy (dialog); + + if (!capplet_file_delete_recursive (theme_dest_dir, NULL)) { + GtkWidget *info_dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Theme cannot be deleted")); + gtk_dialog_run (GTK_DIALOG (info_dialog)); + gtk_widget_destroy (info_dialog); + success = FALSE; + goto end; + } + }else{ + gtk_widget_destroy (dialog); + success = FALSE; + goto end; + } + } + if (!g_file_move (theme_source_dir, theme_dest_dir, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error)) { @@ -490,6 +540,7 @@ mate_theme_install_real (GtkWindow *parent, } } +end: g_free (target_dir); g_object_unref (theme_source_dir); g_object_unref (theme_dest_dir); |