Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Side by Side Diff: chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.cc

Issue 7310023: Pre-fill the 'Add Page' bookmark window with the current page (gtk and windows). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/bookmarks/bookmark_model.h" 13 #include "chrome/browser/bookmarks/bookmark_model.h"
14 #include "chrome/browser/bookmarks/bookmark_utils.h" 14 #include "chrome/browser/bookmarks/bookmark_utils.h"
15 #include "chrome/browser/history/history.h" 15 #include "chrome/browser/history/history.h"
16 #include "chrome/browser/net/url_fixer_upper.h" 16 #include "chrome/browser/net/url_fixer_upper.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_list.h"
18 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" 20 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h"
19 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" 21 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 22 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
21 #include "chrome/browser/ui/gtk/gtk_util.h" 23 #include "chrome/browser/ui/gtk/gtk_util.h"
24 #include "content/browser/tab_contents/tab_contents.h"
22 #include "googleurl/src/gurl.h" 25 #include "googleurl/src/gurl.h"
23 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
24 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
25 #include "grit/locale_settings.h" 28 #include "grit/locale_settings.h"
26 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/models/simple_menu_model.h" 30 #include "ui/base/models/simple_menu_model.h"
28 #include "ui/gfx/gtk_util.h" 31 #include "ui/gfx/gtk_util.h"
29 #include "ui/gfx/point.h" 32 #include "ui/gfx/point.h"
30 33
31 #if defined(TOOLKIT_VIEWS) 34 #if defined(TOOLKIT_VIEWS)
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // +---------------------------------------------------------------+ 272 // +---------------------------------------------------------------+
270 // 273 //
271 // * The url and corresponding label are not shown if creating a new folder. 274 // * The url and corresponding label are not shown if creating a new folder.
272 GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox; 275 GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox;
273 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); 276 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing);
274 277
275 GtkWidget* vbox = gtk_vbox_new(FALSE, 12); 278 GtkWidget* vbox = gtk_vbox_new(FALSE, 12);
276 279
277 name_entry_ = gtk_entry_new(); 280 name_entry_ = gtk_entry_new();
278 std::string title; 281 std::string title;
282 std::string url_spec;
279 if (details_.type == EditDetails::EXISTING_NODE) { 283 if (details_.type == EditDetails::EXISTING_NODE) {
280 title = UTF16ToUTF8(details_.existing_node->GetTitle()); 284 title = UTF16ToUTF8(details_.existing_node->GetTitle());
285 url_spec = details_.existing_node->GetURL().spec();
281 } else if (details_.type == EditDetails::NEW_FOLDER) { 286 } else if (details_.type == EditDetails::NEW_FOLDER) {
282 title = l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); 287 title = l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME);
288 } else if (details_.type == EditDetails::NEW_URL) {
289 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
sky 2011/07/07 16:02:50 Move this off into bookmark_utils so you don't nee
sadrul 2011/07/07 16:37:38 Nice! I wasn't aware of bookmark_utils. Done. Than
290 TabContents* tab_contents = browser ? browser->GetSelectedTabContents()
291 : NULL;
292 if (tab_contents) {
293 title = UTF16ToUTF8(tab_contents->GetTitle());
294 url_spec = tab_contents->GetURL().spec();
295 }
283 } 296 }
284 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str()); 297 gtk_entry_set_text(GTK_ENTRY(name_entry_), title.c_str());
285 g_signal_connect(name_entry_, "changed", 298 g_signal_connect(name_entry_, "changed",
286 G_CALLBACK(OnEntryChangedThunk), this); 299 G_CALLBACK(OnEntryChangedThunk), this);
287 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE); 300 gtk_entry_set_activates_default(GTK_ENTRY(name_entry_), TRUE);
288 301
289 GtkWidget* table; 302 GtkWidget* table;
290 if (details_.type != EditDetails::NEW_FOLDER) { 303 if (details_.type != EditDetails::NEW_FOLDER) {
291 url_entry_ = gtk_entry_new(); 304 url_entry_ = gtk_entry_new();
292 std::string url_spec;
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()); 305 gtk_entry_set_text(GTK_ENTRY(url_entry_), url_spec.c_str());
296 g_signal_connect(url_entry_, "changed", 306 g_signal_connect(url_entry_, "changed",
297 G_CALLBACK(OnEntryChangedThunk), this); 307 G_CALLBACK(OnEntryChangedThunk), this);
298 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE); 308 gtk_entry_set_activates_default(GTK_ENTRY(url_entry_), TRUE);
299 table = gtk_util::CreateLabeledControlsGroup(NULL, 309 table = gtk_util::CreateLabeledControlsGroup(NULL,
300 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NAME_LABEL).c_str(), 310 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NAME_LABEL).c_str(),
301 name_entry_, 311 name_entry_,
302 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_URL_LABEL).c_str(), 312 l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_URL_LABEL).c_str(),
303 url_entry_, 313 url_entry_,
304 NULL); 314 NULL);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 GTK_TREE_MODEL(tree_store_), &new_item_iter); 585 GTK_TREE_MODEL(tree_store_), &new_item_iter);
576 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path); 586 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(tree_view_), path);
577 587
578 // Make the folder name editable. 588 // Make the folder name editable.
579 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path, 589 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view_), path,
580 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0), 590 gtk_tree_view_get_column(GTK_TREE_VIEW(tree_view_), 0),
581 TRUE); 591 TRUE);
582 592
583 gtk_tree_path_free(path); 593 gtk_tree_path_free(path);
584 } 594 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698