diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 02:32:25 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 02:32:25 +0000 |
commit | b6f148453fcbdcf777f71f26da8674ede5b81dce (patch) | |
tree | 9f62b676e073aac40e28c6c0d76b8da17f4c19a4 | |
parent | d24c4015c3976d20001f6de03a09a7d0ef99ffb4 (diff) | |
download | chromium_src-b6f148453fcbdcf777f71f26da8674ede5b81dce.zip chromium_src-b6f148453fcbdcf777f71f26da8674ede5b81dce.tar.gz chromium_src-b6f148453fcbdcf777f71f26da8674ede5b81dce.tar.bz2 |
Workaround for GtkFileChooserButton bug: disable mouse wheel scrolling.
Also disable it for the cookie behavior combobox, because it fights with the scrolled window.
The GtkFileChooserButton spews the following 2 errors (and possibly others) when you scroll on it quickly:
Gtk-WARNING **: idle activate multiple times without clearing the folder object first.
Gtk: gtk_tree_model_get_iter: assertion `path != NULL' failed
This causes us to crash in debug, and causes undesirable console output in release. I verified that this is their bug and not ours by reproing in a simple program that just has a window with a GtkFileChooserButton in it.
BUG=17805
Review URL: http://codereview.chromium.org/159459
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21804 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/options/advanced_contents_gtk.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index 23be335..06bb0ec4 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -58,6 +58,43 @@ GtkWidget* CreateCheckButtonWithWrappedLabel(int string_id) { return checkbox; } +// Don't let the widget handle scroll events. Instead, pass it on to the +// parent widget. +gboolean PassScrollToParent(GtkWidget* widget, GdkEvent* event, + gpointer unused) { + if (widget->parent) + gtk_propagate_event(widget->parent, event); + + return TRUE; +} + +// Recursively search for a combo box among the children of |widget|. +void SearchForComboBox(GtkWidget* widget, gpointer data) { + if (GTK_IS_COMBO_BOX(widget)) { + *reinterpret_cast<GtkWidget**>(data) = widget; + } else if (GTK_IS_CONTAINER(widget)) { + gtk_container_foreach(GTK_CONTAINER(widget), SearchForComboBox, data); + } +} + +// Letting the combo boxes in the advanced options page handle scroll events is +// annoying because they fight with the scrolled window. Also, +// GtkFileChooserButton is buggy in that if you scroll on it very quickly it +// spews Gtk-WARNINGs, which causes us to crash in debug. This function disables +// scrolling for the combo box in |widget| (the first one it finds in a DFS). +void DisableScrolling(GtkWidget* widget) { + gpointer combo_box_ptr = NULL; + SearchForComboBox(widget, &combo_box_ptr); + + if (!combo_box_ptr) { + NOTREACHED() << " Did not find a combo box in this widget."; + return; + } + + g_signal_connect(GTK_WIDGET(combo_box_ptr), "scroll-event", + G_CALLBACK(PassScrollToParent), NULL); +} + } // anonymous namespace @@ -117,6 +154,8 @@ DownloadSection::DownloadSection(Profile* profile) GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); g_signal_connect(download_location_button_, "selection-changed", G_CALLBACK(OnDownloadLocationChanged), this); + DisableScrolling(download_location_button_); + // Add the default download path to the list of shortcuts in the selector. FilePath default_download_path; if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, @@ -470,6 +509,7 @@ PrivacySection::PrivacySection(Profile* profile) FALSE, FALSE, 0); cookie_behavior_combobox_ = gtk_combo_box_new_text(); + DisableScrolling(cookie_behavior_combobox_); gtk_combo_box_append_text( GTK_COMBO_BOX(cookie_behavior_combobox_), l10n_util::GetStringUTF8(IDS_OPTIONS_COOKIES_ACCEPT_ALL_COOKIES).c_str()); |