static GIcon * xfdesktop_special_file_icon_load_icon(XfdesktopIcon *icon) { XfdesktopSpecialFileIcon *special_icon = XFDESKTOP_SPECIAL_FILE_ICON(icon); XfdesktopFileIcon *file_icon = XFDESKTOP_FILE_ICON(icon); gchar *icon_name = NULL; GFile *parent = NULL; GIcon *gicon = NULL; TRACE("entering"); /* use a custom icon name for the local filesystem root */ parent = g_file_get_parent(special_icon->priv->file); if(!parent && g_file_has_uri_scheme(special_icon->priv->file, "file")) icon_name = g_strdup("drive-harddisk"); if(parent) g_object_unref(parent); /* use a custom icon for the trash, based on it having files * the user can delete */ if(special_icon->priv->type == XFDESKTOP_SPECIAL_FILE_ICON_TRASH) { if(special_icon->priv->trash_item_count == 0) icon_name = g_strdup("user-trash"); else icon_name = g_strdup("user-trash-full"); } /* Create the themed icon for it */ if(icon_name) { gicon = g_themed_icon_new(icon_name); g_free(icon_name); } /* If we still don't have an icon, use the default */ if(!G_IS_ICON(gicon)) { gicon = g_file_info_get_icon(special_icon->priv->file_info); if(G_IS_ICON(gicon)) g_object_ref(gicon); } g_object_set(file_icon, "gicon", gicon, NULL); /* Add any user set emblems */ gicon = xfdesktop_file_icon_add_emblems(file_icon); return gicon; }
static GIcon * xfdesktop_volume_icon_load_icon(XfdesktopIcon *icon) { XfdesktopVolumeIcon *volume_icon = XFDESKTOP_VOLUME_ICON(icon); XfdesktopFileIcon *file_icon = XFDESKTOP_FILE_ICON(icon); GIcon *gicon = NULL; TRACE("entering"); /* load icon and keep a ref to it */ if(volume_icon->priv->volume) { gicon = g_volume_get_icon(volume_icon->priv->volume); if(G_IS_ICON(gicon)) g_object_ref(gicon); g_object_set(file_icon, "gicon", gicon, NULL); /* Add any user set emblems */ gicon = xfdesktop_file_icon_add_emblems(file_icon); } return gicon; }
static GIcon * xfdesktop_regular_file_icon_load_icon(XfdesktopIcon *icon) { XfdesktopRegularFileIcon *regular_icon = XFDESKTOP_REGULAR_FILE_ICON(icon); XfdesktopFileIcon *file_icon = XFDESKTOP_FILE_ICON(icon); GIcon *gicon = NULL; TRACE("entering"); /* Try to load the icon referenced in the .desktop file */ if(xfdesktop_file_utils_is_desktop_file(regular_icon->priv->file_info)) { gicon = xfdesktop_load_icon_from_desktop_file(regular_icon); } else if(g_file_info_get_file_type(regular_icon->priv->file_info) == G_FILE_TYPE_DIRECTORY) { /* Try to load a thumbnail from the standard folder image locations */ gchar *thumbnail_file = NULL; if(regular_icon->priv->show_thumbnails) thumbnail_file = xfdesktop_load_icon_location_from_folder(file_icon); if(thumbnail_file) { /* If there's a folder thumbnail, use it */ regular_icon->priv->thumbnail_file = g_file_new_for_path(thumbnail_file); gicon = g_file_icon_new(regular_icon->priv->thumbnail_file); g_free(thumbnail_file); } } else { /* If we have a thumbnail then they are enabled, use it. */ if(regular_icon->priv->thumbnail_file) { gchar *file = g_file_get_path(regular_icon->priv->file); gchar *mimetype = xfdesktop_get_file_mimetype(file); /* Don't use thumbnails for svg, use the file itself */ if(g_strcmp0(mimetype, "image/svg+xml") == 0) gicon = g_file_icon_new(regular_icon->priv->file); else gicon = g_file_icon_new(regular_icon->priv->thumbnail_file); g_free(mimetype); g_free(file); } } /* If we still don't have an icon, use the default */ if(!G_IS_ICON(gicon)) { gicon = g_file_info_get_icon(regular_icon->priv->file_info); if(G_IS_ICON(gicon)) g_object_ref(gicon); } g_object_set(file_icon, "gicon", gicon, NULL); /* Add any user set emblems */ gicon = xfdesktop_file_icon_add_emblems(file_icon); /* load the read only emblem if necessary */ if(!g_file_info_get_attribute_boolean(regular_icon->priv->file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) { GIcon *themed_icon = g_themed_icon_new(EMBLEM_READONLY); GEmblem *emblem = g_emblem_new(themed_icon); g_emblemed_icon_add_emblem(G_EMBLEMED_ICON(gicon), emblem); g_object_unref(emblem); g_object_unref(themed_icon); } /* load the symlink emblem if necessary */ if(g_file_info_get_attribute_boolean(regular_icon->priv->file_info, G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK)) { GIcon *themed_icon = g_themed_icon_new(EMBLEM_SYMLINK); GEmblem *emblem = g_emblem_new(themed_icon); g_emblemed_icon_add_emblem(G_EMBLEMED_ICON(gicon), emblem); g_object_unref(emblem); g_object_unref(themed_icon); } return gicon; }