~ubuntu-branches/ubuntu/trusty/xfdesktop4/trusty

« back to all changes in this revision

Viewing changes to src/xfdesktop-file-icon-manager.c

  • Committer: Package Import Robot
  • Author(s): Jackson Doak
  • Date: 2014-03-19 16:33:54 UTC
  • mfrom: (3.1.14 experimental)
  • Revision ID: package-import@ubuntu.com-20140319163354-9jismnm7xh1jrskz
Tags: 4.11.4-1ubuntu1
* Merge from debian. Remaining changes:
  - debian/patches/xubuntu_improve-nautilus-interactions.patch: added,
    should prevent nautilus from taking over the desktop if xfdesktop is
    running (and vice-versa).
  - debian/patches/xubuntu_set-accountsservice-user-bg.patch: update the
    user background property of Accountsservice on backdrop change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1905
1905
}
1906
1906
#endif
1907
1907
 
1908
 
/* builds a folder/file path and then tests if that file is a valid image.
1909
 
 * returns the file location if it does, NULL if it doesn't */
1910
 
static gchar *
1911
 
xfdesktop_check_file_is_valid(const gchar *folder, const gchar *file)
1912
 
{
1913
 
    gchar *path = g_strconcat(folder, "/", file, NULL);
1914
 
 
1915
 
    if(gdk_pixbuf_get_file_info(path, NULL, NULL) == NULL) {
1916
 
        g_free(path);
1917
 
        path = NULL;
1918
 
    }
1919
 
 
1920
 
    return path;
1921
 
}
1922
 
 
1923
 
static gchar *
1924
 
xfdesktop_load_icon_location_from_folder(XfdesktopFileIcon *icon)
1925
 
{
1926
 
    gchar *icon_file = g_file_get_path(xfdesktop_file_icon_peek_file(icon));
1927
 
    gchar *path;
1928
 
 
1929
 
    g_return_val_if_fail(icon_file, NULL);
1930
 
 
1931
 
    /* So much for standards */
1932
 
    path = xfdesktop_check_file_is_valid(icon_file, "Folder.jpg");
1933
 
    if(path == NULL) {
1934
 
        path = xfdesktop_check_file_is_valid(icon_file, "folder.jpg");
1935
 
    }
1936
 
    if(path == NULL) {
1937
 
        path = xfdesktop_check_file_is_valid(icon_file, "Folder.JPG");
1938
 
    }
1939
 
    if(path == NULL) {
1940
 
        path = xfdesktop_check_file_is_valid(icon_file, "folder.JPG");
1941
 
    }
1942
 
    if(path == NULL) {
1943
 
        path = xfdesktop_check_file_is_valid(icon_file, "Cover.jpg");
1944
 
    }
1945
 
    if(path == NULL) {
1946
 
        path = xfdesktop_check_file_is_valid(icon_file, "cover.jpg");
1947
 
    }
1948
 
    if(path == NULL) {
1949
 
        path = xfdesktop_check_file_is_valid(icon_file, "albumart.jpg");
1950
 
    }
1951
 
    if(path == NULL) {
1952
 
        path = xfdesktop_check_file_is_valid(icon_file, "fanart.jpg");
1953
 
    }
1954
 
    if(path == NULL) {
1955
 
        path = xfdesktop_check_file_is_valid(icon_file, "Fanart.jpg");
1956
 
    }
1957
 
    if(path == NULL) {
1958
 
        path = xfdesktop_check_file_is_valid(icon_file, "fanart.JPG");
1959
 
    }
1960
 
    if(path == NULL) {
1961
 
        path = xfdesktop_check_file_is_valid(icon_file, "Fanart.JPG");
1962
 
    }
1963
 
    if(path == NULL) {
1964
 
        path = xfdesktop_check_file_is_valid(icon_file, "FANART.JPG");
1965
 
    }
1966
 
    if(path == NULL) {
1967
 
        path = xfdesktop_check_file_is_valid(icon_file, "FANART.jpg");
1968
 
    }
1969
 
 
1970
 
    g_free(icon_file);
1971
 
 
1972
 
    /* the file *should* already be a thumbnail */
1973
 
    return path;
1974
 
}
1975
 
 
1976
1908
static void
1977
1909
xfdesktop_file_icon_manager_queue_thumbnail(XfdesktopFileIconManager *fmanager,
1978
1910
                                            XfdesktopFileIcon *icon)
1979
1911
{
1980
1912
    GFile *file;
1981
 
    GFileInfo *file_info;
1982
 
    gchar *path = NULL, *thumbnail_file = NULL;
 
1913
    gchar *path = NULL;
1983
1914
 
1984
1915
    file = xfdesktop_file_icon_peek_file(icon);
1985
 
    file_info = xfdesktop_file_icon_peek_file_info(icon);
1986
1916
 
1987
1917
    if(file != NULL)
1988
1918
        path = g_file_get_path(file);
1989
1919
 
1990
1920
    if(fmanager->priv->show_thumbnails && path != NULL) {
1991
 
        if(g_file_info_get_file_type(file_info) == G_FILE_TYPE_DIRECTORY) {
1992
 
            /* Try to load a thumbnail from the standard folder image locations */
1993
 
            thumbnail_file = xfdesktop_load_icon_location_from_folder(icon);
1994
 
 
1995
 
            if(thumbnail_file) {
1996
 
                GFile *temp = g_file_new_for_path(thumbnail_file);
1997
 
                xfdesktop_icon_set_thumbnail_file(XFDESKTOP_ICON(icon), temp);
1998
 
            }
1999
 
 
2000
 
            g_free(thumbnail_file);
2001
 
        } else {
2002
 
            xfdesktop_thumbnailer_queue_thumbnail(fmanager->priv->thumbnailer,
2003
 
                                                  path);
2004
 
        }
 
1921
        xfdesktop_thumbnailer_queue_thumbnail(fmanager->priv->thumbnailer, path);
2005
1922
    }
2006
1923
 
2007
1924
    if(path) {
2206
2123
        return NULL;
2207
2124
 
2208
2125
    /* should never return NULL */
2209
 
    icon = xfdesktop_regular_file_icon_new(file, info, fmanager->priv->gscreen);
 
2126
    icon = xfdesktop_regular_file_icon_new(file, info, fmanager->priv->gscreen, fmanager);
2210
2127
    
2211
2128
    xfdesktop_file_icon_manager_add_icon(fmanager,
2212
2129
                                         XFDESKTOP_FILE_ICON(icon),
2736
2653
         * send notification messages when monitored files change */
2737
2654
        if(!fmanager->priv->metadata_monitor) {
2738
2655
            gchar *location = xfce_resource_lookup(XFCE_RESOURCE_DATA, "gvfs-metadata/");
2739
 
            GFile *metadata_location = g_file_new_for_path(location);
 
2656
            GFile *metadata_location;
 
2657
 
 
2658
            if(location == NULL)
 
2659
                return;
 
2660
 
 
2661
            metadata_location = g_file_new_for_path(location);
2740
2662
 
2741
2663
            fmanager->priv->metadata_monitor = g_file_monitor(metadata_location,
2742
2664
                                                              G_FILE_MONITOR_NONE,
3025
2947
 
3026
2948
    fmanager->priv->desktop_icon = XFDESKTOP_FILE_ICON(xfdesktop_regular_file_icon_new(fmanager->priv->folder,
3027
2949
                                                                                       desktop_info,
3028
 
                                                                                       fmanager->priv->gscreen));
 
2950
                                                                                       fmanager->priv->gscreen,
 
2951
                                                                                       fmanager));
3029
2952
    
3030
2953
    g_object_unref(desktop_info);
3031
2954