#55 Use gnome_vfs to detect file mime types

closed-accepted
nobody
None
5
2007-09-11
2006-12-06
Anonymous
No

This patch uses the gnomevfs library to detect file mime types instead of relying on what GtkFileChooser informs.

This works around a bug that would make GtkFileChooser not detect the right mime types when gnome-settings-daemon is not running, which would cause some audio files to not display in the file browser (see http://bugs.debian.org/401104\).

Discussion

  • Goedson Teixeira Paixao

    Logged In: YES
    user_id=5955
    Originator: NO

    Sorry for submiting this anonymously. I thought I was logged in.

     
  • Goedson Teixeira Paixao

    Logged In: YES
    user_id=5955
    Originator: NO

    The patch as it is in the attached file, would sefgault when trying to free the file_info pointer. It should use gnome_vfs_file_info_unref instead of g_object_unref. The corrected patch is as follows:

    diff -urNad gnomebaker-0.6.0~/src/gnomebaker.c gnomebaker-0.6.0/src/gnomebaker.c
    --- gnomebaker-0.6.0~/src/gnomebaker.c 2006-09-06 16:18:27.000000000 -0300
    +++ gnomebaker-0.6.0/src/gnomebaker.c 2006-12-06 19:29:56.000000000 -0200
    @@ -170,7 +170,23 @@
    gnomebaker_audio_file_filter(const GtkFileFilterInfo *filter_info, gpointer data)
    {
    GB_LOG_FUNC
    - return (media_get_plugin_status(filter_info->mime_type) == INSTALLED);
    + GnomeVFSFileInfo *file_info = NULL;
    + gboolean return_value = FALSE;
    +
    + file_info = gnome_vfs_file_info_new();
    +
    + g_return_val_if_fail(file_info != NULL, FALSE);
    +
    + GnomeVFSResult gnome_vfs_result = gnome_vfs_get_file_info(filter_info->uri,
    + file_info,
    + GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
    +
    + if (gnome_vfs_result == GNOME_VFS_OK)
    + return_value = media_get_plugin_status(gnome_vfs_file_info_get_mime_type(file_info)) == INSTALLED;
    +
    + gnome_vfs_file_info_unref(file_info);
    + return return_value;
    +
    }
    #endif

    @@ -1150,8 +1166,8 @@
    gtk_paned_pack2(GTK_PANED(vpane), tabs, TRUE, TRUE);

    audio_filter = gtk_file_filter_new();
    - gtk_file_filter_add_custom(audio_filter, GTK_FILE_FILTER_MIME_TYPE,
    - gnomebaker_audio_file_filter, NULL, NULL);
    + gtk_file_filter_add_custom(audio_filter, GTK_FILE_FILTER_URI,
    + gnomebaker_audio_file_filter, NULL, NULL);
    gtk_file_filter_set_name(audio_filter,_("Audio files"));

    gtk_widget_hide(glade_xml_get_widget(xml, "separator4"));

     
  • Goedson Teixeira Paixao

    • status: open --> closed-accepted
     
  • Goedson Teixeira Paixao

    Logged In: YES
    user_id=5955
    Originator: NO

    This patch has already been commited, thanks.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks