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/web_intent_picker_gtk.h" | 5 #include "chrome/browser/ui/gtk/web_intent_picker_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf(); | 130 ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf(); |
131 gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf(star), | 131 gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf(star), |
132 FALSE, FALSE, 0); | 132 FALSE, FALSE, 0); |
133 } | 133 } |
134 | 134 |
135 return hbox; | 135 return hbox; |
136 } | 136 } |
137 | 137 |
138 } // namespace | 138 } // namespace |
139 | 139 |
| 140 // Create a new Widget for the "waiting for CWS" display. |
| 141 |
| 142 class WaitingDialog { |
| 143 public: |
| 144 explicit WaitingDialog(GtkThemeService* theme_service); |
| 145 ~WaitingDialog(); |
| 146 |
| 147 GtkWidget* widget() const { return widget_.get(); } |
| 148 private: |
| 149 // Initialize the widget. |
| 150 void Init(); |
| 151 |
| 152 // The actual GtkWidget |
| 153 ui::OwnedWidgetGtk widget_; |
| 154 |
| 155 // Waiting throbber. |
| 156 scoped_ptr<ThrobberGtk> throbber_; |
| 157 |
| 158 // Weak pointer to theme service. |
| 159 GtkThemeService* theme_service_; |
| 160 }; |
| 161 |
| 162 WaitingDialog::WaitingDialog(GtkThemeService* theme_service) |
| 163 : theme_service_(theme_service) { |
| 164 DCHECK(theme_service_); |
| 165 Init(); |
| 166 } |
| 167 |
| 168 WaitingDialog::~WaitingDialog() { |
| 169 widget_.Destroy(); |
| 170 } |
| 171 |
| 172 void WaitingDialog::Init() { |
| 173 widget_.Own(gtk_hbox_new(FALSE, 0)); |
| 174 GtkWidget* hbox = widget_.get(); |
| 175 |
| 176 // Add the message text. |
| 177 GtkWidget* message_label = theme_service_->BuildLabel( |
| 178 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES).c_str(), |
| 179 ui::kGdkBlack); |
| 180 gtk_label_set_line_wrap(GTK_LABEL(message_label), TRUE); |
| 181 gtk_misc_set_alignment(GTK_MISC(message_label), 0, 0); |
| 182 // Set the label width to the size of the main content width minus borders. |
| 183 gtk_util::SetLabelWidth(message_label, |
| 184 kMainContentWidth - 2 * ui::kContentAreaBorder); |
| 185 gtk_box_pack_start(GTK_BOX(hbox), message_label, TRUE, TRUE, 0); |
| 186 |
| 187 // Create throbber |
| 188 throbber_.reset(new ThrobberGtk(theme_service_)); |
| 189 gtk_box_pack_start(GTK_BOX(hbox), throbber_->widget(), TRUE, TRUE, 0); |
| 190 |
| 191 // TODO(groby): use large spinner. |
| 192 // IDR_SPEECH_INPUT_SPINNER |
| 193 // Animate throbber |
| 194 throbber_->Start(); |
| 195 } |
140 // static | 196 // static |
141 WebIntentPicker* WebIntentPicker::Create(TabContents* tab_contents, | 197 WebIntentPicker* WebIntentPicker::Create(TabContents* tab_contents, |
142 WebIntentPickerDelegate* delegate, | 198 WebIntentPickerDelegate* delegate, |
143 WebIntentPickerModel* model) { | 199 WebIntentPickerModel* model) { |
144 return new WebIntentPickerGtk(tab_contents, delegate, model); | 200 return new WebIntentPickerGtk(tab_contents, delegate, model); |
145 } | 201 } |
146 | 202 |
147 WebIntentPickerGtk::WebIntentPickerGtk(TabContents* tab_contents, | 203 WebIntentPickerGtk::WebIntentPickerGtk(TabContents* tab_contents, |
148 WebIntentPickerDelegate* delegate, | 204 WebIntentPickerDelegate* delegate, |
149 WebIntentPickerModel* model) | 205 WebIntentPickerModel* model) |
(...skipping 26 matching lines...) Expand all Loading... |
176 } | 232 } |
177 | 233 |
178 void WebIntentPickerGtk::Close() { | 234 void WebIntentPickerGtk::Close() { |
179 window_->CloseConstrainedWindow(); | 235 window_->CloseConstrainedWindow(); |
180 if (inline_disposition_tab_contents_.get()) | 236 if (inline_disposition_tab_contents_.get()) |
181 inline_disposition_tab_contents_->web_contents()->OnCloseStarted(); | 237 inline_disposition_tab_contents_->web_contents()->OnCloseStarted(); |
182 } | 238 } |
183 | 239 |
184 void WebIntentPickerGtk::SetActionString(const string16& action) { | 240 void WebIntentPickerGtk::SetActionString(const string16& action) { |
185 header_label_text_ = action; | 241 header_label_text_ = action; |
186 gtk_label_set_text(GTK_LABEL(header_label_), UTF16ToUTF8(action).c_str()); | 242 if (header_label_) |
| 243 gtk_label_set_text(GTK_LABEL(header_label_), UTF16ToUTF8(action).c_str()); |
187 } | 244 } |
188 | 245 |
189 void WebIntentPickerGtk::OnExtensionInstallSuccess(const std::string& id) { | 246 void WebIntentPickerGtk::OnExtensionInstallSuccess(const std::string& id) { |
190 RemoveThrobber(); | 247 RemoveThrobber(); |
191 } | 248 } |
192 | 249 |
193 void WebIntentPickerGtk::OnExtensionInstallFailure(const std::string& id) { | 250 void WebIntentPickerGtk::OnExtensionInstallFailure(const std::string& id) { |
194 // The throbber has an alignment as its parent, so it must be used instead of | 251 // The throbber has an alignment as its parent, so it must be used instead of |
195 // the throbber to find the extension row. | 252 // the throbber to find the extension row. |
196 size_t index = | 253 size_t index = |
197 GetExtensionWidgetRow(gtk_widget_get_parent(throbber_->widget())); | 254 GetExtensionWidgetRow(gtk_widget_get_parent(throbber_->widget())); |
198 GList* vbox_list = | 255 GList* vbox_list = |
199 gtk_container_get_children(GTK_CONTAINER(extensions_vbox_)); | 256 gtk_container_get_children(GTK_CONTAINER(extensions_vbox_)); |
200 GtkWidget* hbox = static_cast<GtkWidget*>(g_list_nth_data(vbox_list, index)); | 257 GtkWidget* hbox = static_cast<GtkWidget*>(g_list_nth_data(vbox_list, index)); |
201 | 258 |
202 RemoveThrobber(); | 259 RemoveThrobber(); |
203 gtk_widget_show_all(hbox); | 260 gtk_widget_show_all(hbox); |
204 g_list_free(vbox_list); | 261 g_list_free(vbox_list); |
205 SetWidgetsEnabled(true); | 262 SetWidgetsEnabled(true); |
206 } | 263 } |
207 | 264 |
208 void WebIntentPickerGtk::OnModelChanged(WebIntentPickerModel* model) { | 265 void WebIntentPickerGtk::OnModelChanged(WebIntentPickerModel* model) { |
| 266 if (waiting_dialog_.get() && !model->IsWaitingForSuggestions()) { |
| 267 waiting_dialog_.reset(); |
| 268 InitMainContents(); |
| 269 } |
209 UpdateInstalledServices(); | 270 UpdateInstalledServices(); |
210 UpdateCWSLabel(); | 271 UpdateCWSLabel(); |
211 UpdateSuggestedExtensions(); | 272 UpdateSuggestedExtensions(); |
| 273 SetActionString(header_label_text_); |
212 } | 274 } |
213 | 275 |
214 void WebIntentPickerGtk::OnFaviconChanged(WebIntentPickerModel* model, | 276 void WebIntentPickerGtk::OnFaviconChanged(WebIntentPickerModel* model, |
215 size_t index) { | 277 size_t index) { |
216 UpdateInstalledServices(); | 278 UpdateInstalledServices(); |
217 } | 279 } |
218 | 280 |
219 void WebIntentPickerGtk::OnExtensionIconChanged(WebIntentPickerModel* model, | 281 void WebIntentPickerGtk::OnExtensionIconChanged(WebIntentPickerModel* model, |
220 const string16& extension_id) { | 282 const string16& extension_id) { |
221 UpdateSuggestedExtensions(); | 283 UpdateSuggestedExtensions(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 387 |
326 // Replace the picker contents with dialog box. | 388 // Replace the picker contents with dialog box. |
327 gtk_util::RemoveAllChildren(contents_); | 389 gtk_util::RemoveAllChildren(contents_); |
328 | 390 |
329 GtkWidget* sub_contents = CreateSubContents(contents_); | 391 GtkWidget* sub_contents = CreateSubContents(contents_); |
330 | 392 |
331 AddCloseButton(contents_); | 393 AddCloseButton(contents_); |
332 AddTitle(sub_contents); | 394 AddTitle(sub_contents); |
333 | 395 |
334 // Replace the dialog header. | 396 // Replace the dialog header. |
| 397 DCHECK(header_label_); |
335 gtk_label_set_text( | 398 gtk_label_set_text( |
336 GTK_LABEL(header_label_), | 399 GTK_LABEL(header_label_), |
337 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES_TITLE).c_str()); | 400 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES_TITLE).c_str()); |
338 | 401 |
339 // Add the message text. | 402 // Add the message text. |
340 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); | 403 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); |
341 gtk_box_pack_start(GTK_BOX(sub_contents), hbox, TRUE, TRUE, 0); | 404 gtk_box_pack_start(GTK_BOX(sub_contents), hbox, TRUE, TRUE, 0); |
342 GtkThemeService* theme_service = GetThemeService(tab_contents_); | 405 GtkThemeService* theme_service = GetThemeService(tab_contents_); |
343 GtkWidget* no_service_label = theme_service->BuildLabel( | 406 GtkWidget* no_service_label = theme_service->BuildLabel( |
344 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES).c_str(), | 407 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES).c_str(), |
(...skipping 24 matching lines...) Expand all Loading... |
369 } | 432 } |
370 | 433 |
371 bool WebIntentPickerGtk::ShouldHaveBorderPadding() const { | 434 bool WebIntentPickerGtk::ShouldHaveBorderPadding() const { |
372 return false; | 435 return false; |
373 } | 436 } |
374 | 437 |
375 void WebIntentPickerGtk::Observe(int type, | 438 void WebIntentPickerGtk::Observe(int type, |
376 const content::NotificationSource& source, | 439 const content::NotificationSource& source, |
377 const content::NotificationDetails& details) { | 440 const content::NotificationDetails& details) { |
378 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED); | 441 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
379 GtkThemeService* theme_service = GetThemeService(tab_contents_); | 442 if (header_label_) { |
380 if (theme_service->UsingNativeTheme()) | 443 GtkThemeService* theme_service = GetThemeService(tab_contents_); |
381 gtk_util::UndoForceFontSize(header_label_); | 444 if (theme_service->UsingNativeTheme()) |
382 else | 445 gtk_util::UndoForceFontSize(header_label_); |
383 gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize); | 446 else |
384 | 447 gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize); |
| 448 } |
385 UpdateInstalledServices(); | 449 UpdateInstalledServices(); |
386 UpdateSuggestedExtensions(); | 450 UpdateSuggestedExtensions(); |
387 } | 451 } |
388 | 452 |
389 void WebIntentPickerGtk::OnDestroy(GtkWidget* button) { | 453 void WebIntentPickerGtk::OnDestroy(GtkWidget* button) { |
390 // Destroy this object when the contents widget is destroyed. It can't be | 454 // Destroy this object when the contents widget is destroyed. It can't be |
391 // "delete this" because this function happens in a callback. | 455 // "delete this" because this function happens in a callback. |
392 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 456 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
393 model_->set_observer(NULL); | 457 model_->set_observer(NULL); |
394 window_ = NULL; | 458 window_ = NULL; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 GtkThemeService* theme_service = GetThemeService(tab_contents_); | 527 GtkThemeService* theme_service = GetThemeService(tab_contents_); |
464 | 528 |
465 // Main contents vbox. | 529 // Main contents vbox. |
466 if (!contents_) { | 530 if (!contents_) { |
467 contents_ = gtk_vbox_new(FALSE, 0); | 531 contents_ = gtk_vbox_new(FALSE, 0); |
468 g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this); | 532 g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this); |
469 } | 533 } |
470 | 534 |
471 gtk_widget_set_size_request(contents_, kMainContentWidth, -1); | 535 gtk_widget_set_size_request(contents_, kMainContentWidth, -1); |
472 | 536 |
| 537 if (model_ && model_->IsWaitingForSuggestions()) { |
| 538 gtk_util::RemoveAllChildren(contents_); |
| 539 AddCloseButton(contents_); |
| 540 waiting_dialog_.reset(new WaitingDialog(theme_service)); |
| 541 gtk_box_pack_start(GTK_BOX(contents_), waiting_dialog_->widget(), |
| 542 TRUE, TRUE, 0); |
| 543 } else { |
| 544 InitMainContents(); |
| 545 } |
| 546 } |
| 547 |
| 548 void WebIntentPickerGtk::InitMainContents() { |
| 549 GtkThemeService* theme_service = GetThemeService(tab_contents_); |
| 550 |
| 551 gtk_util::RemoveAllChildren(contents_); |
| 552 |
473 AddCloseButton(contents_); | 553 AddCloseButton(contents_); |
474 GtkWidget* sub_contents = CreateSubContents(contents_); | 554 GtkWidget* sub_contents = CreateSubContents(contents_); |
| 555 |
475 AddTitle(sub_contents); | 556 AddTitle(sub_contents); |
476 | 557 |
477 // Add separation between the installed services list and the app suggestions. | 558 // Add separation between the installed services list and the app suggestions. |
478 GtkWidget* button_alignment = gtk_alignment_new(0.5, 0, 0, 0); | 559 GtkWidget* button_alignment = gtk_alignment_new(0.5, 0, 0, 0); |
479 gtk_alignment_set_padding(GTK_ALIGNMENT(button_alignment), 0, | 560 gtk_alignment_set_padding(GTK_ALIGNMENT(button_alignment), 0, |
480 kMainContentPixelSize * 2, 0, 0); | 561 kMainContentPixelSize * 2, 0, 0); |
481 | 562 |
482 // Vbox containing all service buttons. | 563 // Vbox containing all service buttons. |
483 button_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing); | 564 button_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing); |
484 gtk_container_add(GTK_CONTAINER(button_alignment), button_vbox_); | 565 gtk_container_add(GTK_CONTAINER(button_alignment), button_vbox_); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 GTK_CHROME_LINK_BUTTON(more_suggestions_link)->label, | 600 GTK_CHROME_LINK_BUTTON(more_suggestions_link)->label, |
520 kMainContentPixelSize); | 601 kMainContentPixelSize); |
521 g_signal_connect(more_suggestions_link, "clicked", | 602 g_signal_connect(more_suggestions_link, "clicked", |
522 G_CALLBACK(OnMoreSuggestionsLinkClickThunk), this); | 603 G_CALLBACK(OnMoreSuggestionsLinkClickThunk), this); |
523 | 604 |
524 GtkWidget* indent_link = gtk_util::IndentWidget(link_alignment); | 605 GtkWidget* indent_link = gtk_util::IndentWidget(link_alignment); |
525 gtk_box_pack_start(GTK_BOX(sub_contents), indent_link, TRUE, TRUE, 0); | 606 gtk_box_pack_start(GTK_BOX(sub_contents), indent_link, TRUE, TRUE, 0); |
526 | 607 |
527 // Throbber, which will be added to the hierarchy when necessary. | 608 // Throbber, which will be added to the hierarchy when necessary. |
528 throbber_.reset(new ThrobberGtk(theme_service)); | 609 throbber_.reset(new ThrobberGtk(theme_service)); |
| 610 |
| 611 gtk_widget_show_all(contents_); |
529 } | 612 } |
530 | 613 |
531 void WebIntentPickerGtk::ResetContents() { | 614 void WebIntentPickerGtk::ResetContents() { |
532 // Wipe out all currently displayed widgets. | 615 // Wipe out all currently displayed widgets. |
533 gtk_util::RemoveAllChildren(contents_); | 616 gtk_util::RemoveAllChildren(contents_); |
534 | 617 |
535 // Reset potential inline disposition data. | 618 // Reset potential inline disposition data. |
536 inline_disposition_delegate_.reset(NULL); | 619 inline_disposition_delegate_.reset(NULL); |
537 tab_contents_container_.reset(NULL); | 620 tab_contents_container_.reset(NULL); |
538 inline_disposition_tab_contents_.reset(NULL); | 621 inline_disposition_tab_contents_.reset(NULL); |
539 | 622 |
540 // Re-initialize picker widgets and data. | 623 // Re-initialize picker widgets and data. |
541 InitContents(); | 624 InitMainContents(); |
542 UpdateInstalledServices(); | 625 UpdateInstalledServices(); |
543 UpdateCWSLabel(); | 626 UpdateCWSLabel(); |
544 UpdateSuggestedExtensions(); | 627 UpdateSuggestedExtensions(); |
545 SetActionString(header_label_text_); | 628 SetActionString(header_label_text_); |
546 | 629 |
547 gtk_widget_show_all(contents_); | 630 gtk_widget_show_all(contents_); |
548 } | 631 } |
549 | 632 |
550 GtkWidget* WebIntentPickerGtk::CreateSubContents(GtkWidget* box) { | 633 GtkWidget* WebIntentPickerGtk::CreateSubContents(GtkWidget* box) { |
551 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 634 GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
(...skipping 29 matching lines...) Expand all Loading... |
581 | 664 |
582 // Label text will be set in the call to SetActionString(). | 665 // Label text will be set in the call to SetActionString(). |
583 header_label_ = GetThemeService(tab_contents_)->BuildLabel( | 666 header_label_ = GetThemeService(tab_contents_)->BuildLabel( |
584 std::string(), ui::kGdkBlack); | 667 std::string(), ui::kGdkBlack); |
585 gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize); | 668 gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize); |
586 gtk_box_pack_start(GTK_BOX(header_hbox), header_label_, TRUE, TRUE, 0); | 669 gtk_box_pack_start(GTK_BOX(header_hbox), header_label_, TRUE, TRUE, 0); |
587 gtk_misc_set_alignment(GTK_MISC(header_label_), 0, 0); | 670 gtk_misc_set_alignment(GTK_MISC(header_label_), 0, 0); |
588 } | 671 } |
589 | 672 |
590 void WebIntentPickerGtk::UpdateInstalledServices() { | 673 void WebIntentPickerGtk::UpdateInstalledServices() { |
| 674 if (!button_vbox_) |
| 675 return; |
| 676 |
591 gtk_util::RemoveAllChildren(button_vbox_); | 677 gtk_util::RemoveAllChildren(button_vbox_); |
592 | 678 |
593 if (model_->GetInstalledServiceCount() == 0) { | 679 if (model_->GetInstalledServiceCount() == 0) { |
594 gtk_widget_hide(gtk_widget_get_parent(button_vbox_)); | 680 gtk_widget_hide(gtk_widget_get_parent(button_vbox_)); |
595 return; | 681 return; |
596 } | 682 } |
597 | 683 |
598 for (size_t i = 0; i < model_->GetInstalledServiceCount(); ++i) { | 684 for (size_t i = 0; i < model_->GetInstalledServiceCount(); ++i) { |
599 const WebIntentPickerModel::InstalledService& installed_service = | 685 const WebIntentPickerModel::InstalledService& installed_service = |
600 model_->GetInstalledServiceAt(i); | 686 model_->GetInstalledServiceAt(i); |
(...skipping 13 matching lines...) Expand all Loading... |
614 // Must be called after SetServiceButtonImage as the internal label widget | 700 // Must be called after SetServiceButtonImage as the internal label widget |
615 // is replaced in that call. | 701 // is replaced in that call. |
616 SetWidgetFontSize(button, kMainContentPixelSize); | 702 SetWidgetFontSize(button, kMainContentPixelSize); |
617 } | 703 } |
618 | 704 |
619 gtk_widget_show_all(button_vbox_); | 705 gtk_widget_show_all(button_vbox_); |
620 gtk_widget_show(gtk_widget_get_parent(button_vbox_)); | 706 gtk_widget_show(gtk_widget_get_parent(button_vbox_)); |
621 } | 707 } |
622 | 708 |
623 void WebIntentPickerGtk::UpdateCWSLabel() { | 709 void WebIntentPickerGtk::UpdateCWSLabel() { |
| 710 if (!button_vbox_) |
| 711 return; |
| 712 |
624 gtk_widget_set_visible(gtk_widget_get_parent(button_vbox_), | 713 gtk_widget_set_visible(gtk_widget_get_parent(button_vbox_), |
625 model_->GetInstalledServiceCount() != 0); | 714 model_->GetInstalledServiceCount() != 0); |
626 | 715 |
627 std::string label_text = UTF16ToUTF8(model_->GetSuggestionsLinkText()); | 716 std::string label_text = UTF16ToUTF8(model_->GetSuggestionsLinkText()); |
628 gtk_label_set_text(GTK_LABEL(cws_label_), label_text.c_str()); | 717 gtk_label_set_text(GTK_LABEL(cws_label_), label_text.c_str()); |
629 gtk_widget_set_visible(cws_label_, !label_text.empty()); | 718 gtk_widget_set_visible(cws_label_, !label_text.empty()); |
630 } | 719 } |
631 | 720 |
632 void WebIntentPickerGtk::UpdateSuggestedExtensions() { | 721 void WebIntentPickerGtk::UpdateSuggestedExtensions() { |
| 722 if (!extensions_vbox_) |
| 723 return; |
| 724 |
633 GtkThemeService* theme_service = GetThemeService(tab_contents_); | 725 GtkThemeService* theme_service = GetThemeService(tab_contents_); |
634 | 726 |
635 gtk_util::RemoveAllChildren(extensions_vbox_); | 727 gtk_util::RemoveAllChildren(extensions_vbox_); |
636 | 728 |
637 if (model_->GetSuggestedExtensionCount() == 0) { | 729 if (model_->GetSuggestedExtensionCount() == 0) { |
638 gtk_widget_hide(gtk_widget_get_parent(extensions_vbox_)); | 730 gtk_widget_hide(gtk_widget_get_parent(extensions_vbox_)); |
639 return; | 731 return; |
640 } | 732 } |
641 | 733 |
642 gtk_widget_show(gtk_widget_get_parent(extensions_vbox_)); | 734 gtk_widget_show(gtk_widget_get_parent(extensions_vbox_)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 G_CALLBACK(OnExtensionInstallButtonClickThunk), this); | 772 G_CALLBACK(OnExtensionInstallButtonClickThunk), this); |
681 gtk_box_pack_end(GTK_BOX(hbox), install_button, FALSE, FALSE, 0); | 773 gtk_box_pack_end(GTK_BOX(hbox), install_button, FALSE, FALSE, 0); |
682 } | 774 } |
683 | 775 |
684 gtk_widget_show_all(extensions_vbox_); | 776 gtk_widget_show_all(extensions_vbox_); |
685 gtk_widget_show(gtk_widget_get_parent(extensions_vbox_)); | 777 gtk_widget_show(gtk_widget_get_parent(extensions_vbox_)); |
686 } | 778 } |
687 | 779 |
688 void WebIntentPickerGtk::SetWidgetsEnabled(bool enabled) { | 780 void WebIntentPickerGtk::SetWidgetsEnabled(bool enabled) { |
689 gboolean data = enabled; | 781 gboolean data = enabled; |
690 gtk_container_foreach(GTK_CONTAINER(button_vbox_), EnableWidgetCallback, | 782 if (button_vbox_) |
691 &data); | 783 gtk_container_foreach(GTK_CONTAINER(button_vbox_), EnableWidgetCallback, |
692 gtk_container_foreach(GTK_CONTAINER(extensions_vbox_), EnableWidgetCallback, | 784 &data); |
693 &data); | 785 if (extensions_vbox_) |
| 786 gtk_container_foreach(GTK_CONTAINER(extensions_vbox_), EnableWidgetCallback, |
| 787 &data); |
694 } | 788 } |
695 | 789 |
696 GtkWidget* WebIntentPickerGtk::AddThrobberToExtensionAt(size_t index) { | 790 GtkWidget* WebIntentPickerGtk::AddThrobberToExtensionAt(size_t index) { |
697 // The throbber should be unparented. | 791 // The throbber should be unparented. |
698 DCHECK(!gtk_widget_get_parent(throbber_->widget())); | 792 DCHECK(!gtk_widget_get_parent(throbber_->widget())); |
699 GList* vbox_list = | 793 GList* vbox_list = |
700 gtk_container_get_children(GTK_CONTAINER(extensions_vbox_)); | 794 gtk_container_get_children(GTK_CONTAINER(extensions_vbox_)); |
701 GtkWidget* hbox = static_cast<GtkWidget*>(g_list_nth_data(vbox_list, index)); | 795 GtkWidget* hbox = static_cast<GtkWidget*>(g_list_nth_data(vbox_list, index)); |
702 GtkWidget* alignment = gtk_alignment_new(0.5, 0.5, 0, 0); | 796 GtkWidget* alignment = gtk_alignment_new(0.5, 0.5, 0, 0); |
703 gtk_container_add(GTK_CONTAINER(alignment), throbber_->widget()); | 797 gtk_container_add(GTK_CONTAINER(alignment), throbber_->widget()); |
704 gtk_box_pack_end(GTK_BOX(hbox), alignment, FALSE, FALSE, 0); | 798 gtk_box_pack_end(GTK_BOX(hbox), alignment, FALSE, FALSE, 0); |
705 g_list_free(vbox_list); | 799 g_list_free(vbox_list); |
706 throbber_->Start(); | 800 throbber_->Start(); |
707 return alignment; | 801 return alignment; |
708 } | 802 } |
709 | 803 |
710 void WebIntentPickerGtk::RemoveThrobber() { | 804 void WebIntentPickerGtk::RemoveThrobber() { |
711 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget()); | 805 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget()); |
712 DCHECK(alignment); | 806 DCHECK(alignment); |
713 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget()); | 807 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget()); |
714 gtk_widget_destroy(alignment); | 808 gtk_widget_destroy(alignment); |
715 throbber_->Stop(); | 809 throbber_->Stop(); |
716 } | 810 } |
OLD | NEW |