aka RedditBar, Mac OS X menu bar reddit client
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

PrefController.m 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // PrefController.m
  3. // RedditBar
  4. //
  5. // Created by Thomas Buck on 30.11.13.
  6. // Copyright (c) 2013 xythobuz. All rights reserved.
  7. //
  8. #import "PrefController.h"
  9. #import "AppDelegate.h"
  10. @implementation PrefController
  11. @synthesize username, password, subscriptions, subreddits, win, parent;
  12. -(Boolean)isValidList:(NSString *)input validated:(NSString **)output {
  13. // TODO: Check if subreddit input is valid
  14. *output = input;
  15. return TRUE;
  16. }
  17. -(IBAction)buttonSave:(id)sender {
  18. Boolean subs;
  19. NSString *reddits;
  20. if (subscriptions.state != 0) {
  21. subs = TRUE;
  22. } else {
  23. subs = FALSE;
  24. if (![self isValidList:subreddits.textStorage.string validated:&reddits]) {
  25. // TODO show error message
  26. return;
  27. }
  28. }
  29. AppDelegate *app = (AppDelegate *)parent;
  30. [app prefReturnName:username.stringValue Pass:password.stringValue subscriptions:subs subreddits:reddits];
  31. [win performClose:self];
  32. }
  33. -(IBAction)toggleSubs:(id)sender {
  34. if (subscriptions.state != 0) {
  35. // Use subscriptions
  36. [subreddits setEditable:FALSE];
  37. [subreddits setString:@""];
  38. } else {
  39. // Use userlist
  40. [subreddits setEditable:TRUE];
  41. [subreddits setString:@"One Subreddit per line!"];
  42. }
  43. }
  44. -(void)showWindow:(id)sender {
  45. [super showWindow:sender];
  46. }
  47. @end