| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // +---------------------------------------------------------------+ | 269 // +---------------------------------------------------------------+ |
| 270 // | 270 // |
| 271 // * The url and corresponding label are not shown if creating a new folder. | 271 // * The url and corresponding label are not shown if creating a new folder. |
| 272 GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox; | 272 GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox; |
| 273 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); | 273 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); |
| 274 | 274 |
| 275 GtkWidget* vbox = gtk_vbox_new(FALSE, 12); | 275 GtkWidget* vbox = gtk_vbox_new(FALSE, 12); |
| 276 | 276 |
| 277 name_entry_ = gtk_entry_new(); | 277 name_entry_ = gtk_entry_new(); |
| 278 std::string title; | 278 std::string title; |
| 279 GURL url; |
| 279 if (details_.type == EditDetails::EXISTING_NODE) { | 280 if (details_.type == EditDetails::EXISTING_NODE) { |
| 280 title = UTF16ToUTF8(details_.existing_node->GetTitle()); | 281 title = UTF16ToUTF8(details_.existing_node->GetTitle()); |
| 282 url = details_.existing_node->GetURL(); |
| 281 } else if (details_.type == EditDetails::NEW_FOLDER) { | 283 } else if (details_.type == EditDetails::NEW_FOLDER) { |
| 282 title = l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); | 284 title = l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); |
| 285 } else if (details_.type == EditDetails::NEW_URL) { |
| 286 string16 title16; |
| 287 bookmark_utils::GetURLAndTitleToBookmarkFromCurrentTab(profile_, |
| 288 &url, &title16); |
| 289 title = UTF16ToUTF8(title16); |
| 283 } | 290 } |
| 284 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str()); | 291 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str()); |
| 285 g_signal_connect(name_entry_, "changed", | 292 g_signal_connect(name_entry_, "changed", |
| 286 G_CALLBACK(OnEntryChangedThunk), this); | 293 G_CALLBACK(OnEntryChangedThunk), this); |
| 287 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); | 294 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); |
| 288 | 295 |
| 289 GtkWidget* table; | 296 GtkWidget* table; |
| 290 if (details_.type != EditDetails::NEW_FOLDER) { | 297 if (details_.type != EditDetails::NEW_FOLDER) { |
| 291 url_entry_ = gtk_entry_new(); | 298 url_entry_ = gtk_entry_new(); |
| 292 std::string url_spec; | 299 gtk_entry_set_text(GTK_ENTRY(url_entry_), url.spec().c_str()); |
| 293 if (details_.type == EditDetails::EXISTING_NODE) | |
| 294 url_spec = details_.existing_node->GetURL().spec(); | |
| 295 gtk_entry_set_text(GTK_ENTRY(url_entry_), url_spec.c_str()); | |
| 296 g_signal_connect(url_entry_, "changed", | 300 g_signal_connect(url_entry_, "changed", |
| 297 G_CALLBACK(OnEntryChangedThunk), this); | 301 G_CALLBACK(OnEntryChangedThunk), this); |
| 298 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); | 302 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); |
| 299 table = gtk_util::CreateLabeledControlsGroup(NULL, | 303 table = gtk_util::CreateLabeledControlsGroup(NULL, |
| 300 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NAME_LABEL).c_str(), | 304 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NAME_LABEL).c_str(), |
| 301 name_entry_, | 305 name_entry_, |
| 302 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_URL_LABEL).c_str(), | 306 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_URL_LABEL).c_str(), |
| 303 url_entry_, | 307 url_entry_, |
| 304 NULL); | 308 NULL); |
| 305 | 309 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 GTK_TREE_MODEL(tree_store_), &new_item_iter); | 579 GTK_TREE_MODEL(tree_store_), &new_item_iter); |
| 576 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); | 580 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); |
| 577 | 581 |
| 578 // Make the folder name editable. | 582 // Make the folder name editable. |
| 579 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, | 583 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, |
| 580 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), | 584 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), |
| 581 TRUE); | 585 TRUE); |
| 582 | 586 |
| 583 gtk_tree_path_free(path); | 587 gtk_tree_path_free(path); |
| 584 } | 588 } |
| OLD | NEW |