Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: chrome/browser/gtk/bookmark_manager_gtk.cc

Issue 417002: GTK bookmark manager polish.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: typo Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bookmark_manager_gtk.h" 5 #include "chrome/browser/gtk/bookmark_manager_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/gtk_dnd_util.h" 10 #include "app/gtk_dnd_util.h"
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 void BookmarkManagerGtk::OnRightTreeViewFocusIn( 1151 void BookmarkManagerGtk::OnRightTreeViewFocusIn(
1152 GtkTreeView* tree_view, 1152 GtkTreeView* tree_view,
1153 GdkEventFocus* event, 1153 GdkEventFocus* event,
1154 BookmarkManagerGtk* bm) { 1154 BookmarkManagerGtk* bm) {
1155 if (bm->organize_is_for_left_) 1155 if (bm->organize_is_for_left_)
1156 bm->ResetOrganizeMenu(false); 1156 bm->ResetOrganizeMenu(false);
1157 } 1157 }
1158 1158
1159 // We do a couple things in this handler. 1159 // We do a couple things in this handler.
1160 // 1160 //
1161 // 1. Ignore left clicks that occur below the lowest row so we don't try to 1161 // 1. On left clicks that occur below the lowest row, unselect all selected
1162 // start an empty drag, or allow the user to start a drag on the selected 1162 // rows. This is not a native GtkTreeView behavior, but it is added by libegg
1163 // row by dragging on whitespace. This is the path == NULL return. 1163 // and is thus present in Nautilus. This is the path == NULL path.
1164 // 2. Cache left clicks that occur on an already active selection. If the user 1164 // 2. Cache left clicks that occur on an already active selection. If the user
1165 // begins a drag, then we will throw away this event and initiate a drag on the 1165 // begins a drag, then we will throw away this event and initiate a drag on the
1166 // tree view manually. If the user doesn't begin a drag (e.g. just releases the 1166 // tree view manually. If the user doesn't begin a drag (e.g. just releases the
1167 // button), send both events to the tree view. This is a workaround for 1167 // button), send both events to the tree view. This is a workaround for
1168 // http://crbug.com/15240. If we don't do this, when the user tries to drag 1168 // http://crbug.com/15240. If we don't do this, when the user tries to drag
1169 // a group of selected rows, the click at the start of the drag will deselect 1169 // a group of selected rows, the click at the start of the drag will deselect
1170 // all rows except the one the cursor is over. 1170 // all rows except the one the cursor is over.
1171 // 1171 //
1172 // We return TRUE for when we want to ignore events (i.e., stop the default 1172 // We return TRUE for when we want to ignore events (i.e., stop the default
1173 // handler from handling them), and FALSE for when we want to continue 1173 // handler from handling them), and FALSE for when we want to continue
(...skipping 16 matching lines...) Expand all
1190 bm->SendDelayedMousedown(); 1190 bm->SendDelayedMousedown();
1191 return FALSE; 1191 return FALSE;
1192 } 1192 }
1193 1193
1194 GtkTreePath* path; 1194 GtkTreePath* path;
1195 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree_view), 1195 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree_view),
1196 static_cast<gint>(event->x), 1196 static_cast<gint>(event->x),
1197 static_cast<gint>(event->y), 1197 static_cast<gint>(event->y),
1198 &path, NULL, NULL, NULL); 1198 &path, NULL, NULL, NULL);
1199 1199
1200 if (path == NULL) 1200 if (path == NULL) {
1201 return TRUE; 1201 // Checking that the widget already has focus matches libegg behavior.
1202 if (GTK_WIDGET_HAS_FOCUS(tree_view))
1203 gtk_tree_selection_unselect_all(bm->right_selection());
1204 return FALSE;
1205 }
1202 1206
1203 if (gtk_tree_selection_path_is_selected(bm->right_selection(), path)) { 1207 if (gtk_tree_selection_path_is_selected(bm->right_selection(), path)) {
1204 bm->mousedown_event_ = *event; 1208 bm->mousedown_event_ = *event;
1205 bm->delaying_mousedown_ = true; 1209 bm->delaying_mousedown_ = true;
1206 gtk_tree_path_free(path); 1210 gtk_tree_path_free(path);
1207 return TRUE; 1211 return TRUE;
1208 } 1212 }
1209 1213
1210 gtk_tree_path_free(path); 1214 gtk_tree_path_free(path);
1211 return FALSE; 1215 return FALSE;
1212 } 1216 }
1213 1217
1214 // static 1218 // static
1215 gboolean BookmarkManagerGtk::OnRightTreeViewMotion( 1219 gboolean BookmarkManagerGtk::OnRightTreeViewMotion(
1216 GtkWidget* tree_view, GdkEventMotion* event, BookmarkManagerGtk* bm) { 1220 GtkWidget* tree_view, GdkEventMotion* event, BookmarkManagerGtk* bm) {
1217 // This handler is only used for the multi-drag workaround. 1221 // Swallow motion events when no row is selected. This prevents the initiation
1222 // of empty drags.
1223 if (gtk_tree_selection_count_selected_rows(bm->right_selection()) == 0)
1224 return TRUE;
1225
1226 // Otherwise this handler is only used for the multi-drag workaround.
1218 if (!bm->delaying_mousedown_) 1227 if (!bm->delaying_mousedown_)
1219 return FALSE; 1228 return FALSE;
1220 1229
1221 if (gtk_drag_check_threshold(tree_view, 1230 if (gtk_drag_check_threshold(tree_view,
1222 static_cast<gint>(bm->mousedown_event_.x), 1231 static_cast<gint>(bm->mousedown_event_.x),
1223 static_cast<gint>(bm->mousedown_event_.y), 1232 static_cast<gint>(bm->mousedown_event_.y),
1224 static_cast<gint>(event->x), 1233 static_cast<gint>(event->x),
1225 static_cast<gint>(event->y))) { 1234 static_cast<gint>(event->y))) {
1226 bm->delaying_mousedown_ = false; 1235 bm->delaying_mousedown_ = false;
1227 GtkTargetList* targets = GtkDndUtil::GetTargetListFromCodeMask( 1236 GtkTargetList* targets = GtkDndUtil::GetTargetListFromCodeMask(
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 modifier & gtk_accelerator_get_default_mod_mask()); 1439 modifier & gtk_accelerator_get_default_mod_mask());
1431 // The only accelerator we have registered is ctrl+w, so any other value is a 1440 // The only accelerator we have registered is ctrl+w, so any other value is a
1432 // non-fatal error. 1441 // non-fatal error.
1433 DCHECK_EQ(keyval, static_cast<guint>(GDK_w)); 1442 DCHECK_EQ(keyval, static_cast<guint>(GDK_w));
1434 DCHECK_EQ(modifier, GDK_CONTROL_MASK); 1443 DCHECK_EQ(modifier, GDK_CONTROL_MASK);
1435 1444
1436 gtk_widget_destroy(bookmark_manager->window_); 1445 gtk_widget_destroy(bookmark_manager->window_);
1437 1446
1438 return TRUE; 1447 return TRUE;
1439 } 1448 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698