| 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 #include "chrome/browser/gtk/download_shelf_gtk.h" | 5 #include "chrome/browser/gtk/download_shelf_gtk.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/gfx/gtk_util.h" | 9 #include "base/gfx/gtk_util.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 GtkWidget* padding_bg = gtk_event_box_new(); | 80 GtkWidget* padding_bg = gtk_event_box_new(); |
| 81 gtk_container_add(GTK_CONTAINER(padding_bg), padding); | 81 gtk_container_add(GTK_CONTAINER(padding_bg), padding); |
| 82 gtk_container_add(GTK_CONTAINER(padding), hbox_); | 82 gtk_container_add(GTK_CONTAINER(padding), hbox_); |
| 83 gtk_widget_modify_bg(padding_bg, GTK_STATE_NORMAL, &kBackgroundColor); | 83 gtk_widget_modify_bg(padding_bg, GTK_STATE_NORMAL, &kBackgroundColor); |
| 84 | 84 |
| 85 shelf_.Own(gtk_vbox_new(FALSE, 0)); | 85 shelf_.Own(gtk_vbox_new(FALSE, 0)); |
| 86 gtk_box_pack_start(GTK_BOX(shelf_.get()), top_border, FALSE, FALSE, 0); | 86 gtk_box_pack_start(GTK_BOX(shelf_.get()), top_border, FALSE, FALSE, 0); |
| 87 gtk_box_pack_start(GTK_BOX(shelf_.get()), padding_bg, FALSE, FALSE, 0); | 87 gtk_box_pack_start(GTK_BOX(shelf_.get()), padding_bg, FALSE, FALSE, 0); |
| 88 | 88 |
| 89 // Create and pack the close button. | 89 // Create and pack the close button. |
| 90 close_button_.reset(CustomDrawButton::AddBarCloseButton(hbox_, 0)); | 90 close_button_.reset(CustomDrawButton::CloseButton()); |
| 91 gtk_util::CenterWidgetInHBox(hbox_, close_button_->widget(), true, 0); |
| 91 g_signal_connect(close_button_->widget(), "clicked", | 92 g_signal_connect(close_button_->widget(), "clicked", |
| 92 G_CALLBACK(OnButtonClick), this); | 93 G_CALLBACK(OnButtonClick), this); |
| 93 | 94 |
| 94 // Create the "Show all downloads..." link and connect to the click event. | 95 // Create the "Show all downloads..." link and connect to the click event. |
| 95 std::string link_text = | 96 std::string link_text = |
| 96 l10n_util::GetStringUTF8(IDS_SHOW_ALL_DOWNLOADS); | 97 l10n_util::GetStringUTF8(IDS_SHOW_ALL_DOWNLOADS); |
| 97 link_button_.reset(new LinkButtonGtk(link_text.c_str())); | 98 link_button_.reset(new LinkButtonGtk(link_text.c_str())); |
| 98 g_signal_connect(link_button_->widget(), "clicked", | 99 g_signal_connect(link_button_->widget(), "clicked", |
| 99 G_CALLBACK(OnButtonClick), this); | 100 G_CALLBACK(OnButtonClick), this); |
| 100 // Until we switch to vector graphics, force the font size. | 101 // Until we switch to vector graphics, force the font size. |
| 101 // 13.4px == 10pt @ 96dpi | 102 // 13.4px == 10pt @ 96dpi |
| 102 gtk_util::ForceFontSizePixels(link_button_->label(), 13.4); | 103 gtk_util::ForceFontSizePixels(link_button_->label(), 13.4); |
| 103 | 104 |
| 104 // Make the download arrow icon. | 105 // Make the download arrow icon. |
| 105 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 106 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 106 GdkPixbuf* download_pixbuf = rb.GetPixbufNamed(IDR_DOWNLOADS_FAVICON); | 107 GdkPixbuf* download_pixbuf = rb.GetPixbufNamed(IDR_DOWNLOADS_FAVICON); |
| 107 GtkWidget* download_image = gtk_image_new_from_pixbuf(download_pixbuf); | 108 GtkWidget* download_image = gtk_image_new_from_pixbuf(download_pixbuf); |
| 108 | 109 |
| 109 // Pack the link and the icon in an hbox. | 110 // Pack the link and the icon in an hbox. |
| 110 link_hbox_ = gtk_hbox_new(FALSE, 5); | 111 link_hbox_ = gtk_hbox_new(FALSE, 5); |
| 111 gtk_box_pack_start(GTK_BOX(link_hbox_), download_image, FALSE, FALSE, 0); | 112 gtk_util::CenterWidgetInHBox(link_hbox_, download_image, false, 0); |
| 112 gtk_box_pack_start(GTK_BOX(link_hbox_), link_button_->widget(), | 113 gtk_util::CenterWidgetInHBox(link_hbox_, link_button_->widget(), false, 0); |
| 113 FALSE, FALSE, 0); | |
| 114 gtk_box_pack_end(GTK_BOX(hbox_), link_hbox_, FALSE, FALSE, 0); | 114 gtk_box_pack_end(GTK_BOX(hbox_), link_hbox_, FALSE, FALSE, 0); |
| 115 | 115 |
| 116 slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), | 116 slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), |
| 117 SlideAnimatorGtk::UP, | 117 SlideAnimatorGtk::UP, |
| 118 kShelfAnimationDurationMs, | 118 kShelfAnimationDurationMs, |
| 119 false, NULL)); | 119 false, NULL)); |
| 120 gtk_widget_show_all(shelf_.get()); | 120 gtk_widget_show_all(shelf_.get()); |
| 121 // Stick ourselves at the bottom of the parent tab contents. | 121 // Stick ourselves at the bottom of the parent tab contents. |
| 122 GtkWidget* parent_contents = tab_contents->GetNativeView(); | 122 GtkWidget* parent_contents = tab_contents->GetNativeView(); |
| 123 gtk_box_pack_end(GTK_BOX(parent_contents), slide_widget_->widget(), | 123 gtk_box_pack_end(GTK_BOX(parent_contents), slide_widget_->widget(), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 void DownloadShelfGtk::OnButtonClick(GtkWidget* button, | 172 void DownloadShelfGtk::OnButtonClick(GtkWidget* button, |
| 173 DownloadShelfGtk* shelf) { | 173 DownloadShelfGtk* shelf) { |
| 174 if (button == shelf->close_button_->widget()) { | 174 if (button == shelf->close_button_->widget()) { |
| 175 shelf->slide_widget_->Close(); | 175 shelf->slide_widget_->Close(); |
| 176 shelf->tab_contents_->SetDownloadShelfVisible(false); | 176 shelf->tab_contents_->SetDownloadShelfVisible(false); |
| 177 } else { | 177 } else { |
| 178 // The link button was clicked. | 178 // The link button was clicked. |
| 179 shelf->ShowAllDownloads(); | 179 shelf->ShowAllDownloads(); |
| 180 } | 180 } |
| 181 } | 181 } |
| OLD | NEW |