Skip to content

Commit 51c0bdd

Browse files
committed
Remove themes managment from Preferences (keep interface, font & color), light/dark theme switch is now managed in background
1 parent 55a1fcc commit 51c0bdd

File tree

17 files changed

+2677
-1173
lines changed

17 files changed

+2677
-1173
lines changed

Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,7 @@
156156
</dict>
157157
</dict>
158158
</array>
159+
<key>SUFeedURL</key>
160+
<string>https://wired.read-write.fr/wiredclient_appcast.xml</string>
159161
</dict>
160162
</plist>

Sources/WCBoardThreadController.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,20 @@ - (void)reloadDataAndSelectPost:(WCBoardPost *)selectPost {
391391
#pragma mark Reload CSS Template
392392

393393
- (void)reloadTemplate {
394+
NSLog(@"Thread reloadTemplate");
395+
394396
WITemplateBundle *template;
395397

396398
template = [WITemplateBundle templateWithPath:_templatePath];
397399

398400
[template setCSSValue:[_font fontName] toAttribute:WITemplateAttributesFontName ofType:WITemplateTypeBoards];
399401
[template setCSSValue:[NSSWF:@"%.0fpx", [_font pointSize]] toAttribute:WITemplateAttributesFontSize ofType:WITemplateTypeBoards];
400402
[template setCSSValue:[NSSWF:@"#%.6x", (unsigned int)[_textColor HTMLValue]] toAttribute:WITemplateAttributesFontColor ofType:WITemplateTypeBoards];
401-
[template setCSSValue:[NSSWF:@"#%.6x", (unsigned int)[_backgroundColor HTMLValue]] toAttribute:WITemplateAttributesBackgroundColor ofType:WITemplateTypeBoards];
403+
404+
[template setCSSValue:[NSApp darkModeEnabled] ? @"#383838" : @"white"
405+
toAttribute:WITemplateAttributesBackgroundColor
406+
ofType:WITemplateTypeBoards];
407+
402408
[template setCSSValue:[NSApp darkModeEnabled] ? @"dimgray" : @"gainsboro"
403409
toAttribute:@"<? headerbackground ?>"
404410
ofType:WITemplateTypeBoards];

Sources/WCBoards.m

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,16 @@ - (void)_setupSplitViews {
316316

317317
#pragma mark -
318318

319+
- (void)appleInterfaceThemeChanged:(NSNotification *) notification {
320+
321+
}
322+
323+
324+
325+
319326
- (void)_themeDidChange {
327+
NSLog(@"_themeDidChange");
328+
320329
NSDictionary *theme;
321330
NSString *templatePath;
322331
WITemplateBundle *templateBundle;
@@ -325,6 +334,8 @@ - (void)_themeDidChange {
325334
templateBundle = [[WCSettings settings] templateBundleWithIdentifier:[theme objectForKey:WCThemesTemplate]];
326335
templatePath = [templateBundle bundlePath];
327336

337+
NSLog(@"theme : %@", [theme valueForKey:WCThemesName]);
338+
328339
[_threadController setFont:WIFontFromString([theme objectForKey:WCThemesBoardsFont])];
329340
[_threadController setTextColor:WIColorFromString([theme objectForKey:WCThemesBoardsTextColor])];
330341
[_threadController setBackgroundColor:WIColorFromString([theme objectForKey:WCThemesBoardsBackgroundColor])];
@@ -660,13 +671,15 @@ - (void)_reloadThread {
660671
[_threadController setThread:thread];
661672

662673
if([thread isLoaded])
663-
[_threadController reloadData];
674+
[_threadController reloadData];
664675
}
665676
else {
666677
[_threadController setBoard:NULL];
667678
[_threadController setThread:NULL];
668679
[_threadController reloadData];
669680
}
681+
682+
[self _themeDidChange];
670683
}
671684

672685

@@ -1459,6 +1472,12 @@ - (id)init {
14591472
addObserver:self
14601473
selector:@selector(boardsDidChangeUnreadCount:)
14611474
name:WCBoardsDidChangeUnreadCountNotification];
1475+
1476+
[[NSNotificationCenter defaultCenter]
1477+
addObserver:self
1478+
selector:@selector(themeDidChange:)
1479+
name:WCThemeDidChangeNotification
1480+
object: nil];
14621481

14631482
[self window];
14641483

@@ -1694,6 +1713,13 @@ - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
16941713

16951714

16961715

1716+
- (void)themeDidChange:(NSDictionary *)theme {
1717+
NSLog(@"Boards themeDidChange:");
1718+
[self _themeDidChange];
1719+
}
1720+
1721+
1722+
16971723
- (void)linkConnectionLoggedIn:(NSNotification *)notification {
16981724
WCServerConnection *connection;
16991725
WCBoard *board;

Sources/WCChatController.m

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ - (void)_printActionChat:(NSString *)chat by:(WCUser *)user;
103103
- (void)_printHTML:(NSString *)html by:(WCUser *)user;
104104

105105
- (void)_sendImage:(NSURL *)url;
106-
- (void)_sendYouTube:(NSURL *)url;
107106
- (void)_sendiTunes;
108107

109108
- (NSArray *)_commands;
@@ -495,52 +494,6 @@ - (void)_sendLocalImage:(NSURL *)url {
495494
}
496495

497496

498-
- (void)_sendYouTube:(NSURL *)url {
499-
NSString *html = nil, *videoID;
500-
NSArray *parameters;
501-
WIP7Message *message;
502-
503-
if([[url scheme] containsSubstring:@"https"]) {
504-
505-
if([[url host] containsSubstring:@"youtu.be"])
506-
videoID = [[url absoluteString] lastPathComponent];
507-
508-
else if([[url host] containsSubstring:@"youtube.com"]) {
509-
parameters = [[url query] componentsSeparatedByString:@"&"];
510-
511-
for (NSString * pair in parameters) {
512-
NSArray * bits = [pair componentsSeparatedByString:@"="];
513-
NSString * key = [[bits objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
514-
NSString * value = [[bits objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
515-
516-
if([key isEqualToString:@"v"]) {
517-
videoID = value;
518-
continue;
519-
}
520-
}
521-
} else
522-
videoID = nil;
523-
524-
//NSLog(@"videoID : %@", videoID);
525-
526-
if(videoID)
527-
html = [NSSWF:@"<div class='chat-media-frame'><iframe width='300' height='233' src='https://www.youtube.com/embed/%@' frameborder='0' allowfullscreen></iframe></div>", videoID];
528-
} else {
529-
html = nil;
530-
}
531-
532-
if(html && [html length] > 0) {
533-
message = [WIP7Message messageWithName:@"wired.chat.send_me" spec:WCP7Spec];
534-
[message setUInt32:[self chatID] forName:@"wired.chat.id"];
535-
[message setString:html forName:@"wired.chat.me"];
536-
[[self connection] sendMessage:message];
537-
}
538-
}
539-
540-
// https://youtu.be/rynxqdNMry4
541-
// <div class="video-container"><iframe src="https://www.youtube-nocookie.com/embed/LJUaJ5PSXGE?rel=0" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>
542-
543-
544497

545498

546499
#pragma mark -
@@ -559,10 +512,7 @@ - (NSArray *)_commands {
559512
@"/ping",
560513
@"/afk",
561514
@"/img",
562-
@"/html",
563515
@"/itunes",
564-
@"/youtube",
565-
@"/utube",
566516
NULL];
567517
}
568518

@@ -678,32 +628,11 @@ - (BOOL)_runCommand:(NSString *)string {
678628

679629
return YES;
680630
}
681-
else if([command isEqualToString:@"/html"]) {
682-
if(argument && [argument length] > 0) {
683-
if([[self class] checkHTMLRestrictionsForString:argument]) {
684-
message = [WIP7Message messageWithName:@"wired.chat.send_say" spec:WCP7Spec];
685-
[message setUInt32:[self chatID] forName:@"wired.chat.id"];
686-
[message setString:argument forName:@"wired.chat.say"];
687-
[[self connection] sendMessage:message];
688-
}
689-
}
690-
return YES;
691-
}
692631
else if([command isEqualToString:@"/itunes"]) {
693632
[self _sendiTunes];
694633

695634
return YES;
696635
}
697-
else if([command isEqualToString:@"/youtube"] || [command isEqualToString:@"/utube"]) {
698-
if(argument && [argument length] > 0) {
699-
NSURL *url = [NSURL URLWithString:argument];
700-
701-
if(url)
702-
[self _sendYouTube:url];
703-
}
704-
705-
return YES;
706-
}
707636

708637
return NO;
709638
}
@@ -1203,10 +1132,8 @@ - (void)appleInterfaceThemeChanged:(NSNotification *) notification {
12031132
NSDictionary *theme;
12041133

12051134
if ([NSApp darkModeEnabled]) {
1206-
NSLog(@"dark");
12071135
theme = [[WCSettings settings] themeWithName:@"Dark"];
12081136
} else {
1209-
NSLog(@"light");
12101137
theme = [[WCSettings settings] themeWithName:@"Light"];
12111138
}
12121139

@@ -1217,7 +1144,7 @@ - (void)appleInterfaceThemeChanged:(NSNotification *) notification {
12171144

12181145

12191146

1220-
- (void)themeDidChange:(NSDictionary *)theme {
1147+
- (void)themeDidChange:(NSDictionary *)theme {
12211148
WITemplateBundle *templateBundle;
12221149
NSColor *textColor, *backgroundColor, *timestampColor, *eventColor, *urlColor;
12231150
NSFont *font;
@@ -1306,11 +1233,11 @@ - (void)themeDidChange:(NSDictionary *)theme {
13061233
toAttribute:WITemplateAttributesFontSize
13071234
ofType:WITemplateTypeChat];
13081235

1309-
[templateBundle setCSSValue:[NSSWF:@"#%.6lx", (unsigned long)[textColor HTMLValue]]
1236+
[templateBundle setCSSValue:[NSApp darkModeEnabled] ? @"white" : @"dimgray"
13101237
toAttribute:WITemplateAttributesFontColor
13111238
ofType:WITemplateTypeChat];
13121239

1313-
[templateBundle setCSSValue:[NSSWF:@"#%.6lx", (unsigned long)[backgroundColor HTMLValue]]
1240+
[templateBundle setCSSValue:[NSApp darkModeEnabled] ? @"#383838" : @"white"
13141241
toAttribute:WITemplateAttributesBackgroundColor
13151242
ofType:WITemplateTypeChat];
13161243

Sources/WCConversationController.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ - (void)reloadData {
223223

224224

225225
- (void)reloadTemplate {
226-
NSLog(@"reloadTemplate");
227-
228226
WITemplateBundle *template;
229227

230228
template = [WITemplateBundle templateWithPath:_templatePath];
@@ -242,7 +240,7 @@ - (void)reloadTemplate {
242240
toAttribute:WITemplateAttributesFontColor
243241
ofType:WITemplateTypeMessages];
244242

245-
[template setCSSValue:[NSApp darkModeEnabled] ? @"dimgray" : @"white"
243+
[template setCSSValue:[NSApp darkModeEnabled] ? @"#383838" : @"white"
246244
toAttribute:WITemplateAttributesBackgroundColor
247245
ofType:WITemplateTypeMessages];
248246

Sources/WCMessages.m

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ - (void)_themeDidChange {
223223
[[_messageTextField.cell fieldEditorForView:_messageTextField] setInsertionPointColor:textColor];
224224
[_messageTextField setBackgroundColor:backgroundColor];
225225

226-
[_broadcastTextView setFont:font];
226+
// [_broadcastTextView setFont:font];
227227
[_broadcastTextView setTextColor:textColor];
228228
[_broadcastTextView setInsertionPointColor:textColor];
229229
[_broadcastTextView setBackgroundColor:backgroundColor];
@@ -394,43 +394,6 @@ - (void)_sendImage:(NSString *)path {
394394
[self _printHTML:html];
395395
}
396396

397-
- (void)_sendYouTube:(NSURL *)url {
398-
NSString *html, *videoID;
399-
NSArray *parameters;
400-
401-
if([[url scheme] containsSubstring:@"http"]) {
402-
403-
if([[url host] containsSubstring:@"youtu.be"])
404-
videoID = [[url absoluteString] lastPathComponent];
405-
406-
else if([[url host] containsSubstring:@"youtube.com"]) {
407-
parameters = [[url query] componentsSeparatedByString:@"&"];
408-
409-
for (NSString * pair in parameters) {
410-
NSArray * bits = [pair componentsSeparatedByString:@"="];
411-
NSString * key = [[bits objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
412-
NSString * value = [[bits objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
413-
414-
if([key isEqualToString:@"v"]) {
415-
videoID = value;
416-
continue;
417-
}
418-
}
419-
} else
420-
videoID = nil;
421-
422-
NSLog(@"videoID : %@", videoID);
423-
424-
if(videoID)
425-
html = [NSSWF:@"<div class='chat-media-frame'><iframe width='300' height='233' src='http://www.youtube.com/embed/%@' frameborder='0' allowfullscreen></iframe></div>", videoID];
426-
} else {
427-
html = nil;
428-
}
429-
430-
if(html && [html length] > 0) {
431-
[self _printHTML:html];
432-
}
433-
}
434397

435398

436399

@@ -439,9 +402,6 @@ - (void)_sendYouTube:(NSURL *)url {
439402
- (NSArray *)_commands {
440403
return [NSArray arrayWithObjects:
441404
@"/img",
442-
@"/html",
443-
@"/youtube",
444-
@"/utube",
445405
NULL];
446406
}
447407

@@ -476,16 +436,6 @@ - (BOOL)_runCommand:(NSString *)string {
476436

477437
return YES;
478438
}
479-
else if([command isEqualToString:@"/youtube"] || [command isEqualToString:@"/utube"]) {
480-
if(argument && [argument length] > 0) {
481-
NSURL *url = [NSURL URLWithString:argument];
482-
483-
if(url)
484-
[self _sendYouTube:url];
485-
}
486-
487-
return YES;
488-
}
489439

490440
return NO;
491441
}

0 commit comments

Comments
 (0)