Based on a patch by: Lincoln de Sousa <lincoln@minaslivre.org>
2008-05-24 Jens Granseuer <jensgr@gmx.net> Based on a patch by: Lincoln de Sousa <lincoln@minaslivre.org> Port the last remaining bits of gnome-vfs to gio (bug #524401). * appearance-main.c: (init_appearance_data): * theme-installer.c: (cleanup_tmp_dir), (file_theme_type), (transfer_cancel_cb), (gnome_theme_install_real), (transfer_done_cb): use gio instead of gnome-vfs * theme-util.c: * theme-util.h: make file_delete_recursive public * gnome-wp-info.c: include string.h to avoid warning svn path=/trunk/; revision=8721
This commit is contained in:
parent
c9dd628887
commit
2c323085cb
6 changed files with 80 additions and 40 deletions
|
@ -1,3 +1,20 @@
|
||||||
|
2008-05-24 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
|
Based on a patch by: Lincoln de Sousa <lincoln@minaslivre.org>
|
||||||
|
|
||||||
|
Port the last remaining bits of gnome-vfs to gio (bug
|
||||||
|
#524401).
|
||||||
|
|
||||||
|
* appearance-main.c: (init_appearance_data):
|
||||||
|
* theme-installer.c: (cleanup_tmp_dir), (file_theme_type),
|
||||||
|
(transfer_cancel_cb), (gnome_theme_install_real),
|
||||||
|
(transfer_done_cb): use gio instead of gnome-vfs
|
||||||
|
|
||||||
|
* theme-util.c:
|
||||||
|
* theme-util.h: make file_delete_recursive public
|
||||||
|
|
||||||
|
* gnome-wp-info.c: include string.h to avoid warning
|
||||||
|
|
||||||
==================== 2.23.2 ====================
|
==================== 2.23.2 ====================
|
||||||
|
|
||||||
2008-05-08 Jens Granseuer <jensgr@gmx.net>
|
2008-05-08 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
|
@ -49,7 +49,6 @@ init_appearance_data (int *argc, char ***argv)
|
||||||
g_thread_init (NULL);
|
g_thread_init (NULL);
|
||||||
theme_thumbnail_factory_init (*argc, *argv);
|
theme_thumbnail_factory_init (*argc, *argv);
|
||||||
gtk_init (argc, argv);
|
gtk_init (argc, argv);
|
||||||
gnome_vfs_init ();
|
|
||||||
activate_settings_daemon ();
|
activate_settings_daemon ();
|
||||||
|
|
||||||
/* set up the data */
|
/* set up the data */
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <string.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include "gnome-wp-info.h"
|
#include "gnome-wp-info.h"
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include "file-transfer-dialog.h"
|
#include "file-transfer-dialog.h"
|
||||||
#include "theme-installer.h"
|
#include "theme-installer.h"
|
||||||
|
@ -48,17 +49,18 @@ enum {
|
||||||
DIRECTORY
|
DIRECTORY
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
cleanup_tmp_dir (const gchar *tmp_dir)
|
cleanup_tmp_dir (GIOSchedulerJob *job,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
const gchar *tmp_dir)
|
||||||
{
|
{
|
||||||
if (gnome_vfs_remove_directory (tmp_dir) == GNOME_VFS_ERROR_DIRECTORY_NOT_EMPTY) {
|
GFile *directory;
|
||||||
GList *list;
|
|
||||||
|
|
||||||
list = g_list_prepend (NULL, gnome_vfs_uri_new (tmp_dir));
|
directory = g_file_new_for_path (tmp_dir);
|
||||||
gnome_vfs_xfer_delete_list (list, GNOME_VFS_XFER_RECURSIVE,
|
file_delete_recursive (directory, &err);
|
||||||
GNOME_VFS_XFER_ERROR_MODE_ABORT, NULL, NULL);
|
g_object_unref (directory);
|
||||||
gnome_vfs_uri_list_free (list);
|
|
||||||
}
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -74,16 +76,12 @@ file_theme_type (const gchar *dir)
|
||||||
exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
|
exists = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
GPatternSpec *pattern = NULL;
|
GPatternSpec *pattern;
|
||||||
gchar *file_contents = NULL;
|
gchar *file_contents = NULL;
|
||||||
gint file_size;
|
gsize file_size;
|
||||||
gchar *uri;
|
|
||||||
gboolean match;
|
gboolean match;
|
||||||
|
|
||||||
uri = gnome_vfs_get_uri_from_local_path (filename);
|
g_file_get_contents (filename, &file_contents, &file_size, NULL);
|
||||||
g_free (filename);
|
|
||||||
gnome_vfs_read_entire_file (uri, &file_size, &file_contents);
|
|
||||||
g_free (uri);
|
|
||||||
|
|
||||||
pattern = g_pattern_spec_new ("*[Icon Theme]*");
|
pattern = g_pattern_spec_new ("*[Icon Theme]*");
|
||||||
match = g_pattern_match_string (pattern, file_contents);
|
match = g_pattern_match_string (pattern, file_contents);
|
||||||
|
@ -93,6 +91,7 @@ file_theme_type (const gchar *dir)
|
||||||
pattern = g_pattern_spec_new ("*Directories=*");
|
pattern = g_pattern_spec_new ("*Directories=*");
|
||||||
match = g_pattern_match_string (pattern, file_contents);
|
match = g_pattern_match_string (pattern, file_contents);
|
||||||
g_pattern_spec_free (pattern);
|
g_pattern_spec_free (pattern);
|
||||||
|
g_free (file_contents);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
/* check if we have a cursor, too */
|
/* check if we have a cursor, too */
|
||||||
|
@ -111,6 +110,7 @@ file_theme_type (const gchar *dir)
|
||||||
pattern = g_pattern_spec_new ("*[X-GNOME-Metatheme]*");
|
pattern = g_pattern_spec_new ("*[X-GNOME-Metatheme]*");
|
||||||
match = g_pattern_match_string (pattern, file_contents);
|
match = g_pattern_match_string (pattern, file_contents);
|
||||||
g_pattern_spec_free (pattern);
|
g_pattern_spec_free (pattern);
|
||||||
|
g_free (file_contents);
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
return THEME_GNOME;
|
return THEME_GNOME;
|
||||||
|
@ -153,7 +153,12 @@ file_theme_type (const gchar *dir)
|
||||||
static void
|
static void
|
||||||
transfer_cancel_cb (GtkWidget *dlg, gchar *path)
|
transfer_cancel_cb (GtkWidget *dlg, gchar *path)
|
||||||
{
|
{
|
||||||
gnome_vfs_unlink (path);
|
GFile *todelete;
|
||||||
|
|
||||||
|
todelete = g_file_new_for_path (path);
|
||||||
|
g_file_delete (todelete, NULL, NULL);
|
||||||
|
|
||||||
|
g_object_unref (todelete);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
gtk_widget_destroy (dlg);
|
gtk_widget_destroy (dlg);
|
||||||
}
|
}
|
||||||
|
@ -259,8 +264,8 @@ gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *them
|
||||||
{
|
{
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
GtkWidget *dialog, *apply_button;
|
GtkWidget *dialog, *apply_button;
|
||||||
int xfer_options;
|
GFile *theme_source_dir, *theme_dest_dir;
|
||||||
GnomeVFSURI *theme_source_dir, *theme_dest_dir;
|
GError *error = NULL;
|
||||||
gint theme_type;
|
gint theme_type;
|
||||||
gchar *user_message = NULL;
|
gchar *user_message = NULL;
|
||||||
gchar *target_dir = NULL;
|
gchar *target_dir = NULL;
|
||||||
|
@ -307,13 +312,25 @@ gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *them
|
||||||
&& (file_theme_type (path) == THEME_ICON))
|
&& (file_theme_type (path) == THEME_ICON))
|
||||||
{
|
{
|
||||||
gchar *new_path, *update_icon_cache;
|
gchar *new_path, *update_icon_cache;
|
||||||
|
GFile *new_file;
|
||||||
|
GFile *src_file;
|
||||||
|
|
||||||
|
src_file = g_file_new_for_path (path);
|
||||||
new_path = g_build_path (G_DIR_SEPARATOR_S,
|
new_path = g_build_path (G_DIR_SEPARATOR_S,
|
||||||
g_get_home_dir (),
|
g_get_home_dir (),
|
||||||
".icons",
|
".icons",
|
||||||
theme_name, NULL);
|
theme_name, NULL);
|
||||||
/* XXX: make some noise if we couldn't install it? */
|
new_file = g_file_new_for_path (new_path);
|
||||||
gnome_vfs_move (path, new_path, FALSE);
|
|
||||||
|
if (!g_file_move (src_file, new_file, G_FILE_COPY_NONE,
|
||||||
|
NULL, NULL, NULL, &error)) {
|
||||||
|
g_warning ("Error while moving from `%s' to `%s': %s",
|
||||||
|
path, new_path, error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
|
g_object_unref (new_file);
|
||||||
|
g_object_unref (src_file);
|
||||||
|
|
||||||
/* update icon cache - shouldn't really matter if this fails */
|
/* update icon cache - shouldn't really matter if this fails */
|
||||||
update_icon_cache = g_strdup_printf ("gtk-update-icon-cache %s", new_path);
|
update_icon_cache = g_strdup_printf ("gtk-update-icon-cache %s", new_path);
|
||||||
|
@ -326,17 +343,12 @@ gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *them
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move the dir to the target dir */
|
/* Move the dir to the target dir */
|
||||||
theme_source_dir = gnome_vfs_uri_new (tmp_dir);
|
theme_source_dir = g_file_new_for_path (tmp_dir);
|
||||||
theme_dest_dir = gnome_vfs_uri_new (target_dir);
|
theme_dest_dir = g_file_new_for_path (target_dir);
|
||||||
|
|
||||||
xfer_options = GNOME_VFS_XFER_RECURSIVE;
|
if (!g_file_move (theme_source_dir, theme_dest_dir,
|
||||||
if (filetype != DIRECTORY)
|
G_FILE_COPY_OVERWRITE, NULL, NULL,
|
||||||
xfer_options |= GNOME_VFS_XFER_REMOVESOURCE;
|
NULL, &error)) {
|
||||||
|
|
||||||
if (gnome_vfs_xfer_uri (theme_source_dir, theme_dest_dir, xfer_options,
|
|
||||||
GNOME_VFS_XFER_ERROR_MODE_ABORT,
|
|
||||||
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
|
|
||||||
NULL, NULL) != GNOME_VFS_OK) {
|
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
str = g_strdup_printf (_("Installation for theme \"%s\" failed."), theme_name);
|
str = g_strdup_printf (_("Installation for theme \"%s\" failed."), theme_name);
|
||||||
|
@ -345,7 +357,13 @@ gnome_theme_install_real (gint filetype, const gchar *tmp_dir, const gchar *them
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
GTK_BUTTONS_OK,
|
GTK_BUTTONS_OK,
|
||||||
str);
|
str);
|
||||||
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||||
|
error->message);
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
g_error_free (error);
|
||||||
|
error = NULL;
|
||||||
|
|
||||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
|
@ -475,12 +493,13 @@ transfer_done_cb (GtkWidget *dlg, gchar *path)
|
||||||
gchar *tmp_dir;
|
gchar *tmp_dir;
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
gint n_themes;
|
gint n_themes;
|
||||||
|
GFile *todelete;
|
||||||
|
|
||||||
tmp_dir = g_strdup_printf ("%s/.themes/.theme-%u",
|
tmp_dir = g_strdup_printf ("%s/.themes/.theme-%u",
|
||||||
g_get_home_dir (),
|
g_get_home_dir (),
|
||||||
g_random_int ());
|
g_random_int ());
|
||||||
|
|
||||||
if ((gnome_vfs_make_directory (tmp_dir, 0700)) != GNOME_VFS_OK) {
|
if ((g_mkdir (tmp_dir, 0700)) != 0) {
|
||||||
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
|
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
|
||||||
GTK_BUTTONS_OK,
|
GTK_BUTTONS_OK,
|
||||||
_("Failed to create temporary directory"));
|
_("Failed to create temporary directory"));
|
||||||
|
@ -491,17 +510,20 @@ transfer_done_cb (GtkWidget *dlg, gchar *path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!transfer_done_archive (filetype, tmp_dir, path) ||
|
if (!transfer_done_archive (filetype, tmp_dir, path) ||
|
||||||
((dir = g_dir_open (tmp_dir, 0, NULL)) == NULL))
|
((dir = g_dir_open (tmp_dir, 0, NULL)) == NULL))
|
||||||
{
|
{
|
||||||
cleanup_tmp_dir (tmp_dir);
|
g_io_scheduler_push_job ((GIOSchedulerJobFunc) cleanup_tmp_dir,
|
||||||
|
g_strdup (tmp_dir), g_free,
|
||||||
|
G_PRIORITY_DEFAULT, NULL);
|
||||||
g_free (tmp_dir);
|
g_free (tmp_dir);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnome_vfs_unlink (path);
|
todelete = g_file_new_for_path (path);
|
||||||
|
g_file_delete (todelete, NULL, NULL);
|
||||||
|
g_object_unref (todelete);
|
||||||
|
|
||||||
/* See whether we have multiple themes to install. If so,
|
/* See whether we have multiple themes to install. If so,
|
||||||
* we won't ask the user whether to apply the new theme
|
* we won't ask the user whether to apply the new theme
|
||||||
|
@ -547,9 +569,9 @@ transfer_done_cb (GtkWidget *dlg, gchar *path)
|
||||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
g_io_scheduler_push_job ((GIOSchedulerJobFunc) cleanup_tmp_dir,
|
||||||
cleanup_tmp_dir (tmp_dir);
|
tmp_dir, g_free,
|
||||||
g_free (tmp_dir);
|
G_PRIORITY_DEFAULT, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
|
|
@ -62,7 +62,7 @@ directory_delete_recursive (GFile *directory, GError **error)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
gboolean
|
||||||
file_delete_recursive (GFile *file, GError **error)
|
file_delete_recursive (GFile *file, GError **error)
|
||||||
{
|
{
|
||||||
GFileInfo *info;
|
GFileInfo *info;
|
||||||
|
|
|
@ -60,3 +60,4 @@ gboolean theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIte
|
||||||
|
|
||||||
void theme_install_file (GtkWindow *parent, const gchar *path);
|
void theme_install_file (GtkWindow *parent, const gchar *path);
|
||||||
gboolean packagekit_available (void);
|
gboolean packagekit_available (void);
|
||||||
|
gboolean file_delete_recursive (GFile *directory, GError **error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue