| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 | 299 |
| 300 // BookmarkManagerGtk, private ------------------------------------------------- | 300 // BookmarkManagerGtk, private ------------------------------------------------- |
| 301 | 301 |
| 302 BookmarkManagerGtk::BookmarkManagerGtk(Profile* profile) | 302 BookmarkManagerGtk::BookmarkManagerGtk(Profile* profile) |
| 303 : profile_(profile), | 303 : profile_(profile), |
| 304 model_(profile->GetBookmarkModel()), | 304 model_(profile->GetBookmarkModel()), |
| 305 organize_is_for_left_(true), | 305 organize_is_for_left_(true), |
| 306 search_factory_(this), | 306 search_factory_(this), |
| 307 select_file_dialog_(SelectFileDialog::Create(this)), | 307 select_file_dialog_(SelectFileDialog::Create(this)), |
| 308 delaying_mousedown_(false) { | 308 delaying_mousedown_(false), |
| 309 sending_delayed_mousedown_(false) { |
| 309 InitWidgets(); | 310 InitWidgets(); |
| 310 g_signal_connect(window_, "destroy", | 311 g_signal_connect(window_, "destroy", |
| 311 G_CALLBACK(OnWindowDestroy), this); | 312 G_CALLBACK(OnWindowDestroy), this); |
| 312 | 313 |
| 313 model_->AddObserver(this); | 314 model_->AddObserver(this); |
| 314 if (model_->IsLoaded()) | 315 if (model_->IsLoaded()) |
| 315 Loaded(model_); | 316 Loaded(model_); |
| 316 | 317 |
| 317 gtk_widget_show_all(window_); | 318 gtk_widget_show_all(window_); |
| 318 } | 319 } |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 prefs->SetInteger(prefs::kBookmarkTablePathWidth, | 756 prefs->SetInteger(prefs::kBookmarkTablePathWidth, |
| 756 gtk_tree_view_column_get_width(path_column_)); | 757 gtk_tree_view_column_get_width(path_column_)); |
| 757 } else { | 758 } else { |
| 758 prefs->SetInteger(prefs::kBookmarkTableNameWidth1, | 759 prefs->SetInteger(prefs::kBookmarkTableNameWidth1, |
| 759 gtk_tree_view_column_get_width(title_column_)); | 760 gtk_tree_view_column_get_width(title_column_)); |
| 760 prefs->SetInteger(prefs::kBookmarkTableURLWidth1, | 761 prefs->SetInteger(prefs::kBookmarkTableURLWidth1, |
| 761 gtk_tree_view_column_get_width(url_column_)); | 762 gtk_tree_view_column_get_width(url_column_)); |
| 762 } | 763 } |
| 763 } | 764 } |
| 764 | 765 |
| 766 void BookmarkManagerGtk::SendDelayedMousedown() { |
| 767 sending_delayed_mousedown_ = true; |
| 768 gtk_propagate_event(right_tree_view_, |
| 769 reinterpret_cast<GdkEvent*>(&mousedown_event_)); |
| 770 sending_delayed_mousedown_ = false; |
| 771 delaying_mousedown_ = false; |
| 772 } |
| 773 |
| 765 bool BookmarkManagerGtk::RecursiveFind(GtkTreeModel* model, GtkTreeIter* iter, | 774 bool BookmarkManagerGtk::RecursiveFind(GtkTreeModel* model, GtkTreeIter* iter, |
| 766 int target) { | 775 int target) { |
| 767 GValue value = { 0, }; | 776 GValue value = { 0, }; |
| 768 bool left = model == GTK_TREE_MODEL(left_store_); | 777 bool left = model == GTK_TREE_MODEL(left_store_); |
| 769 if (left) { | 778 if (left) { |
| 770 if (iter->stamp == 0) | 779 if (iter->stamp == 0) |
| 771 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(left_store_), iter); | 780 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(left_store_), iter); |
| 772 gtk_tree_model_get_value(model, iter, bookmark_utils::ITEM_ID, &value); | 781 gtk_tree_model_get_value(model, iter, bookmark_utils::ITEM_ID, &value); |
| 773 } | 782 } |
| 774 else { | 783 else { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 // a group of selected rows, the click at the start of the drag will deselect | 1101 // a group of selected rows, the click at the start of the drag will deselect |
| 1093 // all rows except the one the cursor is over. | 1102 // all rows except the one the cursor is over. |
| 1094 // | 1103 // |
| 1095 // We return TRUE for when we want to ignore events (i.e., stop the default | 1104 // We return TRUE for when we want to ignore events (i.e., stop the default |
| 1096 // handler from handling them), and FALSE for when we want to continue | 1105 // handler from handling them), and FALSE for when we want to continue |
| 1097 // propagation. | 1106 // propagation. |
| 1098 // | 1107 // |
| 1099 // static | 1108 // static |
| 1100 gboolean BookmarkManagerGtk::OnRightTreeViewButtonPress(GtkWidget* tree_view, | 1109 gboolean BookmarkManagerGtk::OnRightTreeViewButtonPress(GtkWidget* tree_view, |
| 1101 GdkEventButton* event, BookmarkManagerGtk* bm) { | 1110 GdkEventButton* event, BookmarkManagerGtk* bm) { |
| 1102 // Always let the cached mousedown sent from OnTreeViewButtonRelease through. | 1111 // Always let cached mousedown events through. |
| 1103 if (bm->delaying_mousedown_) | 1112 if (bm->sending_delayed_mousedown_) { |
| 1104 return FALSE; | 1113 return FALSE; |
| 1114 } |
| 1105 | 1115 |
| 1106 if (event->button != 1) | 1116 if (event->button != 1) |
| 1107 return FALSE; | 1117 return FALSE; |
| 1108 | 1118 |
| 1119 // If a user double clicks, we will get two button presses in a row without |
| 1120 // any intervening mouse up, hence we must flush delayed mousedowns here as |
| 1121 // well as in the button release handler. |
| 1122 if (bm->delaying_mousedown_) { |
| 1123 bm->SendDelayedMousedown(); |
| 1124 return FALSE; |
| 1125 } |
| 1126 |
| 1109 GtkTreePath* path; | 1127 GtkTreePath* path; |
| 1110 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree_view), | 1128 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree_view), |
| 1111 event->x, event->y, &path, NULL, NULL, NULL); | 1129 event->x, event->y, &path, NULL, NULL, NULL); |
| 1112 | 1130 |
| 1113 if (path == NULL) | 1131 if (path == NULL) |
| 1114 return TRUE; | 1132 return TRUE; |
| 1115 | 1133 |
| 1116 if (gtk_tree_selection_path_is_selected(bm->right_selection(), path)) { | 1134 if (gtk_tree_selection_path_is_selected(bm->right_selection(), path)) { |
| 1117 bm->mousedown_event_ = *event; | 1135 bm->mousedown_event_ = *event; |
| 1118 bm->delaying_mousedown_ = true; | 1136 bm->delaying_mousedown_ = true; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 gboolean BookmarkManagerGtk::OnTreeViewButtonRelease(GtkWidget* tree_view, | 1168 gboolean BookmarkManagerGtk::OnTreeViewButtonRelease(GtkWidget* tree_view, |
| 1151 GdkEventButton* button, BookmarkManagerGtk* bm) { | 1169 GdkEventButton* button, BookmarkManagerGtk* bm) { |
| 1152 #if defined(TOOLKIT_GTK) | 1170 #if defined(TOOLKIT_GTK) |
| 1153 if (button->button == 3) | 1171 if (button->button == 3) |
| 1154 bm->organize_menu_->PopupAsContext(button->time); | 1172 bm->organize_menu_->PopupAsContext(button->time); |
| 1155 #else | 1173 #else |
| 1156 // Implement on GTK+views. | 1174 // Implement on GTK+views. |
| 1157 NOTIMPLEMENTED(); | 1175 NOTIMPLEMENTED(); |
| 1158 #endif | 1176 #endif |
| 1159 | 1177 |
| 1160 if (bm->delaying_mousedown_ && (tree_view == bm->right_tree_view_)) { | 1178 if (bm->delaying_mousedown_ && (tree_view == bm->right_tree_view_)) |
| 1161 gtk_propagate_event(tree_view, | 1179 bm->SendDelayedMousedown(); |
| 1162 reinterpret_cast<GdkEvent*>(&bm->mousedown_event_)); | |
| 1163 bm->delaying_mousedown_ = false; | |
| 1164 } | |
| 1165 | 1180 |
| 1166 return FALSE; | 1181 return FALSE; |
| 1167 } | 1182 } |
| 1168 | 1183 |
| 1169 // static | 1184 // static |
| 1170 void BookmarkManagerGtk::OnImportItemActivated(GtkMenuItem* menuitem, | 1185 void BookmarkManagerGtk::OnImportItemActivated(GtkMenuItem* menuitem, |
| 1171 BookmarkManagerGtk* bm) { | 1186 BookmarkManagerGtk* bm) { |
| 1172 SelectFileDialog::FileTypeInfo file_type_info; | 1187 SelectFileDialog::FileTypeInfo file_type_info; |
| 1173 file_type_info.extensions.resize(1); | 1188 file_type_info.extensions.resize(1); |
| 1174 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); | 1189 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { | 1231 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { |
| 1217 if (g_browser_process->io_thread()) { | 1232 if (g_browser_process->io_thread()) { |
| 1218 bookmark_html_writer::WriteBookmarks( | 1233 bookmark_html_writer::WriteBookmarks( |
| 1219 g_browser_process->io_thread()->message_loop(), model_, | 1234 g_browser_process->io_thread()->message_loop(), model_, |
| 1220 path.ToWStringHack()); | 1235 path.ToWStringHack()); |
| 1221 } | 1236 } |
| 1222 } else { | 1237 } else { |
| 1223 NOTREACHED(); | 1238 NOTREACHED(); |
| 1224 } | 1239 } |
| 1225 } | 1240 } |
| OLD | NEW |