| 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 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // * The url and corresponding label are not shown if creating a new folder. | 336 // * The url and corresponding label are not shown if creating a new folder. |
| 337 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); | 337 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); |
| 338 gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing); | 338 gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing); |
| 339 | 339 |
| 340 GtkWidget* vbox = gtk_vbox_new(FALSE, 12); | 340 GtkWidget* vbox = gtk_vbox_new(FALSE, 12); |
| 341 | 341 |
| 342 name_entry_ = gtk_entry_new(); | 342 name_entry_ = gtk_entry_new(); |
| 343 std::string title; | 343 std::string title; |
| 344 GURL url; | 344 GURL url; |
| 345 if (details_.type == EditDetails::EXISTING_NODE) { | 345 if (details_.type == EditDetails::EXISTING_NODE) { |
| 346 title = UTF16ToUTF8(details_.existing_node->GetTitle()); | 346 title = base::UTF16ToUTF8(details_.existing_node->GetTitle()); |
| 347 url = details_.existing_node->url(); | 347 url = details_.existing_node->url(); |
| 348 } else if (details_.type == EditDetails::NEW_FOLDER) { | 348 } else if (details_.type == EditDetails::NEW_FOLDER) { |
| 349 title = l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME); | 349 title = l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME); |
| 350 } else if (details_.type == EditDetails::NEW_URL) { | 350 } else if (details_.type == EditDetails::NEW_URL) { |
| 351 url = details_.url; | 351 url = details_.url; |
| 352 title = UTF16ToUTF8(details_.title); | 352 title = base::UTF16ToUTF8(details_.title); |
| 353 } | 353 } |
| 354 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str()); | 354 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str()); |
| 355 g_signal_connect(name_entry_, "changed", | 355 g_signal_connect(name_entry_, "changed", |
| 356 G_CALLBACK(OnEntryChangedThunk), this); | 356 G_CALLBACK(OnEntryChangedThunk), this); |
| 357 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); | 357 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); |
| 358 | 358 |
| 359 GtkWidget* table; | 359 GtkWidget* table; |
| 360 if (details_.GetNodeType() != BookmarkNode::FOLDER) { | 360 if (details_.GetNodeType() != BookmarkNode::FOLDER) { |
| 361 url_entry_ = gtk_entry_new(); | 361 url_entry_ = gtk_entry_new(); |
| 362 PrefService* prefs = | 362 PrefService* prefs = |
| 363 profile_ ? user_prefs::UserPrefs::Get(profile_) : NULL; | 363 profile_ ? user_prefs::UserPrefs::Get(profile_) : NULL; |
| 364 gtk_entry_set_text( | 364 gtk_entry_set_text( |
| 365 GTK_ENTRY(url_entry_), | 365 GTK_ENTRY(url_entry_), |
| 366 UTF16ToUTF8(chrome::FormatBookmarkURLForDisplay(url, prefs)).c_str()); | 366 base::UTF16ToUTF8( |
| 367 chrome::FormatBookmarkURLForDisplay(url, prefs)).c_str()); |
| 367 g_signal_connect(url_entry_, "changed", | 368 g_signal_connect(url_entry_, "changed", |
| 368 G_CALLBACK(OnEntryChangedThunk), this); | 369 G_CALLBACK(OnEntryChangedThunk), this); |
| 369 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); | 370 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); |
| 370 table = gtk_util::CreateLabeledControlsGroup(NULL, | 371 table = gtk_util::CreateLabeledControlsGroup(NULL, |
| 371 l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_NAME_LABEL).c_str(), | 372 l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_NAME_LABEL).c_str(), |
| 372 name_entry_, | 373 name_entry_, |
| 373 l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_URL_LABEL).c_str(), | 374 l10n_util::GetStringUTF8(IDS_BOOKMARK_EDITOR_URL_LABEL).c_str(), |
| 374 url_entry_, | 375 url_entry_, |
| 375 NULL); | 376 NULL); |
| 376 | 377 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 511 } |
| 511 | 512 |
| 512 GURL BookmarkEditorGtk::GetInputURL() const { | 513 GURL BookmarkEditorGtk::GetInputURL() const { |
| 513 if (!url_entry_) | 514 if (!url_entry_) |
| 514 return GURL(); // Happens when we're editing a folder. | 515 return GURL(); // Happens when we're editing a folder. |
| 515 return URLFixerUpper::FixupURL(gtk_entry_get_text(GTK_ENTRY(url_entry_)), | 516 return URLFixerUpper::FixupURL(gtk_entry_get_text(GTK_ENTRY(url_entry_)), |
| 516 std::string()); | 517 std::string()); |
| 517 } | 518 } |
| 518 | 519 |
| 519 base::string16 BookmarkEditorGtk::GetInputTitle() const { | 520 base::string16 BookmarkEditorGtk::GetInputTitle() const { |
| 520 return UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(name_entry_))); | 521 return base::UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(name_entry_))); |
| 521 } | 522 } |
| 522 | 523 |
| 523 void BookmarkEditorGtk::ApplyEdits() { | 524 void BookmarkEditorGtk::ApplyEdits() { |
| 524 DCHECK(bb_model_->loaded()); | 525 DCHECK(bb_model_->loaded()); |
| 525 | 526 |
| 526 GtkTreeIter currently_selected_iter; | 527 GtkTreeIter currently_selected_iter; |
| 527 if (show_tree_) { | 528 if (show_tree_) { |
| 528 if (!gtk_tree_selection_get_selected(tree_selection_, NULL, | 529 if (!gtk_tree_selection_get_selected(tree_selection_, NULL, |
| 529 ¤tly_selected_iter)) { | 530 ¤tly_selected_iter)) { |
| 530 ApplyEdits(NULL); | 531 ApplyEdits(NULL); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 GTK_TREE_MODEL(tree_store_), &new_item_iter); | 666 GTK_TREE_MODEL(tree_store_), &new_item_iter); |
| 666 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); | 667 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); |
| 667 | 668 |
| 668 // Make the folder name editable. | 669 // Make the folder name editable. |
| 669 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, | 670 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, |
| 670 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), | 671 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), |
| 671 TRUE); | 672 TRUE); |
| 672 | 673 |
| 673 gtk_tree_path_free(path); | 674 gtk_tree_path_free(path); |
| 674 } | 675 } |
| OLD | NEW |