| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/mac_util.h" | 7 #import "base/mac_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #import "chrome/browser/cocoa/edit_search_engine_cocoa_controller.h" | 9 #import "chrome/browser/cocoa/edit_search_engine_cocoa_controller.h" |
| 10 #import "chrome/browser/cocoa/keyword_editor_cocoa_controller.h" | 10 #import "chrome/browser/cocoa/keyword_editor_cocoa_controller.h" |
| 11 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
| 12 #include "chrome/browser/search_engines/template_url_table_model.h" | 12 #include "chrome/browser/search_engines/template_url_table_model.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 14 | 15 |
| 15 @interface KeywordEditorCocoaController (Private) | 16 @interface KeywordEditorCocoaController (Private) |
| 16 - (void)adjustEditingButtons; | 17 - (void)adjustEditingButtons; |
| 17 - (void)editKeyword:(id)sender; | 18 - (void)editKeyword:(id)sender; |
| 18 @end | 19 @end |
| 19 | 20 |
| 20 // KeywordEditorModelObserver ------------------------------------------------- | 21 // KeywordEditorModelObserver ------------------------------------------------- |
| 21 | 22 |
| 22 KeywordEditorModelObserver::KeywordEditorModelObserver( | 23 KeywordEditorModelObserver::KeywordEditorModelObserver( |
| 23 KeywordEditorCocoaController* controller) : controller_(controller) { | 24 KeywordEditorCocoaController* controller) : controller_(controller) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 62 } |
| 62 return self; | 63 return self; |
| 63 } | 64 } |
| 64 | 65 |
| 65 - (void)dealloc { | 66 - (void)dealloc { |
| 66 controller_->url_model()->RemoveObserver(observer_.get()); | 67 controller_->url_model()->RemoveObserver(observer_.get()); |
| 67 [super dealloc]; | 68 [super dealloc]; |
| 68 } | 69 } |
| 69 | 70 |
| 70 - (void)awakeFromNib { | 71 - (void)awakeFromNib { |
| 72 // Make sure the button fits its label, but keep it the same height as the |
| 73 // other two buttons. |
| 74 [GTMUILocalizerAndLayoutTweaker sizeToFitView:makeDefaultButton_]; |
| 75 NSSize size = [makeDefaultButton_ frame].size; |
| 76 size.height = NSHeight([addButton_ frame]); |
| 77 [makeDefaultButton_ setFrameSize:size]; |
| 78 |
| 71 [self adjustEditingButtons]; | 79 [self adjustEditingButtons]; |
| 72 [tableView_ setDoubleAction:@selector(editKeyword:)]; | 80 [tableView_ setDoubleAction:@selector(editKeyword:)]; |
| 73 [tableView_ setTarget:self]; | 81 [tableView_ setTarget:self]; |
| 74 } | 82 } |
| 75 | 83 |
| 76 // When the window closes, clean ourselves up. | 84 // When the window closes, clean ourselves up. |
| 77 - (void)windowWillClose:(NSNotification*)notif { | 85 - (void)windowWillClose:(NSNotification*)notif { |
| 78 [self autorelease]; | 86 [self autorelease]; |
| 79 } | 87 } |
| 80 | 88 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if ([selection count] != 1) { | 197 if ([selection count] != 1) { |
| 190 [makeDefaultButton_ setEnabled:NO]; | 198 [makeDefaultButton_ setEnabled:NO]; |
| 191 } else { | 199 } else { |
| 192 const TemplateURL& url = | 200 const TemplateURL& url = |
| 193 controller_->table_model()->GetTemplateURL([selection firstIndex]); | 201 controller_->table_model()->GetTemplateURL([selection firstIndex]); |
| 194 [makeDefaultButton_ setEnabled:controller_->CanMakeDefault(&url)]; | 202 [makeDefaultButton_ setEnabled:controller_->CanMakeDefault(&url)]; |
| 195 } | 203 } |
| 196 } | 204 } |
| 197 | 205 |
| 198 @end | 206 @end |
| OLD | NEW |