monotone

monotone Commit Details

Date:2008-06-06 19:17:00 (11 years 2 months ago)
Author:Tony Cooper
Branch:net.venge.monotone.contrib.mtn-browse
Commit:c452699f74fe158f10112e020c0946fa3a5a0f16
Parents: 43fe14a63ad8d76544bfa88fdc61316022207c1a
Message:Now correctly determine mime types for files and honour what is found.

Changes:
MPreferences.pm (1 diff)
Mmtn-browse (5 diffs)

File differences

Preferences.pm
629629
630630
631631
632
632
633633
634634
635635
foreach my $entry (@{$instance->{preferences}->{mime_table}})
{
if (grep(/\Q$pattern\E/, @{$entry->{file_name_patterns}}) > 0)
if (grep(/^\Q$pattern\E$/, @{$entry->{file_name_patterns}}) > 0)
{
$match = $entry->{name};
last;
mtn-browse
118118
119119
120120
121
121122
122123
123124
......
10581059
10591060
10601061
1062
10611063
10621064
10631065
......
10991101
11001102
11011103
1102
1103
1104
1105
1106
1107
1108
1109
1104
1105
1106
1107
11101108
11111109
11121110
11131111
1114
1112
11151113
11161114
11171115
11181116
11191117
1118
11201119
11211120
11221121
......
22962295
22972296
22982297
2299
2298
23002299
2301
2302
2303
2304
2305
2306
2307
2308
2309
2300
2301
2302
2303
23102304
2311
2312
2313
2314
2315
2316
23172305
23182306
23192307
......
24282416
24292417
24302418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
24312483
24322484
24332485
sub advanced_find_button_clicked_cb($$);
sub annotate_button_clicked_cb($$);
sub close_toolbutton_clicked_cb($$);
sub determine_mime_type($$$$);
sub directory_up_button_clicked_cb($$);
sub display_file($$);
sub file_change_history_button_clicked_cb($$);
$fh,
$file_name,
$helper,
$mime_details,
$mime_obj,
$mime_type);
# Get the user preference settings for this type of file.
foreach my $entry (@$mime_match_table)
{
if ($browser->{file_being_viewed}->{short_name} =~ m/$entry->{re}/)
{
$helper = $entry->{details}->{helper_application};
last;
}
}
determine_mime_type($browser->{file_being_viewed}->{short_name},
\$data,
\$mime_type,
\$mime_details);
# If the user has specified a helper application then use that to view the
# file, otherwise use the default desktop settings.
if (defined($helper) && $helper ne "")
if (defined($mime_details) && $mime_details->{helper_application} ne "")
{
# Use the specified helper application, replacing `{file}' with the
# real file name.
$helper = $mime_details->{helper_application};
if ($helper =~ m/\{file\}/)
{
$helper =~ s/\{file\}/$file_name/g;
$browser->{file_being_viewed}->{manifest_entry}->
{file_id});
# Try and work out the MIME type through file name pattern matching.
# Try and work out the MIME type.
foreach my $entry (@$mime_match_table)
{
if ($browser->{file_being_viewed}->{short_name} =~ m/$entry->{re}/)
{
$mime_type = $entry->{details}->{name};
$mime_details = $entry->{details};
last;
}
}
determine_mime_type($browser->{file_being_viewed}->{short_name},
\$contents,
\$mime_type,
\$mime_details);
# If that didn't work then try determining the MIME type based upon the
# file's contents.
$mime_type = Gnome2::VFS->get_mime_type_for_data($contents)
if (! defined($mime_type));
# Only attempt to render the file's contents if requested to do so.
if (! defined($mime_type)
#
##############################################################################
#
# Routine - determine_mime_type
#
# Description - Given a file name and its contents, determine and return
# its MIME type and the related entry in the MIME details
# table.
#
# Data - $file_name : The name of the file.
# $contents : A reference to a variable containing the
# contents of the file.
# $mime_type : A reference to a variable that is to
# contain the MIME type. This will be undef
# if no match can be found.
# $mime_details : A reference to a variable that is to
# contain a refernce to the related entry in
# the MIME information table. This will be
# undef if no match can be found.
#
##############################################################################
sub determine_mime_type($$$$)
{
my($file_name, $contents, $mime_type, $mime_details) = @_;
$$mime_type = $$mime_details = undef;
# Try and work out the MIME type through file name pattern matching.
foreach my $entry (@$mime_match_table)
{
if ($file_name =~ m/$entry->{re}/)
{
$$mime_type = $entry->{details}->{name};
$$mime_details = $entry->{details};
return;
}
}
# If that didn't work then try determining the MIME type based upon its
# contents.
$$mime_type = Gnome2::VFS->get_mime_type_for_data($contents);
# If we now have a MIME type then do another lookup with it but by matching
# MIME type names and not file name patterns.
if (defined($$mime_type))
{
foreach my $entry (@{$user_preferences->{mime_table}})
{
if ($$mime_type eq $entry->{name})
{
$$mime_details = $entry;
return;
}
}
}
}
#
##############################################################################
#
# Routine - mtn_error_handler
#
# Description - This routine is called when ever there is a problem with

Archive Download the corresponding diff file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status