AppleOpenSource/WebKit2-7609.3.5.1.3/UIProcess/API/glib/WebKitFileChooserRequest.cpp
/**
 * webkit_file_chooser_request_get_mime_types_filter:
 * @request: a #WebKitFileChooserRequest
 *
 * Get the filter currently associated with the request, ready to be
 * used by #GtkFileChooser. This function should normally be called
 * before presenting the file chooser dialog to the user, to decide
 * whether to apply a filter so the user would not be allowed to
 * select files with other MIME types.
 *
 * See webkit_file_chooser_request_get_mime_types() if you are
 * interested in getting the list of accepted MIME types.
 *
 * Returns: (transfer none): a #GtkFileFilter if a list of accepted
 * MIME types is defined or %NULL otherwise. The returned object is
 * owned by WebKit should not be modified or freed.
 */


Get the filter currently associated with the request, ready to be
used by #GtkFileChooser. This function should normally be called
before presenting the file chooser dialog to the user, to decide
whether to apply a filter so the user would not be allowed to
select files with other MIME types.

See webkit_file_chooser_request_get_mime_types() if you are
interested in getting the list of accepted MIME types.

(transfer none): a #GtkFileFilter if a list of accepted
MIME types is defined or %NULL otherwise. The returned object is
owned by WebKit should not be modified or freed.
Get the filter currently associated with the request ready to be used by #GtkFileChooser . This function should normally be called before presenting the file chooser dialog to the user to decide whether to apply a filter so the user would not be allowed to select files with other MIME types . See webkit_file_chooser_request_get_mime_types () if you are interested in getting the list of accepted MIME types . ( transfer none ) : a #GtkFileFilter if a list of accepted MIME types is defined or %NULL otherwise . The returned object is owned by WebKit should not be modified or freed .
GtkFileFilter* webkit_file_chooser_request_get_mime_types_filter(WebKitFileChooserRequest* request)
{
    g_return_val_if_fail(WEBKIT_IS_FILE_CHOOSER_REQUEST(request), 0);
    if (request->priv->filter)
        return request->priv->filter.get();
    Ref<API::Array> mimeTypes = request->priv->parameters->acceptMIMETypes();
    size_t numOfMimeTypes = mimeTypes->size();
    if (!numOfMimeTypes)
        return 0;
    request->priv->filter = gtk_file_filter_new();
    for (size_t i = 0; i < numOfMimeTypes; ++i) {
        API::String* webMimeType = static_cast<API::String*>(mimeTypes->at(i));
        String mimeTypeString = webMimeType->string();
        if (mimeTypeString.isEmpty())
            continue;
        gtk_file_filter_add_mime_type(request->priv->filter.get(), mimeTypeString.utf8().data());
    }
    return request->priv->filter.get();
}
GtkFileFilter * webkit_file_chooser_request_get_mime_types_filter ( WebKitFileChooserRequest * request ) { g_return_val_if_fail ( WEBKIT_IS_FILE_CHOOSER_REQUEST ( request ) , 0 ) ; if ( request -> priv -> filter ) return request -> priv -> filter . get ( ) ; Ref < API :: Array > mimeTypes = request -> priv -> parameters -> acceptMIMETypes ( ) ; size_t numOfMimeTypes = mimeTypes -> size ( ) ; if ( ! numOfMimeTypes ) return 0 ; request -> priv -> filter = gtk_file_filter_new ( ) ; for ( size_t i = 0 ; i < numOfMimeTypes ; ++ i ) { API :: String * webMimeType = static_cast < API :: String * > ( mimeTypes -> at ( i ) ) ; String mimeTypeString = webMimeType -> string ( ) ; if ( mimeTypeString . isEmpty ( ) ) continue ; gtk_file_filter_add_mime_type ( request -> priv -> filter . get ( ) , mimeTypeString . utf8 ( ) . data ( ) ) ; } return request -> priv -> filter . get ( ) ; }
webkit_file_chooser_request_get_mime_types_filter:
 @request: a #WebKitFileChooserRequest
webkit_file_chooser_request_get_mime_types_filter : @request : a #WebKitFileChooserRequest
// Do not use adoptGRef here, since we want to sink the floating // reference for the new instance of GtkFileFilter, so we make // sure we keep the ownership during the lifetime of the request.