2
* Authors: Rodney Dawes <dobey@ximian.com>
4
* Copyright 2003-2006 Novell, Inc. (www.novell.com)
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of version 2 of the GNU General Public License
8
* as published by the Free Software Foundation
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
23
#include <glib/gi18n.h>
25
#include "gnome-wp-info.h"
27
GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
28
GnomeDesktopThumbnailFactory * thumbs) {
33
file = g_file_new_for_commandline_arg (uri);
35
info = g_file_query_info (file,
36
G_FILE_ATTRIBUTE_STANDARD_NAME ","
37
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
38
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
39
G_FILE_ATTRIBUTE_TIME_MODIFIED,
40
G_FILE_QUERY_INFO_NONE,
42
g_object_unref (file);
44
if (info == NULL || g_file_info_get_content_type (info) == NULL) {
45
if (!strcmp (uri, "(none)")) {
46
wp = g_new0 (GnomeWPInfo, 1);
48
wp->mime_type = g_strdup ("image/x-no-data");
49
wp->uri = g_strdup (uri);
50
wp->name = g_strdup (_("No Desktop Background"));
56
wp = g_new0 (GnomeWPInfo, 1);
58
wp->uri = g_strdup (uri);
60
wp->name = g_strdup (g_file_info_get_name (info));
61
if (g_file_info_get_content_type (info) != NULL)
62
wp->mime_type = g_strdup (g_file_info_get_content_type (info));
63
wp->size = g_file_info_get_size (info);
64
wp->mtime = g_file_info_get_attribute_uint64 (info,
65
G_FILE_ATTRIBUTE_TIME_MODIFIED);
67
wp->thumburi = gnome_desktop_thumbnail_factory_lookup (thumbs,
73
g_object_unref (info);
78
void gnome_wp_info_free (GnomeWPInfo * info) {
84
g_free (info->thumburi);
86
g_free (info->mime_type);