| 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_bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 | 32 |
| 33 using content::UserMetricsAction; | 33 using content::UserMetricsAction; |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // We basically have a singleton, since a bubble is sort of app-modal. This | 37 // We basically have a singleton, since a bubble is sort of app-modal. This |
| 38 // keeps track of the currently open bubble, or NULL if none is open. | 38 // keeps track of the currently open bubble, or NULL if none is open. |
| 39 BookmarkBubbleGtk* g_bubble = NULL; | 39 BookmarkBubbleGtk* g_bubble = NULL; |
| 40 | 40 |
| 41 // Padding between content and edge of bubble. | |
| 42 const int kContentBorder = 7; | |
| 43 | |
| 44 } // namespace | 41 } // namespace |
| 45 | 42 |
| 46 // static | 43 // static |
| 47 void BookmarkBubbleGtk::Show(GtkWidget* anchor, | 44 void BookmarkBubbleGtk::Show(GtkWidget* anchor, |
| 48 Profile* profile, | 45 Profile* profile, |
| 49 const GURL& url, | 46 const GURL& url, |
| 50 bool newly_bookmarked) { | 47 bool newly_bookmarked) { |
| 51 // Sometimes Ctrl+D may get pressed more than once on top level window | 48 // Sometimes Ctrl+D may get pressed more than once on top level window |
| 52 // before the bookmark bubble window is shown and takes the keyboad focus. | 49 // before the bookmark bubble window is shown and takes the keyboad focus. |
| 53 if (g_bubble) | 50 if (g_bubble) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 GtkWidget* edit_button = gtk_button_new_with_label( | 109 GtkWidget* edit_button = gtk_button_new_with_label( |
| 113 l10n_util::GetStringUTF8(IDS_BOOKMARK_BUBBLE_OPTIONS).c_str()); | 110 l10n_util::GetStringUTF8(IDS_BOOKMARK_BUBBLE_OPTIONS).c_str()); |
| 114 GtkWidget* close_button = gtk_button_new_with_label( | 111 GtkWidget* close_button = gtk_button_new_with_label( |
| 115 l10n_util::GetStringUTF8(IDS_DONE).c_str()); | 112 l10n_util::GetStringUTF8(IDS_DONE).c_str()); |
| 116 | 113 |
| 117 // Our content is arranged in 3 rows. |top| contains a left justified | 114 // Our content is arranged in 3 rows. |top| contains a left justified |
| 118 // message, and a right justified remove link button. |table| is the middle | 115 // message, and a right justified remove link button. |table| is the middle |
| 119 // portion with the name entry and the folder combo. |bottom| is the final | 116 // portion with the name entry and the folder combo. |bottom| is the final |
| 120 // row with a spacer, and the edit... and close buttons on the right. | 117 // row with a spacer, and the edit... and close buttons on the right. |
| 121 GtkWidget* content = gtk_vbox_new(FALSE, 5); | 118 GtkWidget* content = gtk_vbox_new(FALSE, 5); |
| 122 gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); | 119 gtk_container_set_border_width(GTK_CONTAINER(content), |
| 120 ui::kContentAreaBorder); |
| 123 GtkWidget* top = gtk_hbox_new(FALSE, 0); | 121 GtkWidget* top = gtk_hbox_new(FALSE, 0); |
| 124 | 122 |
| 125 gtk_misc_set_alignment(GTK_MISC(label), 0, 1); | 123 gtk_misc_set_alignment(GTK_MISC(label), 0, 1); |
| 126 gtk_box_pack_start(GTK_BOX(top), label, | 124 gtk_box_pack_start(GTK_BOX(top), label, |
| 127 TRUE, TRUE, 0); | 125 TRUE, TRUE, 0); |
| 128 gtk_box_pack_start(GTK_BOX(top), remove_button_, | 126 gtk_box_pack_start(GTK_BOX(top), remove_button_, |
| 129 FALSE, FALSE, 0); | 127 FALSE, FALSE, 0); |
| 130 | 128 |
| 131 folder_combo_ = gtk_combo_box_new_text(); | 129 folder_combo_ = gtk_combo_box_new_text(); |
| 132 InitFolderComboModel(); | 130 InitFolderComboModel(); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // We always have nodes + 1 entries in the combo. The last entry will be | 335 // We always have nodes + 1 entries in the combo. The last entry will be |
| 338 // the 'Select another folder...' entry that opens the bookmark editor. | 336 // the 'Select another folder...' entry that opens the bookmark editor. |
| 339 for (int i = 0; i < folder_combo_model_->GetItemCount(); ++i) { | 337 for (int i = 0; i < folder_combo_model_->GetItemCount(); ++i) { |
| 340 gtk_combo_box_append_text(GTK_COMBO_BOX(folder_combo_), | 338 gtk_combo_box_append_text(GTK_COMBO_BOX(folder_combo_), |
| 341 UTF16ToUTF8(folder_combo_model_->GetItemAt(i)).c_str()); | 339 UTF16ToUTF8(folder_combo_model_->GetItemAt(i)).c_str()); |
| 342 } | 340 } |
| 343 | 341 |
| 344 gtk_combo_box_set_active(GTK_COMBO_BOX(folder_combo_), | 342 gtk_combo_box_set_active(GTK_COMBO_BOX(folder_combo_), |
| 345 folder_combo_model_->node_parent_index()); | 343 folder_combo_model_->node_parent_index()); |
| 346 } | 344 } |
| OLD | NEW |