diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 20:05:35 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 20:05:35 +0000 |
commit | 5dc21090414efa5635c57c94e9c647f819dccfec (patch) | |
tree | 79dbe4e9898f517c48585426a4f1b15f119ead8d /chrome | |
parent | 8adbf7e5d0af7fec5d3fde8d472716739d3183fc (diff) | |
download | chromium_src-5dc21090414efa5635c57c94e9c647f819dccfec.zip chromium_src-5dc21090414efa5635c57c94e9c647f819dccfec.tar.gz chromium_src-5dc21090414efa5635c57c94e9c647f819dccfec.tar.bz2 |
GTK: Prevent inappropriate drag of location bar location icon.
BUG=40840
TEST=manual
Review URL: http://codereview.chromium.org/1607018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.cc | 35 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.h | 5 |
2 files changed, 31 insertions, 9 deletions
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index 2a5a664..6a66cb4 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -147,7 +147,9 @@ LocationBarViewGtk::LocationBarViewGtk(Browser* browser) security_warning_icon_image_(NULL), security_error_icon_image_(NULL), location_icon_alignment_(NULL), + location_icon_event_box_(NULL), location_icon_image_(NULL), + enable_location_drag_(false), security_info_label_(NULL), tab_to_search_box_(NULL), tab_to_search_full_label_(NULL), @@ -369,13 +371,13 @@ void LocationBarViewGtk::BuildLocationIcon() { gtk_widget_set_name(location_icon_image_, "chrome-location-icon"); gtk_widget_show(location_icon_image_); - GtkWidget* location_icon_event_box = gtk_event_box_new(); + location_icon_event_box_ = gtk_event_box_new(); // Make the event box not visible so it does not paint a background. - gtk_event_box_set_visible_window(GTK_EVENT_BOX(location_icon_event_box), + gtk_event_box_set_visible_window(GTK_EVENT_BOX(location_icon_event_box_), FALSE); - gtk_widget_set_name(location_icon_event_box, + gtk_widget_set_name(location_icon_event_box_, "chrome-location-icon-eventbox"); - gtk_container_add(GTK_CONTAINER(location_icon_event_box), + gtk_container_add(GTK_CONTAINER(location_icon_event_box_), location_icon_image_); // Put the event box in an alignment to get the padding correct. @@ -383,21 +385,34 @@ void LocationBarViewGtk::BuildLocationIcon() { gtk_alignment_set_padding(GTK_ALIGNMENT(location_icon_alignment_), 0, 0, 1, 0); gtk_container_add(GTK_CONTAINER(location_icon_alignment_), - location_icon_event_box); + location_icon_event_box_); gtk_box_pack_start(GTK_BOX(hbox_.get()), location_icon_alignment_, FALSE, FALSE, 0); // Set up drags. - gtk_drag_source_set(location_icon_event_box, GDK_BUTTON1_MASK, +} + +void LocationBarViewGtk::SetLocationIconDragSource() { + bool enable = !location_entry()->IsEditingOrEmpty(); + if (enable_location_drag_ == enable) + return; + enable_location_drag_ = enable; + + if (!enable) { + gtk_drag_source_unset(location_icon_event_box_); + return; + } + + gtk_drag_source_set(location_icon_event_box_, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY); - gtk_dnd_util::SetSourceTargetListFromCodeMask(location_icon_event_box, + gtk_dnd_util::SetSourceTargetListFromCodeMask(location_icon_event_box_, gtk_dnd_util::TEXT_PLAIN | gtk_dnd_util::TEXT_URI_LIST | gtk_dnd_util::CHROME_NAMED_URL); - g_signal_connect(location_icon_event_box, "button-release-event", + g_signal_connect(location_icon_event_box_, "button-release-event", G_CALLBACK(&OnIconReleasedThunk), this); - g_signal_connect(location_icon_event_box, "drag-data-get", + g_signal_connect(location_icon_event_box_, "drag-data-get", G_CALLBACK(&OnIconDragDataThunk), this); } @@ -806,6 +821,8 @@ void LocationBarViewGtk::UpdateIcon() { gtk_image_set_from_pixbuf(GTK_IMAGE(location_icon_image_), theme_provider_->GetPixbufNamed(resource_id)); gtk_widget_show(location_icon()); + + SetLocationIconDragSource(); } void LocationBarViewGtk::SetInfoText() { diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index cf7b02f..d8ce564 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -265,6 +265,9 @@ class LocationBarViewGtk : public AutocompleteEditController, // Creates, initializes, and packs the location icon + related widgets. void BuildLocationIcon(); + // Enable or disable the location icon as a drag source for the URL. + void SetLocationIconDragSource(); + GtkWidget* location_icon() { return location_icon_alignment_; } CHROMEGTK_CALLBACK_1(LocationBarViewGtk, gboolean, HandleExpose, @@ -326,7 +329,9 @@ class LocationBarViewGtk : public AutocompleteEditController, GtkWidget* security_error_icon_image_; // An icon to the left of the address bar. GtkWidget* location_icon_alignment_; + GtkWidget* location_icon_event_box_; GtkWidget* location_icon_image_; + bool enable_location_drag_; // TODO(pkasting): Split this label off and move the rest of the items to the // left of the address bar. GtkWidget* security_info_label_; |