~ubuntu-branches/ubuntu/quantal/xscreensaver/quantal

« back to all changes in this revision

Viewing changes to OSX/XScreenSaverConfigSheet.m

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2008-08-28 16:15:25 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080828161525-mxga521aoezxjq8h
Tags: 5.07-0ubuntu1
* Upgrade upstream version
* debian/control: Remove suggest xdaliclock as it is no longer
  included
* Remove 10_jwz-screensaver-randr-patch-3.patch as it has been merged
  upstream.
* Add 24_hacks_xsublim_enable.patch as it seems that xsublim was dropped
  from the build files.  There is nothing in the Changelog about it
  so I believe it was accidental.
* Updating the .desktop files from the XML files using gnome-screensaver's
  utility to do so.  Lots of text updates.  Also:
    * Added: abstractile.desktop
    * Added: cwaves.desktop
    * Added: m6502.desktop
    * Added: skytentacles.desktop
    * Removed: xteevee.desktop
* xscreensaver-gl-extra.files: Added skytentacles
* xscreensaver-data-extra.files: Added abstractile, cwaves and m6502
* xscreensaver-data.files: Remove partial abstractile, m6502 and cwaves

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* xscreensaver, Copyright (c) 2006 Jamie Zawinski <jwz@jwz.org>
 
1
/* xscreensaver, Copyright (c) 2006-2008 Jamie Zawinski <jwz@jwz.org>
2
2
 *
3
3
 * Permission to use, copy, modify, distribute, and sell this software and its
4
4
 * documentation for any purpose is hereby granted without fee, provided that
606
606
               label);
607
607
  }
608
608
    
 
609
  // If either the min or max field contains a decimal point, then this
 
610
  // option may have a floating point value; otherwise, it is constrained
 
611
  // to be an integer.
 
612
  //
 
613
  NSCharacterSet *dot =
 
614
    [NSCharacterSet characterSetWithCharactersInString:@"."];
 
615
  BOOL float_p = ([low rangeOfCharacterFromSet:dot].location != NSNotFound ||
 
616
                  [high rangeOfCharacterFromSet:dot].location != NSNotFound);
 
617
 
609
618
  if ([type isEqualToString:@"slider"]) {
610
619
 
611
620
    NSRect rect;
612
621
    rect.origin.x = rect.origin.y = 0;    
613
622
    rect.size.width = 150;
614
 
    rect.size.height = 20;
 
623
    rect.size.height = 23;  // apparent min height for slider with ticks...
615
624
    NSSlider *slider;
616
625
    if (cvt)
617
626
      slider = [[InvertedSlider alloc] initWithFrame:rect];
621
630
    [slider setMaxValue:[high doubleValue]];
622
631
    [slider setMinValue:[low  doubleValue]];
623
632
    
 
633
    int range = [slider maxValue] - [slider minValue] + 1;
 
634
    int range2 = range;
 
635
    int max_ticks = 21;
 
636
    while (range2 > max_ticks)
 
637
      range2 /= 10;
 
638
 
 
639
    // If we have elided ticks, leave it at the max number of ticks.
 
640
    if (range != range2 && range2 < max_ticks)
 
641
      range2 = max_ticks;
 
642
 
 
643
    // If it's a float, always display the max number of ticks.
 
644
    if (float_p && range2 < max_ticks)
 
645
      range2 = max_ticks;
 
646
 
 
647
    [slider setNumberOfTickMarks:range2];
 
648
 
 
649
    [slider setAllowsTickMarkValuesOnly:
 
650
              (range == range2 &&  // we are showing the actual number of ticks
 
651
               !float_p)];         // and we want integer results
 
652
 
 
653
    // #### Note: when the slider's range is large enough that we aren't
 
654
    //      showing all possible ticks, the slider's value is not constrained
 
655
    //      to be an integer, even though it should be...
 
656
    //      Maybe we need to use a value converter or something?
 
657
 
624
658
    if (label) {
625
659
      NSTextField *lab = make_label (label);
626
660
      place_child (parent, lab, NO);
711
745
    [step sizeToFit];
712
746
    place_child (parent, step, YES);
713
747
    rect = [step frame];
714
 
    rect.size.height = [txt frame].size.height;
715
748
    rect.origin.x -= COLUMN_SPACING;  // this one goes close
 
749
    rect.origin.y += ([txt frame].size.height - rect.size.height) / 2;
716
750
    [step setFrame:rect];
717
751
    
718
752
    [step setMinValue:[low  doubleValue]];
728
762
    else
729
763
      [step setIncrement:1.0];
730
764
 
 
765
    NSNumberFormatter *fmt = [[[NSNumberFormatter alloc] init] autorelease];
 
766
    [fmt setFormatterBehavior:NSNumberFormatterBehavior10_4];
 
767
    [fmt setNumberStyle:NSNumberFormatterDecimalStyle];
 
768
    [fmt setMinimum:[NSNumber numberWithDouble:[low  doubleValue]]];
 
769
    [fmt setMaximum:[NSNumber numberWithDouble:[high doubleValue]]];
 
770
    [fmt setMinimumFractionDigits: (float_p ? 1 : 0)];
 
771
    [fmt setMaximumFractionDigits: (float_p ? 2 : 0)];
 
772
 
 
773
    [fmt setGeneratesDecimalNumbers:float_p];
 
774
    [[txt cell] setFormatter:fmt];
 
775
 
 
776
 
731
777
    bind_switch_to_preferences (prefs, step, arg, opts);
732
778
    bind_switch_to_preferences (prefs, txt,  arg, opts);
733
779
    
997
1043
}
998
1044
 
999
1045
 
 
1046
static char *
 
1047
anchorize (const char *url)
 
1048
{
 
1049
  const char *wiki = "http://en.wikipedia.org/wiki/";
 
1050
  if (!strncmp (wiki, url, strlen(wiki))) {
 
1051
    char *anchor = (char *) malloc (strlen(url) * 3 + 10);
 
1052
    strcpy (anchor, "Wikipedia: \"");
 
1053
    const char *in = url + strlen(wiki);
 
1054
    char *out = anchor + strlen(anchor);
 
1055
    while (*in) {
 
1056
      if (*in == '_') {
 
1057
        *out++ = ' ';
 
1058
      } else if (*in == '#') {
 
1059
        *out++ = ':';
 
1060
        *out++ = ' ';
 
1061
      } else if (*in == '%') {
 
1062
        char hex[3];
 
1063
        hex[0] = in[1];
 
1064
        hex[1] = in[2];
 
1065
        hex[2] = 0;
 
1066
        int n = 0;
 
1067
        sscanf (hex, "%x", &n);
 
1068
        *out++ = (char) n;
 
1069
        in += 2;
 
1070
      } else {
 
1071
        *out++ = *in;
 
1072
      }
 
1073
      in++;
 
1074
    }
 
1075
    *out++ = '"';
 
1076
    *out = 0;
 
1077
    return anchor;
 
1078
 
 
1079
  } else {
 
1080
    return strdup (url);
 
1081
  }
 
1082
}
 
1083
 
 
1084
 
1000
1085
/* Converts any http: URLs in the given text field to clickable links.
1001
1086
 */
1002
1087
static void
1040
1125
    NSString *nsurl = [text substringWithRange:r2];
1041
1126
    const char *url = [nsurl UTF8String];
1042
1127
 
1043
 
    // Construct the RTF corresponding to <A HREF="url">url</A>
 
1128
    // If this is a Wikipedia URL, make the linked text be prettier.
 
1129
    //
 
1130
    char *anchor = anchorize(url);
 
1131
 
 
1132
    // Construct the RTF corresponding to <A HREF="url">anchor</A>
1044
1133
    //
1045
1134
    const char *fmt = "{\\field{\\*\\fldinst{HYPERLINK \"%s\"}}%s}";
1046
 
    char *rtf = malloc (strlen (fmt) + (strlen (url) * 2) + 10);
1047
 
    sprintf (rtf, fmt, url, url);
 
1135
    char *rtf = malloc (strlen (fmt) + strlen(url) + strlen(anchor) + 10);
 
1136
    sprintf (rtf, fmt, url, anchor);
 
1137
    free (anchor);
1048
1138
    NSData *rtfdata = [NSData dataWithBytesNoCopy:rtf length:strlen(rtf)];
1049
1139
 
1050
1140
    // Insert the RTF into the NSText.
1051
1141
    [nstext replaceCharactersInRange:r2 withRTF:rtfdata];
 
1142
 
 
1143
    int L2 = [text length];  // might have changed
 
1144
    start.location -= (L - L2);
 
1145
    L = L2;
1052
1146
  }
1053
1147
}
1054
1148
 
1147
1241
{
1148
1242
  /*
1149
1243
    Display Text:
1150
 
     (x)  Computer Name and Time
 
1244
     (x)  Computer name and time
1151
1245
     ( )  Text       [__________________________]
1152
1246
     ( )  Text file  [_________________] [Choose]
1153
1247
     ( )  URL        [__________________________]
1183
1277
  [matrix setAllowsEmptySelection:NO];
1184
1278
 
1185
1279
  NSArrayController *cnames  = [[NSArrayController alloc] initWithContent:nil];
1186
 
  [cnames addObject:@"Computer Name and Time"];
 
1280
  [cnames addObject:@"Computer name and time"];
1187
1281
  [cnames addObject:@"Text"];
1188
1282
  [cnames addObject:@"File"];
1189
1283
  [cnames addObject:@"URL"];
1301
1395
                     NSView *parent, NSXMLNode *node)
1302
1396
{
1303
1397
  /*
1304
 
    [x]  Grab Desktop Images
1305
 
    [ ]  Choose Random Image:
 
1398
    [x]  Grab desktop images
 
1399
    [ ]  Choose random image:
1306
1400
         [__________________________]  [Choose]
1307
1401
 
1308
 
   <boolean id="grabDesktopImages" _label="Grab Desktop Images"
 
1402
   <boolean id="grabDesktopImages" _label="Grab desktop images"
1309
1403
       arg-unset="-no-grab-desktop"/>
1310
 
   <boolean id="chooseRandomImages" _label="Grab Desktop Images"
 
1404
   <boolean id="chooseRandomImages" _label="Grab desktop images"
1311
1405
       arg-unset="-choose-random-images"/>
1312
1406
   <file id="imageDirectory" _label="" arg-set="-image-directory %"/>
1313
1407
   */
1318
1412
  [node2 setAttributesAsDictionary:
1319
1413
          [NSDictionary dictionaryWithObjectsAndKeys:
1320
1414
                        @"grabDesktopImages",   @"id",
1321
 
                        @"Grab Desktop Images", @"_label",
 
1415
                        @"Grab desktop images", @"_label",
1322
1416
                        @"-no-grab-desktop",    @"arg-unset",
1323
1417
                        nil]];
1324
1418
  make_checkbox (prefs, opts, parent, node2);
1328
1422
  [node2 setAttributesAsDictionary:
1329
1423
          [NSDictionary dictionaryWithObjectsAndKeys:
1330
1424
                        @"chooseRandomImages",    @"id",
1331
 
                        @"Choose Random Images",  @"_label",
 
1425
                        @"Choose random images",  @"_label",
1332
1426
                        @"-choose-random-images", @"arg-set",
1333
1427
                        nil]];
1334
1428
  make_checkbox (prefs, opts, parent, node2);
1338
1432
  [node2 setAttributesAsDictionary:
1339
1433
          [NSDictionary dictionaryWithObjectsAndKeys:
1340
1434
                        @"imageDirectory",     @"id",
1341
 
                        @"Images Directory:",  @"_label",
 
1435
                        @"Images directory:",  @"_label",
1342
1436
                        @"-image-directory %", @"arg",
1343
1437
                        nil]];
1344
1438
  make_file_selector (prefs, opts, parent, node2, YES, NO);
1654
1748
  [pbox setTitlePosition:NSNoTitle];
1655
1749
  [pbox setBorderType:NSBezelBorder];
1656
1750
 
 
1751
  // Enforce a max height on the dialog, so that it's obvious to me
 
1752
  // (on a big screen) when the dialog will fall off the bottom of
 
1753
  // a small screen (e.g., 1024x768 laptop with a huge bottom dock).
1657
1754
  {
1658
1755
    NSRect f = [panel frame];
1659
 
    int screen_height = 800 - 64;
 
1756
    int screen_height = (768    // shortest "modern" Mac display
 
1757
                         - 22   // menu bar
 
1758
                         - 56   // System Preferences toolbar
 
1759
                         - 140  // default magnified bottom dock icon
 
1760
                         );
1660
1761
    if (f.size.height > screen_height) {
1661
1762
      NSLog(@"%@ height was %.0f; clipping to %d", 
1662
1763
          [panel class], f.size.height, screen_height);