~ubuntu-branches/ubuntu/saucy/file-browser-applet/saucy

« back to all changes in this revision

Viewing changes to src/vfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2009-07-01 17:43:20 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090701174320-47ghs6125y9in9e3
Tags: 0.6.4-0ubuntu1
* New upstream release.
 - Added option to display thumbnails (if available) instead of icons.
 - Usability improvements.
 - Code cleanups.
* debian/control:
 - Bump standards version to 3.8.2, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
/******************************************************************************/
47
47
gboolean
48
48
vfs_file_is_executable (const gchar *file_name) {
49
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
50
 
 
51
49
    GFile*     file = g_file_new_for_path (file_name);
52
50
    GFileInfo* file_info =  g_file_query_info (file,
53
51
                                               /*G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE ,*/
68
66
/******************************************************************************/
69
67
gboolean
70
68
vfs_file_is_directory (const gchar *file_name) {
71
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
72
 
 
73
69
    GFile*     file = g_file_new_for_path (file_name);
74
70
    GFileInfo* file_info =  g_file_query_info (file,
75
71
                                               G_FILE_ATTRIBUTE_STANDARD_TYPE,
85
81
/******************************************************************************/
86
82
gboolean
87
83
vfs_file_is_desktop (const gchar *file_name) {
88
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
89
 
 
90
84
    GDesktopAppInfo *app_info = g_desktop_app_info_new_from_filename (file_name);
91
85
    gboolean ret = !(app_info == NULL);
92
86
    app_info ? g_object_unref (app_info) : NULL;
97
91
 * file. The caller must free the returned value. */
98
92
gchar*
99
93
vfs_get_default_mime_application (const gchar *file_name) {
100
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
101
 
 
102
94
    GFile*     file = g_file_new_for_path (file_name);
103
95
    GFileInfo* file_info =  g_file_query_info (file,
104
96
                                               G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
128
120
/******************************************************************************/
129
121
void
130
122
vfs_file_trash (const gchar *file_name) {
131
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
132
 
 
133
123
    GError *error = NULL;
134
124
    GFile *file = g_file_new_for_path (file_name);
135
125
 
169
159
/******************************************************************************/
170
160
GList*
171
161
vfs_get_all_mime_applications (const gchar *file_name) {
172
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
173
 
 
174
162
    GFile*     file = g_file_new_for_path (file_name);
175
163
    GFileInfo* file_info =  g_file_query_info (file,
176
164
                                               G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
287
275
vfs_get_dir_listings (GPtrArray *files,
288
276
                      GPtrArray *dirs,
289
277
                      gboolean show_hidden,
 
278
                      gboolean show_thumbnail,
290
279
                      const gchar *path) {
291
 
    if (DEBUG) g_printf ("In %s\n", __FUNCTION__);
292
 
 
293
280
    GError *error = NULL;
 
281
    const gchar *_attributes = "standard::type,standard::is-hidden,standard::name,standard::display-name,access::can-execute";
 
282
    gchar *attributes = show_thumbnail ? g_strdup_printf ("%s,thumbnail::path", _attributes) : g_strdup(_attributes);
294
283
 
295
284
    GFile *file = g_file_new_for_path (path);
296
285
    /* get ALL the info about the files */
297
286
    GFileEnumerator *enumerator = g_file_enumerate_children (file,
298
 
                                                             /*"*",*/
299
 
                                                             "standard::type,"
300
 
                                                             "standard::is-hidden,"
301
 
                                                             "standard::name,"
302
 
                                                             "standard::display-name,"
303
 
                                                             "access::can-execute",
 
287
                                                             attributes,
304
288
                                                             0,
305
289
                                                             NULL,
306
290
                                                             &error);
 
291
    g_free (attributes);
307
292
    /* did we read the dir correctly? */
308
293
    if (error) {
309
294
        gchar *error_msg = g_strdup (error->message);
319
304
            continue;
320
305
        }
321
306
        VfsFileInfo *vfs_file_info = g_new0 (VfsFileInfo ,1);
 
307
        vfs_file_info->icon = NULL;
322
308
 
323
309
        vfs_file_info->file_name = g_strdup_printf ("%s/%s", path, g_file_info_get_name (file_info));
324
310
 
332
318
        vfs_file_info->is_executable = g_file_info_get_attribute_boolean (file_info,
333
319
                                                                          G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE) &&
334
320
                                            (g_file_info_get_file_type (file_info) != G_FILE_TYPE_DIRECTORY);
335
 
        /* get the icon */
336
 
        vfs_file_info->icon = vfs_get_icon_for_file (vfs_file_info->file_name); 
 
321
 
 
322
        /* get the icon or thumbnail */
 
323
        /* FIXME: How expensive is this call? Should put it around an if (show_hidden) if it is expensive. */
 
324
        const gchar *thumbnail = g_file_info_get_attribute_byte_string (file_info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
 
325
        if (thumbnail) {
 
326
            vfs_file_info->icon = gtk_image_new_from_file (thumbnail);
 
327
        }
 
328
        else {
 
329
            vfs_file_info->icon = vfs_get_icon_for_file (vfs_file_info->file_name); 
 
330
        }
337
331
 
338
332
        /* add it to the array */
339
333
        if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) {