When installing multiple themes at once, don't ask the user whether to
2007-10-30 Jens Granseuer <jensgr@gmx.net> When installing multiple themes at once, don't ask the user whether to apply after each theme. Instead, simply show a success message after installation has finished, and ask only if a single theme has been installed. * theme-installer.c: (gnome_theme_install_real), (transfer_done_cb): check whether there are multiple themes to install up front, and skip the apply dialog if so svn path=/trunk/; revision=8234
This commit is contained in:
parent
e55cb9bf73
commit
9a5c2f7fcf
2 changed files with 113 additions and 64 deletions
|
@ -1,3 +1,14 @@
|
|||
2007-10-30 Jens Granseuer <jensgr@gmx.net>
|
||||
|
||||
When installing multiple themes at once, don't ask the user whether to
|
||||
apply after each theme. Instead, simply show a success message after
|
||||
installation has finished, and ask only if a single theme has been
|
||||
installed.
|
||||
|
||||
* theme-installer.c: (gnome_theme_install_real),
|
||||
(transfer_done_cb): check whether there are multiple themes to install
|
||||
up front, and skip the apply dialog if so
|
||||
|
||||
2007-10-30 Jens Granseuer <jensgr@gmx.net>
|
||||
|
||||
* theme-installer.c: (gnome_theme_install_real): also update the icon
|
||||
|
|
|
@ -234,7 +234,7 @@ transfer_done_archive (gint filetype, const gchar *tmp_dir, const gchar *archive
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *theme_name)
|
||||
gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *theme_name, gboolean ask_user)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GtkWidget *dialog, *apply_button;
|
||||
|
@ -328,11 +328,15 @@ gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *them
|
|||
GNOME_VFS_XFER_ERROR_MODE_ABORT,
|
||||
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
|
||||
NULL, NULL) != GNOME_VFS_OK) {
|
||||
gchar *str;
|
||||
|
||||
str = g_strdup_printf (_("Installation for theme \"%s\" failed."), theme_name);
|
||||
dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_OK,
|
||||
_("Installation failed."));
|
||||
str);
|
||||
g_free (str);
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
success = FALSE;
|
||||
|
@ -347,10 +351,13 @@ gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *them
|
|||
|
||||
g_free (update_icon_cache);
|
||||
}
|
||||
|
||||
if (ask_user)
|
||||
{
|
||||
/* Ask to apply theme (if we can) */
|
||||
if (theme_type == THEME_GTK || theme_type == THEME_METACITY ||
|
||||
if ((theme_type == THEME_GTK || theme_type == THEME_METACITY ||
|
||||
theme_type == THEME_ICON || theme_type == THEME_CURSOR ||
|
||||
theme_type == THEME_ICON_CURSOR)
|
||||
theme_type == THEME_ICON_CURSOR) && ask_user)
|
||||
{
|
||||
/* TODO: currently cannot apply "gnome themes" */
|
||||
gchar *str;
|
||||
|
@ -414,6 +421,7 @@ gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *them
|
|||
}
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (user_message);
|
||||
g_free (target_dir);
|
||||
|
@ -452,7 +460,7 @@ transfer_done_cb (GtkWidget *dlg, gchar *path)
|
|||
|
||||
if (filetype == DIRECTORY) {
|
||||
gchar *name = g_path_get_basename (path);
|
||||
gnome_theme_install_real (filetype, path, name);
|
||||
gnome_theme_install_real (filetype, path, name, TRUE);
|
||||
g_free (name);
|
||||
} else {
|
||||
/* Create a temp directory and uncompress file there */
|
||||
|
@ -460,6 +468,7 @@ transfer_done_cb (GtkWidget *dlg, gchar *path)
|
|||
const gchar *name;
|
||||
gchar *tmp_dir;
|
||||
gboolean ok;
|
||||
gint n_themes;
|
||||
|
||||
tmp_dir = g_strdup_printf ("%s/.themes/.theme-%u",
|
||||
g_get_home_dir (),
|
||||
|
@ -488,22 +497,51 @@ transfer_done_cb (GtkWidget *dlg, gchar *path)
|
|||
|
||||
gnome_vfs_unlink (path);
|
||||
|
||||
/* See whether we have multiple themes to install. If so,
|
||||
* we won't ask the user whether to apply the new theme
|
||||
* after installation. */
|
||||
n_themes = 0;
|
||||
for (name = g_dir_read_name (dir); name && n_themes <= 1;
|
||||
name = g_dir_read_name (dir))
|
||||
{
|
||||
gchar *theme_dir;
|
||||
|
||||
theme_dir = g_build_filename (tmp_dir, name, NULL);
|
||||
|
||||
if (g_file_test (theme_dir, G_FILE_TEST_IS_DIR))
|
||||
++n_themes;
|
||||
|
||||
g_free (theme_dir);
|
||||
}
|
||||
g_dir_rewind (dir);
|
||||
|
||||
ok = TRUE;
|
||||
for (name = g_dir_read_name (dir); name && ok;
|
||||
name = g_dir_read_name (dir))
|
||||
{
|
||||
gchar *theme_dir;
|
||||
|
||||
theme_dir = g_build_path (G_DIR_SEPARATOR_S,
|
||||
tmp_dir, name, NULL);
|
||||
theme_dir = g_build_filename (tmp_dir, name, NULL);
|
||||
|
||||
if (g_file_test (theme_dir, G_FILE_TEST_IS_DIR))
|
||||
ok = gnome_theme_install_real (filetype, theme_dir, name);
|
||||
ok = gnome_theme_install_real (filetype,
|
||||
theme_dir, name, n_themes == 1);
|
||||
|
||||
g_free (theme_dir);
|
||||
}
|
||||
g_dir_close (dir);
|
||||
|
||||
if (ok && n_themes > 1)
|
||||
{
|
||||
dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK,
|
||||
_("New themes have been successfully installed."));
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
cleanup_tmp_dir (tmp_dir);
|
||||
g_free (tmp_dir);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue