Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.cc

Issue 10908157: Integrate ChromeToMobile with GTK Action Box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extra TODOs. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/gtk/chrome_to_mobile_bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // The seconds to delay before automatically closing the bubble after sending. 47 // The seconds to delay before automatically closing the bubble after sending.
48 const int kAutoCloseDelay = 3; 48 const int kAutoCloseDelay = 3;
49 49
50 // The color of the error label. 50 // The color of the error label.
51 const GdkColor kErrorColor = GDK_COLOR_RGB(0xFF, 0x00, 0x00); 51 const GdkColor kErrorColor = GDK_COLOR_RGB(0xFF, 0x00, 0x00);
52 52
53 } // namespace 53 } // namespace
54 54
55 // static 55 // static
56 void ChromeToMobileBubbleGtk::Show(GtkImage* anchor_image, Browser* browser) { 56 void ChromeToMobileBubbleGtk::Show(GtkWidget* anchor_widget, Browser* browser) {
57 // Do not construct a new bubble if one is already being shown. 57 // Do not construct a new bubble if one is already being shown.
58 if (!g_bubble) 58 if (!g_bubble)
59 g_bubble = new ChromeToMobileBubbleGtk(anchor_image, browser); 59 g_bubble = new ChromeToMobileBubbleGtk(anchor_widget, browser);
60 } 60 }
61 61
62 void ChromeToMobileBubbleGtk::BubbleClosing(BubbleGtk* bubble, 62 void ChromeToMobileBubbleGtk::BubbleClosing(BubbleGtk* bubble,
63 bool closed_by_escape) { 63 bool closed_by_escape) {
64 DCHECK_EQ(bubble, bubble_); 64 DCHECK_EQ(bubble, bubble_);
65 65
66 // Instruct the service to delete the snapshot file. 66 // Instruct the service to delete the snapshot file.
67 service_->DeleteSnapshot(snapshot_path_); 67 service_->DeleteSnapshot(snapshot_path_);
68 68
69 // Restore the resting state mobile device icon.
70 gtk_image_set_from_pixbuf(GTK_IMAGE(anchor_image_),
71 theme_service_->GetImageNamed(IDR_MOBILE)->ToGdkPixbuf());
72
73 labels_.clear(); 69 labels_.clear();
74 anchor_image_ = NULL; 70 anchor_widget_ = NULL;
75 send_copy_ = NULL; 71 send_copy_ = NULL;
76 cancel_ = NULL; 72 cancel_ = NULL;
77 send_ = NULL; 73 send_ = NULL;
78 error_ = NULL; 74 error_ = NULL;
79 bubble_ = NULL; 75 bubble_ = NULL;
80 progress_animation_.reset(); 76 progress_animation_.reset();
81 } 77 }
82 78
83 void ChromeToMobileBubbleGtk::AnimationProgressed( 79 void ChromeToMobileBubbleGtk::AnimationProgressed(
84 const ui::Animation* animation) { 80 const ui::Animation* animation) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 base::Bind(&ChromeToMobileBubbleGtk::OnCancelClicked, 131 base::Bind(&ChromeToMobileBubbleGtk::OnCancelClicked,
136 weak_ptr_factory_.GetWeakPtr(), GTK_WIDGET(NULL)), 132 weak_ptr_factory_.GetWeakPtr(), GTK_WIDGET(NULL)),
137 base::TimeDelta::FromSeconds(kAutoCloseDelay)); 133 base::TimeDelta::FromSeconds(kAutoCloseDelay));
138 } else { 134 } else {
139 gtk_button_set_label(GTK_BUTTON(send_), 135 gtk_button_set_label(GTK_BUTTON(send_),
140 l10n_util::GetStringUTF8(IDS_CHROME_TO_MOBILE_BUBBLE_ERROR).c_str()); 136 l10n_util::GetStringUTF8(IDS_CHROME_TO_MOBILE_BUBBLE_ERROR).c_str());
141 gtk_widget_set_visible(error_, TRUE); 137 gtk_widget_set_visible(error_, TRUE);
142 } 138 }
143 } 139 }
144 140
145 ChromeToMobileBubbleGtk::ChromeToMobileBubbleGtk(GtkImage* anchor_image, 141 ChromeToMobileBubbleGtk::ChromeToMobileBubbleGtk(GtkWidget* anchor_widget,
146 Browser* browser) 142 Browser* browser)
147 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 143 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
148 browser_(browser), 144 browser_(browser),
149 service_(ChromeToMobileServiceFactory::GetForProfile(browser->profile())), 145 service_(ChromeToMobileServiceFactory::GetForProfile(browser->profile())),
150 theme_service_(GtkThemeService::GetFrom(browser->profile())), 146 theme_service_(GtkThemeService::GetFrom(browser->profile())),
151 anchor_image_(anchor_image), 147 anchor_widget_(anchor_widget),
152 send_copy_(NULL), 148 send_copy_(NULL),
153 cancel_(NULL), 149 cancel_(NULL),
154 send_(NULL), 150 send_(NULL),
155 error_(NULL), 151 error_(NULL),
156 bubble_(NULL) { 152 bubble_(NULL) {
157 DCHECK(service_->HasMobiles()); 153 DCHECK(service_->HasMobiles());
158 service_->LogMetric(ChromeToMobileService::BUBBLE_SHOWN); 154 service_->LogMetric(ChromeToMobileService::BUBBLE_SHOWN);
159 155
160 // Generate the MHTML snapshot now to report its size in the bubble. 156 // Generate the MHTML snapshot now to report its size in the bubble.
161 service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr()); 157 service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 gtk_misc_set_alignment(GTK_MISC(error_), 0, 1); 243 gtk_misc_set_alignment(GTK_MISC(error_), 0, 1);
248 gtk_util::SetLabelColor(error_, &kErrorColor); 244 gtk_util::SetLabelColor(error_, &kErrorColor);
249 gtk_box_pack_start(GTK_BOX(content), error_, FALSE, FALSE, 0); 245 gtk_box_pack_start(GTK_BOX(content), error_, FALSE, FALSE, 0);
250 gtk_widget_set_no_show_all(error_, TRUE); 246 gtk_widget_set_no_show_all(error_, TRUE);
251 247
252 // Initialize focus to the send button. 248 // Initialize focus to the send button.
253 gtk_container_set_focus_child(GTK_CONTAINER(content), send_); 249 gtk_container_set_focus_child(GTK_CONTAINER(content), send_);
254 250
255 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ? 251 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ?
256 BubbleGtk::ARROW_LOCATION_TOP_LEFT : BubbleGtk::ARROW_LOCATION_TOP_RIGHT; 252 BubbleGtk::ARROW_LOCATION_TOP_LEFT : BubbleGtk::ARROW_LOCATION_TOP_RIGHT;
257 bubble_ = BubbleGtk::Show(GTK_WIDGET(anchor_image_), 253 const int attribute_flags = BubbleGtk::MATCH_SYSTEM_THEME |
258 NULL, 254 BubbleGtk::POPUP_WINDOW | BubbleGtk::GRAB_INPUT;
259 content, 255 bubble_ = BubbleGtk::Show(anchor_widget_, NULL, content, arrow_location,
260 arrow_location, 256 attribute_flags, theme_service_, this /*delegate*/);
261 BubbleGtk::MATCH_SYSTEM_THEME |
262 BubbleGtk::POPUP_WINDOW |
263 BubbleGtk::GRAB_INPUT,
264 theme_service_,
265 this /*delegate*/);
266 if (!bubble_) { 257 if (!bubble_) {
267 NOTREACHED(); 258 NOTREACHED();
268 return; 259 return;
269 } 260 }
270 261
271 g_signal_connect(content, "destroy", G_CALLBACK(&OnDestroyThunk), this); 262 g_signal_connect(content, "destroy", G_CALLBACK(&OnDestroyThunk), this);
272 g_signal_connect(learn_, "clicked", G_CALLBACK(&OnLearnClickedThunk), this); 263 g_signal_connect(learn_, "clicked", G_CALLBACK(&OnLearnClickedThunk), this);
273 g_signal_connect(cancel_, "clicked", G_CALLBACK(&OnCancelClickedThunk), this); 264 g_signal_connect(cancel_, "clicked", G_CALLBACK(&OnCancelClickedThunk), this);
274 g_signal_connect(send_, "clicked", G_CALLBACK(&OnSendClickedThunk), this); 265 g_signal_connect(send_, "clicked", G_CALLBACK(&OnSendClickedThunk), this);
275 266
276 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 267 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
277 content::Source<ThemeService>(theme_service_)); 268 content::Source<ThemeService>(theme_service_));
278 theme_service_->InitThemesFor(this); 269 theme_service_->InitThemesFor(this);
279
280 gtk_image_set_from_pixbuf(GTK_IMAGE(anchor_image_),
281 theme_service_->GetImageNamed(IDR_MOBILE_LIT)->ToGdkPixbuf());
282 } 270 }
283 271
284 ChromeToMobileBubbleGtk::~ChromeToMobileBubbleGtk() { 272 ChromeToMobileBubbleGtk::~ChromeToMobileBubbleGtk() {
285 DCHECK(g_bubble); 273 DCHECK(g_bubble);
286 g_bubble = NULL; 274 g_bubble = NULL;
287 } 275 }
288 276
289 void ChromeToMobileBubbleGtk::OnDestroy(GtkWidget* widget) { 277 void ChromeToMobileBubbleGtk::OnDestroy(GtkWidget* widget) {
290 // We are self deleting, we have a destroy signal setup to catch when we 278 // We are self deleting, we have a destroy signal setup to catch when we
291 // destroyed (via the BubbleGtk being destroyed), and delete ourself. 279 // destroyed (via the BubbleGtk being destroyed), and delete ourself.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 315 }
328 316
329 // Update the view's contents to show the "Sending..." progress animation. 317 // Update the view's contents to show the "Sending..." progress animation.
330 gtk_widget_set_sensitive(cancel_, FALSE); 318 gtk_widget_set_sensitive(cancel_, FALSE);
331 gtk_widget_set_sensitive(send_, FALSE); 319 gtk_widget_set_sensitive(send_, FALSE);
332 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5); 320 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5);
333 progress_animation_.reset(new ui::ThrobAnimation(this)); 321 progress_animation_.reset(new ui::ThrobAnimation(this));
334 progress_animation_->SetDuration(kProgressThrobDurationMS); 322 progress_animation_->SetDuration(kProgressThrobDurationMS);
335 progress_animation_->StartThrobbing(-1); 323 progress_animation_->StartThrobbing(-1);
336 } 324 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/chrome_to_mobile_bubble_gtk.h ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698