| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/speech/speech_input_bubble.h" | 5 #include "chrome/browser/speech/speech_input_bubble.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/gtk/gtk_theme_provider.h" | 10 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 virtual void Show(); | 47 virtual void Show(); |
| 48 virtual void Hide(); | 48 virtual void Hide(); |
| 49 virtual void UpdateLayout(); | 49 virtual void UpdateLayout(); |
| 50 virtual void SetImage(const SkBitmap& image); | 50 virtual void SetImage(const SkBitmap& image); |
| 51 | 51 |
| 52 CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnCancelClicked); | 52 CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnCancelClicked); |
| 53 CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnTryAgainClicked); | 53 CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnTryAgainClicked); |
| 54 | 54 |
| 55 Delegate* delegate_; | 55 Delegate* delegate_; |
| 56 InfoBubbleGtk* info_bubble_; | 56 InfoBubbleGtk* info_bubble_; |
| 57 TabContents* tab_contents_; | |
| 58 gfx::Rect element_rect_; | 57 gfx::Rect element_rect_; |
| 59 bool did_invoke_close_; | 58 bool did_invoke_close_; |
| 60 | 59 |
| 61 GtkWidget* label_; | 60 GtkWidget* label_; |
| 62 GtkWidget* try_again_button_; | 61 GtkWidget* try_again_button_; |
| 63 GtkWidget* icon_; | 62 GtkWidget* icon_; |
| 64 | 63 |
| 65 DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleGtk); | 64 DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleGtk); |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 SpeechInputBubbleGtk::SpeechInputBubbleGtk(TabContents* tab_contents, | 67 SpeechInputBubbleGtk::SpeechInputBubbleGtk(TabContents* tab_contents, |
| 69 Delegate* delegate, | 68 Delegate* delegate, |
| 70 const gfx::Rect& element_rect) | 69 const gfx::Rect& element_rect) |
| 71 : delegate_(delegate), | 70 : SpeechInputBubbleBase(tab_contents), |
| 71 delegate_(delegate), |
| 72 info_bubble_(NULL), | 72 info_bubble_(NULL), |
| 73 tab_contents_(tab_contents), | |
| 74 element_rect_(element_rect), | 73 element_rect_(element_rect), |
| 75 did_invoke_close_(false), | 74 did_invoke_close_(false), |
| 76 label_(NULL), | 75 label_(NULL), |
| 77 try_again_button_(NULL), | 76 try_again_button_(NULL), |
| 78 icon_(NULL) { | 77 icon_(NULL) { |
| 79 } | 78 } |
| 80 | 79 |
| 81 SpeechInputBubbleGtk::~SpeechInputBubbleGtk() { | 80 SpeechInputBubbleGtk::~SpeechInputBubbleGtk() { |
| 82 // The |Close| call below invokes our |InfoBubbleClosing| method. Since we | 81 // The |Close| call below invokes our |InfoBubbleClosing| method. Since we |
| 83 // were destroyed by the caller we don't need to call them back, hence set | 82 // were destroyed by the caller we don't need to call them back, hence set |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 g_signal_connect(try_again_button_, "clicked", | 137 g_signal_connect(try_again_button_, "clicked", |
| 139 G_CALLBACK(&OnTryAgainClickedThunk), this); | 138 G_CALLBACK(&OnTryAgainClickedThunk), this); |
| 140 | 139 |
| 141 GtkWidget* content = gtk_alignment_new(0, 0, 0, 0); | 140 GtkWidget* content = gtk_alignment_new(0, 0, 0, 0); |
| 142 gtk_alignment_set_padding(GTK_ALIGNMENT(content), | 141 gtk_alignment_set_padding(GTK_ALIGNMENT(content), |
| 143 kBubbleControlVerticalSpacing, kBubbleControlVerticalSpacing, | 142 kBubbleControlVerticalSpacing, kBubbleControlVerticalSpacing, |
| 144 kBubbleControlHorizontalSpacing, kBubbleControlHorizontalSpacing); | 143 kBubbleControlHorizontalSpacing, kBubbleControlHorizontalSpacing); |
| 145 gtk_container_add(GTK_CONTAINER(content), vbox); | 144 gtk_container_add(GTK_CONTAINER(content), vbox); |
| 146 | 145 |
| 147 GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( | 146 GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom( |
| 148 tab_contents_->profile()); | 147 tab_contents()->profile()); |
| 149 gfx::Rect rect(element_rect_.x() + kBubbleTargetOffsetX, | 148 gfx::Rect rect(element_rect_.x() + kBubbleTargetOffsetX, |
| 150 element_rect_.y() + element_rect_.height(), 1, 1); | 149 element_rect_.y() + element_rect_.height(), 1, 1); |
| 151 info_bubble_ = InfoBubbleGtk::Show(tab_contents_->GetNativeView(), | 150 info_bubble_ = InfoBubbleGtk::Show(tab_contents()->GetNativeView(), |
| 152 &rect, | 151 &rect, |
| 153 content, | 152 content, |
| 154 InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT, | 153 InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT, |
| 155 false, // match_system_theme | 154 false, // match_system_theme |
| 156 true, // grab_input | 155 true, // grab_input |
| 157 theme_provider, | 156 theme_provider, |
| 158 this); | 157 this); |
| 159 | 158 |
| 160 UpdateLayout(); | 159 UpdateLayout(); |
| 161 } | 160 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 206 |
| 208 } // namespace | 207 } // namespace |
| 209 | 208 |
| 210 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( | 209 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( |
| 211 TabContents* tab_contents, | 210 TabContents* tab_contents, |
| 212 Delegate* delegate, | 211 Delegate* delegate, |
| 213 const gfx::Rect& element_rect) { | 212 const gfx::Rect& element_rect) { |
| 214 return new SpeechInputBubbleGtk(tab_contents, delegate, element_rect); | 213 return new SpeechInputBubbleGtk(tab_contents, delegate, element_rect); |
| 215 } | 214 } |
| 216 | 215 |
| OLD | NEW |