Chromium Code Reviews| 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 <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 // Time between a user action in the search box and when we perform the search. | 48 // Time between a user action in the search box and when we perform the search. |
| 49 const int kSearchDelayMS = 200; | 49 const int kSearchDelayMS = 200; |
| 50 | 50 |
| 51 // The default width of a column in the right tree view. Since we set the | 51 // The default width of a column in the right tree view. Since we set the |
| 52 // columns to ellipsize, if we don't explicitly set a width they will be | 52 // columns to ellipsize, if we don't explicitly set a width they will be |
| 53 // wide enough to display only '...'. This will be overridden if the user | 53 // wide enough to display only '...'. This will be overridden if the user |
| 54 // resizes the column. | 54 // resizes the column. |
| 55 const int kDefaultColumnWidth = 200; | 55 const int kDefaultColumnWidth = 200; |
| 56 | 56 |
| 57 const int kDestTargetList[] = { GtkDndUtil::CHROME_BOOKMARK_ITEM, 0 }; | |
|
tony
2009/07/27 23:33:03
Nit: Comment?
| |
| 58 | |
| 57 // We only have one manager open at a time. | 59 // We only have one manager open at a time. |
| 58 BookmarkManagerGtk* manager = NULL; | 60 BookmarkManagerGtk* manager = NULL; |
| 59 | 61 |
| 60 // Observer installed on the importer. When done importing the newly created | 62 // Observer installed on the importer. When done importing the newly created |
| 61 // folder is selected in the bookmark manager. | 63 // folder is selected in the bookmark manager. |
| 62 // This class is taken almost directly from BookmarkManagerView and should be | 64 // This class is taken almost directly from BookmarkManagerView and should be |
| 63 // kept in sync with it. | 65 // kept in sync with it. |
| 64 class ImportObserverImpl : public ImportObserver { | 66 class ImportObserverImpl : public ImportObserver { |
| 65 public: | 67 public: |
| 66 explicit ImportObserverImpl(Profile* profile) : profile_(profile) { | 68 explicit ImportObserverImpl(Profile* profile) : profile_(profile) { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 g_signal_connect(left_tree_view_, "button-press-event", | 444 g_signal_connect(left_tree_view_, "button-press-event", |
| 443 G_CALLBACK(OnTreeViewButtonPress), this); | 445 G_CALLBACK(OnTreeViewButtonPress), this); |
| 444 g_signal_connect(left_tree_view_, "button-release-event", | 446 g_signal_connect(left_tree_view_, "button-release-event", |
| 445 G_CALLBACK(OnTreeViewButtonRelease), this); | 447 G_CALLBACK(OnTreeViewButtonRelease), this); |
| 446 g_signal_connect(left_tree_view_, "key-press-event", | 448 g_signal_connect(left_tree_view_, "key-press-event", |
| 447 G_CALLBACK(OnTreeViewKeyPress), this); | 449 G_CALLBACK(OnTreeViewKeyPress), this); |
| 448 | 450 |
| 449 // The left side is only a drag destination (not a source). | 451 // The left side is only a drag destination (not a source). |
| 450 gtk_drag_dest_set(left_tree_view_, GTK_DEST_DEFAULT_DROP, | 452 gtk_drag_dest_set(left_tree_view_, GTK_DEST_DEFAULT_DROP, |
| 451 NULL, 0, GDK_ACTION_MOVE); | 453 NULL, 0, GDK_ACTION_MOVE); |
| 452 GtkDndUtil::SetDestTargetListFromCodeMask(left_tree_view_, | 454 GtkDndUtil::SetDestTargetList(left_tree_view_, kDestTargetList); |
| 453 GtkDndUtil::CHROME_BOOKMARK_ITEM); | |
| 454 | 455 |
| 455 g_signal_connect(left_tree_view_, "drag-data-received", | 456 g_signal_connect(left_tree_view_, "drag-data-received", |
| 456 G_CALLBACK(&OnLeftTreeViewDragReceived), this); | 457 G_CALLBACK(&OnLeftTreeViewDragReceived), this); |
| 457 g_signal_connect(left_tree_view_, "drag-motion", | 458 g_signal_connect(left_tree_view_, "drag-motion", |
| 458 G_CALLBACK(&OnLeftTreeViewDragMotion), this); | 459 G_CALLBACK(&OnLeftTreeViewDragMotion), this); |
| 459 | 460 |
| 460 GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL); | 461 GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL); |
| 461 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | 462 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), |
| 462 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | 463 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 463 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), | 464 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 G_CALLBACK(OnTreeViewButtonRelease), this); | 519 G_CALLBACK(OnTreeViewButtonRelease), this); |
| 519 g_signal_connect(right_tree_view_, "key-press-event", | 520 g_signal_connect(right_tree_view_, "key-press-event", |
| 520 G_CALLBACK(OnTreeViewKeyPress), this); | 521 G_CALLBACK(OnTreeViewKeyPress), this); |
| 521 | 522 |
| 522 // We don't advertise GDK_ACTION_COPY, but since we don't explicitly do | 523 // We don't advertise GDK_ACTION_COPY, but since we don't explicitly do |
| 523 // any deleting following a succesful move, this should work. | 524 // any deleting following a succesful move, this should work. |
| 524 gtk_drag_source_set(right_tree_view_, | 525 gtk_drag_source_set(right_tree_view_, |
| 525 GDK_BUTTON1_MASK, | 526 GDK_BUTTON1_MASK, |
| 526 NULL, 0, GDK_ACTION_MOVE); | 527 NULL, 0, GDK_ACTION_MOVE); |
| 527 GtkDndUtil::SetSourceTargetListFromCodeMask( | 528 GtkDndUtil::SetSourceTargetListFromCodeMask( |
| 528 right_tree_view_, GtkDndUtil::CHROME_BOOKMARK_ITEM | | 529 right_tree_view_, kDestTargetList); |
| 529 GtkDndUtil::TEXT_URI_LIST); | |
| 530 | 530 |
| 531 // We connect to drag dest signals, but we don't actually enable the widget | 531 // We connect to drag dest signals, but we don't actually enable the widget |
| 532 // as a drag destination unless it corresponds to the contents of a folder. | 532 // as a drag destination unless it corresponds to the contents of a folder. |
| 533 // See BuildRightStore(). | 533 // See BuildRightStore(). |
| 534 g_signal_connect(right_tree_view_, "drag-data-get", | 534 g_signal_connect(right_tree_view_, "drag-data-get", |
| 535 G_CALLBACK(&OnRightTreeViewDragGet), this); | 535 G_CALLBACK(&OnRightTreeViewDragGet), this); |
| 536 g_signal_connect(right_tree_view_, "drag-data-received", | 536 g_signal_connect(right_tree_view_, "drag-data-received", |
| 537 G_CALLBACK(&OnRightTreeViewDragReceived), this); | 537 G_CALLBACK(&OnRightTreeViewDragReceived), this); |
| 538 g_signal_connect(right_tree_view_, "drag-motion", | 538 g_signal_connect(right_tree_view_, "drag-motion", |
| 539 G_CALLBACK(&OnRightTreeViewDragMotion), this); | 539 G_CALLBACK(&OnRightTreeViewDragMotion), this); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 if (node) { | 611 if (node) { |
| 612 SaveColumnConfiguration(); | 612 SaveColumnConfiguration(); |
| 613 gtk_tree_view_column_set_visible(path_column_, FALSE); | 613 gtk_tree_view_column_set_visible(path_column_, FALSE); |
| 614 SizeColumns(); | 614 SizeColumns(); |
| 615 | 615 |
| 616 right_tree_model_.reset( | 616 right_tree_model_.reset( |
| 617 BookmarkTableModel::CreateBookmarkTableModelForFolder(model_, node)); | 617 BookmarkTableModel::CreateBookmarkTableModelForFolder(model_, node)); |
| 618 | 618 |
| 619 gtk_drag_dest_set(right_tree_view_, GTK_DEST_DEFAULT_ALL, NULL, 0, | 619 gtk_drag_dest_set(right_tree_view_, GTK_DEST_DEFAULT_ALL, NULL, 0, |
| 620 GDK_ACTION_MOVE); | 620 GDK_ACTION_MOVE); |
| 621 GtkDndUtil::SetDestTargetListFromCodeMask(right_tree_view_, | 621 GtkDndUtil::SetDestTargetList(right_tree_view_, kDestTargetList); |
| 622 GtkDndUtil::CHROME_BOOKMARK_ITEM); | |
| 623 } else { | 622 } else { |
| 624 SaveColumnConfiguration(); | 623 SaveColumnConfiguration(); |
| 625 gtk_tree_view_column_set_visible(path_column_, TRUE); | 624 gtk_tree_view_column_set_visible(path_column_, TRUE); |
| 626 SizeColumns(); | 625 SizeColumns(); |
| 627 | 626 |
| 628 int id = GetSelectedRowID(); | 627 int id = GetSelectedRowID(); |
| 629 if (kRecentID == id) { | 628 if (kRecentID == id) { |
| 630 right_tree_model_.reset( | 629 right_tree_model_.reset( |
| 631 BookmarkTableModel::CreateRecentlyBookmarkedModel(model_)); | 630 BookmarkTableModel::CreateRecentlyBookmarkedModel(model_)); |
| 632 } else { // kSearchID == id | 631 } else { // kSearchID == id |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { | 1285 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { |
| 1287 if (g_browser_process->io_thread()) { | 1286 if (g_browser_process->io_thread()) { |
| 1288 bookmark_html_writer::WriteBookmarks( | 1287 bookmark_html_writer::WriteBookmarks( |
| 1289 g_browser_process->io_thread()->message_loop(), model_, | 1288 g_browser_process->io_thread()->message_loop(), model_, |
| 1290 path.ToWStringHack()); | 1289 path.ToWStringHack()); |
| 1291 } | 1290 } |
| 1292 } else { | 1291 } else { |
| 1293 NOTREACHED(); | 1292 NOTREACHED(); |
| 1294 } | 1293 } |
| 1295 } | 1294 } |
| OLD | NEW |