| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 NOTREACHED(); | 176 NOTREACHED(); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 | 179 |
| 180 g_signal_connect(content, "destroy", | 180 g_signal_connect(content, "destroy", |
| 181 G_CALLBACK(&OnDestroyThunk), this); | 181 G_CALLBACK(&OnDestroyThunk), this); |
| 182 g_signal_connect(name_entry_, "activate", | 182 g_signal_connect(name_entry_, "activate", |
| 183 G_CALLBACK(&OnNameActivateThunk), this); | 183 G_CALLBACK(&OnNameActivateThunk), this); |
| 184 g_signal_connect(folder_combo_, "changed", | 184 g_signal_connect(folder_combo_, "changed", |
| 185 G_CALLBACK(&OnFolderChangedThunk), this); | 185 G_CALLBACK(&OnFolderChangedThunk), this); |
| 186 g_signal_connect(folder_combo_, "notify::popup-shown", | |
| 187 G_CALLBACK(&OnFolderPopupShownThunk), this); | |
| 188 g_signal_connect(edit_button, "clicked", | 186 g_signal_connect(edit_button, "clicked", |
| 189 G_CALLBACK(&OnEditClickedThunk), this); | 187 G_CALLBACK(&OnEditClickedThunk), this); |
| 190 g_signal_connect(close_button, "clicked", | 188 g_signal_connect(close_button, "clicked", |
| 191 G_CALLBACK(&OnCloseClickedThunk), this); | 189 G_CALLBACK(&OnCloseClickedThunk), this); |
| 192 g_signal_connect(remove_button_, "clicked", | 190 g_signal_connect(remove_button_, "clicked", |
| 193 G_CALLBACK(&OnRemoveClickedThunk), this); | 191 G_CALLBACK(&OnRemoveClickedThunk), this); |
| 194 | 192 |
| 195 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 193 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 196 content::Source<ThemeService>(theme_service_)); | 194 content::Source<ThemeService>(theme_service_)); |
| 197 theme_service_->InitThemesFor(this); | 195 theme_service_->InitThemesFor(this); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // GTK doesn't handle having the combo box destroyed from the changed | 229 // GTK doesn't handle having the combo box destroyed from the changed |
| 232 // signal. Since showing the editor also closes the bubble, delay this | 230 // signal. Since showing the editor also closes the bubble, delay this |
| 233 // so that GTK can unwind. Specifically gtk_menu_shell_button_release | 231 // so that GTK can unwind. Specifically gtk_menu_shell_button_release |
| 234 // will run, and we need to keep the combo box alive until then. | 232 // will run, and we need to keep the combo box alive until then. |
| 235 MessageLoop::current()->PostTask( | 233 MessageLoop::current()->PostTask( |
| 236 FROM_HERE, | 234 FROM_HERE, |
| 237 base::Bind(&BookmarkBubbleGtk::ShowEditor, factory_.GetWeakPtr())); | 235 base::Bind(&BookmarkBubbleGtk::ShowEditor, factory_.GetWeakPtr())); |
| 238 } | 236 } |
| 239 } | 237 } |
| 240 | 238 |
| 241 void BookmarkBubbleGtk::OnFolderPopupShown(GtkWidget* widget, | |
| 242 GParamSpec* property) { | |
| 243 // GtkComboBox grabs the keyboard and pointer when it displays its popup, | |
| 244 // which steals the grabs that BubbleGtk had installed. When the popup is | |
| 245 // hidden, we notify BubbleGtk so it can try to reacquire the grabs | |
| 246 // (otherwise, GTK won't activate our widgets when the user clicks in them). | |
| 247 gboolean popup_shown = FALSE; | |
| 248 g_object_get(G_OBJECT(folder_combo_), "popup-shown", &popup_shown, NULL); | |
| 249 if (!popup_shown) | |
| 250 bubble_->HandlePointerAndKeyboardUngrabbedByContent(); | |
| 251 } | |
| 252 | |
| 253 void BookmarkBubbleGtk::OnEditClicked(GtkWidget* widget) { | 239 void BookmarkBubbleGtk::OnEditClicked(GtkWidget* widget) { |
| 254 content::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); | 240 content::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); |
| 255 ShowEditor(); | 241 ShowEditor(); |
| 256 } | 242 } |
| 257 | 243 |
| 258 void BookmarkBubbleGtk::OnCloseClicked(GtkWidget* widget) { | 244 void BookmarkBubbleGtk::OnCloseClicked(GtkWidget* widget) { |
| 259 bubble_->Close(); | 245 bubble_->Close(); |
| 260 } | 246 } |
| 261 | 247 |
| 262 void BookmarkBubbleGtk::OnRemoveClicked(GtkWidget* widget) { | 248 void BookmarkBubbleGtk::OnRemoveClicked(GtkWidget* widget) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // We always have nodes + 1 entries in the combo. The last entry will be | 321 // We always have nodes + 1 entries in the combo. The last entry will be |
| 336 // the 'Select another folder...' entry that opens the bookmark editor. | 322 // the 'Select another folder...' entry that opens the bookmark editor. |
| 337 for (int i = 0; i < folder_combo_model_->GetItemCount(); ++i) { | 323 for (int i = 0; i < folder_combo_model_->GetItemCount(); ++i) { |
| 338 gtk_combo_box_append_text(GTK_COMBO_BOX(folder_combo_), | 324 gtk_combo_box_append_text(GTK_COMBO_BOX(folder_combo_), |
| 339 UTF16ToUTF8(folder_combo_model_->GetItemAt(i)).c_str()); | 325 UTF16ToUTF8(folder_combo_model_->GetItemAt(i)).c_str()); |
| 340 } | 326 } |
| 341 | 327 |
| 342 gtk_combo_box_set_active(GTK_COMBO_BOX(folder_combo_), | 328 gtk_combo_box_set_active(GTK_COMBO_BOX(folder_combo_), |
| 343 folder_combo_model_->node_parent_index()); | 329 folder_combo_model_->node_parent_index()); |
| 344 } | 330 } |
| OLD | NEW |