diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-25 23:48:54 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-25 23:48:54 +0000 |
commit | 1bbc8a2970f4916760a810bf630ee1485471b20a (patch) | |
tree | b3cd50caf651798abc50955409fc3256e505cf45 /chrome/browser/gtk/bookmark_manager_gtk.cc | |
parent | cd43e6e776b2283f555f1b59bef06d135504f66f (diff) | |
download | chromium_src-1bbc8a2970f4916760a810bf630ee1485471b20a.zip chromium_src-1bbc8a2970f4916760a810bf630ee1485471b20a.tar.gz chromium_src-1bbc8a2970f4916760a810bf630ee1485471b20a.tar.bz2 |
Fix another bookmark manager crasher.
Also, don't allow drags to originate from parts of the table view that don't have rows.
BUG=http://crbug.com/15388
TEST=try to drag from the white space below the lowest row of the bookmark manager right pane onto the bookmark bar (nothing should happen)
Review URL: http://codereview.chromium.org/149024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/bookmark_manager_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/bookmark_manager_gtk.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index c2a892f..37609df 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -433,6 +433,8 @@ GtkWidget* BookmarkManagerGtk::MakeRightPane() { G_CALLBACK(OnRightSelectionChanged), this); g_signal_connect(right_tree_view_, "focus-in-event", G_CALLBACK(OnRightTreeViewFocusIn), this); + g_signal_connect(right_tree_view_, "button-press-event", + G_CALLBACK(OnRightTreeViewButtonPress), this); g_signal_connect(right_tree_view_, "button-release-event", G_CALLBACK(OnTreeViewButtonRelease), this); @@ -811,10 +813,16 @@ void BookmarkManagerGtk::OnLeftTreeViewRowCollapsed(GtkTreeView *tree_view, void BookmarkManagerGtk::OnRightTreeViewDragGet( GtkWidget* tree_view, GdkDragContext* context, GtkSelectionData* selection_data, - guint target_type, guint time, BookmarkManagerGtk* bookmark_manager) { - bookmark_utils::WriteBookmarksToSelection( - bookmark_manager->GetRightSelection(), selection_data, target_type, - bookmark_manager->profile_); + guint target_type, guint time, BookmarkManagerGtk* bm) { + // No selection, do nothing. This shouldn't get hit, but if it does an early + // return avoids a crash. + if (gtk_tree_selection_count_selected_rows(bm->right_selection()) == 0) { + NOTREACHED(); + return; + } + + bookmark_utils::WriteBookmarksToSelection(bm->GetRightSelection(), + selection_data, target_type, bm->profile_); } // static @@ -952,6 +960,26 @@ void BookmarkManagerGtk::OnRightTreeViewFocusIn(GtkTreeView* tree_view, } // static +gboolean BookmarkManagerGtk::OnRightTreeViewButtonPress(GtkWidget* tree_view, + GdkEventButton* event, BookmarkManagerGtk* bm) { + int x, y; + gtk_widget_get_pointer(tree_view, &x, &y); + + GtkTreePath* path; + GtkTreeViewDropPosition pos; + gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), + x, y, &path, &pos); + // Ignore left clicks that occur below the lowest row so we don't try to + // start an empty drag, or allow the user to start a drag on the selected + // row by dragging on whitespace. + if (path == NULL && event->button == 1) + return TRUE; + + gtk_tree_path_free(path); + return FALSE; +} + +// static gboolean BookmarkManagerGtk::OnTreeViewButtonRelease(GtkTreeView* tree_view, GdkEventButton* button, BookmarkManagerGtk* bookmark_manager) { if (button->button == 3) |