diff options
-rw-r--r-- | chrome/browser/gtk/content_setting_bubble_gtk.cc | 75 | ||||
-rw-r--r-- | chrome/browser/gtk/content_setting_bubble_gtk.h | 21 | ||||
-rw-r--r-- | chrome/browser/gtk/dialogs_gtk.cc | 97 | ||||
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.cc | 127 | ||||
-rw-r--r-- | chrome/browser/gtk/download_item_gtk.h | 30 | ||||
-rw-r--r-- | chrome/browser/gtk/download_shelf_gtk.cc | 14 | ||||
-rw-r--r-- | chrome/browser/gtk/download_shelf_gtk.h | 3 |
7 files changed, 156 insertions, 211 deletions
diff --git a/chrome/browser/gtk/content_setting_bubble_gtk.cc b/chrome/browser/gtk/content_setting_bubble_gtk.cc index 6d46325..66d4a75 100644 --- a/chrome/browser/gtk/content_setting_bubble_gtk.cc +++ b/chrome/browser/gtk/content_setting_bubble_gtk.cc @@ -100,7 +100,7 @@ void ContentSettingBubbleGtk::BuildBubble() { popup_icons_[event_box] = i -popup_items.begin(); g_signal_connect(event_box, "button_press_event", - G_CALLBACK(OnPopupIconButtonPress), this); + G_CALLBACK(OnPopupIconButtonPressThunk), this); gtk_table_attach(GTK_TABLE(table), event_box, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, gtk_util::kControlSpacing / 2, gtk_util::kControlSpacing / 2); @@ -108,7 +108,7 @@ void ContentSettingBubbleGtk::BuildBubble() { GtkWidget* button = gtk_chrome_link_button_new(i->title.c_str()); popup_links_[button] = i -popup_items.begin(); - g_signal_connect(button, "clicked", G_CALLBACK(OnPopupLinkClicked), + g_signal_connect(button, "clicked", G_CALLBACK(OnPopupLinkClickedThunk), this); gtk_table_attach(GTK_TABLE(table), button, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, gtk_util::kControlSpacing / 2, @@ -143,7 +143,7 @@ void ContentSettingBubbleGtk::BuildBubble() { for (std::vector<GtkWidget*>::const_iterator i = radio_group_gtk_.begin(); i != radio_group_gtk_.end(); ++i) { // We can attach signal handlers now that all defaults are set. - g_signal_connect(*i, "toggled", G_CALLBACK(OnRadioToggled), this); + g_signal_connect(*i, "toggled", G_CALLBACK(OnRadioToggledThunk), this); } if (!radio_group_gtk_.empty()) { gtk_box_pack_start(GTK_BOX(bubble_content), gtk_hseparator_new(), FALSE, @@ -176,7 +176,7 @@ void ContentSettingBubbleGtk::BuildBubble() { GtkWidget* clear_link_box = gtk_hbox_new(FALSE, 0); GtkWidget* clear_link = gtk_chrome_link_button_new( content.clear_link.c_str()); - g_signal_connect(clear_link, "clicked", G_CALLBACK(OnClearLinkClicked), + g_signal_connect(clear_link, "clicked", G_CALLBACK(OnClearLinkClickedThunk), this); gtk_box_pack_start(GTK_BOX(clear_link_box), clear_link, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(bubble_content), clear_link_box, @@ -189,13 +189,14 @@ void ContentSettingBubbleGtk::BuildBubble() { GtkWidget* manage_link = gtk_chrome_link_button_new(content.manage_link.c_str()); - g_signal_connect(manage_link, "clicked", G_CALLBACK(OnManageLinkClicked), + g_signal_connect(manage_link, "clicked", G_CALLBACK(OnManageLinkClickedThunk), this); gtk_box_pack_start(GTK_BOX(bottom_box), manage_link, FALSE, FALSE, 0); GtkWidget* button = gtk_button_new_with_label( l10n_util::GetStringUTF8(IDS_DONE).c_str()); - g_signal_connect(button, "clicked", G_CALLBACK(OnCloseButtonClicked), this); + g_signal_connect(button, "clicked", G_CALLBACK(OnCloseButtonClickedThunk), + this); gtk_box_pack_end(GTK_BOX(bottom_box), button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(bubble_content), bottom_box, FALSE, FALSE, 0); @@ -217,65 +218,49 @@ void ContentSettingBubbleGtk::BuildBubble() { this); } -// static void ContentSettingBubbleGtk::OnPopupIconButtonPress( GtkWidget* icon_event_box, - GdkEventButton* event, - ContentSettingBubbleGtk* bubble) { - PopupMap::iterator i(bubble->popup_icons_.find(icon_event_box)); - DCHECK(i != bubble->popup_icons_.end()); - bubble->content_setting_bubble_model_->OnPopupClicked(i->second); + GdkEventButton* event) { + PopupMap::iterator i(popup_icons_.find(icon_event_box)); + DCHECK(i != popup_icons_.end()); + content_setting_bubble_model_->OnPopupClicked(i->second); // The views interface implicitly closes because of the launching of a new // window; we need to do that explicitly. - bubble->Close(); + Close(); } -// static -void ContentSettingBubbleGtk::OnPopupLinkClicked( - GtkWidget* button, - ContentSettingBubbleGtk* bubble) { - PopupMap::iterator i(bubble->popup_links_.find(button)); - DCHECK(i != bubble->popup_links_.end()); - bubble->content_setting_bubble_model_->OnPopupClicked(i->second); +void ContentSettingBubbleGtk::OnPopupLinkClicked(GtkWidget* button) { + PopupMap::iterator i(popup_links_.find(button)); + DCHECK(i != popup_links_.end()); + content_setting_bubble_model_->OnPopupClicked(i->second); // The views interface implicitly closes because of the launching of a new // window; we need to do that explicitly. - bubble->Close(); + Close(); } -// static -void ContentSettingBubbleGtk::OnRadioToggled( - GtkWidget* widget, - ContentSettingBubbleGtk* bubble) { +void ContentSettingBubbleGtk::OnRadioToggled(GtkWidget* widget) { for (ContentSettingBubbleGtk::RadioGroupGtk::const_iterator i = - bubble->radio_group_gtk_.begin(); - i != bubble->radio_group_gtk_.end(); ++i) { + radio_group_gtk_.begin(); + i != radio_group_gtk_.end(); ++i) { if (widget == *i) { - bubble->content_setting_bubble_model_->OnRadioClicked( - i - bubble->radio_group_gtk_.begin()); + content_setting_bubble_model_->OnRadioClicked( + i - radio_group_gtk_.begin()); return; } } NOTREACHED() << "unknown radio toggled"; } -// static -void ContentSettingBubbleGtk::OnCloseButtonClicked( - GtkButton *button, - ContentSettingBubbleGtk* bubble) { - bubble->Close(); +void ContentSettingBubbleGtk::OnCloseButtonClicked(GtkWidget *button) { + Close(); } -// static -void ContentSettingBubbleGtk::OnManageLinkClicked( - GtkButton* button, - ContentSettingBubbleGtk* bubble) { - bubble->content_setting_bubble_model_->OnManageLinkClicked(); - bubble->Close(); +void ContentSettingBubbleGtk::OnManageLinkClicked(GtkWidget* button) { + content_setting_bubble_model_->OnManageLinkClicked(); + Close(); } -void ContentSettingBubbleGtk::OnClearLinkClicked( - GtkButton* button, - ContentSettingBubbleGtk* bubble) { - bubble->content_setting_bubble_model_->OnClearLinkClicked(); - bubble->Close(); +void ContentSettingBubbleGtk::OnClearLinkClicked(GtkWidget* button) { + content_setting_bubble_model_->OnClearLinkClicked(); + Close(); } diff --git a/chrome/browser/gtk/content_setting_bubble_gtk.h b/chrome/browser/gtk/content_setting_bubble_gtk.h index a09acab..e0e9921 100644 --- a/chrome/browser/gtk/content_setting_bubble_gtk.h +++ b/chrome/browser/gtk/content_setting_bubble_gtk.h @@ -8,6 +8,7 @@ #include <map> #include <string> +#include "app/gtk_signal.h" #include "base/scoped_ptr.h" #include "chrome/browser/gtk/info_bubble_gtk.h" #include "chrome/common/content_settings_types.h" @@ -50,19 +51,13 @@ class ContentSettingBubbleGtk : public InfoBubbleGtkDelegate, void BuildBubble(); // Widget callback methods. - static void OnPopupIconButtonPress(GtkWidget* icon, - GdkEventButton* event, - ContentSettingBubbleGtk* bubble); - static void OnPopupLinkClicked(GtkWidget* button, - ContentSettingBubbleGtk* bubble); - static void OnRadioToggled(GtkWidget* widget, - ContentSettingBubbleGtk* bubble); - static void OnCloseButtonClicked(GtkButton *button, - ContentSettingBubbleGtk* bubble); - static void OnManageLinkClicked(GtkButton* button, - ContentSettingBubbleGtk* bubble); - static void OnClearLinkClicked(GtkButton* button, - ContentSettingBubbleGtk* bubble); + CHROMEGTK_CALLBACK_1(ContentSettingBubbleGtk, void, OnPopupIconButtonPress, + GdkEventButton*); + CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnPopupLinkClicked); + CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnRadioToggled); + CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked); + CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked); + CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnClearLinkClicked); // We position the bubble near this widget. GtkWidget* anchor_; diff --git a/chrome/browser/gtk/dialogs_gtk.cc b/chrome/browser/gtk/dialogs_gtk.cc index 8ea3f44..aaeebd3 100644 --- a/chrome/browser/gtk/dialogs_gtk.cc +++ b/chrome/browser/gtk/dialogs_gtk.cc @@ -6,6 +6,7 @@ #include <map> #include <set> +#include "app/gtk_signal.h" #include "app/l10n_util.h" #include "base/file_util.h" #include "base/logging.h" @@ -87,34 +88,31 @@ class SelectFileDialogImpl : public SelectFileDialog { // Check whether response_id corresponds to the user cancelling/closing the // dialog. Used as a helper for the below callbacks. - static bool IsCancelResponse(gint response_id); + bool IsCancelResponse(gint response_id); // Common function for OnSelectSingleFileDialogResponse and // OnSelectSingleFolderDialogResponse. - static void SelectSingleFileHelper(GtkWidget* dialog, - gint response_id, - SelectFileDialogImpl* dialog_impl, - bool allow_folder); + void SelectSingleFileHelper(GtkWidget* dialog, + gint response_id, + bool allow_folder); // Callback for when the user responds to a Save As or Open File dialog. - static void OnSelectSingleFileDialogResponse( - GtkWidget* dialog, gint response_id, SelectFileDialogImpl* dialog_impl); + CHROMEGTK_CALLBACK_1(SelectFileDialogImpl, void, + OnSelectSingleFileDialogResponse, gint); // Callback for when the user responds to a Select Folder dialog. - static void OnSelectSingleFolderDialogResponse( - GtkWidget* dialog, gint response_id, SelectFileDialogImpl* dialog_impl); + CHROMEGTK_CALLBACK_1(SelectFileDialogImpl, void, + OnSelectSingleFolderDialogResponse, gint); // Callback for when the user responds to a Open Multiple Files dialog. - static void OnSelectMultiFileDialogResponse( - GtkWidget* dialog, gint response_id, SelectFileDialogImpl* dialog_impl); + CHROMEGTK_CALLBACK_1(SelectFileDialogImpl, void, + OnSelectMultiFileDialogResponse, gint); // Callback for when the file chooser gets destroyed. - static void OnFileChooserDestroy(GtkWidget* dialog, - SelectFileDialogImpl* dialog_impl); + CHROMEGTK_CALLBACK_0(SelectFileDialogImpl, void, OnFileChooserDestroy); // Callback for when we update the preview for the selection. - static void OnUpdatePreview(GtkFileChooser* chooser, - SelectFileDialogImpl* dialog); + CHROMEGTK_CALLBACK_0(SelectFileDialogImpl, void, OnUpdatePreview); // The listener to be notified of selection completion. Listener* listener_; @@ -229,8 +227,10 @@ void SelectFileDialogImpl::SelectFile( dialogs_.insert(dialog); preview_ = gtk_image_new(); - g_signal_connect(dialog, "destroy", G_CALLBACK(OnFileChooserDestroy), this); - g_signal_connect(dialog, "update-preview", G_CALLBACK(OnUpdatePreview), this); + g_signal_connect(dialog, "destroy", + G_CALLBACK(OnFileChooserDestroyThunk), this); + g_signal_connect(dialog, "update-preview", + G_CALLBACK(OnUpdatePreviewThunk), this); gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); params_map_[dialog] = params; @@ -350,7 +350,7 @@ GtkWidget* SelectFileDialogImpl::CreateSelectFolderDialog( } gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); g_signal_connect(dialog, "response", - G_CALLBACK(OnSelectSingleFolderDialogResponse), this); + G_CALLBACK(OnSelectSingleFolderDialogResponseThunk), this); return dialog; } @@ -378,7 +378,7 @@ GtkWidget* SelectFileDialogImpl::CreateFileOpenDialog(const std::string& title, } gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); g_signal_connect(dialog, "response", - G_CALLBACK(OnSelectSingleFileDialogResponse), this); + G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this); return dialog; } @@ -408,7 +408,7 @@ GtkWidget* SelectFileDialogImpl::CreateMultiFileOpenDialog( } gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); g_signal_connect(dialog, "response", - G_CALLBACK(OnSelectMultiFileDialogResponse), this); + G_CALLBACK(OnSelectMultiFileDialogResponseThunk), this); return dialog; } @@ -441,7 +441,7 @@ GtkWidget* SelectFileDialogImpl::CreateSaveAsDialog(const std::string& title, gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); g_signal_connect(dialog, "response", - G_CALLBACK(OnSelectSingleFileDialogResponse), this); + G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this); return dialog; } @@ -471,7 +471,6 @@ void SelectFileDialogImpl::FileDialogDestroyed(GtkWidget* dialog) { NOTREACHED(); } -// static bool SelectFileDialogImpl::IsCancelResponse(gint response_id) { bool is_cancel = response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_DELETE_EVENT; @@ -482,19 +481,17 @@ bool SelectFileDialogImpl::IsCancelResponse(gint response_id) { return false; } -// static void SelectFileDialogImpl::SelectSingleFileHelper(GtkWidget* dialog, gint response_id, - SelectFileDialogImpl* dialog_impl, bool allow_folder) { if (IsCancelResponse(response_id)) { - dialog_impl->FileNotSelected(dialog); + FileNotSelected(dialog); return; } gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); if (!filename) { - dialog_impl->FileNotSelected(dialog); + FileNotSelected(dialog); return; } @@ -502,7 +499,7 @@ void SelectFileDialogImpl::SelectSingleFileHelper(GtkWidget* dialog, g_free(filename); if (allow_folder) { - dialog_impl->FileSelected(dialog, path); + FileSelected(dialog, path); return; } @@ -510,37 +507,31 @@ void SelectFileDialogImpl::SelectSingleFileHelper(GtkWidget* dialog, // ok because we may have just done lots of stats in the file selection // dialog. One more won't hurt too badly. if (file_util::DirectoryExists(path)) - dialog_impl->FileNotSelected(dialog); + FileNotSelected(dialog); else - dialog_impl->FileSelected(dialog, path); + FileSelected(dialog, path); } -// static void SelectFileDialogImpl::OnSelectSingleFileDialogResponse( - GtkWidget* dialog, gint response_id, - SelectFileDialogImpl* dialog_impl) { - return SelectSingleFileHelper(dialog, response_id, dialog_impl, false); + GtkWidget* dialog, gint response_id) { + return SelectSingleFileHelper(dialog, response_id, false); } -// static void SelectFileDialogImpl::OnSelectSingleFolderDialogResponse( - GtkWidget* dialog, gint response_id, - SelectFileDialogImpl* dialog_impl) { - return SelectSingleFileHelper(dialog, response_id, dialog_impl, true); + GtkWidget* dialog, gint response_id) { + return SelectSingleFileHelper(dialog, response_id, true); } -// static void SelectFileDialogImpl::OnSelectMultiFileDialogResponse( - GtkWidget* dialog, gint response_id, - SelectFileDialogImpl* dialog_impl) { + GtkWidget* dialog, gint response_id) { if (IsCancelResponse(response_id)) { - dialog_impl->FileNotSelected(dialog); + FileNotSelected(dialog); return; } GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); if (!filenames) { - dialog_impl->FileNotSelected(dialog); + FileNotSelected(dialog); return; } @@ -555,22 +546,19 @@ void SelectFileDialogImpl::OnSelectMultiFileDialogResponse( g_slist_free(filenames); if (filenames_fp.empty()) { - dialog_impl->FileNotSelected(dialog); + FileNotSelected(dialog); return; } - dialog_impl->MultiFilesSelected(dialog, filenames_fp); + MultiFilesSelected(dialog, filenames_fp); } -// static -void SelectFileDialogImpl::OnFileChooserDestroy(GtkWidget* dialog, - SelectFileDialogImpl* dialog_impl) { - dialog_impl->FileDialogDestroyed(dialog); +void SelectFileDialogImpl::OnFileChooserDestroy(GtkWidget* dialog) { + FileDialogDestroyed(dialog); } -// static -void SelectFileDialogImpl::OnUpdatePreview(GtkFileChooser* chooser, - SelectFileDialogImpl* dialog) { - gchar* filename = gtk_file_chooser_get_preview_filename(chooser); +void SelectFileDialogImpl::OnUpdatePreview(GtkWidget* chooser) { + gchar* filename = gtk_file_chooser_get_preview_filename( + GTK_FILE_CHOOSER(chooser)); if (!filename) return; // This will preserve the image's aspect ratio. @@ -578,8 +566,9 @@ void SelectFileDialogImpl::OnUpdatePreview(GtkFileChooser* chooser, kPreviewHeight, NULL); g_free(filename); if (pixbuf) { - gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->preview_), pixbuf); + gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); g_object_unref(pixbuf); } - gtk_file_chooser_set_preview_widget_active(chooser, pixbuf ? TRUE : FALSE); + gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), + pixbuf ? TRUE : FALSE); } diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index fd17beb..5260d0f 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -160,9 +160,9 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, UpdateTooltip(); g_signal_connect(body_.get(), "expose-event", - G_CALLBACK(OnExpose), this); + G_CALLBACK(OnExposeThunk), this); g_signal_connect(body_.get(), "clicked", - G_CALLBACK(OnClick), this); + G_CALLBACK(OnClickThunk), this); GTK_WIDGET_UNSET_FLAGS(body_.get(), GTK_CAN_FOCUS); // Remove internal padding on the button. GtkRcStyle* no_padding_style = gtk_rc_style_new(); @@ -196,7 +196,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, download_util::kSmallProgressIconSize); gtk_widget_set_app_paintable(progress_area_.get(), TRUE); g_signal_connect(progress_area_.get(), "expose-event", - G_CALLBACK(OnProgressAreaExpose), this); + G_CALLBACK(OnProgressAreaExposeThunk), this); // Put the download progress icon on the left of the labels. GtkWidget* body_hbox = gtk_hbox_new(FALSE, 0); @@ -208,16 +208,16 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, gtk_widget_set_app_paintable(menu_button_, TRUE); GTK_WIDGET_UNSET_FLAGS(menu_button_, GTK_CAN_FOCUS); g_signal_connect(menu_button_, "expose-event", - G_CALLBACK(OnExpose), this); + G_CALLBACK(OnExposeThunk), this); g_signal_connect(menu_button_, "button-press-event", - G_CALLBACK(OnMenuButtonPressEvent), this); + G_CALLBACK(OnMenuButtonPressEventThunk), this); g_object_set_data(G_OBJECT(menu_button_), "left-align-popup", reinterpret_cast<void*>(true)); GtkWidget* shelf_hbox = parent_shelf->GetHBox(); hbox_.Own(gtk_hbox_new(FALSE, 0)); g_signal_connect(hbox_.get(), "expose-event", - G_CALLBACK(OnHboxExpose), this); + G_CALLBACK(OnHboxExposeThunk), this); gtk_box_pack_start(GTK_BOX(hbox_.get()), body_.get(), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox_.get()), menu_button_, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_.get(), FALSE, FALSE, 0); @@ -262,7 +262,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, GtkWidget* dangerous_decline = gtk_button_new_with_label( l10n_util::GetStringUTF8(IDS_DISCARD_DOWNLOAD).c_str()); g_signal_connect(dangerous_decline, "clicked", - G_CALLBACK(OnDangerousDecline), this); + G_CALLBACK(OnDangerousDeclineThunk), this); gtk_util::CenterWidgetInHBox(dangerous_hbox_, dangerous_decline, false, 0); // Create the ok button. @@ -271,7 +271,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, download_model->download()->is_extension_install() ? IDS_CONTINUE_EXTENSION_DOWNLOAD : IDS_SAVE_DOWNLOAD).c_str()); g_signal_connect(dangerous_accept, "clicked", - G_CALLBACK(OnDangerousAccept), this); + G_CALLBACK(OnDangerousAcceptThunk), this); gtk_util::CenterWidgetInHBox(dangerous_hbox_, dangerous_accept, false, 0); // Put it in an alignment so that padding will be added on the left and @@ -285,7 +285,7 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf, gtk_widget_set_app_paintable(dangerous_prompt_, TRUE); gtk_widget_set_redraw_on_allocate(dangerous_prompt_, TRUE); g_signal_connect(dangerous_prompt_, "expose-event", - G_CALLBACK(OnDangerousPromptExpose), this); + G_CALLBACK(OnDangerousPromptExposeThunk), this); gtk_widget_show_all(dangerous_prompt_); } @@ -675,16 +675,15 @@ void DownloadItemGtk::InitNineBoxes() { IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_NO_DD); } -gboolean DownloadItemGtk::OnHboxExpose(GtkWidget* widget, GdkEventExpose* e, - DownloadItemGtk* download_item) { - if (download_item->theme_provider_->UseGtkTheme()) { +gboolean DownloadItemGtk::OnHboxExpose(GtkWidget* widget, GdkEventExpose* e) { + if (theme_provider_->UseGtkTheme()) { int border_width = GTK_CONTAINER(widget)->border_width; int x = widget->allocation.x + border_width; int y = widget->allocation.y + border_width; int width = widget->allocation.width - border_width * 2; int height = widget->allocation.height - border_width * 2; - if (download_item->IsDangerous()) { + if (IsDangerous()) { // Draw a simple frame around the area when we're displaying the warning. gtk_paint_shadow(widget->style, widget->window, static_cast<GtkStateType>(widget->state), @@ -699,36 +698,32 @@ gboolean DownloadItemGtk::OnHboxExpose(GtkWidget* widget, GdkEventExpose* e, // the button, we instruct GTK to draw the entire button...with a // doctored clip rectangle to the left part of the button sans // separator. We then repeat this for the right button. - GtkStyle* style = download_item->body_.get()->style; + GtkStyle* style = body_.get()->style; - GtkAllocation left_allocation = download_item->body_.get()->allocation; + GtkAllocation left_allocation = body_.get()->allocation; GdkRectangle left_clip = { left_allocation.x, left_allocation.y, left_allocation.width, left_allocation.height }; - GtkAllocation right_allocation = download_item->menu_button_->allocation; + GtkAllocation right_allocation = menu_button_->allocation; GdkRectangle right_clip = { right_allocation.x, right_allocation.y, right_allocation.width, right_allocation.height }; GtkShadowType body_shadow = - GTK_BUTTON(download_item->body_.get())->depressed ? - GTK_SHADOW_IN : GTK_SHADOW_OUT; + GTK_BUTTON(body_.get())->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; gtk_paint_box(style, widget->window, - static_cast<GtkStateType>( - GTK_WIDGET_STATE(download_item->body_.get())), + static_cast<GtkStateType>(GTK_WIDGET_STATE(body_.get())), body_shadow, &left_clip, widget, "button", x, y, width, height); GtkShadowType menu_shadow = - GTK_BUTTON(download_item->menu_button_)->depressed ? - GTK_SHADOW_IN : GTK_SHADOW_OUT; + GTK_BUTTON(menu_button_)->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; gtk_paint_box(style, widget->window, - static_cast<GtkStateType>( - GTK_WIDGET_STATE(download_item->menu_button_)), + static_cast<GtkStateType>(GTK_WIDGET_STATE(menu_button_)), menu_shadow, &right_clip, widget, "button", x, y, width, height); @@ -737,7 +732,7 @@ gboolean DownloadItemGtk::OnHboxExpose(GtkWidget* widget, GdkEventExpose* e, // is hard and relies on copying GTK internals, so instead steal the // allocation of the gtk arrow which is close enough (and will error on // the conservative side). - GtkAllocation arrow_allocation = download_item->arrow_->allocation; + GtkAllocation arrow_allocation = arrow_->allocation; gtk_paint_vline(style, widget->window, static_cast<GtkStateType>(GTK_WIDGET_STATE(widget)), &e->area, widget, "button", @@ -749,11 +744,9 @@ gboolean DownloadItemGtk::OnHboxExpose(GtkWidget* widget, GdkEventExpose* e, return FALSE; } -// static -gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, - DownloadItemGtk* download_item) { - if (!download_item->theme_provider_->UseGtkTheme()) { - bool is_body = widget == download_item->body_.get(); +gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e) { + if (!theme_provider_->UseGtkTheme()) { + bool is_body = widget == body_.get(); NineBox* nine_box = NULL; // If true, this widget is |body_|, otherwise it is |menu_button_|. @@ -767,7 +760,7 @@ gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, // When the button is showing, we want to draw it as active. We have to do // this explicitly because the button's state will be NORMAL while the menu // has focus. - if (!is_body && download_item->menu_showing_) + if (!is_body && menu_showing_) nine_box = menu_nine_box_active_; nine_box->RenderToWidget(widget); @@ -780,12 +773,11 @@ gboolean DownloadItemGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, return TRUE; } -// static -void DownloadItemGtk::OnClick(GtkWidget* widget, DownloadItemGtk* item) { +void DownloadItemGtk::OnClick(GtkWidget* widget) { UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", - base::Time::Now() - item->creation_time_); + base::Time::Now() - creation_time_); - DownloadItem* download = item->get_download(); + DownloadItem* download = get_download(); if (download->state() == DownloadItem::IN_PROGRESS) { download->set_open_when_complete( @@ -795,58 +787,53 @@ void DownloadItemGtk::OnClick(GtkWidget* widget, DownloadItemGtk* item) { } } -// static gboolean DownloadItemGtk::OnProgressAreaExpose(GtkWidget* widget, - GdkEventExpose* event, DownloadItemGtk* download_item) { + GdkEventExpose* event) { // Create a transparent canvas. gfx::CanvasPaint canvas(event, false); - if (download_item->complete_animation_.get()) { - if (download_item->complete_animation_->IsAnimating()) { + if (complete_animation_.get()) { + if (complete_animation_->IsAnimating()) { download_util::PaintDownloadComplete(&canvas, widget->allocation.x, widget->allocation.y, - download_item->complete_animation_->GetCurrentValue(), + complete_animation_->GetCurrentValue(), download_util::SMALL); } - } else if (download_item->get_download()->state() != + } else if (get_download()->state() != DownloadItem::CANCELLED) { download_util::PaintDownloadProgress(&canvas, widget->allocation.x, widget->allocation.y, - download_item->progress_angle_, - download_item->get_download()->PercentComplete(), + progress_angle_, + get_download()->PercentComplete(), download_util::SMALL); } // |icon_small_| may be NULL if it is still loading. If the file is an // unrecognized type then we will get back a generic system icon. Hence // there is no need to use the chromium-specific default download item icon. - if (download_item->icon_small_) { + if (icon_small_) { const int offset = download_util::kSmallProgressIconOffset; - canvas.DrawBitmapInt(*download_item->icon_small_, + canvas.DrawBitmapInt(*icon_small_, widget->allocation.x + offset, widget->allocation.y + offset); } return TRUE; } -// static gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button, - GdkEvent* event, - DownloadItemGtk* item) { + GdkEvent* event) { // Stop any completion animation. - if (item->complete_animation_.get() && - item->complete_animation_->IsAnimating()) { - item->complete_animation_->End(); - } + if (complete_animation_.get() && complete_animation_->IsAnimating()) + complete_animation_->End(); if (event->type == GDK_BUTTON_PRESS) { GdkEventButton* event_button = reinterpret_cast<GdkEventButton*>(event); if (event_button->button == 1) { - if (item->menu_.get() == NULL) { - item->menu_.reset(new DownloadShelfContextMenuGtk( - item->download_model_.get(), item)); + if (menu_.get() == NULL) { + menu_.reset(new DownloadShelfContextMenuGtk( + download_model_.get(), this)); } - item->menu_->Popup(button, event); - item->menu_showing_ = true; + menu_->Popup(button, event); + menu_showing_ = true; gtk_widget_queue_draw(button); } } @@ -854,31 +841,25 @@ gboolean DownloadItemGtk::OnMenuButtonPressEvent(GtkWidget* button, return FALSE; } -// static gboolean DownloadItemGtk::OnDangerousPromptExpose(GtkWidget* widget, - GdkEventExpose* event, DownloadItemGtk* item) { - if (!item->theme_provider_->UseGtkTheme()) { + GdkEventExpose* event) { + if (!theme_provider_->UseGtkTheme()) { // The hbox renderer will take care of the border when in GTK mode. dangerous_nine_box_->RenderToWidget(widget); } return FALSE; // Continue propagation. } -// static -void DownloadItemGtk::OnDangerousAccept(GtkWidget* button, - DownloadItemGtk* item) { +void DownloadItemGtk::OnDangerousAccept(GtkWidget* button) { UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", - base::Time::Now() - item->creation_time_); - item->get_download()->manager()->DangerousDownloadValidated( - item->get_download()); + base::Time::Now() - creation_time_); + get_download()->manager()->DangerousDownloadValidated(get_download()); } -// static -void DownloadItemGtk::OnDangerousDecline(GtkWidget* button, - DownloadItemGtk* item) { +void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", - base::Time::Now() - item->creation_time_); - if (item->get_download()->state() == DownloadItem::IN_PROGRESS) - item->get_download()->Cancel(true); - item->get_download()->Remove(true); + base::Time::Now() - creation_time_); + if (get_download()->state() == DownloadItem::IN_PROGRESS) + get_download()->Cancel(true); + get_download()->Remove(true); } diff --git a/chrome/browser/gtk/download_item_gtk.h b/chrome/browser/gtk/download_item_gtk.h index 9cf6dc2..4b498b4 100644 --- a/chrome/browser/gtk/download_item_gtk.h +++ b/chrome/browser/gtk/download_item_gtk.h @@ -10,6 +10,7 @@ #include <string> #include "app/animation.h" +#include "app/gtk_signal.h" #include "base/scoped_ptr.h" #include "base/time.h" #include "chrome/browser/download/download_manager.h" @@ -95,32 +96,27 @@ class DownloadItemGtk : public DownloadItem::Observer, static void InitNineBoxes(); // Draws everything in GTK rendering mode. - static gboolean OnHboxExpose(GtkWidget* widget, GdkEventExpose* e, - DownloadItemGtk* download_item); + CHROMEGTK_CALLBACK_1(DownloadItemGtk, gboolean, OnHboxExpose, + GdkEventExpose*); // Used for the download item's body and menu button in chrome theme mode. - static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, - DownloadItemGtk* download_item); + CHROMEGTK_CALLBACK_1(DownloadItemGtk, gboolean, OnExpose, GdkEventExpose*); // Called when |body_| is clicked. - static void OnClick(GtkWidget* widget, DownloadItemGtk* item); + CHROMEGTK_CALLBACK_0(DownloadItemGtk, void, OnClick); // Used for the download icon. - static gboolean OnProgressAreaExpose(GtkWidget* widget, - GdkEventExpose* e, - DownloadItemGtk* download_item); + CHROMEGTK_CALLBACK_1(DownloadItemGtk, gboolean, OnProgressAreaExpose, + GdkEventExpose*); - static gboolean OnMenuButtonPressEvent(GtkWidget* button, - GdkEvent* event, - DownloadItemGtk* item); + CHROMEGTK_CALLBACK_1(DownloadItemGtk, gboolean, OnMenuButtonPressEvent, + GdkEvent*); // Dangerous download related. ----------------------------------------------- - static gboolean OnDangerousPromptExpose(GtkWidget* widget, - GdkEventExpose* event, - DownloadItemGtk* item); - - static void OnDangerousAccept(GtkWidget* button, DownloadItemGtk* item); - static void OnDangerousDecline(GtkWidget* button, DownloadItemGtk* item); + CHROMEGTK_CALLBACK_1(DownloadItemGtk, gboolean, OnDangerousPromptExpose, + GdkEventExpose*); + CHROMEGTK_CALLBACK_0(DownloadItemGtk, void, OnDangerousAccept); + CHROMEGTK_CALLBACK_0(DownloadItemGtk, void, OnDangerousDecline); // Nineboxes for the body area. static NineBox* body_nine_box_normal_; diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc index 9dfc552..f7ef409 100644 --- a/chrome/browser/gtk/download_shelf_gtk.cc +++ b/chrome/browser/gtk/download_shelf_gtk.cc @@ -97,14 +97,14 @@ DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) close_button_.reset(CustomDrawButton::CloseButton(theme_provider_)); gtk_util::CenterWidgetInHBox(outer_hbox, close_button_->widget(), true, 0); g_signal_connect(close_button_->widget(), "clicked", - G_CALLBACK(OnButtonClick), this); + G_CALLBACK(OnButtonClickThunk), this); // Create the "Show all downloads..." link and connect to the click event. std::string link_text = l10n_util::GetStringUTF8(IDS_SHOW_ALL_DOWNLOADS); link_button_ = gtk_chrome_link_button_new(link_text.c_str()); g_signal_connect(link_button_, "clicked", - G_CALLBACK(OnButtonClick), this); + G_CALLBACK(OnButtonClickThunk), this); gtk_util::SetButtonTriggersNavigation(link_button_); // Until we switch to vector graphics, force the font size. // 13.4px == 10pt @ 96dpi @@ -253,13 +253,11 @@ void DownloadShelfGtk::MaybeShowMoreDownloadItems() { gtk_widget_show_all(items_hbox_.get()); } -// static -void DownloadShelfGtk::OnButtonClick(GtkWidget* button, - DownloadShelfGtk* shelf) { - if (button == shelf->close_button_->widget()) { - shelf->Close(); +void DownloadShelfGtk::OnButtonClick(GtkWidget* button) { + if (button == close_button_->widget()) { + Close(); } else { // The link button was clicked. - shelf->browser_->ShowDownloadsTab(); + browser_->ShowDownloadsTab(); } } diff --git a/chrome/browser/gtk/download_shelf_gtk.h b/chrome/browser/gtk/download_shelf_gtk.h index 71f10c4..35d7f3e 100644 --- a/chrome/browser/gtk/download_shelf_gtk.h +++ b/chrome/browser/gtk/download_shelf_gtk.h @@ -9,6 +9,7 @@ #include <vector> +#include "app/gtk_signal.h" #include "base/scoped_ptr.h" #include "chrome/browser/download/download_shelf.h" #include "chrome/browser/gtk/slide_animator_gtk.h" @@ -63,7 +64,7 @@ class DownloadShelfGtk : public DownloadShelf, // size is changed. void MaybeShowMoreDownloadItems(); - static void OnButtonClick(GtkWidget* button, DownloadShelfGtk* toolbar); + CHROMEGTK_CALLBACK_0(DownloadShelfGtk, void, OnButtonClick); // The browser that owns this download shelf. Browser* browser_; |