| OLD | NEW |
| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 const ListValue* mobiles = service_->GetMobiles(); | 166 const ListValue* mobiles = service_->GetMobiles(); |
| 167 | 167 |
| 168 GtkWidget* content = gtk_vbox_new(FALSE, 5); | 168 GtkWidget* content = gtk_vbox_new(FALSE, 5); |
| 169 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); | 169 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); |
| 170 | 170 |
| 171 // Create and pack the title label; init the selected mobile device. | 171 // Create and pack the title label; init the selected mobile device. |
| 172 GtkWidget* title = NULL; | 172 GtkWidget* title = NULL; |
| 173 if (mobiles->GetSize() == 1) { | 173 if (mobiles->GetSize() == 1) { |
| 174 string16 name; | 174 string16 name; |
| 175 DictionaryValue* mobile = NULL; | 175 const DictionaryValue* mobile = NULL; |
| 176 if (mobiles->GetDictionary(0, &mobile) && | 176 if (mobiles->GetDictionary(0, &mobile) && |
| 177 mobile->GetString("name", &name)) { | 177 mobile->GetString("name", &name)) { |
| 178 title = gtk_label_new(l10n_util::GetStringFUTF8( | 178 title = gtk_label_new(l10n_util::GetStringFUTF8( |
| 179 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name).c_str()); | 179 IDS_CHROME_TO_MOBILE_BUBBLE_SINGLE_TITLE, name).c_str()); |
| 180 } else { | 180 } else { |
| 181 NOTREACHED(); | 181 NOTREACHED(); |
| 182 } | 182 } |
| 183 } else { | 183 } else { |
| 184 title = gtk_label_new(l10n_util::GetStringUTF8( | 184 title = gtk_label_new(l10n_util::GetStringUTF8( |
| 185 IDS_CHROME_TO_MOBILE_BUBBLE_MULTI_TITLE).c_str()); | 185 IDS_CHROME_TO_MOBILE_BUBBLE_MULTI_TITLE).c_str()); |
| 186 } | 186 } |
| 187 gtk_misc_set_alignment(GTK_MISC(title), 0, 1); | 187 gtk_misc_set_alignment(GTK_MISC(title), 0, 1); |
| 188 gtk_box_pack_start(GTK_BOX(content), title, FALSE, FALSE, 0); | 188 gtk_box_pack_start(GTK_BOX(content), title, FALSE, FALSE, 0); |
| 189 labels_.push_back(title); | 189 labels_.push_back(title); |
| 190 | 190 |
| 191 // Create and pack the device radio group; init the selected mobile device. | 191 // Create and pack the device radio group; init the selected mobile device. |
| 192 if (mobiles->GetSize() > 1) { | 192 if (mobiles->GetSize() > 1) { |
| 193 std::string name; | 193 std::string name; |
| 194 DictionaryValue* mobile = NULL; | 194 const DictionaryValue* mobile = NULL; |
| 195 GtkWidget* radio = NULL; | 195 GtkWidget* radio = NULL; |
| 196 GtkWidget* row = NULL; | 196 GtkWidget* row = NULL; |
| 197 for (size_t index = 0; index < mobiles->GetSize(); ++index) { | 197 for (size_t index = 0; index < mobiles->GetSize(); ++index) { |
| 198 if (mobiles->GetDictionary(index, &mobile) && | 198 if (mobiles->GetDictionary(index, &mobile) && |
| 199 mobile->GetStringASCII("name", &name)) { | 199 mobile->GetStringASCII("name", &name)) { |
| 200 radio = gtk_radio_button_new_with_label_from_widget( | 200 radio = gtk_radio_button_new_with_label_from_widget( |
| 201 GTK_RADIO_BUTTON(radio), name.c_str()); | 201 GTK_RADIO_BUTTON(radio), name.c_str()); |
| 202 radio_buttons_.push_back(radio); | 202 radio_buttons_.push_back(radio); |
| 203 } else { | 203 } else { |
| 204 NOTREACHED(); | 204 NOTREACHED(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 GtkToggleButton* button = NULL; | 314 GtkToggleButton* button = NULL; |
| 315 for (; selected_index < radio_buttons_.size(); ++selected_index) { | 315 for (; selected_index < radio_buttons_.size(); ++selected_index) { |
| 316 button = GTK_TOGGLE_BUTTON(radio_buttons_[selected_index]); | 316 button = GTK_TOGGLE_BUTTON(radio_buttons_[selected_index]); |
| 317 if (gtk_toggle_button_get_active(button)) | 317 if (gtk_toggle_button_get_active(button)) |
| 318 break; | 318 break; |
| 319 } | 319 } |
| 320 } else { | 320 } else { |
| 321 DCHECK(radio_buttons_.empty()); | 321 DCHECK(radio_buttons_.empty()); |
| 322 } | 322 } |
| 323 | 323 |
| 324 DictionaryValue* mobile = NULL; | 324 const DictionaryValue* mobile = NULL; |
| 325 if (mobiles->GetDictionary(selected_index, &mobile)) { | 325 if (mobiles->GetDictionary(selected_index, &mobile)) { |
| 326 bool snapshot = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_copy_)); | 326 bool snapshot = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(send_copy_)); |
| 327 service_->SendToMobile(*mobile, snapshot ? snapshot_path_ : FilePath(), | 327 service_->SendToMobile(*mobile, snapshot ? snapshot_path_ : FilePath(), |
| 328 browser_, weak_ptr_factory_.GetWeakPtr()); | 328 browser_, weak_ptr_factory_.GetWeakPtr()); |
| 329 } else { | 329 } else { |
| 330 NOTREACHED(); | 330 NOTREACHED(); |
| 331 } | 331 } |
| 332 | 332 |
| 333 // Update the view's contents to show the "Sending..." progress animation. | 333 // Update the view's contents to show the "Sending..." progress animation. |
| 334 gtk_widget_set_sensitive(cancel_, FALSE); | 334 gtk_widget_set_sensitive(cancel_, FALSE); |
| 335 gtk_widget_set_sensitive(send_, FALSE); | 335 gtk_widget_set_sensitive(send_, FALSE); |
| 336 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5); | 336 gtk_button_set_alignment(GTK_BUTTON(send_), 0, 0.5); |
| 337 progress_animation_.reset(new ui::ThrobAnimation(this)); | 337 progress_animation_.reset(new ui::ThrobAnimation(this)); |
| 338 progress_animation_->SetDuration(kProgressThrobDurationMS); | 338 progress_animation_->SetDuration(kProgressThrobDurationMS); |
| 339 progress_animation_->StartThrobbing(-1); | 339 progress_animation_->StartThrobbing(-1); |
| 340 } | 340 } |
| OLD | NEW |