| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/bookmark_bubble_gtk.h" | 5 #include "chrome/browser/gtk/bookmark_bubble_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 NotificationType::BOOKMARK_BUBBLE_HIDDEN, | 111 NotificationType::BOOKMARK_BUBBLE_HIDDEN, |
| 112 Source<Profile>(profile_->GetOriginalProfile()), | 112 Source<Profile>(profile_->GetOriginalProfile()), |
| 113 NotificationService::NoDetails()); | 113 NotificationService::NoDetails()); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void BookmarkBubbleGtk::Observe(NotificationType type, | 116 void BookmarkBubbleGtk::Observe(NotificationType type, |
| 117 const NotificationSource& source, | 117 const NotificationSource& source, |
| 118 const NotificationDetails& details) { | 118 const NotificationDetails& details) { |
| 119 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 119 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); |
| 120 | 120 |
| 121 gtk_chrome_link_button_set_use_gtk_theme( | |
| 122 GTK_CHROME_LINK_BUTTON(remove_button_), | |
| 123 theme_provider_->UseGtkTheme()); | |
| 124 | |
| 125 if (theme_provider_->UseGtkTheme()) { | 121 if (theme_provider_->UseGtkTheme()) { |
| 126 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); | 122 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); |
| 127 it != labels_.end(); ++it) { | 123 it != labels_.end(); ++it) { |
| 128 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); | 124 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); |
| 129 } | 125 } |
| 130 } else { | 126 } else { |
| 131 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); | 127 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); |
| 132 it != labels_.end(); ++it) { | 128 it != labels_.end(); ++it) { |
| 133 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack); | 129 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack); |
| 134 } | 130 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 149 folder_combo_(NULL), | 145 folder_combo_(NULL), |
| 150 bubble_(NULL), | 146 bubble_(NULL), |
| 151 factory_(this), | 147 factory_(this), |
| 152 newly_bookmarked_(newly_bookmarked), | 148 newly_bookmarked_(newly_bookmarked), |
| 153 apply_edits_(true), | 149 apply_edits_(true), |
| 154 remove_bookmark_(false) { | 150 remove_bookmark_(false) { |
| 155 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8( | 151 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8( |
| 156 newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED : | 152 newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED : |
| 157 IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK).c_str()); | 153 IDS_BOOMARK_BUBBLE_PAGE_BOOKMARK).c_str()); |
| 158 labels_.push_back(label); | 154 labels_.push_back(label); |
| 159 remove_button_ = gtk_chrome_link_button_new( | 155 GtkWidget* remove_button = gtk_chrome_link_button_new( |
| 160 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_REMOVE_BOOKMARK).c_str()); | 156 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_REMOVE_BOOKMARK).c_str()); |
| 161 GtkWidget* edit_button = gtk_button_new_with_label( | 157 GtkWidget* edit_button = gtk_button_new_with_label( |
| 162 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_OPTIONS).c_str()); | 158 l10n_util::GetStringUTF8(IDS_BOOMARK_BUBBLE_OPTIONS).c_str()); |
| 163 GtkWidget* close_button = gtk_button_new_with_label( | 159 GtkWidget* close_button = gtk_button_new_with_label( |
| 164 l10n_util::GetStringUTF8(IDS_CLOSE).c_str()); | 160 l10n_util::GetStringUTF8(IDS_CLOSE).c_str()); |
| 165 | 161 |
| 166 // Our content is arrange in 3 rows. |top| contains a left justified | 162 // Our content is arrange in 3 rows. |top| contains a left justified |
| 167 // message, and a right justified remove link button. |table| is the middle | 163 // message, and a right justified remove link button. |table| is the middle |
| 168 // portion with the name entry and the folder combo. |bottom| is the final | 164 // portion with the name entry and the folder combo. |bottom| is the final |
| 169 // row with a spacer, and the edit... and close buttons on the right. | 165 // row with a spacer, and the edit... and close buttons on the right. |
| 170 GtkWidget* content = gtk_vbox_new(FALSE, 5); | 166 GtkWidget* content = gtk_vbox_new(FALSE, 5); |
| 171 GtkWidget* top = gtk_hbox_new(FALSE, 0); | 167 GtkWidget* top = gtk_hbox_new(FALSE, 0); |
| 172 | 168 |
| 173 gtk_misc_set_alignment(GTK_MISC(label), 0, 1); | 169 gtk_misc_set_alignment(GTK_MISC(label), 0, 1); |
| 174 gtk_box_pack_start(GTK_BOX(top), label, | 170 gtk_box_pack_start(GTK_BOX(top), label, |
| 175 TRUE, TRUE, 0); | 171 TRUE, TRUE, 0); |
| 176 gtk_box_pack_start(GTK_BOX(top), remove_button_, | 172 gtk_box_pack_start(GTK_BOX(top), remove_button, |
| 177 FALSE, FALSE, 0); | 173 FALSE, FALSE, 0); |
| 178 | 174 |
| 179 // TODO(deanm): We should show the bookmark bar folder along with the top | 175 // TODO(deanm): We should show the bookmark bar folder along with the top |
| 180 // other choices and an entry to go into the bookmark editor. Since we don't | 176 // other choices and an entry to go into the bookmark editor. Since we don't |
| 181 // have the editor up yet on Linux, just show the bookmark bar for now. | 177 // have the editor up yet on Linux, just show the bookmark bar for now. |
| 182 folder_combo_ = gtk_combo_box_new_text(); | 178 folder_combo_ = gtk_combo_box_new_text(); |
| 183 folder_nodes_ = PopulateFolderCombo(profile_->GetBookmarkModel(), | 179 folder_nodes_ = PopulateFolderCombo(profile_->GetBookmarkModel(), |
| 184 url_, folder_combo_); | 180 url_, folder_combo_); |
| 185 | 181 |
| 186 // Create the edit entry for updating the bookmark name / title. | 182 // Create the edit entry for updating the bookmark name / title. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 g_signal_connect(content, "destroy", | 219 g_signal_connect(content, "destroy", |
| 224 G_CALLBACK(&HandleDestroyThunk), this); | 220 G_CALLBACK(&HandleDestroyThunk), this); |
| 225 g_signal_connect(name_entry_, "activate", | 221 g_signal_connect(name_entry_, "activate", |
| 226 G_CALLBACK(&HandleNameActivateThunk), this); | 222 G_CALLBACK(&HandleNameActivateThunk), this); |
| 227 g_signal_connect(folder_combo_, "changed", | 223 g_signal_connect(folder_combo_, "changed", |
| 228 G_CALLBACK(&HandleFolderChangedThunk), this); | 224 G_CALLBACK(&HandleFolderChangedThunk), this); |
| 229 g_signal_connect(edit_button, "clicked", | 225 g_signal_connect(edit_button, "clicked", |
| 230 G_CALLBACK(&HandleEditButtonThunk), this); | 226 G_CALLBACK(&HandleEditButtonThunk), this); |
| 231 g_signal_connect(close_button, "clicked", | 227 g_signal_connect(close_button, "clicked", |
| 232 G_CALLBACK(&HandleCloseButtonThunk), this); | 228 G_CALLBACK(&HandleCloseButtonThunk), this); |
| 233 g_signal_connect(remove_button_, "clicked", | 229 g_signal_connect(remove_button, "clicked", |
| 234 G_CALLBACK(&HandleRemoveButtonThunk), this); | 230 G_CALLBACK(&HandleRemoveButtonThunk), this); |
| 235 | 231 |
| 236 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 232 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
| 237 NotificationService::AllSources()); | 233 NotificationService::AllSources()); |
| 238 theme_provider_->InitThemesFor(this); | 234 theme_provider_->InitThemesFor(this); |
| 239 } | 235 } |
| 240 | 236 |
| 241 BookmarkBubbleGtk::~BookmarkBubbleGtk() { | 237 BookmarkBubbleGtk::~BookmarkBubbleGtk() { |
| 242 DCHECK(!content_); // |content_| should have already been destroyed. | 238 DCHECK(!content_); // |content_| should have already been destroyed. |
| 243 | 239 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 GtkWidget* toplevel = GTK_WIDGET(transient_toplevel_); | 346 GtkWidget* toplevel = GTK_WIDGET(transient_toplevel_); |
| 351 | 347 |
| 352 // Close the bubble, deleting the C++ objects, etc. | 348 // Close the bubble, deleting the C++ objects, etc. |
| 353 bubble_->Close(); | 349 bubble_->Close(); |
| 354 | 350 |
| 355 if (node) { | 351 if (node) { |
| 356 BookmarkEditor::Show(toplevel, profile, NULL, node, | 352 BookmarkEditor::Show(toplevel, profile, NULL, node, |
| 357 BookmarkEditor::SHOW_TREE, NULL); | 353 BookmarkEditor::SHOW_TREE, NULL); |
| 358 } | 354 } |
| 359 } | 355 } |
| OLD | NEW |