even more gio migration

2008-05-04  Jens Granseuer  <jensgr@gmx.net>

	* appearance-desktop.c: (desktop_init):
	* gnome-wp-info.c: (gnome_wp_info_new), (gnome_wp_info_free):
	* gnome-wp-info.h:
	* gnome-wp-item.c: (gnome_wp_item_new),
	(gnome_wp_item_update_description):
	* gnome-wp-item.h: even more gio migration

svn path=/trunk/; revision=8689
This commit is contained in:
Jens Granseuer 2008-05-04 13:39:46 +00:00 committed by Jens Granseuer
parent 225e397072
commit 259efe4102
6 changed files with 61 additions and 54 deletions

View file

@ -1,3 +1,12 @@
2008-05-04 Jens Granseuer <jensgr@gmx.net>
* appearance-desktop.c: (desktop_init):
* gnome-wp-info.c: (gnome_wp_info_new), (gnome_wp_info_free):
* gnome-wp-info.h:
* gnome-wp-item.c: (gnome_wp_item_new),
(gnome_wp_item_update_description):
* gnome-wp-item.h: even more gio migration
2008-05-01 Jens Granseuer <jensgr@gmx.net>
* appearance-themes.c: (theme_get_mtime),

View file

@ -931,8 +931,6 @@ desktop_init (AppearanceData *data,
data->wp_hash = g_hash_table_new (g_str_hash, g_str_equal);
gconf_client_add_dir (data->client, WP_KEYBOARD_PATH,
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (data->client, WP_PATH_KEY,
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

View file

@ -19,52 +19,60 @@
*/
#include <config.h>
#include <gnome.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include "gnome-wp-info.h"
GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
GnomeThumbnailFactory * thumbs) {
GnomeWPInfo * new;
GnomeVFSFileInfo * info;
GnomeVFSResult result;
gchar * escaped_path;
GnomeWPInfo *wp;
GFile *file;
GFileInfo *info;
info = gnome_vfs_file_info_new ();
escaped_path = gnome_vfs_escape_path_string (uri);
file = g_file_new_for_commandline_arg (uri);
result = gnome_vfs_get_file_info (escaped_path, info,
GNOME_VFS_FILE_INFO_DEFAULT |
GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
if (info == NULL || info->mime_type == NULL || result != GNOME_VFS_OK) {
info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_NAME ","
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_TIME_MODIFIED,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
g_object_unref (file);
if (info == NULL || g_file_info_get_content_type (info) == NULL) {
if (!strcmp (uri, "(none)")) {
new = g_new0 (GnomeWPInfo, 1);
wp = g_new0 (GnomeWPInfo, 1);
new->mime_type = g_strdup ("image/x-no-data");
new->uri = g_strdup (uri);
new->name = g_strdup (_("No Wallpaper"));
new->size = 0;
wp->mime_type = g_strdup ("image/x-no-data");
wp->uri = g_strdup (uri);
wp->name = g_strdup (_("No Wallpaper"));
wp->size = 0;
} else {
new = NULL;
wp = NULL;
}
} else {
new = g_new0 (GnomeWPInfo, 1);
wp = g_new0 (GnomeWPInfo, 1);
new->uri = g_strdup (uri);
wp->uri = g_strdup (uri);
new->thumburi = gnome_thumbnail_factory_lookup (thumbs,
escaped_path,
info->mtime);
new->name = g_strdup (info->name);
new->mime_type = g_strdup (info->mime_type);
wp->name = g_strdup (g_file_info_get_name (info));
if (g_file_info_get_content_type (info) != NULL)
wp->mime_type = g_strdup (g_file_info_get_content_type (info));
wp->size = g_file_info_get_size (info);
wp->mtime = g_file_info_get_attribute_uint64 (info,
G_FILE_ATTRIBUTE_TIME_MODIFIED);
wp->thumburi = gnome_thumbnail_factory_lookup (thumbs,
uri,
wp->mtime);
new->size = info->size;
new->mtime = info->mtime;
}
g_free (escaped_path);
gnome_vfs_file_info_unref (info);
return new;
if (info != NULL)
g_object_unref (info);
return wp;
}
void gnome_wp_info_free (GnomeWPInfo * info) {
@ -76,7 +84,4 @@ void gnome_wp_info_free (GnomeWPInfo * info) {
g_free (info->thumburi);
g_free (info->name);
g_free (info->mime_type);
info = NULL;
}

View file

@ -22,7 +22,6 @@
#define _GNOME_WP_INFO_H_
#include <glib.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomeui/gnome-thumbnail.h>
typedef struct _GnomeWPInfo GnomeWPInfo;
@ -33,7 +32,7 @@ struct _GnomeWPInfo {
gchar * name;
gchar * mime_type;
GnomeVFSFileSize size;
goffset size;
time_t mtime;
};

View file

@ -24,7 +24,6 @@
#include <gconf/gconf-client.h>
#include <gnome.h>
#include <string.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include "gnome-wp-item.h"
static GConfEnumStringPair options_lookup[] = {
@ -129,20 +128,18 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
GnomeThumbnailFactory * thumbnails) {
GnomeWPItem *item = g_new0 (GnomeWPItem, 1);
item->filename = gnome_vfs_unescape_string_for_display (filename);
item->filename = g_strdup (filename);
item->fileinfo = gnome_wp_info_new (filename, thumbnails);
item->fileinfo = gnome_wp_info_new (item->filename, thumbnails);
if (item->fileinfo != NULL &&
if (item->fileinfo != NULL && item->fileinfo->mime_type != NULL &&
(g_str_has_prefix (item->fileinfo->mime_type, "image/") ||
strcmp (item->fileinfo->mime_type, "application/xml") == 0)) {
if (item->name == NULL) {
if (g_utf8_validate (item->fileinfo->name, -1, NULL))
item->name = g_strdup (item->fileinfo->name);
else
item->name = g_filename_to_utf8 (item->fileinfo->name, -1, NULL,
NULL, NULL);
}
if (g_utf8_validate (item->fileinfo->name, -1, NULL))
item->name = g_strdup (item->fileinfo->name);
else
item->name = g_filename_to_utf8 (item->fileinfo->name, -1, NULL,
NULL, NULL);
gnome_wp_item_update (item);
gnome_wp_item_update_description (item);
@ -211,7 +208,7 @@ void gnome_wp_item_update_description (GnomeWPItem * item) {
if (strcmp (item->fileinfo->mime_type, "application/xml") == 0)
description = _("Slide Show");
else
description = gnome_vfs_mime_get_description (item->fileinfo->mime_type);
description = g_content_type_get_description (item->fileinfo->mime_type);
/* translators: <b>wallpaper name</b>
* mime type, x pixel(s) by y pixel(s)

View file

@ -19,14 +19,15 @@
*/
#include <glib.h>
#include <gio/gio.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtktreeview.h>
#include <libgnomeui/gnome-thumbnail.h>
#include <gnome-wp-info.h>
#include <libgnomevfs/gnome-vfs.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnomeui/gnome-bg.h>
#include "gnome-wp-info.h"
#ifndef _GNOME_WP_ITEM_H_
#define _GNOME_WP_ITEM_H_
@ -36,8 +37,6 @@
#define WP_SHADING_KEY WP_PATH_KEY "/color_shading_type"
#define WP_PCOLOR_KEY WP_PATH_KEY "/primary_color"
#define WP_SCOLOR_KEY WP_PATH_KEY "/secondary_color"
#define WP_KEYBOARD_PATH "/desktop/gnome/peripherals/keyboard"
#define WP_DELAY_KEY WP_KEYBOARD_PATH "/delay"
typedef struct _GnomeWPItem GnomeWPItem;