~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to capplets/appearance/gnome-wp-info.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Authors: Rodney Dawes <dobey@ximian.com>
3
 
 *
4
 
 *  Copyright 2003-2006 Novell, Inc. (www.novell.com)
5
 
 *
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
9
 
 *
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.
14
 
 *
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.
18
 
 *
19
 
 */
20
 
 
21
 
#include <config.h>
22
 
#include <string.h>
23
 
#include <glib/gi18n.h>
24
 
#include <gio/gio.h>
25
 
#include "gnome-wp-info.h"
26
 
 
27
 
GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
28
 
                                 GnomeDesktopThumbnailFactory * thumbs) {
29
 
  GnomeWPInfo *wp;
30
 
  GFile *file;
31
 
  GFileInfo *info;
32
 
 
33
 
  file = g_file_new_for_commandline_arg (uri);
34
 
 
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,
41
 
                            NULL, NULL);
42
 
  g_object_unref (file);
43
 
 
44
 
  if (info == NULL || g_file_info_get_content_type (info) == NULL) {
45
 
    if (!strcmp (uri, "(none)")) {
46
 
      wp = g_new0 (GnomeWPInfo, 1);
47
 
 
48
 
      wp->mime_type = g_strdup ("image/x-no-data");
49
 
      wp->uri = g_strdup (uri);
50
 
      wp->name = g_strdup (_("No Desktop Background"));
51
 
      wp->size = 0;
52
 
    } else {
53
 
      wp = NULL;
54
 
    }
55
 
  } else {
56
 
    wp = g_new0 (GnomeWPInfo, 1);
57
 
 
58
 
    wp->uri = g_strdup (uri);
59
 
 
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);
66
 
 
67
 
    wp->thumburi = gnome_desktop_thumbnail_factory_lookup (thumbs,
68
 
                                                           uri,
69
 
                                                           wp->mtime);
70
 
  }
71
 
 
72
 
  if (info != NULL)
73
 
    g_object_unref (info);
74
 
 
75
 
  return wp;
76
 
}
77
 
 
78
 
void gnome_wp_info_free (GnomeWPInfo * info) {
79
 
  if (info == NULL) {
80
 
    return;
81
 
  }
82
 
 
83
 
  g_free (info->uri);
84
 
  g_free (info->thumburi);
85
 
  g_free (info->name);
86
 
  g_free (info->mime_type);
87
 
}