William Bowling is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

wbowling / adium (fork of adium / adium)

Fork of Adium for patches/improvements

Clone this repository (size: 338.7 MB): HTTPS / SSH
hg clone https://bitbucket.org/wbowling/adium
hg clone ssh://hg@bitbucket.org/wbowling/adium

adium / Source / AIListLayoutWindowController.m

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
/* 
 * Adium is the legal property of its developers, whose names are listed in the copyright file included
 * with this source distribution.
 * 
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
 * Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program; if not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#import "AIListLayoutWindowController.h"
#import "AIDockController.h"
#import "AISCLViewPlugin.h"
#import <AIUtilities/AIFontAdditions.h>
#import <AIUtilities/AIMenuAdditions.h>
#import <AIUtilities/AIPopUpButtonAdditions.h>
#import <AIUtilities/AIArrayAdditions.h>
#import <Adium/AIAbstractListController.h>
#import <Adium/JVFontPreviewField.h>

#define MAX_ALIGNMENT_CHOICES   10

@interface AIListLayoutWindowController ()
- (id)initWithWindowNibName:(NSString *)windowNibName name:(NSString *)inName notifyingTarget:(id)inTarget;
- (void)configureControls;
- (void)configureControlDimming;
- (void)updateSliderValues;
- (void)updateDisplayedTabsFromPrefDict:(NSDictionary *)prefDict;
- (void)updateStatusAndServiceIconMenusFromPrefDict:(NSDictionary *)prefDict;
- (void)updateUserIconMenuFromPrefDict:(NSDictionary *)prefDict;
- (NSMenu *)alignmentMenuWithChoices:(NSInteger [])alignmentChoices;
- (NSMenu *)positionMenuWithChoices:(NSInteger [])positionChoices;
- (NSMenu *)extendedStatusStyleMenu;
- (NSMenu *)extendedStatusPositionMenu;
@end

@implementation AIListLayoutWindowController

+ (id)editListLayoutWithName:(NSString *)inName onWindow:(NSWindow *)parentWindow notifyingTarget:(id)inTarget
{
        AIListLayoutWindowController    *listLayoutWindow = [[self alloc] initWithWindowNibName:@"ListLayoutSheet"
                                                                                                                                                                           name:inName
                                                                                                                                                        notifyingTarget:inTarget];
        
        if (parentWindow) {
                [NSApp beginSheet:[listLayoutWindow window]
                   modalForWindow:parentWindow
                        modalDelegate:listLayoutWindow
                   didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
                          contextInfo:nil];
        } else {
                [listLayoutWindow showWindow:nil];
        }
        
        return listLayoutWindow;
}

- (id)initWithWindowNibName:(NSString *)windowNibName name:(NSString *)inName notifyingTarget:(id)inTarget
{
    [super initWithWindowNibName:windowNibName];
        
        NSParameterAssert(inTarget && [inTarget respondsToSelector:@selector(listLayoutEditorWillCloseWithChanges:forLayoutNamed:)]);
        
        target = inTarget;
        layoutName = [inName retain];
        
        return self;
}

- (void)dealloc
{
        [layoutName release];
    [super dealloc];
}


//Window Methods -------------------------------------------------------------------------------------------------------
#pragma mark Window Methods
- (void)windowDidLoad
{
        //We'll be adding/removing this from our view
        [tabViewItem_advancedContactBubbles retain];
        
        //Allow alpha in our color pickers
        [[NSColorPanel sharedColorPanel] setShowsAlpha:YES];    

        //Setup
        [fontField_contact setShowPointSize:YES];
        [fontField_contact setShowFontFace:YES];
        [fontField_status setShowPointSize:YES];
        [fontField_status setShowFontFace:YES];
        [fontField_group setShowPointSize:YES];
        [fontField_group setShowFontFace:YES];
        
        [self configureControls];
}

//Called as the sheet closes, dismisses the sheet
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
    [sheet orderOut:nil];
        
        [[NSColorPanel sharedColorPanel] close];
        
        //No longer allow alpha in our color pickers
        [[NSColorPanel sharedColorPanel] setShowsAlpha:NO];
        
        [tabViewItem_advancedContactBubbles autorelease];
        [self autorelease];
}

//Cancel
- (IBAction)cancel:(id)sender
{
        [target listLayoutEditorWillCloseWithChanges:NO forLayoutNamed:layoutName];
        [self closeWindow:sender];
}

//Okay
- (IBAction)okay:(id)sender
{
        [target listLayoutEditorWillCloseWithChanges:YES forLayoutNamed:layoutName];
        [self closeWindow:sender];
}


//Window Methods -------------------------------------------------------------------------------------------------------
- (void)configureControls
{
        NSDictionary    *prefDict = [adium.preferenceController preferencesForGroup:PREF_GROUP_LIST_LAYOUT];
        NSInteger                               textAlignmentChoices[4];
        
        textAlignmentChoices[0] = NSLeftTextAlignment;
        textAlignmentChoices[1] = NSCenterTextAlignment;
        textAlignmentChoices[2] = NSRightTextAlignment;
        textAlignmentChoices[3] = -1;
        
        [self updateDisplayedTabsFromPrefDict:prefDict];
        
        [self updateStatusAndServiceIconMenusFromPrefDict:prefDict];
        
        [self updateUserIconMenuFromPrefDict:prefDict];
        
        //Context text alignment
        [popUp_contactTextAlignment setMenu:[self alignmentMenuWithChoices:textAlignmentChoices]];
        [popUp_contactTextAlignment selectItemWithTag:[[prefDict objectForKey:KEY_LIST_LAYOUT_ALIGNMENT] integerValue]];
        
        //Group text alignment
        [popUp_groupTextAlignment setMenu:[self alignmentMenuWithChoices:textAlignmentChoices]];
        [popUp_groupTextAlignment selectItemWithTag:[[prefDict objectForKey:KEY_LIST_LAYOUT_GROUP_ALIGNMENT] integerValue]];
        
        //Extended Status position
        [popUp_extendedStatusPosition setMenu:[self extendedStatusPositionMenu]];
        [popUp_extendedStatusPosition selectItemWithTag:[[prefDict objectForKey:KEY_LIST_LAYOUT_EXTENDED_STATUS_POSITION] integerValue]];
        
        //Window style
        [popUp_extendedStatusStyle setMenu:[self extendedStatusStyleMenu]];
        [popUp_extendedStatusStyle selectItemWithTag:[[prefDict objectForKey:KEY_LIST_LAYOUT_EXTENDED_STATUS_STYLE] integerValue]];
        
        [slider_userIconSize setIntegerValue:[[prefDict objectForKey:KEY_LIST_LAYOUT_USER_ICON_SIZE] integerValue]];
        [slider_contactSpacing setIntegerValue:[[prefDict objectForKey:KEY_LIST_LAYOUT_CONTACT_SPACING] integerValue]];

        [slider_groupTopSpacing setIntegerValue:[[prefDict objectForKey:KEY_LIST_LAYOUT_GROUP_TOP_SPACING] integerValue]];
        [slider_groupTopSpacing setMinValue:0];
        [slider_groupTopSpacing setMaxValue:16];

        [slider_contactLeftIndent setIntegerValue:[[prefDict objectForKey:KEY_LIST_LAYOUT_CONTACT_LEFT_INDENT] integerValue]];
        [slider_contactRightIndent setIntegerValue:[[prefDict objectForKey:KEY_LIST_LAYOUT_CONTACT_RIGHT_INDENT] integerValue]];
        [self updateSliderValues];
        
        [fontField_contact setFont:[[prefDict objectForKey:KEY_LIST_LAYOUT_CONTACT_FONT] representedFont]];
        [fontField_status setFont:[[prefDict objectForKey:KEY_LIST_LAYOUT_STATUS_FONT] representedFont]];
        [fontField_group setFont:[[prefDict objectForKey:KEY_LIST_LAYOUT_GROUP_FONT] representedFont]];
        
        [self configureControlDimming];
}

- (void)preferenceChanged:(id)sender
{
        if (sender == popUp_contactTextAlignment) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_ALIGNMENT
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
                NSDictionary    *prefDict;
                prefDict = [adium.preferenceController preferencesForGroup:PREF_GROUP_LIST_LAYOUT];
                
                [self updateStatusAndServiceIconMenusFromPrefDict:prefDict];
                [self updateUserIconMenuFromPrefDict:prefDict];
                
                [self configureControlDimming];
                
        } else if (sender == popUp_groupTextAlignment) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_GROUP_ALIGNMENT
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
        } else if (sender == popUp_extendedStatusPosition) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_EXTENDED_STATUS_POSITION
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
        } else if (sender == popUp_userIconPosition) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_USER_ICON_POSITION
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
        } else if (sender == popUp_statusIconPosition) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_STATUS_ICON_POSITION
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
        } else if (sender == popUp_serviceIconPosition) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_SERVICE_ICON_POSITION
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
        } else if (sender == popUp_extendedStatusStyle) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[sender selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_EXTENDED_STATUS_STYLE
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
                
        } else if (sender == slider_userIconSize) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[sender integerValue]]
                                                                                         forKey:KEY_LIST_LAYOUT_USER_ICON_SIZE
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                [self updateSliderValues];
                
        } else if (sender == slider_contactSpacing) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[sender integerValue]]
                                                                                         forKey:KEY_LIST_LAYOUT_CONTACT_SPACING
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                [self updateSliderValues];
        } else if (sender == slider_groupTopSpacing) {
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[sender integerValue]]
                                                                                         forKey:KEY_LIST_LAYOUT_GROUP_TOP_SPACING
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                [self updateSliderValues];
                
        } else if (sender == checkBox_userIconVisible) {
                NSDictionary    *prefDict;
                
                [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
                                                                                         forKey:KEY_LIST_LAYOUT_SHOW_ICON
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                
                prefDict  = [adium.preferenceController preferencesForGroup:PREF_GROUP_LIST_LAYOUT];
                //Update the status and service icon menus to show/hide the badge options
                [self updateStatusAndServiceIconMenusFromPrefDict:prefDict];
                [self configureControlDimming];
                
        } else if (sender == checkBox_extendedStatusVisible) {
                [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
                                                                                         forKey:KEY_LIST_LAYOUT_SHOW_EXT_STATUS
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                [self configureControlDimming];
                
        } else if (sender == checkBox_statusIconsVisible) {
                [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
                                                                                         forKey:KEY_LIST_LAYOUT_SHOW_STATUS_ICONS
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                [self configureControlDimming];
                
        } else if (sender == checkBox_serviceIconsVisible) {
                [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
                                                                                         forKey:KEY_LIST_LAYOUT_SHOW_SERVICE_ICONS
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
                [self configureControlDimming];
                
    } else if (sender == checkBox_outlineBubbles) {
        [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
                                             forKey:KEY_LIST_LAYOUT_OUTLINE_BUBBLE
                                              group:PREF_GROUP_LIST_LAYOUT];
                [self configureControlDimming];
                
    } else if (sender == checkBox_drawContactBubblesWithGraadient) {
        [adium.preferenceController setPreference:[NSNumber numberWithBool:[sender state]]
                                             forKey:KEY_LIST_LAYOUT_CONTACT_BUBBLE_GRADIENT
                                              group:PREF_GROUP_LIST_LAYOUT];
                
    } else if (sender == checkBox_showGroupBubbles) {
                BOOL shouldHideGroupBubbles = ![sender state];
                
        [adium.preferenceController setPreference:[NSNumber numberWithBool:shouldHideGroupBubbles]
                                             forKey:KEY_LIST_LAYOUT_GROUP_HIDE_BUBBLE
                                              group:PREF_GROUP_LIST_LAYOUT];
                [self configureControlDimming];
                
    } else if (sender == slider_contactLeftIndent) {
        [adium.preferenceController setPreference:[NSNumber numberWithInteger:[sender integerValue]]
                                             forKey:KEY_LIST_LAYOUT_CONTACT_LEFT_INDENT
                                              group:PREF_GROUP_LIST_LAYOUT];
                [self updateSliderValues];
                
    } else if (sender == slider_contactRightIndent) {
        [adium.preferenceController setPreference:[NSNumber numberWithInteger:[sender integerValue]]
                                             forKey:KEY_LIST_LAYOUT_CONTACT_RIGHT_INDENT
                                              group:PREF_GROUP_LIST_LAYOUT];
                [self updateSliderValues];
                
        } else if (sender == slider_outlineWidth) {
                NSInteger newValue = [sender integerValue];
                NSInteger oldValue = [[adium.preferenceController preferenceForKey:KEY_LIST_LAYOUT_OUTLINE_BUBBLE_WIDTH
                                                                                                                                 group:PREF_GROUP_LIST_LAYOUT] integerValue];
                if (newValue != oldValue) { 
                        [adium.preferenceController setPreference:[NSNumber numberWithInteger:newValue]
                                                                                                 forKey:KEY_LIST_LAYOUT_OUTLINE_BUBBLE_WIDTH
                                                                                                  group:PREF_GROUP_LIST_LAYOUT];
                        [self updateSliderValues];
                }
        }
}

- (BOOL)fontPreviewField:(JVFontPreviewField *)field shouldChangeToFont:(NSFont *)font
{
        return YES;
}

- (void)fontPreviewField:(JVFontPreviewField *)field didChangeToFont:(NSFont *)font
{
        if (field == fontField_contact) {
        [adium.preferenceController setPreference:[font stringRepresentation]
                                             forKey:KEY_LIST_LAYOUT_CONTACT_FONT
                                              group:PREF_GROUP_LIST_LAYOUT];
                
        } else if (field == fontField_status) {
        [adium.preferenceController setPreference:[font stringRepresentation]
                                             forKey:KEY_LIST_LAYOUT_STATUS_FONT
                                              group:PREF_GROUP_LIST_LAYOUT];
                
        } else if (field == fontField_group) {
        [adium.preferenceController setPreference:[font stringRepresentation]
                                             forKey:KEY_LIST_LAYOUT_GROUP_FONT
                                              group:PREF_GROUP_LIST_LAYOUT];
                
        }
}

- (void)updateSliderValues
{
        NSInteger       iconSize = [slider_userIconSize integerValue];
        [textField_userIconSize setStringValue:[NSString stringWithFormat:@"%ldx%ld",iconSize,iconSize]];
        
        [textField_contactSpacing setStringValue:[NSString stringWithFormat:@"%ldpx",[slider_contactSpacing integerValue]]];
        [textField_groupTopSpacing setStringValue:[NSString stringWithFormat:@"%ldpx",[slider_groupTopSpacing integerValue]]];
        [textField_contactLeftIndent setStringValue:[NSString stringWithFormat:@"%ldpx",[slider_contactLeftIndent integerValue]]];
        [textField_contactRightIndent setStringValue:[NSString stringWithFormat:@"%ldpx",[slider_contactRightIndent integerValue]]];
        [textField_outlineWidthIndicator setStringValue:[NSString stringWithFormat:@"%ldpx",[slider_outlineWidth integerValue]]];
}

//Configure control dimming
- (void)configureControlDimming
{
        NSDictionary    *prefDict = [adium.preferenceController preferencesForGroup:PREF_GROUP_LIST_LAYOUT];
        NSInteger                               windowStyle = [[adium.preferenceController preferenceForKey:KEY_LIST_LAYOUT_WINDOW_STYLE group:PREF_GROUP_APPEARANCE] integerValue];
        
        //Bubble to fit limitations
        BOOL nonFitted = (windowStyle != AIContactListWindowStyleContactBubbles_Fitted);
        if (nonFitted) {
                //For the non-fitted styles, enable and set the proper state
                [checkBox_extendedStatusVisible setEnabled:YES];
                [checkBox_extendedStatusVisible setState:[[prefDict objectForKey:KEY_LIST_LAYOUT_SHOW_EXT_STATUS] boolValue]];
        } else {
                //For the fitted style, disable and set to NO the extendedStatus
                [checkBox_extendedStatusVisible setEnabled:NO];
                [checkBox_extendedStatusVisible setState:NO];
        }
        
        if (nonFitted || ([[prefDict objectForKey:KEY_LIST_LAYOUT_ALIGNMENT] integerValue] != NSCenterTextAlignment)) {
                //For non-fitted or non-centered fitted, enable and set the appropriate value
                [checkBox_userIconVisible setEnabled:YES];
                [checkBox_userIconVisible setState:[[prefDict objectForKey:KEY_LIST_LAYOUT_SHOW_ICON] boolValue]];
                
                [checkBox_statusIconsVisible setEnabled:YES];
                [checkBox_statusIconsVisible setState:[[prefDict objectForKey:KEY_LIST_LAYOUT_SHOW_STATUS_ICONS] boolValue]];
                
                [checkBox_serviceIconsVisible setEnabled:YES];
                [checkBox_serviceIconsVisible setState:[[prefDict objectForKey:KEY_LIST_LAYOUT_SHOW_SERVICE_ICONS] boolValue]]; 
                
        } else {
                //For fitted and centered, disable and set to NO
                [checkBox_userIconVisible setEnabled:NO];
                [checkBox_userIconVisible setState:NO];
                
                [checkBox_statusIconsVisible setEnabled:NO];
                [checkBox_statusIconsVisible setState:NO];
                
                [checkBox_serviceIconsVisible setEnabled:NO];
                [checkBox_serviceIconsVisible setState:NO];
        }
        
        
        
        
        //User icon controls
        [slider_userIconSize setEnabled:([checkBox_userIconVisible state] && [checkBox_userIconVisible isEnabled])];
        [textField_userIconSize setEnabled:([checkBox_userIconVisible state] && [checkBox_userIconVisible isEnabled])];
        [popUp_userIconPosition setEnabled:([checkBox_userIconVisible state] && [checkBox_userIconVisible isEnabled])];
        
        //Other controls
        BOOL extendedStatusEnabled = ([checkBox_extendedStatusVisible state] && [checkBox_extendedStatusVisible isEnabled]);
        
        
        [popUp_extendedStatusStyle setEnabled:extendedStatusEnabled];
        [popUp_extendedStatusPosition setEnabled:extendedStatusEnabled];
        [popUp_statusIconPosition setEnabled:([checkBox_statusIconsVisible state] && 
                                                                                  [checkBox_statusIconsVisible isEnabled] &&
                                                                                  ([popUp_statusIconPosition numberOfItems] > 0))];
        [popUp_serviceIconPosition setEnabled:([checkBox_serviceIconsVisible state] &&
                                                                                   [checkBox_serviceIconsVisible isEnabled] &&
                                                                                   ([popUp_serviceIconPosition numberOfItems] > 0))];
        [popUp_userIconPosition setEnabled:([checkBox_userIconVisible state] &&
                                                                                [checkBox_userIconVisible isEnabled] &&
                                                                                ([popUp_userIconPosition numberOfItems] > 0))];
        
        //Disable group spacing when not using mockie
        [slider_groupTopSpacing setEnabled:(windowStyle == AIContactListWindowStyleGroupBubbles)];
        [textField_groupTopSpacing setEnabled:(windowStyle == AIContactListWindowStyleGroupBubbles)];
        
        //Contact Bubbles Advanced
        
        //Only enable the outline width slider if outline width is being shown
        [slider_outlineWidth setEnabled:[checkBox_outlineBubbles state]];
}

- (void)updateStatusAndServiceIconMenusFromPrefDict:(NSDictionary *)prefDict
{
        NSInteger                               statusAndServicePositionChoices[7];
        BOOL                    showUserIcon = [[prefDict objectForKey:KEY_LIST_LAYOUT_SHOW_ICON] boolValue];
        NSInteger                               indexForFinishingChoices = 0;
        
        if ([[adium.preferenceController preferenceForKey:KEY_LIST_LAYOUT_WINDOW_STYLE group:PREF_GROUP_APPEARANCE] integerValue] != AIContactListWindowStyleContactBubbles_Fitted) {
                statusAndServicePositionChoices[0] = LIST_POSITION_FAR_LEFT;
                statusAndServicePositionChoices[1] = LIST_POSITION_LEFT;
                statusAndServicePositionChoices[2] = LIST_POSITION_RIGHT;
                statusAndServicePositionChoices[3] = LIST_POSITION_FAR_RIGHT;
                
                indexForFinishingChoices = 4;
                
        } else {
                //For fitted pillows, only show the options which correspond to the text alignment
                switch ([[prefDict objectForKey:KEY_LIST_LAYOUT_ALIGNMENT] integerValue]) {
                        case NSLeftTextAlignment:
                                statusAndServicePositionChoices[0] = LIST_POSITION_FAR_LEFT;
                                statusAndServicePositionChoices[1] = LIST_POSITION_LEFT;
                                indexForFinishingChoices = 2;
                                break;
                                
                        case NSRightTextAlignment:
                                statusAndServicePositionChoices[0] = LIST_POSITION_RIGHT;
                                statusAndServicePositionChoices[1] = LIST_POSITION_FAR_RIGHT;
                                indexForFinishingChoices = 2;
                                
                                break;
                        case NSCenterTextAlignment:
                                
                                break;
                }       
        }
        
        //Only show the badge choices if we are showing the user icon
        if (showUserIcon && (indexForFinishingChoices != 0)) {
                statusAndServicePositionChoices[indexForFinishingChoices] = LIST_POSITION_BADGE_LEFT;
                statusAndServicePositionChoices[indexForFinishingChoices + 1] = LIST_POSITION_BADGE_RIGHT;
                statusAndServicePositionChoices[indexForFinishingChoices + 2] = -1;
                
        } else {
                statusAndServicePositionChoices[indexForFinishingChoices] = -1;
                
        }
        
        /* If we can't select an item in the status icon or service icon menu, that means our previous selection is no longer available;
         * set the preference to whichever option we just 'selected' by default.
         */
        [popUp_statusIconPosition setMenu:[self positionMenuWithChoices:statusAndServicePositionChoices]];
        if ([popUp_statusIconPosition numberOfItems] &&
                ![popUp_statusIconPosition selectItemWithTag:[[prefDict objectForKey:KEY_LIST_LAYOUT_STATUS_ICON_POSITION] integerValue]]) {
                [popUp_statusIconPosition selectItemAtIndex:0];
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[popUp_statusIconPosition selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_STATUS_ICON_POSITION
                                                                                          group:PREF_GROUP_LIST_LAYOUT];                
        }

        [popUp_serviceIconPosition setMenu:[self positionMenuWithChoices:statusAndServicePositionChoices]];
        if ([popUp_serviceIconPosition numberOfItems] &&
                ![popUp_serviceIconPosition selectItemWithTag:[[prefDict objectForKey:KEY_LIST_LAYOUT_SERVICE_ICON_POSITION] integerValue]]) {
                [popUp_serviceIconPosition selectItemAtIndex:0];
                [adium.preferenceController setPreference:[NSNumber numberWithInteger:[[popUp_serviceIconPosition selectedItem] tag]]
                                                                                         forKey:KEY_LIST_LAYOUT_SERVICE_ICON_POSITION
                                                                                          group:PREF_GROUP_LIST_LAYOUT];
        }
}

- (void)updateUserIconMenuFromPrefDict:(NSDictionary *)prefDict
{
        NSInteger                               userIconPositionChoices[3];
        
        if ([[adium.preferenceController preferenceForKey:KEY_LIST_LAYOUT_WINDOW_STYLE group:PREF_GROUP_APPEARANCE] integerValue] != AIContactListWindowStyleContactBubbles_Fitted) {
                userIconPositionChoices[0] = LIST_POSITION_LEFT;
                userIconPositionChoices[1] = LIST_POSITION_RIGHT;
                userIconPositionChoices[2] = -1;
        } else {
                //For fitted pillows, only show the options which correspond to the text alignment
                switch ([[prefDict objectForKey:KEY_LIST_LAYOUT_ALIGNMENT] integerValue]) {
                        case NSLeftTextAlignment:
                                userIconPositionChoices[0] = LIST_POSITION_LEFT;
                                userIconPositionChoices[1] = -1;
                                break;
                                
                        case NSRightTextAlignment:              
                                userIconPositionChoices[0] = LIST_POSITION_RIGHT;
                                userIconPositionChoices[1] = -1;
                                break;
                        case NSCenterTextAlignment:
                                userIconPositionChoices[0] = -1;                                
                                break;
                }       
        }
        
        
        //User icon position
        [popUp_userIconPosition setMenu:[self positionMenuWithChoices:userIconPositionChoices]];
        [popUp_userIconPosition selectItemWithTag:[[prefDict objectForKey:KEY_LIST_LAYOUT_USER_ICON_POSITION] integerValue]];
}

#pragma mark Menu generation

- (NSMenu *)alignmentMenuWithChoices:(NSInteger [])alignmentChoices
{
    NSMenu              *alignmentMenu = [[[NSMenu allocWithZone:[NSMenu menuZone]] init] autorelease];
        NSMenuItem      *menuItem;
    
        NSUInteger      i = 0;
        
        while (alignmentChoices[i] != -1) {
                NSString        *menuTitle = nil;
                
                switch (alignmentChoices[i]) {
                        case NSLeftTextAlignment:       menuTitle = AILocalizedString(@"Left",nil);
                                break;
                        case NSCenterTextAlignment:     menuTitle = AILocalizedString(@"Center",nil);
                                break;
                        case NSRightTextAlignment:      menuTitle = AILocalizedString(@"Right",nil);
                                break;
                }
                menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:menuTitle
                                                                                                                                                 target:nil
                                                                                                                                                 action:nil
                                                                                                                                  keyEquivalent:@""] autorelease];
                [menuItem setTag:alignmentChoices[i]];
                [alignmentMenu addItem:menuItem];
                
                i++;
        }
        
        return alignmentMenu;
        
}

- (NSMenu *)positionMenuWithChoices:(NSInteger [])positionChoices
{
    NSMenu              *positionMenu = [[[NSMenu allocWithZone:[NSMenu menuZone]] init] autorelease];
    NSMenuItem  *menuItem;
    
        NSUInteger      i = 0;
        
        while (positionChoices[i] != -1) {
                NSString        *menuTitle = nil;
                
                switch (positionChoices[i]) {
                        case LIST_POSITION_LEFT:
                                menuTitle = AILocalizedString(@"Left",nil);
                                break;
                        case LIST_POSITION_RIGHT:
                                menuTitle = AILocalizedString(@"Right",nil);
                                break;
                        case LIST_POSITION_FAR_LEFT: menuTitle = AILocalizedString(@"Far Left",nil);
                                break;
                        case LIST_POSITION_FAR_RIGHT: menuTitle = AILocalizedString(@"Far Right",nil);
                                break;
                        case LIST_POSITION_BADGE_LEFT: menuTitle = AILocalizedString(@"Badge (Lower Left)",nil);
                                break;
                        case LIST_POSITION_BADGE_RIGHT: menuTitle = AILocalizedString(@"Badge (Lower Right)",nil);
                                break;
                }
                menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:menuTitle
                                                                                                                                                 target:nil
                                                                                                                                                 action:nil
                                                                                                                                  keyEquivalent:@""] autorelease];
                [menuItem setTag:positionChoices[i]];
                [positionMenu addItem:menuItem];
                
                i++;
        }
        
        return positionMenu;
}

- (NSMenu *)extendedStatusPositionMenu
{
        NSMenu          *extendedStatusPositionMenu = [[[NSMenu allocWithZone:[NSMenu menuZone]] init] autorelease];
    NSMenuItem  *menuItem;
        
        menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Below Name",nil)
                                                                                                                                         target:nil
                                                                                                                                         action:nil
                                                                                                                          keyEquivalent:@""] autorelease];
        [menuItem setTag:EXTENDED_STATUS_POSITION_BELOW_NAME];
        [extendedStatusPositionMenu addItem:menuItem];
        
        menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Beside Name",nil)
                                                                                                                                         target:nil
                                                                                                                                         action:nil
                                                                                                                          keyEquivalent:@""] autorelease];
        [menuItem setTag:EXTENDED_STATUS_POSITION_BESIDE_NAME];
        [extendedStatusPositionMenu addItem:menuItem];
        
        menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Idle Beside, Status Below",nil)
                                                                                                                                         target:nil
                                                                                                                                         action:nil
                                                                                                                          keyEquivalent:@""] autorelease];
        [menuItem setTag:EXTENDED_STATUS_POSITION_BOTH];
        [extendedStatusPositionMenu addItem:menuItem];
        
        return extendedStatusPositionMenu;
}

- (NSMenu *)extendedStatusStyleMenu
{
    NSMenu              *extendedStatusStyleMenu = [[[NSMenu allocWithZone:[NSMenu menuZone]] init] autorelease];
    NSMenuItem  *menuItem;
        
        menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Status",nil)
                                                                                                                                         target:nil
                                                                                                                                         action:nil
                                                                                                                          keyEquivalent:@""] autorelease];
        [menuItem setTag:STATUS_ONLY];
        [extendedStatusStyleMenu addItem:menuItem];
        
        menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Idle Time",nil)
                                                                                                                                         target:nil
                                                                                                                                         action:nil
                                                                                                                          keyEquivalent:@""] autorelease];
        [menuItem setTag:IDLE_ONLY];
        [extendedStatusStyleMenu addItem:menuItem];
        
        menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"Idle and Status",nil)
                                                                                                                                         target:nil
                                                                                                                                         action:nil
                                                                                                                          keyEquivalent:@""] autorelease];
        [menuItem setTag:IDLE_AND_STATUS];
        [extendedStatusStyleMenu addItem:menuItem];
        
        return extendedStatusStyleMenu;
}


#pragma mark Displayed Tabs
//Displayed Tabs
- (void)updateDisplayedTabsFromPrefDict:(NSDictionary *)prefDict
{
        AIContactListWindowStyle        windowStyle;
        BOOL                            tabViewCurrentHasAdvancedContactBubbles;
        
        windowStyle = [[adium.preferenceController preferenceForKey:KEY_LIST_LAYOUT_WINDOW_STYLE group:PREF_GROUP_APPEARANCE] integerValue];
        tabViewCurrentHasAdvancedContactBubbles = ([[tabView_preferences tabViewItems] containsObjectIdenticalTo:tabViewItem_advancedContactBubbles]);
        
        if ((windowStyle == AIContactListWindowStyleContactBubbles_Fitted) ||
                (windowStyle == AIContactListWindowStyleContactBubbles)) {
                
                if (!tabViewCurrentHasAdvancedContactBubbles) {
                        [tabView_preferences addTabViewItem:tabViewItem_advancedContactBubbles];
                }
                
                //Configure the controls whose state we only care about if we are showing this tab view item
                BOOL showGroupBubbles = ![[prefDict objectForKey:KEY_LIST_LAYOUT_GROUP_HIDE_BUBBLE] boolValue];
                [checkBox_showGroupBubbles setState:showGroupBubbles];
                
                [checkBox_outlineBubbles setState:[[prefDict objectForKey:KEY_LIST_LAYOUT_OUTLINE_BUBBLE] boolValue]];
                [checkBox_drawContactBubblesWithGraadient setState:[[prefDict objectForKey:KEY_LIST_LAYOUT_CONTACT_BUBBLE_GRADIENT] boolValue]];
                
                [slider_outlineWidth setIntegerValue:[[prefDict objectForKey:KEY_LIST_LAYOUT_OUTLINE_BUBBLE_WIDTH] integerValue]];
                
        } else {
                if (tabViewCurrentHasAdvancedContactBubbles) {
                        [tabView_preferences removeTabViewItem:tabViewItem_advancedContactBubbles];
                }               
        }
}

@end