OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/bookmarks/bookmark_editor_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" | 15 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" |
16 #include "chrome/browser/bookmarks/bookmark_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
17 #include "chrome/browser/bookmarks/bookmark_utils.h" | 18 #include "chrome/browser/bookmarks/bookmark_utils.h" |
18 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/net/url_fixer_upper.h" | 20 #include "chrome/browser/net/url_fixer_upper.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" | 22 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" |
22 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 23 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 24 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
24 #include "chrome/browser/ui/gtk/gtk_util.h" | 25 #include "chrome/browser/ui/gtk/gtk_util.h" |
25 #include "chrome/browser/ui/gtk/menu_gtk.h" | 26 #include "chrome/browser/ui/gtk/menu_gtk.h" |
26 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 271 } |
271 | 272 |
272 BookmarkEditorGtk::~BookmarkEditorGtk() { | 273 BookmarkEditorGtk::~BookmarkEditorGtk() { |
273 // The tree model is deleted before the view. Reset the model otherwise the | 274 // The tree model is deleted before the view. Reset the model otherwise the |
274 // tree will reference a deleted model. | 275 // tree will reference a deleted model. |
275 | 276 |
276 bb_model_->RemoveObserver(this); | 277 bb_model_->RemoveObserver(this); |
277 } | 278 } |
278 | 279 |
279 void BookmarkEditorGtk::Init(GtkWindow* parent_window) { | 280 void BookmarkEditorGtk::Init(GtkWindow* parent_window) { |
280 bb_model_ = profile_->GetBookmarkModel(); | 281 bb_model_ = BookmarkModelFactory::GetForProfile(profile_); |
281 DCHECK(bb_model_); | 282 DCHECK(bb_model_); |
282 bb_model_->AddObserver(this); | 283 bb_model_->AddObserver(this); |
283 | 284 |
284 dialog_ = gtk_dialog_new_with_buttons( | 285 dialog_ = gtk_dialog_new_with_buttons( |
285 l10n_util::GetStringUTF8(details_.GetWindowTitleId()).c_str(), | 286 l10n_util::GetStringUTF8(details_.GetWindowTitleId()).c_str(), |
286 parent_window, | 287 parent_window, |
287 GTK_DIALOG_MODAL, | 288 GTK_DIALOG_MODAL, |
288 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, | 289 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
289 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, | 290 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
290 NULL); | 291 NULL); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 GTK_TREE_MODEL(tree_store_), &new_item_iter); | 656 GTK_TREE_MODEL(tree_store_), &new_item_iter); |
656 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); | 657 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); |
657 | 658 |
658 // Make the folder name editable. | 659 // Make the folder name editable. |
659 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, | 660 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, |
660 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), | 661 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), |
661 TRUE); | 662 TRUE); |
662 | 663 |
663 gtk_tree_path_free(path); | 664 gtk_tree_path_free(path); |
664 } | 665 } |
OLD | NEW |