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/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" | 16 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" |
17 #include "chrome/browser/bookmarks/bookmark_model.h" | 17 #include "chrome/browser/bookmarks/bookmark_model.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/bookmark_utils.h" | 19 #include "chrome/browser/bookmarks/bookmark_utils.h" |
20 #include "chrome/browser/history/history_service.h" | 20 #include "chrome/browser/history/history_service.h" |
21 #include "chrome/browser/net/url_fixer_upper.h" | 21 #include "chrome/browser/net/url_fixer_upper.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 23 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
24 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" | 24 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" |
25 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 25 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
26 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 26 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
27 #include "chrome/browser/ui/gtk/gtk_util.h" | 27 #include "chrome/browser/ui/gtk/gtk_util.h" |
28 #include "chrome/browser/ui/gtk/menu_gtk.h" | 28 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 29 #include "components/user_prefs/user_prefs.h" |
29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
30 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
31 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
32 #include "grit/locale_settings.h" | 33 #include "grit/locale_settings.h" |
33 #include "ui/base/gtk/gtk_hig_constants.h" | 34 #include "ui/base/gtk/gtk_hig_constants.h" |
34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/models/simple_menu_model.h" | 36 #include "ui/base/models/simple_menu_model.h" |
36 #include "ui/gfx/gtk_util.h" | 37 #include "ui/gfx/gtk_util.h" |
37 #include "ui/gfx/image/image.h" | 38 #include "ui/gfx/image/image.h" |
38 #include "ui/gfx/point.h" | 39 #include "ui/gfx/point.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 354 } |
354 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str()); | 355 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str()); |
355 g_signal_connect(name_entry_, "changed", | 356 g_signal_connect(name_entry_, "changed", |
356 G_CALLBACK(OnEntryChangedThunk), this); | 357 G_CALLBACK(OnEntryChangedThunk), this); |
357 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); | 358 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); |
358 | 359 |
359 GtkWidget* table; | 360 GtkWidget* table; |
360 if (details_.GetNodeType() != BookmarkNode::FOLDER) { | 361 if (details_.GetNodeType() != BookmarkNode::FOLDER) { |
361 url_entry_ = gtk_entry_new(); | 362 url_entry_ = gtk_entry_new(); |
362 PrefService* prefs = profile_ ? | 363 PrefService* prefs = profile_ ? |
363 PrefServiceFromBrowserContext(profile_) : | 364 components::UserPrefs::Get(profile_) : |
364 NULL; | 365 NULL; |
365 gtk_entry_set_text( | 366 gtk_entry_set_text( |
366 GTK_ENTRY(url_entry_), | 367 GTK_ENTRY(url_entry_), |
367 UTF16ToUTF8(chrome::FormatBookmarkURLForDisplay(url, prefs)).c_str()); | 368 UTF16ToUTF8(chrome::FormatBookmarkURLForDisplay(url, prefs)).c_str()); |
368 g_signal_connect(url_entry_, "changed", | 369 g_signal_connect(url_entry_, "changed", |
369 G_CALLBACK(OnEntryChangedThunk), this); | 370 G_CALLBACK(OnEntryChangedThunk), this); |
370 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); | 371 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); |
371 table = gtk_util::CreateLabeledControlsGroup(NULL, | 372 table = gtk_util::CreateLabeledControlsGroup(NULL, |
372 l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_NAME_LABEL).c_str(), | 373 l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_NAME_LABEL).c_str(), |
373 name_entry_, | 374 name_entry_, |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 GTK_TREE_MODEL(tree_store_), &new_item_iter); | 665 GTK_TREE_MODEL(tree_store_), &new_item_iter); |
665 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); | 666 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); |
666 | 667 |
667 // Make the folder name editable. | 668 // Make the folder name editable. |
668 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, | 669 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, |
669 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), | 670 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), |
670 TRUE); | 671 TRUE); |
671 | 672 |
672 gtk_tree_path_free(path); | 673 gtk_tree_path_free(path); |
673 } | 674 } |
OLD | NEW |